keith-turner commented on code in PR #89:
URL: https://github.com/apache/accumulo-access/pull/89#discussion_r2608441749


##########
src/main/java/org/apache/accumulo/access/BytesWrapper.java:
##########
@@ -22,10 +22,12 @@
 import static java.util.Objects.checkFromIndexSize;
 import static java.util.Objects.checkIndex;
 
+import java.io.Serializable;
 import java.util.Arrays;
 
-final class BytesWrapper implements Comparable<BytesWrapper> {
+public final class BytesWrapper implements Comparable<BytesWrapper>, 
Serializable {

Review Comment:
   If this will be in the public api then could just call it `Bytes`.  It would 
need a since tag.  Also could add a `byte[] toArray()` method that returns a 
copy of the array.  The `byteAt()` method should be made public.



##########
src/main/java/org/apache/accumulo/access/StringUtils.java:
##########
@@ -0,0 +1,36 @@
+/*
+ * 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
+ *
+ *   https://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.accumulo.access;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+/**
+ * Utilities for String to byte[] conversion and vice-versa
+ */
+public class StringUtils {

Review Comment:
   Anything public in this package will be in the public API.  Is this intended 
to be in the public API?  Feels out of scope to me.   
   
   ```suggestion
   class StringUtils {
   ```



##########
src/main/java/org/apache/accumulo/access/AccessExpressionImpl.java:
##########
@@ -18,40 +18,35 @@
  */
 package org.apache.accumulo.access;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.accumulo.access.ByteUtils.EMPTY_BYTES;
 
+import java.util.Arrays;
 import java.util.concurrent.atomic.AtomicReference;
 
 final class AccessExpressionImpl extends AccessExpression {
 
   private static final long serialVersionUID = 1L;
 
-  public static final AccessExpression EMPTY = new AccessExpressionImpl("");
+  public static final AccessExpression EMPTY = new 
AccessExpressionImpl(EMPTY_BYTES);
 
-  private final String expression;
+  private final byte[] expression;
   private final AtomicReference<ParsedAccessExpression> parseTreeRef = new 
AtomicReference<>();
 
-  AccessExpressionImpl(String expression) {
-    validate(expression);
-    this.expression = expression;
-  }
-
   AccessExpressionImpl(byte[] expression) {
     validate(expression);
-    this.expression = new String(expression, UTF_8);
+    this.expression = Arrays.copyOf(expression, expression.length);
   }
 
   @Override
-  public String getExpression() {
+  public byte[] getExpression() {
     return expression;

Review Comment:
   This needs to copy if we want to keep AccessExpressions immutable.



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