incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Fixing a bug that prevented sub columns from being indexed.
Date Thu, 06 Feb 2014 22:21:20 GMT
Updated Branches:
  refs/heads/apache-blur-0.2 1a445d006 -> 912a100fa


Fixing a bug that prevented sub columns from being indexed.


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

Branch: refs/heads/apache-blur-0.2
Commit: 912a100fa08ecd403c764f27ab95de05a820a5bd
Parents: 1a445d0
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Thu Feb 6 17:21:21 2014 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Thu Feb 6 17:21:21 2014 -0500

----------------------------------------------------------------------
 .../apache/blur/analysis/BaseFieldManager.java  |  7 +++----
 .../blur/analysis/BaseFieldManagerTest.java     | 20 +++++++++++++++++++-
 2 files changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/912a100f/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 f11c504..1316161 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
@@ -395,9 +395,9 @@ public abstract class BaseFieldManager extends FieldManager {
     for (String alternateFieldName : fieldTypeDefinition.getAlternateFieldNames()) {
       _fieldNameToDefMap.put(alternateFieldName, fieldTypeDefinition);
     }
-    String baseFieldName = getBaseFieldName(fieldName);
     String subColumnName = getSubColumnName(fieldName);
     if (subColumnName != null) {
+      String baseFieldName = getBaseFieldName(fieldName);
       Set<String> subColumnNames = _columnToSubColumn.get(baseFieldName);
       if (subColumnNames == null) {
         subColumnNames = getConcurrentSet();
@@ -417,8 +417,7 @@ public abstract class BaseFieldManager extends FieldManager {
   }
 
   private String getBaseFieldName(String fieldName) {
-    int indexOf = fieldName.indexOf('.');
-    return fieldName.substring(0, indexOf);
+    return fieldName.substring(0, fieldName.lastIndexOf('.'));
   }
 
   protected FieldTypeDefinition newFieldTypeDefinition(String fieldName, boolean fieldLessIndexed,
String fieldType,
@@ -640,7 +639,7 @@ public abstract class BaseFieldManager extends FieldManager {
     }
     if (fieldTypeDefinition.checkSupportForSorting()) {
       if (fieldTypeDefinition.isSortEnable()) {
-        return fieldTypeDefinition.getSortField(reverse);  
+        return fieldTypeDefinition.getSortField(reverse);
       }
       throw new IOException("Field [" + field + "] does not have sorting enabled.");
     }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/912a100f/blur-query/src/test/java/org/apache/blur/analysis/BaseFieldManagerTest.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/analysis/BaseFieldManagerTest.java b/blur-query/src/test/java/org/apache/blur/analysis/BaseFieldManagerTest.java
index 50a2e91..b974906 100644
--- a/blur-query/src/test/java/org/apache/blur/analysis/BaseFieldManagerTest.java
+++ b/blur-query/src/test/java/org/apache/blur/analysis/BaseFieldManagerTest.java
@@ -119,7 +119,6 @@ public class BaseFieldManagerTest {
 
     int c = 0;
     List<Field> fields2 = memoryFieldManager.getFields("1", record);
-    System.out.println(fields2);
     for (Field field : fields2) {
       assertFieldEquals(fields.get(c++), field);
     }
@@ -208,6 +207,25 @@ public class BaseFieldManagerTest {
     }
   }
 
+  @Test
+  public void testFieldManagerSubName() throws IOException {
+    BaseFieldManager memoryFieldManager = newFieldManager(true);
+    memoryFieldManager.addColumnDefinition("fam1", "col1", null, false, "text", false, null);
+    memoryFieldManager.addColumnDefinition("fam1", "col1", "sub1", false, "text", false,
null);
+
+    Record record = new Record();
+    record.setRecordId("1213");
+    record.setFamily("fam1");
+    record.addToColumns(new Column("col1", "value1"));
+
+    List<Field> fields = getFields("fam1", "1", "1213", newFieldsNoStore(BlurConstants.FIELDS,
"fam1.col1"),
+        newTextField("fam1.col1", "value1"), newTextFieldNoStore("fam1.col1.sub1", "value1"));
+    int c = 0;
+    for (Field field : memoryFieldManager.getFields("1", record)) {
+      assertFieldEquals(fields.get(c++), field);
+    }
+  }
+
   private List<Field> getFields(String family, String rowId, String recordId, Field...
fields) {
     List<Field> fieldLst = new ArrayList<Field>();
     if (family != null) {


Mime
View raw message