incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [12/28] git commit: Fixed a NPE in the fetching of a row with both columns to fetch and families to fetch being used with different families.
Date Wed, 15 Jan 2014 22:03:35 GMT
Fixed a NPE in the fetching of a row with both columns to fetch and families to fetch being
used with different 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/ae314135
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/ae314135
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/ae314135

Branch: refs/heads/master
Commit: ae3141357d358f8423b7449611644acee96a7ede
Parents: d72ce23
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Tue Jan 14 06:02:38 2014 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Wed Jan 15 17:02:27 2014 -0500

----------------------------------------------------------------------
 .../java/org/apache/blur/utils/BlurUtil.java    |  4 ++
 .../apache/blur/manager/IndexManagerTest.java   | 43 ++++++++++++++++++++
 2 files changed, 47 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ae314135/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java b/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
index 87d5b4f..da1b0dd 100644
--- a/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
+++ b/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
@@ -856,6 +856,10 @@ public class BlurUtil {
     if (columnFamiliesToFetch == null || columnFamiliesToFetch.isEmpty()) {
       return docs;
     }
+    Map<String, Set<String>> columnsToFetch = selector.getColumnsToFetch();
+    if (columnsToFetch != null) {
+      columnFamiliesToFetch.addAll(columnsToFetch.keySet());
+    }
     final Map<String, Integer> familyOrdering = getFamilyOrdering(columnFamiliesToFetch);
     Collections.sort(docs, new Comparator<Document>() {
       @Override

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ae314135/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 3ae25f7..e805930 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
@@ -40,6 +40,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Random;
 import java.util.UUID;
@@ -596,6 +597,48 @@ public class IndexManagerTest {
   }
 
   @Test
+  public void testFetchRowByRowIdWithFamilySet() throws Exception {
+    Selector selector = new Selector().setRowId("row-6");
+    selector.addToColumnFamiliesToFetch(FAMILY2);
+    FetchResult fetchResult = new FetchResult();
+    indexManager.fetchRow(TABLE, selector, fetchResult);
+    assertNotNull(fetchResult.rowResult.row);
+    Row row = newRow("row-6", newRecord(FAMILY2, "record-6C", newColumn("testcol18", "value501")));
+    row.recordCount = 1;
+    assertEquals(row, fetchResult.rowResult.row);
+  }
+
+  @Test
+  public void testFetchRowByRowIdWithColumnSet() throws Exception {
+    Selector selector = new Selector().setRowId("row-6");
+    selector.putToColumnsToFetch(FAMILY, new HashSet<String>(Arrays.asList("testcol12")));
+
+    FetchResult fetchResult = new FetchResult();
+    indexManager.fetchRow(TABLE, selector, fetchResult);
+    assertNotNull(fetchResult.rowResult.row);
+    Row row = newRow("row-6", newRecord(FAMILY, "record-6A", newColumn("testcol12", "value110")),
+        newRecord(FAMILY, "record-6B", newColumn("testcol12", "value101")));
+    row.recordCount = 2;
+    assertEquals(row, fetchResult.rowResult.row);
+  }
+
+  @Test
+  public void testFetchRowByRowIdWithFamilyAndColumnSet() throws Exception {
+    Selector selector = new Selector().setRowId("row-6");
+    selector.addToColumnFamiliesToFetch(FAMILY2);
+    selector.putToColumnsToFetch(FAMILY, new HashSet<String>(Arrays.asList("testcol12")));
+
+    FetchResult fetchResult = new FetchResult();
+    indexManager.fetchRow(TABLE, selector, fetchResult);
+    assertNotNull(fetchResult.rowResult.row);
+    Row row = newRow("row-6", newRecord(FAMILY2, "record-6C", newColumn("testcol18", "value501")),
+        newRecord(FAMILY, "record-6A", newColumn("testcol12", "value110")),
+        newRecord(FAMILY, "record-6B", newColumn("testcol12", "value101")));
+    row.recordCount = 3;
+    assertEquals(row, fetchResult.rowResult.row);
+  }
+
+  @Test
   public void testFetchRowByRowIdWithFilter() throws Exception {
     IndexManagerTestReadInterceptor.interceptor = new ReadInterceptor(null) {
       @Override


Mime
View raw message