lidavidm commented on code in PR #38266:
URL: https://github.com/apache/arrow/pull/38266#discussion_r1367483526


##########
java/vector/src/main/java/org/apache/arrow/vector/util/ReusableByteArray.java:
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.arrow.vector.util;
+
+import java.util.Arrays;
+import java.util.Base64;
+
+import org.apache.arrow.memory.ArrowBuf;
+import org.apache.arrow.memory.ReusableBuffer;
+
+/**
+ * A wrapper around byte arrays for repeated writing.
+ */
+public class ReusableByteArray implements ReusableBuffer<byte[]> {
+
+  protected static final byte[] EMPTY_BYTES = new byte[0];
+
+  protected byte[] bytes;
+  protected int length;
+
+  public ReusableByteArray() {
+    bytes = EMPTY_BYTES;
+  }
+
+  /**
+   * Get the number of bytes in the byte array.
+   *
+   * @return the number of bytes in the byte array
+   */
+  @Override
+  public long getLength() {
+    return length;
+  }
+
+  @Override
+  public byte[] getBuffer() {
+    return bytes;
+  }
+
+  @Override
+  public void set(ArrowBuf srcBytes, long start, long len) {
+    setCapacity((int) len, false);
+    srcBytes.getBytes(start, bytes, 0, (int) len);
+    length = (int) len;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (o == this) {
+      return true;
+    } else if (o == null) {
+      return false;
+    }
+    if (!(o instanceof ReusableByteArray)) {
+      return false;
+    }
+
+    final ReusableByteArray that = (ReusableByteArray) o;
+    if (this.getLength() != that.getLength()) {
+      return false;
+    }
+
+    // copied from Arrays.equals so we don'thave to copy the byte arrays

Review Comment:
   Ok, it was introduced in c322cbf225b5da5e17ceec0e9e7373852bcba85c and that 
was contemporary with Java 7/Java 8 (Feb 2017). Looking at the OpenJDK source 
for both of those, it appears this is different than Arrays.equals in both 
(well, the algorithm is the same but it doesn't appear to be a copy-paste) so I 
think we're clear.
   
   Can you remove the comments here and below?



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