tkhurana commented on code in PR #1937:
URL: https://github.com/apache/phoenix/pull/1937#discussion_r1679839171
##########
phoenix-core-client/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java:
##########
@@ -220,14 +223,24 @@ public boolean evaluate(Tuple tuple,
ImmutableBytesWritable ptr) {
// we'd have an ambiguity if this value happened
to be the
// min possible value.
previousCarryOver = childType == null ||
childType.isFixedWidth();
- int bytesToWrite = getExpressionByteCount(child);
- for (int m = 0; m < bytesToWrite; m++) {
- output.write(QueryConstants.SEPARATOR_BYTE);
+ if (childType == PVarbinaryEncoded.INSTANCE) {
+
output.write(QueryConstants.VARBINARY_ENCODED_SEPARATOR_BYTES);
+ } else {
+ int bytesToWrite =
getExpressionByteCount(child);
+ for (int m = 0; m < bytesToWrite; m++) {
+
output.write(QueryConstants.SEPARATOR_BYTE);
+ }
}
} else {
output.write(tempPtr.get(), tempPtr.getOffset(),
tempPtr.getLength());
if (!childType.isFixedWidth()) {
- output.write(SchemaUtil.getSeparatorByte(true,
false, child));
+ if (childType != PVarbinaryEncoded.INSTANCE) {
+
output.write(SchemaUtil.getSeparatorByte(true, false, child));
+ } else {
+ output.write(
+
SchemaUtil.getSeparatorBytesForVarBinaryEncoded(true, false,
+ child.getSortOrder()));
+ }
Review Comment:
Could we introduce an API which always returns a byte array and we simply
iterate over the array. That should work regardless whether there is one
separator byte or multiple and reduce the amount of code duplication.
##########
phoenix-core-client/src/main/java/org/apache/phoenix/filter/SkipScanFilter.java:
##########
@@ -576,13 +577,21 @@ private void setStartKey() {
private int setStartKey(ImmutableBytesWritable ptr, int offset, int i, int
nSlots, boolean atEndOfKey) {
int length = ptr.getOffset() - offset;
- startKey = copyKey(startKey, length + this.maxKeyLength, ptr.get(),
offset, length);
+ startKey = copyKey(startKey, length + this.maxKeyLength + 1,
ptr.get(), offset, length);
startKeyLength = length;
// Add separator byte if we're at end of the key, since trailing
separator bytes are stripped
- if (atEndOfKey && i > 0 && i-1 < nSlots) {
- Field field = schema.getField(i-1);
+ if (atEndOfKey && i > 0 && i - 1 < nSlots) {
+ Field field = schema.getField(i - 1);
if (!field.getDataType().isFixedWidth()) {
- startKey[startKeyLength++] =
SchemaUtil.getSeparatorByte(schema.rowKeyOrderOptimizable(), true, field);
+ if (field.getDataType() != PVarbinaryEncoded.INSTANCE) {
+ startKey[startKeyLength++] =
+
SchemaUtil.getSeparatorByte(schema.rowKeyOrderOptimizable(), true, field);
+ } else {
+ byte[] sepBytes =
SchemaUtil.getSeparatorBytesForVarBinaryEncoded(
+ schema.rowKeyOrderOptimizable(), true,
field.getSortOrder());
+ startKey[startKeyLength++] = sepBytes[0];
+ startKey[startKeyLength++] = sepBytes[1];
+ }
Review Comment:
Could we introduce an API which always returns a byte array and we simply
iterate over the array. That should work regardless whether there is one
separator byte or multiple and reduce the amount of code duplication.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]