incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Fix to read mask.
Date Tue, 01 Dec 2015 21:31:47 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/master 289de4e9e -> 55cc3f685


Fix to read mask.


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

Branch: refs/heads/master
Commit: 55cc3f685ce55c079e4c830f15a5fc764f42cb80
Parents: 289de4e
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Tue Dec 1 16:31:36 2015 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Tue Dec 1 16:31:36 2015 -0500

----------------------------------------------------------------------
 .../security/index/FilterAccessControlFactory.java     | 10 ++--------
 .../type/BaseReadMaskFieldTypeDefinitionTest.java      | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/55cc3f68/blur-document-security/src/main/java/org/apache/blur/lucene/security/index/FilterAccessControlFactory.java
----------------------------------------------------------------------
diff --git a/blur-document-security/src/main/java/org/apache/blur/lucene/security/index/FilterAccessControlFactory.java
b/blur-document-security/src/main/java/org/apache/blur/lucene/security/index/FilterAccessControlFactory.java
index b9414da..059ad05 100644
--- a/blur-document-security/src/main/java/org/apache/blur/lucene/security/index/FilterAccessControlFactory.java
+++ b/blur-document-security/src/main/java/org/apache/blur/lucene/security/index/FilterAccessControlFactory.java
@@ -47,7 +47,6 @@ import org.apache.lucene.document.TextField;
 import org.apache.lucene.index.AtomicReader;
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.IndexableField;
-import org.apache.lucene.index.IndexableFieldType;
 import org.apache.lucene.search.DocIdSet;
 import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.Filter;
@@ -339,9 +338,7 @@ public class FilterAccessControlFactory extends AccessControlFactory {
       }
       List<IndexableField> result = new ArrayList<IndexableField>();
       for (IndexableField field : fields) {
-        IndexableFieldType fieldType = field.fieldType();
-        // If field is to be indexed and is to be read masked.
-        if (fieldsToMask.contains(field.name()) && fieldType.indexed()) {
+        if (fieldsToMask.contains(field.name())) {
           // If field is a doc value, then don't bother indexing.
           if (!isDocValue(field)) {
             if (isStoredField(field)) {
@@ -382,10 +379,7 @@ public class FilterAccessControlFactory extends AccessControlFactory
{
     }
 
     private static boolean isStoredField(IndexableField field) {
-      if (field instanceof StoredField) {
-        return true;
-      }
-      return false;
+      return !field.fieldType().indexed();
     }
 
     private static IndexableField createMaskField(IndexableField field) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/55cc3f68/blur-query/src/test/java/org/apache/blur/analysis/type/BaseReadMaskFieldTypeDefinitionTest.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/analysis/type/BaseReadMaskFieldTypeDefinitionTest.java
b/blur-query/src/test/java/org/apache/blur/analysis/type/BaseReadMaskFieldTypeDefinitionTest.java
index 4f4f29c..8be969b 100644
--- a/blur-query/src/test/java/org/apache/blur/analysis/type/BaseReadMaskFieldTypeDefinitionTest.java
+++ b/blur-query/src/test/java/org/apache/blur/analysis/type/BaseReadMaskFieldTypeDefinitionTest.java
@@ -49,6 +49,7 @@ import org.apache.lucene.index.Fields;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.SortedDocValues;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
@@ -159,7 +160,7 @@ public abstract class BaseReadMaskFieldTypeDefinitionTest {
   }
 
   private void setupFieldManager(BaseFieldManager fieldManager) throws IOException {
-    fieldManager.addColumnDefinition(FAM, "string", null, false, "string", false, false,
null);
+    fieldManager.addColumnDefinition(FAM, "string", null, false, "string", true, false, null);
     fieldManager.addColumnDefinition(FAM, "string2", null, false, "string", false, false,
null);
     fieldManager.addColumnDefinition(FAM, "read", null, false, "acl-read", false, false,
null);
     fieldManager.addColumnDefinition(FAM, "mask", null, false, "read-mask", false, false,
null);
@@ -221,6 +222,16 @@ public abstract class BaseReadMaskFieldTypeDefinitionTest {
           assertEquals(defaultReadMask, s);
         }
       }
+
+      String s = document.get("fam.string");
+      if (s == null || s.equals(getDefaultReadMask())) {
+        AtomicReader atomicReader = searcher.getIndexReader().leaves().get(0).reader();
+        SortedDocValues sortedDocValues = atomicReader.getSortedDocValues("fam.string");
+        BytesRef result = new BytesRef();
+        sortedDocValues.get(doc, result);
+        assertEquals(0, result.length);
+      }
+
     }
 
     reader.close();


Mime
View raw message