incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [30/47] git commit: Upgrade to Lucene 3.6.1 complete.
Date Mon, 03 Sep 2012 00:32:20 GMT
Upgrade to Lucene 3.6.1 complete.


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

Branch: refs/heads/master
Commit: 4cb2f33838d29db30d53b2c9084d27295503daf5
Parents: b847652
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Tue Aug 21 23:14:01 2012 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Tue Aug 21 23:14:01 2012 -0400

----------------------------------------------------------------------
 src/blur-store/pom.xml                             |    2 +-
 .../apache/lucene/lucene-core/3.5.0.lm/lm.patch    |  165 -------
 .../lucene-core/3.5.0.lm/lucene-core-3.5.0.lm.jar  |  Bin 1466283 -> 0 bytes
 .../lucene-core/3.6.1.lm/lucene-core-3.6.1.lm.jar  |  Bin 0 -> 1538596 bytes
 .../lucene-core/3.6.1.lm/lucene_3.6.1.lm.patch     |  367 +++++++++++++++
 5 files changed, 368 insertions(+), 166 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4cb2f338/src/blur-store/pom.xml
----------------------------------------------------------------------
diff --git a/src/blur-store/pom.xml b/src/blur-store/pom.xml
index 58ae6af..5540ca0 100644
--- a/src/blur-store/pom.xml
+++ b/src/blur-store/pom.xml
@@ -20,7 +20,7 @@
 		<dependency>
 			<groupId>org.apache.lucene</groupId>
 			<artifactId>lucene-core</artifactId>
-			<version>3.6.1</version>
+			<version>3.6.1.lm</version>
 		</dependency>
 		<dependency>
 			<groupId>commons-cli</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4cb2f338/src/lib/org/apache/lucene/lucene-core/3.5.0.lm/lm.patch
