virajjasani commented on code in PR #1937:
URL: https://github.com/apache/phoenix/pull/1937#discussion_r1759134665


##########
phoenix-core-client/src/main/java/org/apache/phoenix/schema/RowKeySchema.java:
##########
@@ -232,11 +262,24 @@ public Boolean previous(ImmutableBytesWritable ptr, int 
position, int minOffset)
             byte[] buf = ptr.get();
             int offset = ptr.getOffset()-1-offsetAdjustment;
             // Separator always zero byte if zero length
-            if (offset > minOffset && buf[offset] != 
QueryConstants.SEPARATOR_BYTE) {
-                byte sepByte = 
SchemaUtil.getSeparatorByte(rowKeyOrderOptimizable, false, field);
-                do {
-                    offset--;
-                } while (offset > minOffset && buf[offset] != sepByte);
+            if (field.getDataType() != PVarbinaryEncoded.INSTANCE) {
+                if (offset > minOffset && buf[offset] != 
QueryConstants.SEPARATOR_BYTE) {
+                    byte sepByte =
+                        SchemaUtil.getSeparatorByte(rowKeyOrderOptimizable, 
false, field);
+                    do {
+                        offset--;
+                    } while (offset > minOffset && buf[offset] != sepByte);
+                }
+            } else {
+                if (offset > minOffset && 
SchemaUtil.areSeparatorBytesForVarBinaryEncoded(buf,
+                    offset, SortOrder.ASC)) {
+                    boolean ascSort =
+                        !rowKeyOrderOptimizable || field.getSortOrder() == 
SortOrder.ASC;
+                    do {
+                        offset++;

Review Comment:
   Excellent catch, previous() is not being tested by the tests



-- 
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: issues-unsubscr...@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to