Skip to content

Commit

Permalink
Upgrade to Lucene 3.1, closes #825.
Browse files Browse the repository at this point in the history
  • Loading branch information
kimchy committed Apr 4, 2011
1 parent db1dcad commit 4e4495f
Show file tree
Hide file tree
Showing 82 changed files with 554 additions and 3,076 deletions.
24 changes: 10 additions & 14 deletions .idea/libraries/lucene.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 6 additions & 28 deletions .idea/modules/plugin-analysis-icu.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -20,10 +20,7 @@
package org.elasticsearch.benchmark.common.lucene.uidscan;

import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermPositions;
import org.apache.lucene.index.*;
import org.apache.lucene.store.FSDirectory;
import org.elasticsearch.common.Numbers;
import org.elasticsearch.common.StopWatch;
Expand All @@ -43,7 +40,7 @@ public class LuceneUidScanBenchmark {
public static void main(String[] args) throws Exception {

FSDirectory dir = FSDirectory.open(new File("work/test"));
IndexWriter writer = new IndexWriter(dir, Lucene.STANDARD_ANALYZER, true, IndexWriter.MaxFieldLength.UNLIMITED);
IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));

final int NUMBER_OF_THREADS = 2;
final long INDEX_COUNT = SizeValue.parseSizeValue("1m").singles();
Expand All @@ -60,7 +57,7 @@ public static void main(String[] args) throws Exception {
}
System.out.println("Done indexing, took " + watch.stop().lastTaskTime());

final IndexReader reader = writer.getReader();
final IndexReader reader = IndexReader.open(writer, true);

final CountDownLatch latch = new CountDownLatch(NUMBER_OF_THREADS);
Thread[] threads = new Thread[NUMBER_OF_THREADS];
Expand Down
12 changes: 5 additions & 7 deletions modules/elasticsearch/build.gradle
Expand Up @@ -37,13 +37,11 @@ dependencies {

compile('net.java.dev.jna:jna:3.2.7') { transitive = false }

compile 'org.apache.lucene:lucene-core:3.0.3'
compile 'org.apache.lucene:lucene-analyzers:3.0.3'
compile 'org.apache.lucene:lucene-snowball:3.0.3'
compile 'org.apache.lucene:lucene-queries:3.0.3'
compile 'org.apache.lucene:lucene-fast-vector-highlighter:3.0.3'
compile 'org.apache.lucene:lucene-memory:3.0.3'
compile 'org.apache.lucene:lucene-highlighter:3.0.3'
compile('org.apache.lucene:lucene-core:3.1.0') { transitive = false }
compile('org.apache.lucene:lucene-analyzers:3.1.0') { transitive = false }
compile('org.apache.lucene:lucene-queries:3.1.0') { transitive = false }
compile('org.apache.lucene:lucene-memory:3.1.0') { transitive = false }
compile('org.apache.lucene:lucene-highlighter:3.1.0') { transitive = false }
}

configurations {
Expand Down
Expand Up @@ -17,9 +17,8 @@
* under the License.
*/

package org.elasticsearch.common.lucene.search;
package org.apache.lucene.index;

import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.IndexSearcher;

/**
Expand All @@ -44,26 +43,7 @@ public int[] docStarts() {
return this.docStarts;
}

// taken from DirectoryReader#readerIndex

public int readerIndex(int doc) {
int lo = 0; // search starts array
int hi = subReaders.length - 1; // for first element less

while (hi >= lo) {
int mid = (lo + hi) >>> 1;
int midValue = docStarts[mid];
if (doc < midValue)
hi = mid - 1;
else if (doc > midValue)
lo = mid + 1;
else { // found a match
while (mid + 1 < subReaders.length && docStarts[mid + 1] == midValue) {
mid++; // scan to last match
}
return mid;
}
}
return hi;
return DirectoryReader.readerIndex(doc, docStarts, subReaders.length);
}
}

0 comments on commit 4e4495f

Please sign in to comment.