incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Refactoring util method into it's own util class.
Date Sun, 11 Jan 2015 21:25:48 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/master d2e67d714 -> 4728ce990


Refactoring util method into it's own util class.


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

Branch: refs/heads/master
Commit: 4728ce99068d478b0bc59a5dcc5e87b93b641dc4
Parents: d2e67d7
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sun Jan 11 16:25:59 2015 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sun Jan 11 16:25:59 2015 -0500

----------------------------------------------------------------------
 .../org/apache/blur/manager/IndexManager.java   |  3 +-
 .../java/org/apache/blur/utils/BlurUtil.java    | 16 ++-------
 .../blur/lucene/search/PrimeDocCache.java       | 12 ++-----
 .../org/apache/blur/index/AtomicReaderUtil.java | 38 ++++++++++++++++++++
 4 files changed, 44 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4728ce99/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 46023cc..2c6c249 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
@@ -48,6 +48,7 @@ import java.util.concurrent.atomic.AtomicLongArray;
 
 import org.apache.blur.analysis.FieldManager;
 import org.apache.blur.concurrent.Executors;
+import org.apache.blur.index.AtomicReaderUtil;
 import org.apache.blur.index.ExitableReader;
 import org.apache.blur.index.ExitableReader.ExitingReaderException;
 import org.apache.blur.log.Log;
@@ -848,7 +849,7 @@ public class IndexManager {
       int readerBase = BaseCompositeReaderUtil.readerBase(indexReader, readerIndex);
       int docId = notAdjustedDocId - readerBase;
       IndexReader orgReader = sequentialSubReaders.get(readerIndex);
-      SegmentReader sReader = BlurUtil.getSegmentReader(orgReader);
+      SegmentReader sReader = AtomicReaderUtil.getSegmentReader(orgReader);
       if (sReader != null) {
         SegmentReader segmentReader = (SegmentReader) sReader;
         DocIdSet docIdSet = filter.getDocIdSet(segmentReader.getContext(), segmentReader.getLiveDocs());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4728ce99/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 44778f6..b11a11f 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
@@ -63,7 +63,7 @@ import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicLongArray;
 
 import org.apache.blur.BlurConfiguration;
-import org.apache.blur.index.ExitableReader.ExitableFilterAtomicReader;
+import org.apache.blur.index.AtomicReaderUtil;
 import org.apache.blur.log.Log;
 import org.apache.blur.log.LogFactory;
 import org.apache.blur.lucene.search.PrimeDocCache;
@@ -891,7 +891,7 @@ public class BlurUtil {
       int readerBase = BaseCompositeReaderUtil.readerBase(indexReader, readerIndex);
       int primeDocId = notAdjustedPrimeDocId - readerBase;
       IndexReader orgReader = sequentialSubReaders.get(readerIndex);
-      SegmentReader sReader = getSegmentReader(orgReader);
+      SegmentReader sReader = AtomicReaderUtil.getSegmentReader(orgReader);
       if (sReader != null) {
         SegmentReader segmentReader = (SegmentReader) sReader;
         Bits liveDocs = segmentReader.getLiveDocs();
@@ -995,18 +995,6 @@ public class BlurUtil {
     return ordering;
   }
 
-  public static SegmentReader getSegmentReader(IndexReader indexReader) {
-    if (indexReader instanceof SegmentReader) {
-      return (SegmentReader) indexReader;
-    }
-    if (indexReader instanceof ExitableFilterAtomicReader) {
-      ExitableFilterAtomicReader exitableFilterAtomicReader = (ExitableFilterAtomicReader)
indexReader;
-      AtomicReader originalReader = exitableFilterAtomicReader.getOriginalReader();
-      return getSegmentReader(originalReader);
-    }
-    return null;
-  }
-
   private static int getStartingPosition(OpenBitSet docsInRowSpanToFetch, int start) {
     int docStartingPosition = docsInRowSpanToFetch.nextSetBit(0);
     int offset = 0;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4728ce99/blur-query/src/main/java/org/apache/blur/lucene/search/PrimeDocCache.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/lucene/search/PrimeDocCache.java b/blur-query/src/main/java/org/apache/blur/lucene/search/PrimeDocCache.java
index 0eb9443..995ed7e 100644
--- a/blur-query/src/main/java/org/apache/blur/lucene/search/PrimeDocCache.java
+++ b/blur-query/src/main/java/org/apache/blur/lucene/search/PrimeDocCache.java
@@ -20,7 +20,7 @@ import java.io.IOException;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.blur.index.ExitableReader.ExitableFilterAtomicReader;
+import org.apache.blur.index.AtomicReaderUtil;
 import org.apache.blur.log.Log;
 import org.apache.blur.log.LogFactory;
 import org.apache.lucene.index.AtomicReader;
@@ -45,7 +45,7 @@ public class PrimeDocCache {
    * this method is not synced.
    */
   public static OpenBitSet getPrimeDocBitSet(Term primeDocTerm, AtomicReader providedReader)
throws IOException {
-    AtomicReader reader = getRealReader(providedReader);
+    AtomicReader reader = AtomicReaderUtil.getSegmentReader(providedReader);
     final Object key = reader.getCoreCacheKey();
     final Map<Object, OpenBitSet> primeDocMap = getPrimeDocMap(primeDocTerm);
     OpenBitSet bitSet = primeDocMap.get(key);
@@ -90,14 +90,6 @@ public class PrimeDocCache {
     return bitSet;
   }
 
-  private static AtomicReader getRealReader(AtomicReader providedReader) {
-    if (providedReader instanceof ExitableFilterAtomicReader) {
-      ExitableFilterAtomicReader exitableFilterAtomicReader = (ExitableFilterAtomicReader)
providedReader;
-      return exitableFilterAtomicReader.getOriginalReader();
-    }
-    return providedReader;
-  }
-
   private static Map<Object, OpenBitSet> getPrimeDocMap(Term primeDocTerm) {
     Map<Object, OpenBitSet> map = termPrimeDocMap.get(primeDocTerm);
     if (map == null) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4728ce99/blur-store/src/main/java/org/apache/blur/index/AtomicReaderUtil.java
----------------------------------------------------------------------
diff --git a/blur-store/src/main/java/org/apache/blur/index/AtomicReaderUtil.java b/blur-store/src/main/java/org/apache/blur/index/AtomicReaderUtil.java
new file mode 100644
index 0000000..3f88e4f
--- /dev/null
+++ b/blur-store/src/main/java/org/apache/blur/index/AtomicReaderUtil.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.index;
+
+import java.io.IOException;
+
+import org.apache.blur.index.ExitableReader.ExitableFilterAtomicReader;
+import org.apache.lucene.index.AtomicReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.SegmentReader;
+
+public class AtomicReaderUtil {
+  public static SegmentReader getSegmentReader(IndexReader indexReader) throws IOException
{
+    if (indexReader instanceof SegmentReader) {
+      return (SegmentReader) indexReader;
+    }
+    if (indexReader instanceof ExitableFilterAtomicReader) {
+      ExitableFilterAtomicReader exitableFilterAtomicReader = (ExitableFilterAtomicReader)
indexReader;
+      AtomicReader originalReader = exitableFilterAtomicReader.getOriginalReader();
+      return getSegmentReader(originalReader);
+    }
+    throw new IOException("SegmentReader could not be found.");
+  }
+}


Mime
View raw message