incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [1/4] git commit: Fixing issue with terms lookup.
Date Mon, 21 Sep 2015 14:43:02 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/master 55ef5b897 -> af67f6c2b


Fixing issue with terms lookup.


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

Branch: refs/heads/master
Commit: 3c30ddd801150b577d86a98fe762872aee20e04a
Parents: 55ef5b8
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Mon Sep 21 10:39:27 2015 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Mon Sep 21 10:39:27 2015 -0400

----------------------------------------------------------------------
 .../java/org/apache/blur/manager/IndexManager.java   | 15 +++++++++++----
 .../org/apache/blur/manager/IndexManagerTest.java    |  8 +++++++-
 2 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3c30ddd8/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java b/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
index acd473a..de225d5 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
@@ -1042,10 +1042,7 @@ public class IndexManager {
 
     BytesRef currentTermText = termEnum.term();
     do {
-      terms.add(currentTermText.utf8ToString());
-      String readTerm = typeDef.readTerm(currentTermText);
-      if (readTerm != null)
-        terms.add(readTerm);
+      terms.add(convert(typeDef, currentTermText));
       if (terms.size() >= size) {
         return terms;
       }
@@ -1053,6 +1050,16 @@ public class IndexManager {
     return terms;
   }
 
+  private static String convert(FieldTypeDefinition typeDef, BytesRef currentTermText) {
+    if (typeDef != null) {
+      String readTerm = typeDef.readTerm(currentTermText);
+      if (readTerm != null) {
+        return readTerm;
+      }
+    }
+    return currentTermText.utf8ToString();
+  }
+
   private static Term getTerm(String columnFamily, String columnName, String value) {
     if (columnName == null) {
       throw new NullPointerException("ColumnName cannot be null.");

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3c30ddd8/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java b/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java
index 250f8e4..7ea90be 100644
--- a/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java
+++ b/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java
@@ -1194,6 +1194,12 @@ public class IndexManagerTest {
   }
 
   @Test
+  public void testTerms2() throws Exception {
+    List<String> terms = indexManager.terms(TABLE, FAMILY, "rowid", "", (short) 100);
+    assertEquals(Arrays.asList("row-1", "row-2", "row-3", "row-4", "row-5", "row-6", "row-7"),
terms);
+  }
+
+  @Test
   public void testTermsNonExistentField() throws Exception {
     List<String> terms = indexManager.terms(TABLE, FAMILY, "nonexistentfield", "",
(short) 100);
     assertNotNull("Non-existent fields should not return null.", terms);
@@ -1236,7 +1242,7 @@ public class IndexManagerTest {
     } catch (BlurException e) {
     }
   }
-  
+
   @Test
   public void testMutationReplaceRowWithNullRowId() throws Exception {
     RowMutation mutation = newRowMutation(


Mime
View raw message