----------------------------------------------------------------------
diff --git a/src/lib/org/apache/lucene/lucene-core/3.5.0.lm/lm.patch b/src/lib/org/apache/lucene/lucene-core/3.5.0.lm/lm.patch
deleted file mode 100644
index ce40bd0..0000000
--- a/src/lib/org/apache/lucene/lucene-core/3.5.0.lm/lm.patch
+++ /dev/null
@@ -1,165 +0,0 @@
-### Eclipse Workspace Patch 1.0
-#P lucene-3.5.0
-Index: src/java/org/apache/lucene/index/TermInfosReader.java
-===================================================================
---- src/java/org/apache/lucene/index/TermInfosReader.java	(revision 1214027)
-+++ src/java/org/apache/lucene/index/TermInfosReader.java	(working copy)
-@@ -22,8 +22,8 @@
- 
- import org.apache.lucene.store.Directory;
- import org.apache.lucene.util.BytesRef;
--import org.apache.lucene.util.DoubleBarrelLRUCache;
- import org.apache.lucene.util.CloseableThreadLocal;
-+import org.apache.lucene.util.DoubleBarrelLRUCache;
- 
- /** This stores a monotonically increasing set of <Term, TermInfo> pairs in a
-  * Directory.  Pairs are accessed either by Term or by ordinal position the
-@@ -84,8 +84,12 @@
-   /**
-    * Per-thread resources managed by ThreadLocal
-    */
--  private static final class ThreadResources {
-+  static final class ThreadResources {
-     SegmentTermEnum termEnum;
-+    BytesRef termBytesRefGetMethodTermInfosReader = new BytesRef();
-+    BytesRef scratchGetIndexOffsetMethodTermInfosReaderIndex = new BytesRef();
-+    BytesRef termBytesRefGetIndexOffsetMethodTermInfosReaderIndex = new BytesRef();
-+    BytesRef bufferCompareToMethodTermInfosReaderIndex = new BytesRef();
-   }
-   
-   TermInfosReader(Directory dir, String seg, FieldInfos fis, int readBufferSize, int indexDivisor)
-@@ -168,12 +172,11 @@
- 
-   /** Returns the TermInfo for a Term in the set, or null. */
-   TermInfo get(Term term) throws IOException {
--    BytesRef termBytesRef = new BytesRef(term.text);
--    return get(term, false, termBytesRef);
-+    return get(term, false);
-   }
-   
-   /** Returns the TermInfo for a Term in the set, or null. */
--  private TermInfo get(Term term, boolean mustSeekEnum, BytesRef termBytesRef) throws IOException
{
-+  private TermInfo get(Term term, boolean mustSeekEnum) throws IOException {
-     if (size == 0) return null;
- 
-     ensureIndexIsRead();
-@@ -183,18 +186,22 @@
-     TermInfoAndOrd tiOrd = termsCache.get(cacheKey);
-     ThreadResources resources = getThreadResources();
-     
-+    BytesRef termBytesRef = resources.termBytesRefGetMethodTermInfosReader;
-+    termBytesRef.copy(term.text);
-+    
-     if (!mustSeekEnum && tiOrd != null) {
-       return tiOrd;
-     }
-     
-     // optimize sequential access: first try scanning cached enum w/o seeking
-     SegmentTermEnum enumerator = resources.termEnum;
-+    BytesRef buffer = resources.bufferCompareToMethodTermInfosReaderIndex;
-     if (enumerator.term() != null                 // term is at or past current
- 	&& ((enumerator.prev() != null && term.compareTo(enumerator.prev())>
0)
- 	    || term.compareTo(enumerator.term()) >= 0)) {
-       int enumOffset = (int)(enumerator.position/totalIndexInterval)+1;
-       if (indexLength == enumOffset    // but before end of block
--    || index.compareTo(term,termBytesRef,enumOffset) < 0) {
-+    || index.compareTo(term,termBytesRef,enumOffset,buffer) < 0) {
-        // no need to seek
- 
-         final TermInfo ti;
-@@ -229,7 +236,7 @@
-       indexPos = (int) (tiOrd.termOrd / totalIndexInterval);
-     } else {
-       // Must do binary search:
--      indexPos = index.getIndexOffset(term,termBytesRef);
-+      indexPos = index.getIndexOffset(term,resources);
-     }
- 
-     index.seekEnum(enumerator, indexPos);
-@@ -279,10 +286,11 @@
-     if (size == 0) return -1;
- 
-     ensureIndexIsRead();
--    BytesRef termBytesRef = new BytesRef(term.text);
--    int indexOffset = index.getIndexOffset(term,termBytesRef);
-+    
-+    ThreadResources resources = getThreadResources();
-+    int indexOffset = index.getIndexOffset(term,resources);
-     
--    SegmentTermEnum enumerator = getThreadResources().termEnum;
-+    SegmentTermEnum enumerator = resources.termEnum;
-     index.seekEnum(enumerator, indexOffset);
- 
-     while(term.compareTo(enumerator.term()) > 0 && enumerator.next()) {}
-@@ -300,8 +308,7 @@
- 
-   /** Returns an enumeration of terms starting at or after the named term. */
-   public SegmentTermEnum terms(Term term) throws IOException {
--    BytesRef termBytesRef = new BytesRef(term.text);
--    get(term, true, termBytesRef);
-+    get(term, true);
-     return (SegmentTermEnum)getThreadResources().termEnum.clone();
-   }
- }
-Index: src/java/org/apache/lucene/index/TermInfosReaderIndex.java
-===================================================================
---- src/java/org/apache/lucene/index/TermInfosReaderIndex.java	(revision 1214027)
-+++ src/java/org/apache/lucene/index/TermInfosReaderIndex.java	(working copy)
-@@ -22,6 +22,7 @@
- import java.util.Comparator;
- import java.util.List;
- 
-+import org.apache.lucene.index.TermInfosReader.ThreadResources;
- import org.apache.lucene.util.BitUtil;
- import org.apache.lucene.util.BytesRef;
- import org.apache.lucene.util.PagedBytes.PagedBytesDataInput;
-@@ -38,7 +39,7 @@
-  */
- class TermInfosReaderIndex {
- 
--  private static final int MAX_PAGE_BITS = 18; // 256 KB block
-+  private static final int MAX_PAGE_BITS = 24; // 16 MB block
-   private Term[] fields;
-   private int totalIndexInterval;
-   private Comparator<BytesRef> comparator = BytesRef.getUTF8SortedAsUTF16Comparator();
-@@ -146,11 +147,14 @@
-    *          the term to locate.
-    * @throws IOException 
-    */
--  int getIndexOffset(Term term, BytesRef termBytesRef) throws IOException {
-+  int getIndexOffset(Term term, ThreadResources resources) throws IOException {
-     int lo = 0;
-     int hi = indexSize - 1;
-     PagedBytesDataInput input = (PagedBytesDataInput) dataInput.clone();
--    BytesRef scratch = new BytesRef();
-+    BytesRef termBytesRef = resources.termBytesRefGetIndexOffsetMethodTermInfosReaderIndex;
-+    termBytesRef.copy(term.text);
-+    
-+    BytesRef scratch = resources.scratchGetIndexOffsetMethodTermInfosReaderIndex;
-     while (hi >= lo) {
-       int mid = (lo + hi) >>> 1;
-       int delta = compareTo(term, termBytesRef, mid, input, scratch);
-@@ -202,8 +206,8 @@
-    * @return int.
-    * @throws IOException 
-    */
--  int compareTo(Term term, BytesRef termBytesRef, int termIndex) throws IOException {
--    return compareTo(term, termBytesRef, termIndex, (PagedBytesDataInput) dataInput.clone(),
new BytesRef());
-+  int compareTo(Term term, BytesRef termBytesRef, int termIndex, BytesRef buffer) throws
IOException {
-+    return compareTo(term, termBytesRef, termIndex, (PagedBytesDataInput) dataInput.clone(),
buffer);
-   }
- 
-   /**
-Index: src/test/org/apache/lucene/index/TestTermInfosReaderIndex.java
-===================================================================
---- src/test/org/apache/lucene/index/TestTermInfosReaderIndex.java	(revision 1214027)
-+++ src/test/org/apache/lucene/index/TestTermInfosReaderIndex.java	(working copy)
-@@ -103,7 +103,7 @@
-     for (int i = 0; i < index.length(); i++) {
-       Term t = index.getTerm(i);
-       int compareTo = term.compareTo(t);
--      assertEquals(compareTo, index.compareTo(term, termBytesRef, i));
-+      assertEquals(compareTo, index.compareTo(term, termBytesRef, i, new BytesRef()));
-     }
-   }
-   

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4cb2f338/src/lib/org/apache/lucene/lucene-core/3.5.0.lm/lucene-core-3.5.0.lm.jar
----------------------------------------------------------------------
diff --git a/src/lib/org/apache/lucene/lucene-core/3.5.0.lm/lucene-core-3.5.0.lm.jar b/src/lib/org/apache/lucene/lucene-core/3.5.0.lm/lucene-core-3.5.0.lm.jar
deleted file mode 100644
index 03ff337..0000000
Binary files a/src/lib/org/apache/lucene/lucene-core/3.5.0.lm/lucene-core-3.5.0.lm.jar and
/dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4cb2f338/src/lib/org/apache/lucene/lucene-core/3.6.1.lm/lucene-core-3.6.1.lm.jar
----------------------------------------------------------------------
diff --git a/src/lib/org/apache/lucene/lucene-core/3.6.1.lm/lucene-core-3.6.1.lm.jar b/src/lib/org/apache/lucene/lucene-core/3.6.1.lm/lucene-core-3.6.1.lm.jar
new file mode 100644
index 0000000..cb7f47a
Binary files /dev/null and b/src/lib/org/apache/lucene/lucene-core/3.6.1.lm/lucene-core-3.6.1.lm.jar
differ

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4cb2f338/src/lib/org/apache/lucene/lucene-core/3.6.1.lm/lucene_3.6.1.lm.patch
----------------------------------------------------------------------
diff --git a/src/lib/org/apache/lucene/lucene-core/3.6.1.lm/lucene_3.6.1.lm.patch b/src/lib/org/apache/lucene/lucene-core/3.6.1.lm/lucene_3.6.1.lm.patch
new file mode 100644
index 0000000..307f2f9
--- /dev/null
+++ b/src/lib/org/apache/lucene/lucene-core/3.6.1.lm/lucene_3.6.1.lm.patch
@@ -0,0 +1,367 @@
+From 84a68b88d7e51a367b6133dff47a224ad98202d8 Mon Sep 17 00:00:00 2001
+From: Aaron McCurry <amccurry@gmail.com>
+Date: Tue, 21 Aug 2012 23:11:05 -0400
+Subject: [PATCH] Lower memory creation patch.
+
+---
+ .../org/apache/lucene/index/TermInfosReader.java   |   94 +++++++++++---------
+ .../apache/lucene/index/TermInfosReaderIndex.java  |   30 ++++---
+ .../lucene/index/TestTermInfosReaderIndex.java     |    4 +-
+ 3 files changed, 69 insertions(+), 59 deletions(-)
+
+diff --git a/lucene/core/src/java/org/apache/lucene/index/TermInfosReader.java b/lucene/core/src/java/org/apache/lucene/index/TermInfosReader.java
+index 10a1054..03fbd8d 100644
+--- a/lucene/core/src/java/org/apache/lucene/index/TermInfosReader.java
++++ b/lucene/core/src/java/org/apache/lucene/index/TermInfosReader.java
+@@ -25,9 +25,10 @@ import org.apache.lucene.util.BytesRef;
+ import org.apache.lucene.util.DoubleBarrelLRUCache;
+ import org.apache.lucene.util.CloseableThreadLocal;
+ 
+-/** This stores a monotonically increasing set of <Term, TermInfo> pairs in a
+- * Directory.  Pairs are accessed either by Term or by ordinal position the
+- * set.  */
++/**
++ * This stores a monotonically increasing set of <Term, TermInfo> pairs in a
++ * Directory. Pairs are accessed either by Term or by ordinal position the set.
++ */
+ 
+ final class TermInfosReader implements Closeable {
+   private final Directory directory;
+@@ -40,7 +41,7 @@ final class TermInfosReader implements Closeable {
+ 
+   private final TermInfosReaderIndex index;
+   private final int indexLength;
+-  
++
+   private final int totalIndexInterval;
+ 
+   private final static int DEFAULT_CACHE_SIZE = 1024;
+@@ -48,6 +49,7 @@ final class TermInfosReader implements Closeable {
+   // Just adds term's ord to TermInfo
+   private final static class TermInfoAndOrd extends TermInfo {
+     final long termOrd;
++
+     public TermInfoAndOrd(TermInfo ti, long termOrd) {
+       super(ti);
+       assert termOrd >= 0;
+@@ -79,17 +81,20 @@ final class TermInfosReader implements Closeable {
+     }
+   }
+ 
+-  private final DoubleBarrelLRUCache<CloneableTerm,TermInfoAndOrd> termsCache = new
DoubleBarrelLRUCache<CloneableTerm,TermInfoAndOrd>(DEFAULT_CACHE_SIZE);
+-  
++  private final DoubleBarrelLRUCache<CloneableTerm, TermInfoAndOrd> termsCache = new
DoubleBarrelLRUCache<CloneableTerm, TermInfoAndOrd>(DEFAULT_CACHE_SIZE);
++
+   /**
+    * Per-thread resources managed by ThreadLocal
+    */
+-  private static final class ThreadResources {
++  static final class ThreadResources {
+     SegmentTermEnum termEnum;
++    BytesRef termBytesRefGetMethodTermInfosReader = new BytesRef();
++    BytesRef scratchGetIndexOffsetMethodTermInfosReaderIndex = new BytesRef();
++    BytesRef termBytesRefGetIndexOffsetMethodTermInfosReaderIndex = new BytesRef();
++    BytesRef bufferCompareToMethodTermInfosReaderIndex = new BytesRef();
+   }
+-  
+-  TermInfosReader(Directory dir, String seg, FieldInfos fis, int readBufferSize, int indexDivisor)
+-       throws CorruptIndexException, IOException {
++
++  TermInfosReader(Directory dir, String seg, FieldInfos fis, int readBufferSize, int indexDivisor)
throws CorruptIndexException, IOException {
+     boolean success = false;
+ 
+     if (indexDivisor < 1 && indexDivisor != -1) {
+@@ -101,17 +106,14 @@ final class TermInfosReader implements Closeable {
+       segment = seg;
+       fieldInfos = fis;
+ 
+-      origEnum = new SegmentTermEnum(directory.openInput(IndexFileNames.segmentFileName(segment,
IndexFileNames.TERMS_EXTENSION),
+-          readBufferSize), fieldInfos, false);
++      origEnum = new SegmentTermEnum(directory.openInput(IndexFileNames.segmentFileName(segment,
IndexFileNames.TERMS_EXTENSION), readBufferSize), fieldInfos, false);
+       size = origEnum.size;
+ 
+-
+       if (indexDivisor != -1) {
+         // Load terms index
+         totalIndexInterval = origEnum.indexInterval * indexDivisor;
+         final String indexFileName = IndexFileNames.segmentFileName(segment, IndexFileNames.TERMS_INDEX_EXTENSION);
+-        final SegmentTermEnum indexEnum = new SegmentTermEnum(directory.openInput(indexFileName,
+-                                                                                  readBufferSize),
fieldInfos, true);
++        final SegmentTermEnum indexEnum = new SegmentTermEnum(directory.openInput(indexFileName,
readBufferSize), fieldInfos, true);
+         try {
+           index = new TermInfosReaderIndex(indexEnum, indexDivisor, dir.fileLength(indexFileName),
totalIndexInterval);
+           indexLength = index.length();
+@@ -140,7 +142,7 @@ final class TermInfosReader implements Closeable {
+   public int getSkipInterval() {
+     return origEnum.skipInterval;
+   }
+-  
++
+   public int getMaxSkipLevels() {
+     return origEnum.maxSkipLevels;
+   }
+@@ -168,13 +170,13 @@ final class TermInfosReader implements Closeable {
+ 
+   /** Returns the TermInfo for a Term in the set, or null. */
+   TermInfo get(Term term) throws IOException {
+-    BytesRef termBytesRef = new BytesRef(term.text);
+-    return get(term, false, termBytesRef);
++    return get(term, false);
+   }
+-  
++
+   /** Returns the TermInfo for a Term in the set, or null. */
+-  private TermInfo get(Term term, boolean mustSeekEnum, BytesRef termBytesRef) throws IOException
{
+-    if (size == 0) return null;
++  private TermInfo get(Term term, boolean mustSeekEnum) throws IOException {
++    if (size == 0)
++      return null;
+ 
+     ensureIndexIsRead();
+ 
+@@ -182,20 +184,23 @@ final class TermInfosReader implements Closeable {
+ 
+     TermInfoAndOrd tiOrd = termsCache.get(cacheKey);
+     ThreadResources resources = getThreadResources();
++
++    BytesRef termBytesRef = resources.termBytesRefGetMethodTermInfosReader;
++    termBytesRef.copyChars(term.text);
+     
+     if (!mustSeekEnum && tiOrd != null) {
+       return tiOrd;
+     }
+-    
++
+     // optimize sequential access: first try scanning cached enum w/o seeking
+     SegmentTermEnum enumerator = resources.termEnum;
+-    if (enumerator.term() != null                 // term is at or past current
+-	&& ((enumerator.prev() != null && term.compareTo(enumerator.prev())>
0)
+-	    || term.compareTo(enumerator.term()) >= 0)) {
+-      int enumOffset = (int)(enumerator.position/totalIndexInterval)+1;
+-      if (indexLength == enumOffset    // but before end of block
+-    || index.compareTo(term,termBytesRef,enumOffset) < 0) {
+-       // no need to seek
++    BytesRef buffer = resources.bufferCompareToMethodTermInfosReaderIndex;
++    if (enumerator.term() != null // term is at or past current
++        && ((enumerator.prev() != null && term.compareTo(enumerator.prev())
> 0) || term.compareTo(enumerator.term()) >= 0)) {
++      int enumOffset = (int) (enumerator.position / totalIndexInterval) + 1;
++      if (indexLength == enumOffset // but before end of block
++          || index.compareTo(term, termBytesRef, enumOffset,buffer) < 0) {
++        // no need to seek
+ 
+         final TermInfo ti;
+ 
+@@ -203,9 +208,9 @@ final class TermInfosReader implements Closeable {
+         if (enumerator.term() != null && term.compareTo(enumerator.term()) == 0)
{
+           ti = enumerator.termInfo();
+           if (numScans > 1) {
+-            // we only  want to put this TermInfo into the cache if
++            // we only want to put this TermInfo into the cache if
+             // scanEnum skipped more than one dictionary entry.
+-            // This prevents RangeQueries or WildcardQueries to 
++            // This prevents RangeQueries or WildcardQueries to
+             // wipe out the cache when they iterate over a large numbers
+             // of terms in order
+             if (tiOrd == null) {
+@@ -220,7 +225,7 @@ final class TermInfosReader implements Closeable {
+         }
+ 
+         return ti;
+-      }  
++      }
+     }
+ 
+     // random-access: must seek
+@@ -229,7 +234,7 @@ final class TermInfosReader implements Closeable {
+       indexPos = (int) (tiOrd.termOrd / totalIndexInterval);
+     } else {
+       // Must do binary search:
+-      indexPos = index.getIndexOffset(term,termBytesRef);
++      indexPos = index.getIndexOffset(term, resources);
+     }
+ 
+     index.seekEnum(enumerator, indexPos);
+@@ -261,8 +266,7 @@ final class TermInfosReader implements Closeable {
+       return false;
+     }
+     // skipOffset is only valid when docFreq >= skipInterval:
+-    if (ti1.docFreq >= enumerator.skipInterval &&
+-        ti1.skipOffset != ti2.skipOffset) {
++    if (ti1.docFreq >= enumerator.skipInterval && ti1.skipOffset != ti2.skipOffset)
{
+       return false;
+     }
+     return true;
+@@ -276,16 +280,19 @@ final class TermInfosReader implements Closeable {
+ 
+   /** Returns the position of a Term in the set or -1. */
+   final long getPosition(Term term) throws IOException {
+-    if (size == 0) return -1;
++    if (size == 0)
++      return -1;
+ 
+     ensureIndexIsRead();
+-    BytesRef termBytesRef = new BytesRef(term.text);
+-    int indexOffset = index.getIndexOffset(term,termBytesRef);
+     
+-    SegmentTermEnum enumerator = getThreadResources().termEnum;
++    ThreadResources resources = getThreadResources();
++    int indexOffset = index.getIndexOffset(term,resources);
++
++    SegmentTermEnum enumerator = resources.termEnum;
+     index.seekEnum(enumerator, indexOffset);
+ 
+-    while(term.compareTo(enumerator.term()) > 0 && enumerator.next()) {}
++    while (term.compareTo(enumerator.term()) > 0 && enumerator.next()) {
++    }
+ 
+     if (term.compareTo(enumerator.term()) == 0)
+       return enumerator.position;
+@@ -295,13 +302,12 @@ final class TermInfosReader implements Closeable {
+ 
+   /** Returns an enumeration of all the Terms and TermInfos in the set. */
+   public SegmentTermEnum terms() {
+-    return (SegmentTermEnum)origEnum.clone();
++    return (SegmentTermEnum) origEnum.clone();
+   }
+ 
+   /** Returns an enumeration of terms starting at or after the named term. */
+   public SegmentTermEnum terms(Term term) throws IOException {
+-    BytesRef termBytesRef = new BytesRef(term.text);
+-    get(term, true, termBytesRef);
+-    return (SegmentTermEnum)getThreadResources().termEnum.clone();
++    get(term, true);
++    return (SegmentTermEnum) getThreadResources().termEnum.clone();
+   }
+ }
+diff --git a/lucene/core/src/java/org/apache/lucene/index/TermInfosReaderIndex.java b/lucene/core/src/java/org/apache/lucene/index/TermInfosReaderIndex.java
+index 4786bb5..d7286b3 100644
+--- a/lucene/core/src/java/org/apache/lucene/index/TermInfosReaderIndex.java
++++ b/lucene/core/src/java/org/apache/lucene/index/TermInfosReaderIndex.java
+@@ -22,11 +22,12 @@ import java.util.ArrayList;
+ import java.util.Comparator;
+ import java.util.List;
+ 
++import org.apache.lucene.index.TermInfosReader.ThreadResources;
+ import org.apache.lucene.util.BitUtil;
+ import org.apache.lucene.util.BytesRef;
++import org.apache.lucene.util.PagedBytes;
+ import org.apache.lucene.util.PagedBytes.PagedBytesDataInput;
+ import org.apache.lucene.util.PagedBytes.PagedBytesDataOutput;
+-import org.apache.lucene.util.PagedBytes;
+ import org.apache.lucene.util.packed.GrowableWriter;
+ import org.apache.lucene.util.packed.PackedInts;
+ 
+@@ -38,7 +39,7 @@ import org.apache.lucene.util.packed.PackedInts;
+  */
+ class TermInfosReaderIndex {
+ 
+-  private static final int MAX_PAGE_BITS = 18; // 256 KB block
++  private static final int MAX_PAGE_BITS = 24; // 16 MB block
+   private Term[] fields;
+   private int totalIndexInterval;
+   private Comparator<BytesRef> comparator = BytesRef.getUTF8SortedAsUTF16Comparator();
+@@ -102,7 +103,7 @@ class TermInfosReaderIndex {
+     for (int i = 0; i < fields.length; i++) {
+       fields[i] = new Term(fieldStrs.get(i));
+     }
+-    
++
+     dataPagedBytes.freeze(true);
+     dataInput = dataPagedBytes.getDataInput();
+     indexToDataOffset = indexToTerms.getMutable();
+@@ -114,7 +115,7 @@ class TermInfosReaderIndex {
+ 
+   void seekEnum(SegmentTermEnum enumerator, int indexOffset) throws IOException {
+     PagedBytesDataInput input = (PagedBytesDataInput) dataInput.clone();
+-    
++
+     input.setPosition(indexToDataOffset.get(indexOffset));
+ 
+     // read the term
+@@ -144,13 +145,16 @@ class TermInfosReaderIndex {
+    * 
+    * @param term
+    *          the term to locate.
+-   * @throws IOException 
++   * @throws IOException
+    */
+-  int getIndexOffset(Term term, BytesRef termBytesRef) throws IOException {
++  int getIndexOffset(Term term, ThreadResources resources) throws IOException {
+     int lo = 0;
+     int hi = indexSize - 1;
+     PagedBytesDataInput input = (PagedBytesDataInput) dataInput.clone();
+-    BytesRef scratch = new BytesRef();
++    BytesRef termBytesRef = resources.termBytesRefGetIndexOffsetMethodTermInfosReaderIndex;
++    termBytesRef.copyChars(term.text);
++
++    BytesRef scratch = resources.scratchGetIndexOffsetMethodTermInfosReaderIndex;
+     while (hi >= lo) {
+       int mid = (lo + hi) >>> 1;
+       int delta = compareTo(term, termBytesRef, mid, input, scratch);
+@@ -165,7 +169,7 @@ class TermInfosReaderIndex {
+   }
+ 
+   /**
+-   * Gets the term at the given position.  For testing.
++   * Gets the term at the given position. For testing.
+    * 
+    * @param termIndex
+    *          the position to read the term from the index.
+@@ -200,10 +204,10 @@ class TermInfosReaderIndex {
+    * @param termIndex
+    *          the index of the of term to compare.
+    * @return int.
+-   * @throws IOException 
++   * @throws IOException
+    */
+-  int compareTo(Term term, BytesRef termBytesRef, int termIndex) throws IOException {
+-    return compareTo(term, termBytesRef, termIndex, (PagedBytesDataInput) dataInput.clone(),
new BytesRef());
++  int compareTo(Term term, BytesRef termBytesRef, int termIndex, BytesRef buffer) throws
IOException {
++    return compareTo(term, termBytesRef, termIndex, (PagedBytesDataInput) dataInput.clone(),
buffer);
+   }
+ 
+   /**
+@@ -217,7 +221,7 @@ class TermInfosReaderIndex {
+    * @param input
+    *          the input buffer.
+    * @return int.
+-   * @throws IOException 
++   * @throws IOException
+    */
+   private int compareTo(Term term, BytesRef termBytesRef, int termIndex, PagedBytesDataInput
input, BytesRef reuse) throws IOException {
+     // if term field does not equal mid's field index, then compare fields
+@@ -242,7 +246,7 @@ class TermInfosReaderIndex {
+    * @param input
+    *          the data block.
+    * @return int.
+-   * @throws IOException 
++   * @throws IOException
+    */
+   private int compareField(Term term, int termIndex, PagedBytesDataInput input) throws IOException
{
+     input.setPosition(indexToDataOffset.get(termIndex));
+diff --git a/lucene/core/src/test/org/apache/lucene/index/TestTermInfosReaderIndex.java b/lucene/core/src/test/org/apache/lucene/index/TestTermInfosReaderIndex.java
+index 0289b4c..c016588 100644
+--- a/lucene/core/src/test/org/apache/lucene/index/TestTermInfosReaderIndex.java
++++ b/lucene/core/src/test/org/apache/lucene/index/TestTermInfosReaderIndex.java
+@@ -37,8 +37,8 @@ import org.apache.lucene.store.LockObtainFailedException;
+ import org.apache.lucene.util.BytesRef;
+ import org.apache.lucene.util.LuceneTestCase;
+ import org.apache.lucene.util._TestUtil;
+-import org.junit.BeforeClass;
+ import org.junit.AfterClass;
++import org.junit.BeforeClass;
+ 
+ public class TestTermInfosReaderIndex extends LuceneTestCase {
+   
+@@ -119,7 +119,7 @@ public class TestTermInfosReaderIndex extends LuceneTestCase {
+     for (int i = 0; i < index.length(); i++) {
+       Term t = index.getTerm(i);
+       int compareTo = term.compareTo(t);
+-      assertEquals(compareTo, index.compareTo(term, termBytesRef, i));
++      assertEquals(compareTo, index.compareTo(term, termBytesRef, i, new BytesRef()));
+     }
+   }
+   
+-- 
+1.7.5.4
+


Mime
View raw message