|
17 | 17 |
|
18 | 18 | package com.alipay.oceanbase.rpc.protocol.payload.impl.execute; |
19 | 19 |
|
| 20 | +import com.alipay.oceanbase.rpc.ObGlobal; |
20 | 21 | import com.alipay.oceanbase.rpc.protocol.payload.AbstractPayload; |
21 | 22 | import com.alipay.oceanbase.rpc.protocol.payload.impl.ObObj; |
22 | 23 | import com.alipay.oceanbase.rpc.protocol.payload.impl.ObTableSerialUtil; |
@@ -76,39 +77,34 @@ public byte[] encode() { |
76 | 77 | System.arraycopy(Serialization.encodeVString(filterString), 0, bytes, idx, len); |
77 | 78 | idx += len; |
78 | 79 |
|
79 | | - // selectColumns + scanOrder + hTableFilter + obKVParams |
80 | | - |
81 | | - len = Serialization.getNeedBytes(selectColumns.size()); |
82 | | - System.arraycopy(Serialization.encodeVi64(selectColumns.size()), 0, bytes, idx, len); |
83 | | - idx += len; |
84 | | - for (String selectColumn : selectColumns) { |
85 | | - len = Serialization.getNeedBytes(selectColumn); |
86 | | - System.arraycopy(Serialization.encodeVString(selectColumn), 0, bytes, idx, len); |
| 80 | + // encode HBase Batch Get required |
| 81 | + if (isHbaseQuery && ObGlobal.isHBaseBatchGetSupport()) { |
| 82 | + len = Serialization.getNeedBytes(selectColumns.size()); |
| 83 | + System.arraycopy(Serialization.encodeVi64(selectColumns.size()), 0, bytes, idx, len); |
87 | 84 | idx += len; |
88 | | - } |
| 85 | + for (String selectColumn : selectColumns) { |
| 86 | + len = Serialization.getNeedBytes(selectColumn); |
| 87 | + System.arraycopy(Serialization.encodeVString(selectColumn), 0, bytes, idx, len); |
| 88 | + idx += len; |
| 89 | + } |
89 | 90 |
|
90 | | - System.arraycopy(Serialization.encodeI8(scanOrder.getByteValue()), 0, bytes, idx, 1); |
91 | | - idx += 1; |
| 91 | + System.arraycopy(Serialization.encodeI8(scanOrder.getByteValue()), 0, bytes, idx, 1); |
| 92 | + idx += 1; |
92 | 93 |
|
93 | | - if (isHbaseQuery) { |
94 | 94 | len = (int) hTableFilter.getPayloadSize(); |
95 | 95 | System.arraycopy(hTableFilter.encode(), 0, bytes, idx, len); |
96 | | - } else { |
97 | | - len = HTABLE_DUMMY_BYTES.length; |
98 | | - System.arraycopy(HTABLE_DUMMY_BYTES, 0, bytes, idx, len); |
99 | | - } |
100 | | - idx += len; |
101 | | - |
102 | | - if (isHbaseQuery && obKVParams != null) { |
103 | | - len = (int) obKVParams.getPayloadSize(); |
104 | | - System.arraycopy(obKVParams.encode(), 0, bytes, idx, len); |
105 | | - idx += len; |
106 | | - } else { |
107 | | - len = HTABLE_DUMMY_BYTES.length; |
108 | | - System.arraycopy(HTABLE_DUMMY_BYTES, 0, bytes, idx, len); |
109 | 96 | idx += len; |
110 | | - } |
111 | 97 |
|
| 98 | + if (obKVParams != null) { |
| 99 | + len = (int) obKVParams.getPayloadSize(); |
| 100 | + System.arraycopy(obKVParams.encode(), 0, bytes, idx, len); |
| 101 | + idx += len; |
| 102 | + } else { |
| 103 | + len = HTABLE_DUMMY_BYTES.length; |
| 104 | + System.arraycopy(HTABLE_DUMMY_BYTES, 0, bytes, idx, len); |
| 105 | + idx += len; |
| 106 | + } |
| 107 | + } |
112 | 108 | return bytes; |
113 | 109 | } |
114 | 110 |
|
@@ -169,21 +165,24 @@ public long getPayloadContentSize() { |
169 | 165 | payloadContentSize += Serialization.getNeedBytes(indexName); |
170 | 166 | payloadContentSize += Serialization.getNeedBytes(filterString); |
171 | 167 |
|
172 | | - payloadContentSize += Serialization.getNeedBytes(selectColumns.size()); |
173 | | - for (String selectColumn : selectColumns) { |
174 | | - payloadContentSize += Serialization.getNeedBytes(selectColumn); |
175 | | - } |
176 | | - payloadContentSize += 1; // scanOrder |
| 168 | + // calculate part required by HBase Batch Get |
| 169 | + if (isHbaseQuery && ObGlobal.isHBaseBatchGetSupport()) { |
| 170 | + payloadContentSize += Serialization.getNeedBytes(selectColumns.size()); |
| 171 | + for (String selectColumn : selectColumns) { |
| 172 | + payloadContentSize += Serialization.getNeedBytes(selectColumn); |
| 173 | + } |
| 174 | + payloadContentSize += 1; // scanOrder |
177 | 175 |
|
178 | | - if (isHbaseQuery) { |
179 | | - payloadContentSize += hTableFilter.getPayloadSize(); |
180 | | - } else { |
181 | | - payloadContentSize += HTABLE_DUMMY_BYTES.length; |
182 | | - } |
183 | | - if (isHbaseQuery && obKVParams != null) { |
184 | | - payloadContentSize += obKVParams.getPayloadSize(); |
185 | | - } else { |
186 | | - payloadContentSize += HTABLE_DUMMY_BYTES.length; |
| 176 | + if (isHbaseQuery) { |
| 177 | + payloadContentSize += hTableFilter.getPayloadSize(); |
| 178 | + } else { |
| 179 | + payloadContentSize += HTABLE_DUMMY_BYTES.length; |
| 180 | + } |
| 181 | + if (isHbaseQuery && obKVParams != null) { |
| 182 | + payloadContentSize += obKVParams.getPayloadSize(); |
| 183 | + } else { |
| 184 | + payloadContentSize += HTABLE_DUMMY_BYTES.length; |
| 185 | + } |
187 | 186 | } |
188 | 187 |
|
189 | 188 | return payloadContentSize; |
|
0 commit comments