incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Fixed BLUR-416
Date Mon, 16 Mar 2015 13:57:42 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/master dede09fc1 -> e186d7ad5


Fixed BLUR-416


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

Branch: refs/heads/master
Commit: e186d7ad530fbe01f074ee19366769ee50cda337
Parents: dede09f
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Mon Mar 16 09:57:23 2015 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Mon Mar 16 09:57:23 2015 -0400

----------------------------------------------------------------------
 .../java/org/apache/blur/utils/BlurUtil.java    |  7 ++--
 .../apache/blur/manager/IndexManagerTest.java   | 36 ++++++++++++++++++++
 2 files changed, 40 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/e186d7ad/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 dfd2043..fc0be76 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
@@ -886,16 +886,17 @@ public class BlurUtil {
       if (indexOf < 0) {
         throw new IOException("Location id [" + locationId + "] not valid");
       }
-      int notAdjustedPrimeDocId = Integer.parseInt(locationId.substring(indexOf + 1));
-      int readerIndex = BaseCompositeReaderUtil.readerIndex(indexReader, notAdjustedPrimeDocId);
+      int notAdjustedRequestedDocId = Integer.parseInt(locationId.substring(indexOf + 1));
+      int readerIndex = BaseCompositeReaderUtil.readerIndex(indexReader, notAdjustedRequestedDocId);
       int readerBase = BaseCompositeReaderUtil.readerBase(indexReader, readerIndex);
-      int primeDocId = notAdjustedPrimeDocId - readerBase;
+      int requestedDocId = notAdjustedRequestedDocId - readerBase;
       IndexReader orgReader = sequentialSubReaders.get(readerIndex);
       if (orgReader != null && orgReader instanceof AtomicReader) {
         AtomicReader atomicReader = (AtomicReader) orgReader;
         Bits liveDocs = atomicReader.getLiveDocs();
 
         OpenBitSet bitSet = PrimeDocCache.getPrimeDocBitSet(primeDocTerm, atomicReader);
+        int primeDocId = bitSet.prevSetBit(requestedDocId);
         int nextPrimeDoc = bitSet.nextSetBit(primeDocId + 1);
         int numberOfDocsInRow;
         if (nextPrimeDoc == -1) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/e186d7ad/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 d51f8cd..5960e0e 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
@@ -605,6 +605,42 @@ public class IndexManagerTest {
   }
 
   @Test
+  public void testFetchRowByLocationIdFromRecordOnlySearch() throws Exception {
+
+    BlurQuery blurQuery = new BlurQuery();
+    Query query = new Query();
+    query.setQuery("recordid:record-5B");
+    query.setRowQuery(false);
+    blurQuery.setQuery(query);
+
+    BlurResultIterable blurResultIterable = indexManager.query(TABLE, blurQuery, null);
+    BlurIterator<BlurResult, BlurException> iterator = blurResultIterable.iterator();
+    String locationId = null;
+    if (iterator.hasNext()) {
+      BlurResult result = iterator.next();
+      locationId = result.locationId;
+    } else {
+      fail();
+    }
+
+    Selector selector = new Selector().setLocationId(locationId);
+    FetchResult fetchResult = new FetchResult();
+    indexManager.fetchRow(TABLE, selector, fetchResult);
+    assertNotNull(fetchResult.rowResult.row);
+
+    Row row = newRow(
+        "row-5",
+        newRecord(FAMILY, "record-5A", newColumn("testcol1", "value13"), newColumn("testcol2",
"value14"),
+            newColumn("testcol3", "value15")),
+        newRecord(FAMILY, "record-5B", newColumn("testcol1", "value16"), newColumn("testcol2",
"value17"),
+            newColumn("testcol3", "value18"), newColumn("testcol3", "value19")));
+    assertEquals(row, fetchResult.rowResult.row);
+    FetchRowResult rowResult = fetchResult.getRowResult();
+    assertEquals(row, rowResult.getRow());
+    assertEquals(2, rowResult.getTotalRecords());
+  }
+
+  @Test
   public void testFetchMissingRowByLocationId() throws Exception {
     try {
       Selector selector = new Selector().setLocationId("shard4/0");


Mime
View raw message