accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From md...@apache.org
Subject [03/10] git commit: ACCUMULO-1434 Added 'empty' node to CV parse tree
Date Mon, 11 Nov 2013 19:49:51 GMT
ACCUMULO-1434 Added 'empty' node to CV parse tree


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/d059d007
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/d059d007
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/d059d007

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: d059d007766920b58946a52e2c051ab19b8e8bda
Parents: 6648056
Author: Mike Drob <mdrob@mdrob.com>
Authored: Mon Nov 11 14:10:20 2013 -0500
Committer: Mike Drob <mdrob@mdrob.com>
Committed: Mon Nov 11 14:16:34 2013 -0500

----------------------------------------------------------------------
 .../accumulo/core/security/ColumnVisibility.java       | 13 +++++++++++--
 .../accumulo/core/security/ColumnVisibilityTest.java   |  7 +++++++
 2 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/d059d007/src/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java
----------------------------------------------------------------------
diff --git a/src/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java
b/src/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java
index a7ac8e0..e628c23 100644
--- a/src/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java
+++ b/src/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java
@@ -46,8 +46,13 @@ public class ColumnVisibility {
   }
   
   public static enum NodeType {
-    TERM, OR, AND,
+    EMPTY, TERM, OR, AND,
   }
+
+  /**
+   * All empty nodes are equal and represent the same value.
+   */
+  private static final Node EMPTY_NODE = new Node(NodeType.EMPTY);
   
   public static class Node {
     public final static List<Node> EMPTY = Collections.emptyList();
@@ -104,6 +109,8 @@ public class ColumnVisibility {
       if (diff != 0)
         return diff;
       switch (a.type) {
+        case EMPTY:
+          return 0; // All empty nodes are the same
         case TERM:
           return WritableComparator.compareBytes(text, a.start, a.end - a.start, text, b.start,
b.end - b.start);
         case OR:
@@ -255,6 +262,8 @@ public class ColumnVisibility {
     if (expression != null && expression.length > 0) {
       ColumnVisibilityParser p = new ColumnVisibilityParser();
       node = p.parse(expression);
+    } else {
+      node = EMPTY_NODE;
     }
     this.expression = expression;
   }
@@ -263,7 +272,7 @@ public class ColumnVisibility {
    * Empty visibility. Normally, elements with empty visibility can be seen by everyone.
Though, one could change this behavior with filters.
    */
   public ColumnVisibility() {
-    expression = new byte[0];
+    this(new byte[] {});
   }
   
   /**

http://git-wip-us.apache.org/repos/asf/accumulo/blob/d059d007/src/core/src/test/java/org/apache/accumulo/core/security/ColumnVisibilityTest.java
----------------------------------------------------------------------
diff --git a/src/core/src/test/java/org/apache/accumulo/core/security/ColumnVisibilityTest.java
b/src/core/src/test/java/org/apache/accumulo/core/security/ColumnVisibilityTest.java
index df1863a..e698599 100644
--- a/src/core/src/test/java/org/apache/accumulo/core/security/ColumnVisibilityTest.java
+++ b/src/core/src/test/java/org/apache/accumulo/core/security/ColumnVisibilityTest.java
@@ -47,6 +47,13 @@ public class ColumnVisibilityTest {
   }
   
   @Test
+  public void testEmptyFlatten() {
+    // empty visibility is valid
+    new ColumnVisibility().flatten();
+    new ColumnVisibility("").flatten();
+  }
+
+  @Test
   public void testSimple() {
     shouldNotThrow("test", "(one)");
   }


Mime
View raw message