incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [2/2] git commit: Fixing issue with using acl-read and acl-discover types across column families.
Date Tue, 07 Apr 2015 12:39:10 GMT
Fixing issue with using acl-read and acl-discover types across column families.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/96592cc3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/96592cc3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/96592cc3

Branch: refs/heads/master
Commit: 96592cc326afa168c8d937d5080194726a81cecd
Parents: 5e6589f
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Tue Apr 7 08:39:35 2015 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Tue Apr 7 08:39:35 2015 -0400

----------------------------------------------------------------------
 .../java/org/apache/blur/analysis/BaseFieldManager.java  | 11 ++++++++++-
 .../org/apache/blur/analysis/FieldTypeDefinition.java    |  8 ++++++++
 .../analysis/type/AclDiscoverFieldTypeDefinition.java    |  7 ++++++-
 .../blur/analysis/type/AclReadFieldTypeDefinition.java   |  7 ++++++-
 .../type/AclDiscoverFieldTypeDefinitionTest.java         |  3 +++
 .../analysis/type/AclReadFieldTypeDefinitionTest.java    |  3 +++
 6 files changed, 36 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/96592cc3/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java b/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java
index f4f8f6e..42f33c9 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/BaseFieldManager.java
@@ -405,8 +405,17 @@ public abstract class BaseFieldManager extends FieldManager {
     fieldTypeDefinition = newFieldTypeDefinition(fieldName, fieldLessIndexed, fieldType,
sortable, multiValueField,
         props);
     synchronized (_fieldNameToDefMap) {
+      boolean alternateFieldNamesSharedAcrossInstances = fieldTypeDefinition
+          .isAlternateFieldNamesSharedAcrossInstances();
       for (String alternateFieldName : fieldTypeDefinition.getAlternateFieldNames()) {
-        if (_fieldNameToDefMap.containsKey(alternateFieldName)) {
+        if (alternateFieldNamesSharedAcrossInstances && _fieldNameToDefMap.containsKey(alternateFieldName))
{
+          FieldTypeDefinition ftd = _fieldNameToDefMap.get(alternateFieldName);
+          if (!ftd.getName().equals(fieldTypeDefinition.getName())) {
+            throw new IllegalArgumentException("Alternate fieldName collision of [" + alternateFieldName
+                + "] from field type definition [" + fieldTypeDefinition
+                + "], this field type definition cannot be added.");
+          }
+        } else if (_fieldNameToDefMap.containsKey(alternateFieldName)) {
           throw new IllegalArgumentException("Alternate fieldName collision of [" + alternateFieldName
               + "] from field type definition [" + fieldTypeDefinition
               + "], this field type definition cannot be added.");

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/96592cc3/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java b/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java
index 4fc6452..101ef62 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/FieldTypeDefinition.java
@@ -258,4 +258,12 @@ public abstract class FieldTypeDefinition {
     return _multiValueField;
   }
 
+  /**
+   * If true this will allow the same alternate field name(s) across instances of the same
{@link FieldTypeDefinition}.
+   * @return booelan.
+   */
+  public boolean isAlternateFieldNamesSharedAcrossInstances() {
+    return false;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/96592cc3/blur-query/src/main/java/org/apache/blur/analysis/type/AclDiscoverFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/AclDiscoverFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/AclDiscoverFieldTypeDefinition.java
index d5a13e5..ca65a27 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/AclDiscoverFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/AclDiscoverFieldTypeDefinition.java
@@ -56,7 +56,7 @@ public class AclDiscoverFieldTypeDefinition extends FieldTypeDefinition
{
 
   @Override
   public void configure(String fieldNameForThisInstance, Map<String, String> properties,
Configuration configuration) {
-    
+
   }
 
   @Override
@@ -65,6 +65,11 @@ public class AclDiscoverFieldTypeDefinition extends FieldTypeDefinition
{
   }
 
   @Override
+  public boolean isAlternateFieldNamesSharedAcrossInstances() {
+    return true;
+  }
+
+  @Override
   public Iterable<? extends Field> getFieldsForColumn(String family, Column column)
{
     String fieldName = getFieldName();
     String value = column.getValue();

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/96592cc3/blur-query/src/main/java/org/apache/blur/analysis/type/AclReadFieldTypeDefinition.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/analysis/type/AclReadFieldTypeDefinition.java
b/blur-query/src/main/java/org/apache/blur/analysis/type/AclReadFieldTypeDefinition.java
index 52e37b2..1342362 100644
--- a/blur-query/src/main/java/org/apache/blur/analysis/type/AclReadFieldTypeDefinition.java
+++ b/blur-query/src/main/java/org/apache/blur/analysis/type/AclReadFieldTypeDefinition.java
@@ -56,7 +56,7 @@ public class AclReadFieldTypeDefinition extends FieldTypeDefinition {
 
   @Override
   public void configure(String fieldNameForThisInstance, Map<String, String> properties,
Configuration configuration) {
-    
+
   }
 
   @Override
@@ -65,6 +65,11 @@ public class AclReadFieldTypeDefinition extends FieldTypeDefinition {
   }
 
   @Override
+  public boolean isAlternateFieldNamesSharedAcrossInstances() {
+    return true;
+  }
+
+  @Override
   public Iterable<? extends Field> getFieldsForColumn(String family, Column column)
{
     String fieldName = getFieldName();
     String value = column.getValue();

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/96592cc3/blur-query/src/test/java/org/apache/blur/analysis/type/AclDiscoverFieldTypeDefinitionTest.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/analysis/type/AclDiscoverFieldTypeDefinitionTest.java
b/blur-query/src/test/java/org/apache/blur/analysis/type/AclDiscoverFieldTypeDefinitionTest.java
index 19e27cd..8e68b53 100644
--- a/blur-query/src/test/java/org/apache/blur/analysis/type/AclDiscoverFieldTypeDefinitionTest.java
+++ b/blur-query/src/test/java/org/apache/blur/analysis/type/AclDiscoverFieldTypeDefinitionTest.java
@@ -63,6 +63,7 @@ import org.junit.Test;
 public class AclDiscoverFieldTypeDefinitionTest {
 
   private static final String FAM = "fam";
+  private static final String FAM2 = "fam2";
 
   private Directory _dir = new RAMDirectory();
   private AccessControlFactory _accessControlFactory = new FilterAccessControlFactory();
@@ -147,6 +148,8 @@ public class AclDiscoverFieldTypeDefinitionTest {
   private void setupFieldManager(BaseFieldManager fieldManager) throws IOException {
     fieldManager.addColumnDefinition(FAM, "string", null, false, "string", false, false,
null);
     fieldManager.addColumnDefinition(FAM, "discover", null, false, "acl-discover", false,
false, null);
+    fieldManager.addColumnDefinition(FAM2, "string", null, false, "string", false, false,
null);
+    fieldManager.addColumnDefinition(FAM2, "discover", null, false, "acl-discover", false,
false, null);
   }
 
   protected BaseFieldManager getFieldManager(Analyzer a) throws IOException {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/96592cc3/blur-query/src/test/java/org/apache/blur/analysis/type/AclReadFieldTypeDefinitionTest.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/analysis/type/AclReadFieldTypeDefinitionTest.java
b/blur-query/src/test/java/org/apache/blur/analysis/type/AclReadFieldTypeDefinitionTest.java
index c221367..7d4c323 100644
--- a/blur-query/src/test/java/org/apache/blur/analysis/type/AclReadFieldTypeDefinitionTest.java
+++ b/blur-query/src/test/java/org/apache/blur/analysis/type/AclReadFieldTypeDefinitionTest.java
@@ -59,6 +59,7 @@ import org.junit.Test;
 public class AclReadFieldTypeDefinitionTest {
 
   private static final String FAM = "fam";
+  private static final String FAM2 = "fam2";
 
   private Directory _dir = new RAMDirectory();
   private AccessControlFactory _accessControlFactory = new FilterAccessControlFactory();
@@ -143,6 +144,8 @@ public class AclReadFieldTypeDefinitionTest {
   private void setupFieldManager(BaseFieldManager fieldManager) throws IOException {
     fieldManager.addColumnDefinition(FAM, "string", null, false, "string", false, false,
null);
     fieldManager.addColumnDefinition(FAM, "read", null, false, "acl-read", false, false,
null);
+    fieldManager.addColumnDefinition(FAM2, "string", null, false, "string", false, false,
null);
+    fieldManager.addColumnDefinition(FAM2, "read", null, false, "acl-read", false, false,
null);
   }
 
   protected BaseFieldManager getFieldManager(Analyzer a) throws IOException {


Mime
View raw message