pvary commented on a change in pull request #1095:
URL: https://github.com/apache/hive/pull/1095#discussion_r439068205



##########
File path: 
storage-api/src/java/org/apache/hadoop/hive/common/ValidReaderWriteIdList.java
##########
@@ -260,5 +260,25 @@ public RangeResponse isWriteIdRangeAborted(long 
minWriteId, long maxWriteId) {
   public ValidReaderWriteIdList updateHighWatermark(long value) {
     return new ValidReaderWriteIdList(tableName, exceptions, abortedBits, 
value, minOpenWriteId);
   }
+
+  public void locallyCommitWriteId(long writeId) {
+    if (writeId > highWatermark) {
+      highWatermark = writeId;
+      long[] newExceptions = new long[exceptions.length + (int) (writeId - 
highWatermark)];
+      System.arraycopy(exceptions, 0, newExceptions, 0, exceptions.length);
+      for (long i = highWatermark; i < writeId; i++) {
+        exceptions[exceptions.length + (int) (i - highWatermark)] = i;
+      }
+      exceptions = newExceptions;
+    } else {
+      int pos = Arrays.binarySearch(exceptions, writeId);
+      if (pos >= 0) {
+        long[] newExceptions = new long[exceptions.length - 1];
+        System.arraycopy(exceptions, 0, newExceptions, 0, pos);
+        System.arraycopy(exceptions, pos + 1, newExceptions, pos, 
exceptions.length - pos - 1);
+        exceptions = newExceptions;
+      }
+    }
+  }

Review comment:
       Again this is for optimization




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

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to