You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2022/11/18 16:14:38 UTC

[GitHub] [hbase-connectors] richardantal commented on a diff in pull request #105: HBASE-27397 Spark-hbase support for 'startWith' predicate

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


##########
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:
   You are right. 
   I updated the PR so that when someone passes `0xFF` or `-1` in the code then the endrange will be `null`



-- 
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-unsubscribe@hbase.apache.org

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