You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "ctubbsii (via GitHub)" <gi...@apache.org> on 2023/04/25 21:26:37 UTC

[GitHub] [accumulo] ctubbsii commented on a diff in pull request #3342: WIP - Add RowRange object

ctubbsii commented on code in PR #3342:
URL: https://github.com/apache/accumulo/pull/3342#discussion_r1177071781


##########
core/src/main/java/org/apache/accumulo/core/data/RowRange.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.core.data;
+
+import org.apache.hadoop.io.Text;
+
+/**
+ * This class is used to specify a range of rows.
+ */
+public class RowRange {
+  final private Text startRow;
+  final private Text endRow;
+  final private boolean startRowInclusive;
+  final private boolean endRowInclusive;
+  private final boolean infiniteStartRow;
+  private final boolean infiniteEndRow;
+
+  /**
+   * Creates a range of rows that goes from negative to positive infinity
+   */

Review Comment:
   This is a common way we've expressed this, but it's technically incorrect. The range goes from an empty byte array to an infinitely large byte array of all 1 bits. We should try to find a better way to express this succinctly.
   
   Maybe "from null to positive infinity" or "from no bytes to positive infinity" or "range that includes all possible rows".



##########
core/src/main/java/org/apache/accumulo/core/data/RowRange.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.core.data;
+
+import org.apache.hadoop.io.Text;
+
+/**
+ * This class is used to specify a range of rows.
+ */
+public class RowRange {
+  final private Text startRow;
+  final private Text endRow;
+  final private boolean startRowInclusive;
+  final private boolean endRowInclusive;
+  private final boolean infiniteStartRow;
+  private final boolean infiniteEndRow;
+
+  /**
+   * Creates a range of rows that goes from negative to positive infinity
+   */
+  public RowRange() {
+    this(null, true, null, true);
+  }
+
+  /**
+   * Creates a range of rows from startRow inclusive to endRow inclusive.
+   *
+   * @param startRow starting row; set to null for negative infinity

Review Comment:
   ```suggestion
      * @param startRow starting row; set to null for the smallest possible row (an empty one)
   ```
   
   Instead of overloading constructors, you could have static entry points to more clearly express bounded and unbounded ranges. See [Guava's Range API](https://guava.dev/releases/19.0/api/docs/com/google/common/collect/Range.html) for a really good example of static entry points with phrases like "atLeast(lowerBound)", or "atMost(upperBound)" or "between(lowerBound,upperBound)". If we're adding any new Range API, these would be really useful to have right up front, rather than trying to add them in later.



-- 
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: notifications-unsubscribe@accumulo.apache.org

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