meszibalu commented on code in PR #105:
URL: https://github.com/apache/hbase-connectors/pull/105#discussion_r1023992023


##########
spark/hbase-spark/src/main/scala/org/apache/hadoop/hbase/spark/datasources/Utils.scala:
##########
@@ -89,4 +89,47 @@ object Utils {
       }
     }
   }
+
+  // increment Byte array's value by 1
+  def incrementByteArray(array: Array[Byte]): Array[Byte] = {
+    if (array.length == 0) {
+      return null
+    }
+    var index = -1 // index of the byte we have to increment
+    var a = array.length - 1
+
+    while (a >= 0) {
+      if (array(a) != (-1).toByte) {
+        index = a
+        a = -1 // break from the loop because we found a non -1 element
+      }
+      a = a - 1
+    }
+
+    val shouldIncreaseLength = index < 0
+    var newLenght = array.length - 1

Review Comment:
   `newLength`



##########
spark/hbase-spark/src/main/scala/org/apache/hadoop/hbase/spark/datasources/Utils.scala:
##########
@@ -89,4 +89,47 @@ object Utils {
       }
     }
   }
+
+  // increment Byte array's value by 1
+  def incrementByteArray(array: Array[Byte]): Array[Byte] = {
+    if (array.length == 0) {
+      return null
+    }
+    var index = -1 // index of the byte we have to increment
+    var a = array.length - 1
+
+    while (a >= 0) {
+      if (array(a) != (-1).toByte) {
+        index = a
+        a = -1 // break from the loop because we found a non -1 element
+      }
+      a = a - 1
+    }
+
+    val shouldIncreaseLength = index < 0
+    var newLenght = array.length - 1
+
+    if (shouldIncreaseLength) {

Review Comment:
   Why should we increase the length? If someone passes `0xFF` for `startsWith` 
then it is true that `0x01 0x00` if the next value, however the scan range in 
`startsWith` going to be `0xFF <= row < 0x10 0x00` which is wrong.



-- 
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]

Reply via email to