incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [12/14] git commit: Fixes for the record ordering.
Date Wed, 15 Jan 2014 22:03:59 GMT
Fixes for the record ordering.


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

Branch: refs/heads/apache-blur-0.2
Commit: ecadcb1c3ece5b9ccffba9898910202c07e30f54
Parents: 3c9089a
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Wed Jan 15 15:41:13 2014 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Wed Jan 15 15:41:13 2014 -0500

----------------------------------------------------------------------
 .../java/org/apache/blur/utils/BlurUtil.java    | 24 +++++++++++---------
 .../apache/blur/manager/IndexManagerTest.java   |  2 ++
 2 files changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ecadcb1c/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 01271bf..50634fa 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
@@ -799,14 +799,14 @@ public class BlurUtil {
    * @param selector
    * @param primeDocTerm
    * @param filter
-   * @param totalRecords 
+   * @param totalRecords
    * 
    * @throws IOException
    */
   @SuppressWarnings("unchecked")
   public static List<Document> fetchDocuments(IndexReader reader, ResetableDocumentStoredFieldVisitor
fieldSelector,
-      Selector selector, int maxHeap, String context, Term primeDocTerm, Filter filter, AtomicBoolean
moreToFetch, AtomicInteger totalRecords)
-      throws IOException {
+      Selector selector, int maxHeap, String context, Term primeDocTerm, Filter filter, AtomicBoolean
moreToFetch,
+      AtomicInteger totalRecords) throws IOException {
     if (reader instanceof BaseCompositeReader) {
       BaseCompositeReader<IndexReader> indexReader = (BaseCompositeReader<IndexReader>)
reader;
       List<? extends IndexReader> sequentialSubReaders = BaseCompositeReaderUtil.getSequentialSubReaders(indexReader);
@@ -879,16 +879,19 @@ public class BlurUtil {
   }
 
   private static List<Document> orderDocsBasedOnFamilyOrder(List<Document> docs,
Selector selector) {
-    List<String> columnFamiliesToFetch = selector.getColumnFamiliesToFetch() == null
? null : new ArrayList<String>(
-        selector.getColumnFamiliesToFetch());
-    if (columnFamiliesToFetch == null || columnFamiliesToFetch.isEmpty()) {
+    List<String> orderOfFamiliesToFetch = selector.getOrderOfFamiliesToFetch();
+    if (orderOfFamiliesToFetch == null || orderOfFamiliesToFetch.isEmpty()) {
       return docs;
     }
+    Set<String> columnFamiliesToFetch = selector.getColumnFamiliesToFetch();
+    if (columnFamiliesToFetch != null) {
+      orderOfFamiliesToFetch.addAll(columnFamiliesToFetch);
+    }
     Map<String, Set<String>> columnsToFetch = selector.getColumnsToFetch();
     if (columnsToFetch != null) {
-      columnFamiliesToFetch.addAll(columnsToFetch.keySet());
+      orderOfFamiliesToFetch.addAll(columnsToFetch.keySet());
     }
-    final Map<String, Integer> familyOrdering = getFamilyOrdering(columnFamiliesToFetch);
+    final Map<String, Integer> familyOrdering = getFamilyOrdering(orderOfFamiliesToFetch);
     Collections.sort(docs, new Comparator<Document>() {
       @Override
       public int compare(Document o1, Document o2) {
@@ -946,8 +949,7 @@ public class BlurUtil {
       DocIdSet docIdSet = filter.getDocIdSet(segmentReader.getContext(), liveDocs);
       mask = getMask(docIdSet, primeDocRowId, numberOfDocsInRow);
     }
-    List<String> columnFamiliesToFetch = selector.getColumnFamiliesToFetch() == null
? null : new ArrayList<String>(
-        selector.getColumnFamiliesToFetch());
+    Set<String> columnFamiliesToFetch = selector.getColumnFamiliesToFetch();
     boolean fetchAll = true;
     if (columnFamiliesToFetch != null) {
       fetchAll = false;
@@ -995,7 +997,7 @@ public class BlurUtil {
     }
   }
 
-  private static void applyFamilies(Set<String> alreadyProcessed, OpenBitSet bits,
List<String> columnFamiliesToFetch,
+  private static void applyFamilies(Set<String> alreadyProcessed, OpenBitSet bits,
Set<String> columnFamiliesToFetch,
       SegmentReader segmentReader, int primeDocRowId, int numberOfDocsInRow, Bits liveDocs)
throws IOException {
     for (String family : columnFamiliesToFetch) {
       if (!alreadyProcessed.contains(family)) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/ecadcb1c/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 68ad8ea..52dd58b 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
@@ -653,6 +653,8 @@ public class IndexManagerTest {
     Selector selector = new Selector().setRowId("row-6");
     selector.addToColumnFamiliesToFetch(FAMILY2);
     selector.putToColumnsToFetch(FAMILY, new HashSet<String>(Arrays.asList("testcol12")));
+    selector.addToOrderOfFamiliesToFetch(FAMILY2);
+    selector.addToOrderOfFamiliesToFetch(FAMILY);
 
     FetchResult fetchResult = new FetchResult();
     indexManager.fetchRow(TABLE, selector, fetchResult);


Mime
View raw message