incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [24/45] git commit: Let terms command return empty list when field isn't in the index.
Date Sat, 28 Sep 2013 02:12:10 GMT
Let terms command return empty list when field isn't in the index.


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

Branch: refs/heads/apache-blur-0.2
Commit: f102dcbf3cc0c361e03318c5a24ec67443dec4c3
Parents: ad1cdba
Author: williamstw <twilliams@apache.org>
Authored: Wed Sep 18 22:48:47 2013 -0400
Committer: williamstw <twilliams@apache.org>
Committed: Wed Sep 18 22:48:47 2013 -0400

----------------------------------------------------------------------
 .../src/main/java/org/apache/blur/manager/IndexManager.java   | 6 ++++++
 .../test/java/org/apache/blur/manager/IndexManagerTest.java   | 7 +++++++
 2 files changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f102dcbf/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 98c0bcf..a734d78 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
@@ -722,7 +722,13 @@ public class IndexManager {
     List<String> terms = new ArrayList<String>(size);
     AtomicReader areader = BlurUtil.getAtomicReader(reader);
     Terms termsAll = areader.terms(term.field());
+    
+    if(termsAll == null) {
+    	return terms;
+    }
+    
     TermsEnum termEnum = termsAll.iterator(null);
+
     termEnum.seekCeil(term.bytes());
 
     BytesRef currentTermText = termEnum.term();

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f102dcbf/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 8edb2d7..d6ff887 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
@@ -806,6 +806,13 @@ public class IndexManagerTest {
   }
 
   @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);
+    assertEquals("The terms of non-existent fields should be empty.", 0, terms.size());
+  }
+  
+  @Test
   public void testMutationReplaceRow() throws Exception {
     RowMutation mutation = newRowMutation(
         TABLE,


Mime
View raw message