You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2011/11/02 18:11:06 UTC
svn commit: r1196701 [2/3] - in /lucene/dev/branches/lucene2621: ./
dev-tools/eclipse/ dev-tools/idea/.idea/ dev-tools/idea/.idea/libraries/
dev-tools/idea/lucene/contrib/ dev-tools/idea/solr/contrib/velocity/
dev-tools/maven/ dev-tools/maven/lucene/co...
Modified: lucene/dev/branches/lucene2621/dev-tools/maven/solr/webapp/pom.xml.template
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/dev-tools/maven/solr/webapp/pom.xml.template?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/dev-tools/maven/solr/webapp/pom.xml.template (original)
+++ lucene/dev/branches/lucene2621/dev-tools/maven/solr/webapp/pom.xml.template Wed Nov 2 17:11:00 2011
@@ -40,68 +40,6 @@
<groupId>${project.groupId}</groupId>
<artifactId>solr-core</artifactId>
<version>${project.version}</version>
- <exclusions>
- <exclusion>
- <groupId>commons-chain</groupId>
- <artifactId>commons-chain</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-digester</groupId>
- <artifactId>commons-digester</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-validator</groupId>
- <artifactId>commons-validator</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jakarta-regexp</groupId>
- <artifactId>jakarta-regexp</artifactId>
- </exclusion>
- <exclusion>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.activation</groupId>
- <artifactId>activation</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jline</groupId>
- <artifactId>jline</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.struts</groupId>
- <artifactId>struts-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.struts</groupId>
- <artifactId>struts-taglib</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.struts</groupId>
- <artifactId>struts-tiles</artifactId>
- </exclusion>
- <exclusion>
- <groupId>oro</groupId>
- <artifactId>oro</artifactId>
- </exclusion>
- <exclusion>
- <groupId>sslext</groupId>
- <artifactId>sslext</artifactId>
- </exclusion>
- <exclusion>
- <groupId>xml-apis</groupId>
- <artifactId>xml-apis</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
@@ -109,22 +47,14 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.codehaus.woodstox</groupId>
- <artifactId>wstx-asl</artifactId>
- <exclusions>
- <exclusion>
- <groupId>stax</groupId>
- <artifactId>stax-api</artifactId>
- </exclusion>
- </exclusions>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>log4j-over-slf4j</artifactId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>runtime</scope>
</dependency>
</dependencies>
<build>
Modified: lucene/dev/branches/lucene2621/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/CHANGES.txt?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/lucene2621/lucene/CHANGES.txt Wed Nov 2 17:11:00 2011
@@ -364,11 +364,6 @@ New features
and FuzzyQuery with finite-state methods. Adds RegexpQuery.
(Robert Muir, Mike McCandless, Uwe Schindler, Mark Miller)
-* LUCENE-1990: Adds internal packed ints implementation, to be used
- for more efficient storage of int arrays when the values are
- bounded, for example for storing the terms dict index (Toke
- Eskildsen via Mike McCandless)
-
* LUCENE-2321: Cutover to a more RAM efficient packed-ints based
representation for the in-memory terms dict index. (Mike
McCandless)
@@ -614,9 +609,6 @@ Optimizations
Bug fixes
-* LUCENE-2633: PackedInts Packed32 and Packed64 did not support internal
- structures larger than 256MB (Toke Eskildsen via Mike McCandless)
-
* LUCENE-2803: The FieldCache can miss values if an entry for a reader
with more document deletions is requested before a reader with fewer
deletions, provided they share some segments. (yonik)
@@ -655,6 +647,10 @@ Changes in backwards compatibility polic
(instead of the old reader) if there are no changes in the index, to
prevent the common pitfall of accidentally closing the old reader.
+* LUCENE-3541: Remove IndexInput's protected copyBuf. If you want to
+ keep a buffer in your IndexInput, do this yourself in your implementation,
+ and be sure to do the right thing on clone()! (Robert Muir)
+
Changes in runtime behavior
* LUCENE-3520: IndexReader.openIfChanged, when passed a near-real-time
@@ -700,6 +696,20 @@ Bug fixes
flush, if you didn't, you would get an invalid index.
(Mike McCandless, Robert Muir)
+* LUCENE-2633: PackedInts Packed32 and Packed64 did not support internal
+ structures larger than 256MB (Toke Eskildsen via Mike McCandless)
+
+* LUCENE-3540: LUCENE-3255 dropped support for pre-1.9 indexes, but the
+ error message in IndexFormatTooOldException was incorrect. (Uwe Schindler,
+ Mike McCandless)
+
+* LUCENE-3541: IndexInput's default copyBytes() implementation was not safe
+ across multiple threads, because all clones shared the same buffer.
+ (Robert Muir)
+
+* LUCENE-3548: Fix CharsRef#append to extend length of the existing char[]
+ and presever existing chars. (Simon Willnauer)
+
New Features
* LUCENE-3448: Added FixedBitSet.and(other/DISI), andNot(other/DISI).
@@ -709,6 +719,11 @@ New Features
specified ScoreDoc (e.g. last document on the previous page) to support deep
paging use cases. (Aaron McCurry, Grant Ingersoll, Robert Muir)
+* LUCENE-1990: Adds internal packed ints implementation, to be used
+ for more efficient storage of int arrays when the values are
+ bounded, for example for storing the terms dict index (Toke
+ Eskildsen via Mike McCandless)
+
Optimizations
* LUCENE-3426: Add NGramPhraseQuery which extends PhraseQuery and tries to
@@ -718,12 +733,29 @@ Optimizations
* LUCENE-3494: Optimize FilteredQuery to remove a multiply in score()
(Uwe Schindler, Robert Muir)
+* LUCENE-3534: Remove filter logic from IndexSearcher and delegate to
+ FilteredQuery's Scorer. This is a partial backport of a cleanup in
+ FilteredQuery/IndexSearcher added by LUCENE-1536 to Lucene 4.0.
+ (Uwe Schindler)
+
+* LUCENE-2205: Very substantial (3-5X) RAM reduction required to hold
+ the terms index on opening an IndexReader (Aaron McCurry via Mike McCandless)
+
Test Cases
* LUCENE-3420: Disable the finalness checks in TokenStream and Analyzer
for implementing subclasses in different packages, where assertions are not
enabled. (Uwe Schindler)
+* LUCENE-3506: tests relying on assertions being enabled were no-op because
+ they ignored AssertionError. With this fix now entire test framework
+ (every test) fails if assertions are disabled, unless
+ -Dtests.asserts.gracious=true is specified. (Doron Cohen)
+
+Build
+
+* SOLR-2849: Fix dependencies in Maven POMs. (David Smiley via Steve Rowe)
+
======================= Lucene 3.4.0 =======================
Bug fixes
Modified: lucene/dev/branches/lucene2621/lucene/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/common-build.xml?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/common-build.xml (original)
+++ lucene/dev/branches/lucene2621/lucene/common-build.xml Wed Nov 2 17:11:00 2011
@@ -94,6 +94,7 @@
<property name="tests.loggingfile" value="/dev/null"/>
<property name="tests.nightly" value="false" />
<property name="tests.cleanthreads.sysprop" value="perMethod"/>
+ <property name="tests.asserts.gracious" value="false"/>
<property name="javac.deprecation" value="off"/>
<property name="javac.debug" value="on"/>
@@ -132,6 +133,7 @@
<property name="build.dir" location="build"/>
<!-- Needed in case a contrib needs the original build, also for compile-tools to be called from contrib -->
<property name="common.build.dir" location="${common.dir}/build"/>
+ <property name="tests.lockdir" location="${common.build.dir}"/>
<property name="dist.dir" location="dist"/>
<property name="maven.dist.dir" location="dist/maven"/>
<property name="m2.repository.url" value="file://${maven.dist.dir}"/>
@@ -550,6 +552,8 @@
<!-- allow tests to control debug prints -->
<sysproperty key="tests.verbose" value="${tests.verbose}"/>
+ <!-- directory for formatter lock -->
+ <sysproperty key="tests.lockdir" value="${tests.lockdir}"/>
<!-- set the codec tests should run with -->
<sysproperty key="tests.postingsformat" value="${tests.postingsformat}"/>
<!-- set the locale tests should run with -->
@@ -574,6 +578,9 @@
<sysproperty key="java.util.logging.config.file" value="${tests.loggingfile}"/>
<!-- set whether or not nightly tests should run -->
<sysproperty key="tests.nightly" value="@{tests.nightly}"/>
+
+ <!-- set whether tests framework should not require java assertions enabled -->
+ <sysproperty key="tests.asserts.gracious" value="${tests.asserts.gracious}"/>
<!-- TODO: create propertyset for test properties, so each project can have its own set -->
<sysproperty key="tests.multiplier" value="@{tests.multiplier}"/>
Modified: lucene/dev/branches/lucene2621/lucene/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/contrib/CHANGES.txt?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/contrib/CHANGES.txt (original)
+++ lucene/dev/branches/lucene2621/lucene/contrib/CHANGES.txt Wed Nov 2 17:11:00 2011
@@ -51,6 +51,10 @@ New Features
* LUCENE-2507: Added DirectSpellChecker, which retrieves correction candidates directly
from the term dictionary using levenshtein automata. (Robert Muir)
+
+ * LUCENE-3527: Add LuceneLevenshteinDistance, which computes string distance in a compatible
+ way as DirectSpellChecker. This can be used to merge top-N results from more than one
+ SpellChecker. (James Dyer via Robert Muir)
API Changes
@@ -135,6 +139,9 @@ Bug Fixes
* LUCENE-3508: Decompounders based on CompoundWordTokenFilterBase can now be
used with custom attributes. All those attributes are preserved and set on all
added decompounded tokens. (Spyros Kapnissis, Uwe Schindler)
+
+ * LUCENE-3542: Group expanded query terms to preserve parent boolean operator
+ in StandartQueryParser. (Simon Willnauer)
API Changes
Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/DocumentsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/DocumentsWriter.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/DocumentsWriter.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/DocumentsWriter.java Wed Nov 2 17:11:00 2011
@@ -582,6 +582,7 @@ final class DocumentsWriter {
}
applyFlushTickets();
}
+ assert !flushingDeleteQueue.anyChanges();
} finally {
assert flushingDeleteQueue == currentFullFlushDelQueue;
}
Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java Wed Nov 2 17:11:00 2011
@@ -169,7 +169,13 @@ final class DocumentsWriterDeleteQueue {
boolean anyChanges() {
globalBufferLock.lock();
try {
- return !globalSlice.isEmpty() || globalBufferedDeletes.any();
+ /*
+ * check if all items in the global slice were applied
+ * and if the global slice is up-to-date
+ * and if globalBufferedDeletes has changes
+ */
+ return globalBufferedDeletes.any() || !globalSlice.isEmpty() || globalSlice.sliceTail != tail
+ || tail.next != null;
} finally {
globalBufferLock.unlock();
}
Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/codecs/lucene3x/TermInfosReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/codecs/lucene3x/TermInfosReader.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/codecs/lucene3x/TermInfosReader.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/codecs/lucene3x/TermInfosReader.java Wed Nov 2 17:11:00 2011
@@ -47,9 +47,8 @@ public final class TermInfosReader {
private final SegmentTermEnum origEnum;
private final long size;
- private final Term[] indexTerms;
- private final TermInfo[] indexInfos;
- private final long[] indexPointers;
+ private final TermInfosReaderIndex index;
+ private final int indexLength;
private final int totalIndexInterval;
@@ -118,37 +117,22 @@ public final class TermInfosReader {
if (indexDivisor != -1) {
// Load terms index
totalIndexInterval = origEnum.indexInterval * indexDivisor;
- final SegmentTermEnum indexEnum = new SegmentTermEnum(directory.openInput(IndexFileNames.segmentFileName(segment, "", Lucene3xPostingsFormat.TERMS_INDEX_EXTENSION),
- context), fieldInfos, true);
- try {
- int indexSize = 1+((int)indexEnum.size-1)/indexDivisor; // otherwise read index
+ final String indexFileName = IndexFileNames.segmentFileName(segment, "", Lucene3xPostingsFormat.TERMS_INDEX_EXTENSION);
+ final SegmentTermEnum indexEnum = new SegmentTermEnum(directory.openInput(indexFileName,
+ context), fieldInfos, true);
- indexTerms = new Term[indexSize];
- indexInfos = new TermInfo[indexSize];
- indexPointers = new long[indexSize];
-
- for (int i=0;indexEnum.next(); i++) {
- indexTerms[i] = indexEnum.term();
- assert indexTerms[i] != null;
- assert indexTerms[i].text() != null;
- assert indexTerms[i].field() != null;
- indexInfos[i] = indexEnum.termInfo();
- indexPointers[i] = indexEnum.indexPointer;
-
- for (int j = 1; j < indexDivisor; j++)
- if (!indexEnum.next())
- break;
- }
+ try {
+ index = new TermInfosReaderIndex(indexEnum, indexDivisor, dir.fileLength(indexFileName), totalIndexInterval);
+ indexLength = index.length();
} finally {
indexEnum.close();
}
} else {
// Do not load terms index:
totalIndexInterval = -1;
- indexTerms = null;
- indexInfos = null;
- indexPointers = null;
+ index = null;
+ indexLength = -1;
}
success = true;
} finally {
@@ -203,31 +187,6 @@ public final class TermInfosReader {
}
}
- /** Returns the offset of the greatest index entry which is less than or equal to term.*/
- private int getIndexOffset(Term term) {
- int lo = 0; // binary search indexTerms[]
- int hi = indexTerms.length - 1;
-
- while (hi >= lo) {
- int mid = (lo + hi) >>> 1;
- assert indexTerms[mid] != null : "indexTerms = " + indexTerms.length + " mid=" + mid;
- int delta = compareAsUTF16(term, indexTerms[mid]);
- if (delta < 0)
- hi = mid - 1;
- else if (delta > 0)
- lo = mid + 1;
- else
- return mid;
- }
- return hi;
- }
-
- private void seekEnum(SegmentTermEnum enumerator, int indexOffset) throws IOException {
- enumerator.seek(indexPointers[indexOffset],
- ((long) indexOffset * totalIndexInterval) - 1,
- indexTerms[indexOffset], indexInfos[indexOffset]);
- }
-
/** Returns the TermInfo for a Term in the set, or null. */
TermInfo get(Term term) throws IOException {
return get(term, false);
@@ -269,11 +228,11 @@ public final class TermInfosReader {
// optimize sequential access: first try scanning cached enum w/o seeking
if (enumerator.term() != null // term is at or past current
- && ((enumerator.prev() != null && compareAsUTF16(term, enumerator.prev())> 0)
- || compareAsUTF16(term, enumerator.term()) >= 0)) {
+ && ((enumerator.prev() != null && compareAsUTF16(term, enumerator.prev())> 0)
+ || compareAsUTF16(term, enumerator.term()) >= 0)) {
int enumOffset = (int)(enumerator.position/totalIndexInterval)+1;
- if (indexTerms.length == enumOffset // but before end of block
- || compareAsUTF16(term, indexTerms[enumOffset]) < 0) {
+ if (indexLength == enumOffset // but before end of block
+ || index.compareTo(term, enumOffset) < 0) {
// no need to seek
final TermInfo ti;
@@ -309,10 +268,10 @@ public final class TermInfosReader {
indexPos = (int) (tiOrd.termOrd / totalIndexInterval);
} else {
// Must do binary search:
- indexPos = getIndexOffset(term);
+ indexPos = index.getIndexOffset(term);
}
- seekEnum(enumerator, indexPos);
+ index.seekEnum(enumerator, indexPos);
enumerator.scanTo(term);
final TermInfo ti;
@@ -352,7 +311,7 @@ public final class TermInfosReader {
}
private void ensureIndexIsRead() {
- if (indexTerms == null) {
+ if (index == null) {
throw new IllegalStateException("terms index was not loaded when this reader was created");
}
}
@@ -362,10 +321,10 @@ public final class TermInfosReader {
if (size == 0) return -1;
ensureIndexIsRead();
- int indexOffset = getIndexOffset(term);
+ int indexOffset = index.getIndexOffset(term);
SegmentTermEnum enumerator = getThreadResources().termEnum;
- seekEnum(enumerator, indexOffset);
+ index.seekEnum(enumerator, indexOffset);
while(compareAsUTF16(term, enumerator.term()) > 0 && enumerator.next()) {}
Copied: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/codecs/lucene3x/TermInfosReaderIndex.java (from r1196682, lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/preflex/TermInfosReaderIndex.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/codecs/lucene3x/TermInfosReaderIndex.java?p2=lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/codecs/lucene3x/TermInfosReaderIndex.java&p1=lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/preflex/TermInfosReaderIndex.java&r1=1196682&r2=1196701&rev=1196701&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/codecs/preflex/TermInfosReaderIndex.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/codecs/lucene3x/TermInfosReaderIndex.java Wed Nov 2 17:11:00 2011
@@ -1,4 +1,4 @@
-package org.apache.lucene.index.codecs.preflex;
+package org.apache.lucene.index.codecs.lucene3x;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/values/Bytes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/values/Bytes.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/values/Bytes.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/values/Bytes.java Wed Nov 2 17:11:00 2011
@@ -334,17 +334,17 @@ public final class Bytes {
IndexInput indexIn = null;
boolean success = false;
try {
- dataIn = dir.openInput(IndexFileNames.segmentFileName(id, "",
- Writer.DATA_EXTENSION), context);
- version = CodecUtil.checkHeader(dataIn, codecName, maxVersion, maxVersion);
- if (doIndex) {
- indexIn = dir.openInput(IndexFileNames.segmentFileName(id, "",
- Writer.INDEX_EXTENSION), context);
- final int version2 = CodecUtil.checkHeader(indexIn, codecName,
- maxVersion, maxVersion);
- assert version == version2;
- }
- success = true;
+ dataIn = dir.openInput(IndexFileNames.segmentFileName(id, "",
+ Writer.DATA_EXTENSION), context);
+ version = CodecUtil.checkHeader(dataIn, codecName, maxVersion, maxVersion);
+ if (doIndex) {
+ indexIn = dir.openInput(IndexFileNames.segmentFileName(id, "",
+ Writer.INDEX_EXTENSION), context);
+ final int version2 = CodecUtil.checkHeader(indexIn, codecName,
+ maxVersion, maxVersion);
+ assert version == version2;
+ }
+ success = true;
} finally {
if (!success) {
IOUtils.closeWhileHandlingException(dataIn, indexIn);
Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/search/CachingSpanFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/search/CachingSpanFilter.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/search/CachingSpanFilter.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/search/CachingSpanFilter.java Wed Nov 2 17:11:00 2011
@@ -37,9 +37,7 @@ public class CachingSpanFilter extends S
*/
private final CachingWrapperFilter.FilterCache<SpanFilterResult> cache;
- /**
- * New deletions always result in a cache miss, by default
- * ({@link CachingWrapperFilter.DeletesMode#RECACHE}.
+ /** Wraps another SpanFilter's result and caches it.
* @param filter Filter to cache results of
*/
public CachingSpanFilter(SpanFilter filter) {
Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/search/CachingWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/search/CachingWrapperFilter.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/search/CachingWrapperFilter.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/search/CachingWrapperFilter.java Wed Nov 2 17:11:00 2011
@@ -63,9 +63,7 @@ public class CachingWrapperFilter extend
}
}
- /**
- * New deletes are ignored by default, which gives higher
- * cache hit rate on reopened readers.
+ /** Wraps another filter's result and caches it.
* @param filter Filter to cache results of
*/
public CachingWrapperFilter(Filter filter) {
Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/search/ConstantScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/search/ConstantScoreQuery.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/search/ConstantScoreQuery.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/search/ConstantScoreQuery.java Wed Nov 2 17:11:00 2011
@@ -30,12 +30,6 @@ import java.util.Set;
* A query that wraps another query or a filter and simply returns a constant score equal to the
* query boost for every document that matches the filter or query.
* For queries it therefore simply strips of all scores and returns a constant one.
- *
- * <p><b>NOTE</b>: if the wrapped filter is an instance of
- * {@link CachingWrapperFilter}, you'll likely want to
- * enforce deletions in the filter (using either {@link
- * CachingWrapperFilter.DeletesMode#RECACHE} or {@link
- * CachingWrapperFilter.DeletesMode#DYNAMIC}).
*/
public class ConstantScoreQuery extends Query {
protected final Filter filter;
Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/store/ByteArrayDataInput.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/store/ByteArrayDataInput.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/store/ByteArrayDataInput.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/store/ByteArrayDataInput.java Wed Nov 2 17:11:00 2011
@@ -52,7 +52,7 @@ public final class ByteArrayDataInput ex
public int getPosition() {
return pos;
}
-
+
public void setPosition(int pos) {
this.pos = pos;
}
Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/store/IndexInput.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/store/IndexInput.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/store/IndexInput.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/store/IndexInput.java Wed Nov 2 17:11:00 2011
@@ -26,8 +26,6 @@ import java.io.IOException;
*/
public abstract class IndexInput extends DataInput implements Cloneable,Closeable {
- protected byte[] copyBuf = null;
-
/** Closes the stream to further operations. */
public abstract void close() throws IOException;
@@ -59,9 +57,7 @@ public abstract class IndexInput extends
public void copyBytes(IndexOutput out, long numBytes) throws IOException {
assert numBytes >= 0: "numBytes=" + numBytes;
- if (copyBuf == null) {
- copyBuf = new byte[BufferedIndexInput.BUFFER_SIZE];
- }
+ byte copyBuf[] = new byte[BufferedIndexInput.BUFFER_SIZE];
while (numBytes > 0) {
final int toCopy = (int) (numBytes > copyBuf.length ? copyBuf.length : numBytes);
Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/util/CharsRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/util/CharsRef.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/util/CharsRef.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/util/CharsRef.java Wed Nov 2 17:11:00 2011
@@ -189,18 +189,22 @@ public final class CharsRef implements C
* Copies the given array into this CharsRef starting at offset 0
*/
public void copy(char[] otherChars, int otherOffset, int otherLength) {
+ grow(otherLength);
+ System.arraycopy(otherChars, otherOffset, this.chars, 0,
+ otherLength);
this.offset = 0;
- append(otherChars, otherOffset, otherLength);
+ this.length = otherLength;
}
/**
- * Appends the given array to this CharsRef starting at the current offset
+ * Appends the given array to this CharsRef
*/
public void append(char[] otherChars, int otherOffset, int otherLength) {
- grow(this.offset + otherLength);
- System.arraycopy(otherChars, otherOffset, this.chars, this.offset,
+ final int newLength = length + otherLength;
+ grow(this.offset + newLength);
+ System.arraycopy(otherChars, otherOffset, this.chars, this.offset+length,
otherLength);
- this.length = otherLength;
+ this.length += otherLength;
}
@Override
Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/util/FixedBitSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/util/FixedBitSet.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/util/FixedBitSet.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/util/FixedBitSet.java Wed Nov 2 17:11:00 2011
@@ -146,7 +146,7 @@ public final class FixedBitSet extends D
public int nextSetBit(int index) {
assert index >= 0 && index < numBits;
int i = index >> 6;
- int subIndex = index & 0x3f; // index within the word
+ final int subIndex = index & 0x3f; // index within the word
long word = bits[i] >> subIndex; // skip all the bits to the right of index
if (word!=0) {
@@ -163,6 +163,9 @@ public final class FixedBitSet extends D
return -1;
}
+ /** Returns the index of the last set bit before or on the index specified.
+ * -1 is returned if there are no more set bits.
+ */
public int prevSetBit(int index) {
assert index >= 0 && index < numBits: "index=" + index + " numBits=" + numBits;
int i = index >> 6;
Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/util/PagedBytes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/util/PagedBytes.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/util/PagedBytes.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/util/PagedBytes.java Wed Nov 2 17:11:00 2011
@@ -17,12 +17,14 @@ package org.apache.lucene.util;
* limitations under the License.
*/
-import org.apache.lucene.store.IndexInput;
-
-import java.util.List;
-import java.util.ArrayList;
import java.io.Closeable;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lucene.store.DataInput;
+import org.apache.lucene.store.DataOutput;
+import org.apache.lucene.store.IndexInput;
/** Represents a logical byte[] as a series of pages. You
* can write-once into the logical byte[] (append only),
@@ -37,6 +39,8 @@ public final class PagedBytes {
private final int blockSize;
private final int blockBits;
private final int blockMask;
+ private boolean didSkipBytes;
+ private boolean frozen;
private int upto;
private byte[] currentBlock;
@@ -320,6 +324,7 @@ public final class PagedBytes {
if (currentBlock != null) {
blocks.add(currentBlock);
blockEnd.add(upto);
+ didSkipBytes = true;
}
currentBlock = new byte[blockSize];
upto = 0;
@@ -338,6 +343,12 @@ public final class PagedBytes {
/** Commits final byte[], trimming it if necessary and if trim=true */
public Reader freeze(boolean trim) {
+ if (frozen) {
+ throw new IllegalStateException("already frozen");
+ }
+ if (didSkipBytes) {
+ throw new IllegalStateException("cannot freeze when copy(BytesRef, BytesRef) was used");
+ }
if (trim && upto < blockSize) {
final byte[] newBlock = new byte[upto];
System.arraycopy(currentBlock, 0, newBlock, 0, upto);
@@ -348,6 +359,7 @@ public final class PagedBytes {
}
blocks.add(currentBlock);
blockEnd.add(upto);
+ frozen = true;
currentBlock = null;
return new Reader(this);
}
@@ -389,4 +401,150 @@ public final class PagedBytes {
return pointer;
}
+
+ public final class PagedBytesDataInput extends DataInput {
+ private int currentBlockIndex;
+ private int currentBlockUpto;
+ private byte[] currentBlock;
+
+ PagedBytesDataInput() {
+ currentBlock = blocks.get(0);
+ }
+
+ @Override
+ public Object clone() {
+ PagedBytesDataInput clone = getDataInput();
+ clone.setPosition(getPosition());
+ return clone;
+ }
+
+ /** Returns the current byte position. */
+ public long getPosition() {
+ return currentBlockIndex * blockSize + currentBlockUpto;
+ }
+
+ /** Seek to a position previously obtained from
+ * {@link #getPosition}. */
+ public void setPosition(long pos) {
+ currentBlockIndex = (int) (pos >> blockBits);
+ currentBlock = blocks.get(currentBlockIndex);
+ currentBlockUpto = (int) (pos & blockMask);
+ }
+
+ @Override
+ public byte readByte() {
+ if (currentBlockUpto == blockSize) {
+ nextBlock();
+ }
+ return currentBlock[currentBlockUpto++];
+ }
+
+ @Override
+ public void readBytes(byte[] b, int offset, int len) {
+ final int offsetEnd = offset + len;
+ while (true) {
+ final int blockLeft = blockSize - currentBlockUpto;
+ final int left = offsetEnd - offset;
+ if (blockLeft < left) {
+ System.arraycopy(currentBlock, currentBlockUpto,
+ b, offset,
+ blockLeft);
+ nextBlock();
+ offset += blockLeft;
+ } else {
+ // Last block
+ System.arraycopy(currentBlock, currentBlockUpto,
+ b, offset,
+ left);
+ currentBlockUpto += left;
+ break;
+ }
+ }
+ }
+
+ private void nextBlock() {
+ currentBlockIndex++;
+ currentBlockUpto = 0;
+ currentBlock = blocks.get(currentBlockIndex);
+ }
+ }
+
+ public final class PagedBytesDataOutput extends DataOutput {
+ @Override
+ public void writeByte(byte b) {
+ if (upto == blockSize) {
+ if (currentBlock != null) {
+ blocks.add(currentBlock);
+ blockEnd.add(upto);
+ }
+ currentBlock = new byte[blockSize];
+ upto = 0;
+ }
+ currentBlock[upto++] = b;
+ }
+
+ @Override
+ public void writeBytes(byte[] b, int offset, int length) throws IOException {
+ if (length == 0) {
+ return;
+ }
+
+ if (upto == blockSize) {
+ if (currentBlock != null) {
+ blocks.add(currentBlock);
+ blockEnd.add(upto);
+ }
+ currentBlock = new byte[blockSize];
+ upto = 0;
+ }
+
+ final int offsetEnd = offset + length;
+ while(true) {
+ final int left = offsetEnd - offset;
+ final int blockLeft = blockSize - upto;
+ if (blockLeft < left) {
+ System.arraycopy(b, offset, currentBlock, upto, blockLeft);
+ blocks.add(currentBlock);
+ blockEnd.add(blockSize);
+ currentBlock = new byte[blockSize];
+ upto = 0;
+ offset += blockLeft;
+ } else {
+ // Last block
+ System.arraycopy(b, offset, currentBlock, upto, left);
+ upto += left;
+ break;
+ }
+ }
+ }
+
+ /** Return the current byte position. */
+ public long getPosition() {
+ if (currentBlock == null) {
+ return 0;
+ } else {
+ return blocks.size() * blockSize + upto;
+ }
+ }
+ }
+
+ /** Returns a DataInput to read values from this
+ * PagedBytes instance. */
+ public PagedBytesDataInput getDataInput() {
+ if (!frozen) {
+ throw new IllegalStateException("must call freeze() before getDataInput");
+ }
+ return new PagedBytesDataInput();
+ }
+
+ /** Returns a DataOutput that you may use to write into
+ * this PagedBytes instance. If you do this, you should
+ * not call the other writing methods (eg, copy);
+ * results are undefined. */
+ public PagedBytesDataOutput getDataOutput() {
+ if (frozen) {
+ throw new IllegalStateException("cannot get DataOutput after freeze()");
+ }
+ return new PagedBytesDataOutput();
+ }
}
Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/util/mutable/MutableValue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/util/mutable/MutableValue.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/util/mutable/MutableValue.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/util/mutable/MutableValue.java Wed Nov 2 17:11:00 2011
@@ -17,7 +17,7 @@
package org.apache.lucene.util.mutable;
/** @lucene.internal */
-public abstract class MutableValue implements Comparable {
+public abstract class MutableValue implements Comparable<MutableValue> {
public boolean exists = true;
public abstract void copy(MutableValue source);
@@ -30,9 +30,9 @@ public abstract class MutableValue imple
return exists;
}
- public int compareTo(Object other) {
- Class c1 = this.getClass();
- Class c2 = other.getClass();
+ public int compareTo(MutableValue other) {
+ Class<? extends MutableValue> c1 = this.getClass();
+ Class<? extends MutableValue> c2 = other.getClass();
if (c1 != c2) {
int c = c1.hashCode() - c2.hashCode();
if (c == 0) {
@@ -45,9 +45,7 @@ public abstract class MutableValue imple
@Override
public boolean equals(Object other) {
- Class c1 = this.getClass();
- Class c2 = other.getClass();
- return (c1 == c2) && this.equalsSameType(other);
+ return (getClass() == other.getClass()) && this.equalsSameType(other);
}
@Override
Modified: lucene/dev/branches/lucene2621/lucene/src/test-framework/java/org/apache/lucene/store/MockIndexInputWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test-framework/java/org/apache/lucene/store/MockIndexInputWrapper.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test-framework/java/org/apache/lucene/store/MockIndexInputWrapper.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test-framework/java/org/apache/lucene/store/MockIndexInputWrapper.java Wed Nov 2 17:11:00 2011
@@ -30,6 +30,7 @@ public class MockIndexInputWrapper exten
final String name;
private IndexInput delegate;
private boolean isClone;
+ private boolean closed;
/** Construct an empty output buffer. */
public MockIndexInputWrapper(MockDirectoryWrapper dir, String name, IndexInput delegate) {
@@ -45,6 +46,7 @@ public class MockIndexInputWrapper exten
// after fixing TestTransactions
// dir.maybeThrowDeterministicException();
} finally {
+ closed = true;
delegate.close();
// Pending resolution on LUCENE-686 we may want to
// remove the conditional check so we also track that
@@ -54,9 +56,16 @@ public class MockIndexInputWrapper exten
}
}
}
+
+ private void ensureOpen() {
+ if (closed) {
+ throw new RuntimeException("Abusing closed IndexInput!");
+ }
+ }
@Override
public Object clone() {
+ ensureOpen();
dir.inputCloneCount.incrementAndGet();
IndexInput iiclone = (IndexInput) delegate.clone();
MockIndexInputWrapper clone = new MockIndexInputWrapper(dir, name, iiclone);
@@ -80,72 +89,86 @@ public class MockIndexInputWrapper exten
@Override
public long getFilePointer() {
+ ensureOpen();
return delegate.getFilePointer();
}
@Override
public void seek(long pos) throws IOException {
+ ensureOpen();
delegate.seek(pos);
}
@Override
public long length() {
+ ensureOpen();
return delegate.length();
}
@Override
public byte readByte() throws IOException {
+ ensureOpen();
return delegate.readByte();
}
@Override
public void readBytes(byte[] b, int offset, int len) throws IOException {
+ ensureOpen();
delegate.readBytes(b, offset, len);
}
@Override
public void copyBytes(IndexOutput out, long numBytes) throws IOException {
+ ensureOpen();
delegate.copyBytes(out, numBytes);
}
@Override
public void readBytes(byte[] b, int offset, int len, boolean useBuffer)
throws IOException {
+ ensureOpen();
delegate.readBytes(b, offset, len, useBuffer);
}
@Override
public short readShort() throws IOException {
+ ensureOpen();
return delegate.readShort();
}
@Override
public int readInt() throws IOException {
+ ensureOpen();
return delegate.readInt();
}
@Override
public long readLong() throws IOException {
+ ensureOpen();
return delegate.readLong();
}
@Override
public String readString() throws IOException {
+ ensureOpen();
return delegate.readString();
}
@Override
public Map<String,String> readStringStringMap() throws IOException {
+ ensureOpen();
return delegate.readStringStringMap();
}
@Override
public int readVInt() throws IOException {
+ ensureOpen();
return delegate.readVInt();
}
@Override
public long readVLong() throws IOException {
+ ensureOpen();
return delegate.readVLong();
}
Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/TestAssertions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/TestAssertions.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/TestAssertions.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/TestAssertions.java Wed Nov 2 17:11:00 2011
@@ -17,55 +17,14 @@ package org.apache.lucene;
* limitations under the License.
*/
-import java.io.Reader;
-
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
+/**
+ * validate that assertions are enabled during tests
+ */
public class TestAssertions extends LuceneTestCase {
- public void testBasics() {
- try {
- assert Boolean.FALSE.booleanValue();
- fail("assertions are not enabled!");
- } catch (AssertionError e) {
- assert Boolean.TRUE.booleanValue();
- }
- }
-
- static class TestAnalyzer1 extends Analyzer {
-
- @Override
- protected TokenStreamComponents createComponents(String fieldName, Reader aReader) {
- return null;
- }
- }
-
- static final class TestAnalyzer2 extends Analyzer {
-
- @Override
- protected TokenStreamComponents createComponents(String fieldName, Reader aReader) {
- return null;
- }
- }
-
- static class TestAnalyzer3 extends Analyzer {
-
- @Override
- protected TokenStreamComponents createComponents(String fieldName, Reader aReader) {
- return null;
- }
- }
-
- static class TestAnalyzer4 extends Analyzer {
-
- @Override
- protected TokenStreamComponents createComponents(String fieldName, Reader aReader) {
- return null;
- }
- }
-
static class TestTokenStream1 extends TokenStream {
@Override
public final boolean incrementToken() { return false; }
@@ -82,31 +41,15 @@ public class TestAssertions extends Luce
}
public void testTokenStreams() {
- new TestAnalyzer1();
-
- new TestAnalyzer2();
-
- try {
- new TestAnalyzer3();
- fail("TestAnalyzer3 should fail assertion");
- } catch (AssertionError e) {
- }
-
- try {
- new TestAnalyzer4();
- fail("TestAnalyzer4 should fail assertion");
- } catch (AssertionError e) {
- }
-
new TestTokenStream1();
-
new TestTokenStream2();
-
+ boolean doFail = false;
try {
new TestTokenStream3();
- fail("TestTokenStream3 should fail assertion");
+ doFail = true;
} catch (AssertionError e) {
+ // expected
}
+ assertFalse("TestTokenStream3 should fail assertion", doFail);
}
-
}
Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestDocumentsWriterDeleteQueue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestDocumentsWriterDeleteQueue.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestDocumentsWriterDeleteQueue.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestDocumentsWriterDeleteQueue.java Wed Nov 2 17:11:00 2011
@@ -16,10 +16,12 @@ package org.apache.lucene.index;
* License for the specific language governing permissions and limitations under
* the License.
*/
+import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.ReentrantLock;
import org.apache.lucene.index.DocumentsWriterDeleteQueue.DeleteSlice;
import org.apache.lucene.search.TermQuery;
@@ -142,6 +144,32 @@ public class TestDocumentsWriterDeleteQu
}
}
}
+
+ public void testPartiallyAppliedGlobalSlice() throws SecurityException,
+ NoSuchFieldException, IllegalArgumentException, IllegalAccessException,
+ InterruptedException {
+ final DocumentsWriterDeleteQueue queue = new DocumentsWriterDeleteQueue();
+ Field field = DocumentsWriterDeleteQueue.class
+ .getDeclaredField("globalBufferLock");
+ field.setAccessible(true);
+ ReentrantLock lock = (ReentrantLock) field.get(queue);
+ lock.lock();
+ Thread t = new Thread() {
+ public void run() {
+ queue.addDelete(new Term("foo", "bar"));
+ }
+ };
+ t.start();
+ t.join();
+ lock.unlock();
+ assertTrue("changes in del queue but not in slice yet", queue.anyChanges());
+ queue.tryApplyGlobalSlice();
+ assertTrue("changes in global buffer", queue.anyChanges());
+ FrozenBufferedDeletes freezeGlobalBuffer = queue.freezeGlobalBuffer(null);
+ assertTrue(freezeGlobalBuffer.any());
+ assertEquals(1, freezeGlobalBuffer.termCount);
+ assertFalse("all changes applied", queue.anyChanges());
+ }
public void testStressDeleteQueue() throws InterruptedException {
DocumentsWriterDeleteQueue queue = new DocumentsWriterDeleteQueue();
Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java Wed Nov 2 17:11:00 2011
@@ -147,12 +147,14 @@ public class TestSegmentMerger extends L
// Assert that SM fails if .del exists
SegmentMerger sm = new SegmentMerger(dir, 1, "a", null, null, null, Codec.getDefault(), newIOContext(random));
+ boolean doFail = false;
try {
sm.createCompoundFile("b1", w.segmentInfos.info(0), newIOContext(random));
- fail("should not have been able to create a .cfs with .del and .s* files");
+ doFail = true; // should never get here
} catch (AssertionError e) {
// expected
}
+ assertFalse("should not have been able to create a .cfs with .del and .s* files", doFail);
// Create an index w/ .s*
w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.CREATE));
@@ -165,12 +167,15 @@ public class TestSegmentMerger extends L
r.close();
// Assert that SM fails if .s* exists
+ SegmentInfos sis = new SegmentInfos();
+ sis.read(dir);
try {
- sm.createCompoundFile("b2", w.segmentInfos.info(0), newIOContext(random));
- fail("should not have been able to create a .cfs with .del and .s* files");
+ sm.createCompoundFile("b2", sis.info(0), newIOContext(random));
+ doFail = true; // should never get here
} catch (AssertionError e) {
// expected
}
+ assertFalse("should not have been able to create a .cfs with .del and .s* files", doFail);
dir.close();
}
Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/lucene3x/TestImpersonation.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/lucene3x/TestImpersonation.java?rev=1196701&r1=1196591&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/lucene3x/TestImpersonation.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/lucene3x/TestImpersonation.java Wed Nov 2 17:11:00 2011
@@ -1,4 +1,4 @@
-package org.apache.lucene.index.codecs.preflex;
+package org.apache.lucene.index.codecs.lucene3x;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
Copied: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/lucene3x/TestSurrogates.java (from r1196601, lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/lucene3x/TestSurrogates.java?p2=lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/lucene3x/TestSurrogates.java&p1=lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java&r1=1196601&r2=1196701&rev=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/lucene3x/TestSurrogates.java Wed Nov 2 17:11:00 2011
@@ -1,4 +1,4 @@
-package org.apache.lucene.index.codecs.preflex;
+package org.apache.lucene.index.codecs.lucene3x;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
Copied: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/lucene3x/TestTermInfosReaderIndex.java (from r1196665, lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestTermInfosReaderIndex.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/lucene3x/TestTermInfosReaderIndex.java?p2=lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/lucene3x/TestTermInfosReaderIndex.java&p1=lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestTermInfosReaderIndex.java&r1=1196665&r2=1196701&rev=1196701&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestTermInfosReaderIndex.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/index/codecs/lucene3x/TestTermInfosReaderIndex.java Wed Nov 2 17:11:00 2011
@@ -1,4 +1,4 @@
-package org.apache.lucene.index.codecs.preflex;
+package org.apache.lucene.index.codecs.lucene3x;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -39,9 +39,6 @@ import org.apache.lucene.index.RandomInd
import org.apache.lucene.index.SegmentReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermsEnum;
-import org.apache.lucene.index.codecs.Codec;
-import org.apache.lucene.index.codecs.CodecProvider;
-import org.apache.lucene.index.codecs.CoreCodecProvider;
import org.apache.lucene.index.codecs.preflexrw.PreFlexRWCodec;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.TermQuery;
@@ -49,9 +46,9 @@ import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IndexInput;
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;
public class TestTermInfosReaderIndex extends LuceneTestCase {
@@ -65,6 +62,12 @@ public class TestTermInfosReaderIndex ex
private IndexReader reader;
private List<Term> sampleTerms;
+ /** we will manually instantiate preflex-rw here */
+ @BeforeClass
+ public static void beforeClass() {
+ LuceneTestCase.PREFLEX_IMPERSONATION_IS_ACTIVE = true;
+ }
+
@Override
public void setUp() throws Exception {
super.setUp();
@@ -78,10 +81,10 @@ public class TestTermInfosReaderIndex ex
r.close();
FieldInfos fieldInfos = new FieldInfos(directory, IndexFileNames.segmentFileName(segment, "", IndexFileNames.FIELD_INFOS_EXTENSION));
- String segmentFileName = IndexFileNames.segmentFileName(segment, "", PreFlexCodec.TERMS_INDEX_EXTENSION);
+ String segmentFileName = IndexFileNames.segmentFileName(segment, "", Lucene3xPostingsFormat.TERMS_INDEX_EXTENSION);
long tiiFileLength = directory.fileLength(segmentFileName);
IndexInput input = directory.openInput(segmentFileName, newIOContext(random));
- termEnum = new SegmentTermEnum(directory.openInput(IndexFileNames.segmentFileName(segment, "", PreFlexCodec.TERMS_EXTENSION), newIOContext(random)), fieldInfos, false);
+ termEnum = new SegmentTermEnum(directory.openInput(IndexFileNames.segmentFileName(segment, "", Lucene3xPostingsFormat.TERMS_EXTENSION), newIOContext(random)), fieldInfos, false);
int totalIndexInterval = termEnum.indexInterval * indexDivisor;
SegmentTermEnum indexEnum = new SegmentTermEnum(input, fieldInfos, true);
@@ -164,11 +167,7 @@ public class TestTermInfosReaderIndex ex
private int populate(Directory directory) throws CorruptIndexException, LockObtainFailedException, IOException {
IndexWriterConfig config = newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer(random, MockTokenizer.KEYWORD, false));
- CoreCodecProvider cp = new CoreCodecProvider();
- cp.unregister(cp.lookup("PreFlex"));
- cp.register(new PreFlexRWCodec());
- cp.setDefaultFieldCodec("PreFlex");
- config.setCodecProvider(cp);
+ config.setCodec(new PreFlexRWCodec());
// turn off compound file, this test will open some index files directly.
LogMergePolicy mp = newLogMergePolicy();
mp.setUseCompoundFile(false);
Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/store/TestCopyBytes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/store/TestCopyBytes.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/store/TestCopyBytes.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/store/TestCopyBytes.java Wed Nov 2 17:11:00 2011
@@ -17,6 +17,8 @@ package org.apache.lucene.store;
* limitations under the License.
*/
+import java.io.IOException;
+
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
@@ -104,4 +106,68 @@ public class TestCopyBytes extends Lucen
dir.close();
}
}
+
+ // LUCENE-3541
+ public void testCopyBytesWithThreads() throws Exception {
+ int datalen = _TestUtil.nextInt(random, 101, 10000);
+ byte data[] = new byte[datalen];
+ random.nextBytes(data);
+
+ Directory d = newDirectory();
+ IndexOutput output = d.createOutput("data", IOContext.DEFAULT);
+ output.writeBytes(data, 0, datalen);
+ output.close();
+
+ IndexInput input = d.openInput("data", IOContext.DEFAULT);
+ IndexOutput outputHeader = d.createOutput("header", IOContext.DEFAULT);
+ // copy our 100-byte header
+ input.copyBytes(outputHeader, 100);
+ outputHeader.close();
+
+ // now make N copies of the remaining bytes
+ CopyThread copies[] = new CopyThread[10];
+ for (int i = 0; i < copies.length; i++) {
+ copies[i] = new CopyThread((IndexInput) input.clone(), d.createOutput("copy" + i, IOContext.DEFAULT));
+ }
+
+ for (int i = 0; i < copies.length; i++) {
+ copies[i].start();
+ }
+
+ for (int i = 0; i < copies.length; i++) {
+ copies[i].join();
+ }
+
+ for (int i = 0; i < copies.length; i++) {
+ IndexInput copiedData = d.openInput("copy" + i, IOContext.DEFAULT);
+ byte[] dataCopy = new byte[datalen];
+ System.arraycopy(data, 0, dataCopy, 0, 100); // copy the header for easy testing
+ copiedData.readBytes(dataCopy, 100, datalen-100);
+ assertArrayEquals(data, dataCopy);
+ copiedData.close();
+ }
+ input.close();
+ d.close();
+
+ }
+
+ static class CopyThread extends Thread {
+ final IndexInput src;
+ final IndexOutput dst;
+
+ CopyThread(IndexInput src, IndexOutput dst) {
+ this.src = src;
+ this.dst = dst;
+ }
+
+ @Override
+ public void run() {
+ try {
+ src.copyBytes(dst, src.length()-100);
+ dst.close();
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ }
}
Modified: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/util/TestCharsRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/util/TestCharsRef.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/util/TestCharsRef.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/util/TestCharsRef.java Wed Nov 2 17:11:00 2011
@@ -38,4 +38,33 @@ public class TestCharsRef extends Lucene
assertEquals(utf8[i].utf8ToString(), utf16[i].toString());
}
}
+
+ public void testAppend() {
+ CharsRef ref = new CharsRef();
+ StringBuilder builder = new StringBuilder();
+ int numStrings = atLeast(10);
+ for (int i = 0; i < numStrings; i++) {
+ char[] charArray = _TestUtil.randomRealisticUnicodeString(random, 1, 100).toCharArray();
+ int offset = random.nextInt(charArray.length);
+ int length = charArray.length - offset;
+ builder.append(charArray, offset, length);
+ ref.append(charArray, offset, length);
+ }
+
+ assertEquals(builder.toString(), ref.toString());
+ }
+
+ public void testCopy() {
+ int numIters = atLeast(10);
+ for (int i = 0; i < numIters; i++) {
+ CharsRef ref = new CharsRef();
+ char[] charArray = _TestUtil.randomRealisticUnicodeString(random, 1, 100).toCharArray();
+ int offset = random.nextInt(charArray.length);
+ int length = charArray.length - offset;
+ String str = new String(charArray, offset, length);
+ ref.copy(charArray, offset, length);
+ assertEquals(str, ref.toString());
+ }
+
+ }
}
Modified: lucene/dev/branches/lucene2621/modules/facet/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/modules/facet/build.xml?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/modules/facet/build.xml (original)
+++ lucene/dev/branches/lucene2621/modules/facet/build.xml Wed Nov 2 17:11:00 2011
@@ -24,10 +24,10 @@
</description>
<property name="build.dir" location="build/" />
- <import file="../../lucene/contrib/contrib-build.xml"/>
-
- <property name="build.dir" location="build/" />
<property name="dist.dir" location="dist/" />
+ <property name="maven.dist.dir" location="../dist/maven" />
+
+ <import file="../../lucene/contrib/contrib-build.xml"/>
<property name="examples.dir" location="src/examples"/>
Modified: lucene/dev/branches/lucene2621/modules/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/modules/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/modules/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java (original)
+++ lucene/dev/branches/lucene2621/modules/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java Wed Nov 2 17:11:00 2011
@@ -14,7 +14,6 @@ import org.apache.lucene.index.IndexWrit
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
-import org.apache.lucene.DocumentBuilder;
import org.apache.lucene.facet.example.ExampleUtils;
import org.apache.lucene.facet.example.simple.SimpleUtils;
import org.apache.lucene.facet.index.CategoryDocumentBuilder;
@@ -167,7 +166,7 @@ public class MultiCLIndexer {
// we do not alter indexing parameters!
// a category document builder will add the categories to a document
// once build() is called
- DocumentBuilder categoryDocBuilder = new CategoryDocumentBuilder(
+ CategoryDocumentBuilder categoryDocBuilder = new CategoryDocumentBuilder(
taxo, iParams).setCategoryPaths(facetList);
// create a plain Lucene document and add some regular Lucene fields
Modified: lucene/dev/branches/lucene2621/modules/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleIndexer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/modules/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleIndexer.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/modules/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleIndexer.java (original)
+++ lucene/dev/branches/lucene2621/modules/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleIndexer.java Wed Nov 2 17:11:00 2011
@@ -11,7 +11,6 @@ import org.apache.lucene.index.IndexWrit
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.DocumentBuilder;
import org.apache.lucene.facet.example.ExampleUtils;
import org.apache.lucene.facet.index.CategoryDocumentBuilder;
import org.apache.lucene.facet.taxonomy.CategoryPath;
@@ -66,7 +65,7 @@ public class SimpleIndexer {
// we do not alter indexing parameters!
// a category document builder will add the categories to a document once build() is called
- DocumentBuilder categoryDocBuilder = new CategoryDocumentBuilder(taxo).setCategoryPaths(facetList);
+ CategoryDocumentBuilder categoryDocBuilder = new CategoryDocumentBuilder(taxo).setCategoryPaths(facetList);
// create a plain Lucene document and add some regular Lucene fields to it
Document doc = new Document();
Modified: lucene/dev/branches/lucene2621/modules/facet/src/java/org/apache/lucene/DocumentBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/modules/facet/src/java/org/apache/lucene/DocumentBuilder.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/modules/facet/src/java/org/apache/lucene/DocumentBuilder.java (original)
+++ lucene/dev/branches/lucene2621/modules/facet/src/java/org/apache/lucene/DocumentBuilder.java Wed Nov 2 17:11:00 2011
@@ -1,77 +0,0 @@
-package org.apache.lucene;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-
-/**
- * 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.
- */
-
-/**
- * An interface which standardizes the process of building an indexable
- * {@link Document}.
- * <p>
- * The idea is that implementations implement {@link #build(Document doc)},
- * which adds to the given Document whatever {@link Field}s it wants to add. A
- * DocumentBuilder is also allowed to inspect or change existing Fields in the
- * Document, if it wishes to.
- * <p>
- * Implementations should normally have a constructor with parameters which
- * determine what {@link #build(Document)} will add to doc.<br>
- * To allow reuse of the DocumentBuilder object, implementations are also
- * encouraged to have a setter method, which remembers its parameters just like
- * the constructor. This setter method cannot be described in this interface,
- * because it will take different parameters in each implementation.
- * <p>
- * The interface defines a builder pattern, which allows applications to invoke
- * several document builders in the following way:
- *
- * <pre>
- * builder1.build(builder2.build(builder3.build(new Document())));
- * </pre>
- *
- * @lucene.experimental
- */
-public interface DocumentBuilder {
-
- /** An exception thrown from {@link DocumentBuilder}'s build(). */
- public static class DocumentBuilderException extends Exception {
-
- public DocumentBuilderException() {
- super();
- }
-
- public DocumentBuilderException(String message) {
- super(message);
- }
-
- public DocumentBuilderException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public DocumentBuilderException(Throwable cause) {
- super(cause);
- }
-
- }
-
- /**
- * Adds to the given document whatever {@link Field}s the implementation needs
- * to add. Return the docunment instance to allow for chaining calls.
- */
- public Document build(Document doc) throws DocumentBuilderException;
-
-}
Modified: lucene/dev/branches/lucene2621/modules/facet/src/java/org/apache/lucene/facet/index/CategoryDocumentBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/modules/facet/src/java/org/apache/lucene/facet/index/CategoryDocumentBuilder.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/modules/facet/src/java/org/apache/lucene/facet/index/CategoryDocumentBuilder.java (original)
+++ lucene/dev/branches/lucene2621/modules/facet/src/java/org/apache/lucene/facet/index/CategoryDocumentBuilder.java Wed Nov 2 17:11:00 2011
@@ -13,7 +13,6 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.TextField;
-import org.apache.lucene.DocumentBuilder;
import org.apache.lucene.facet.index.attributes.CategoryAttribute;
import org.apache.lucene.facet.index.attributes.CategoryAttributesIterable;
import org.apache.lucene.facet.index.categorypolicy.OrdinalPolicy;
@@ -64,7 +63,7 @@ import org.apache.lucene.facet.taxonomy.
*
* @lucene.experimental
*/
-public class CategoryDocumentBuilder implements DocumentBuilder {
+public class CategoryDocumentBuilder {
/**
* A {@link TaxonomyWriter} for adding categories and retrieving their
@@ -288,9 +287,7 @@ public class CategoryDocumentBuilder imp
return new CategoryTokenizer(categoryStream, indexingParams);
}
- /**
- * Adds the fields created in one of the "set" methods to the document
- */
+ /** Adds the fields created in one of the "set" methods to the document */
public Document build(Document doc) {
for (Field f : fieldList) {
doc.add(f);
Modified: lucene/dev/branches/lucene2621/modules/facet/src/test/org/apache/lucene/facet/FacetTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/modules/facet/src/test/org/apache/lucene/facet/FacetTestBase.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/modules/facet/src/test/org/apache/lucene/facet/FacetTestBase.java (original)
+++ lucene/dev/branches/lucene2621/modules/facet/src/test/org/apache/lucene/facet/FacetTestBase.java Wed Nov 2 17:11:00 2011
@@ -9,7 +9,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import org.apache.lucene.DocumentBuilder.DocumentBuilderException;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
@@ -191,7 +190,7 @@ public abstract class FacetTestBase exte
* <p>Subclasses can override this to test different scenarios
*/
protected void populateIndex(RandomIndexWriter iw, TaxonomyWriter taxo, FacetIndexingParams iParams)
- throws IOException, DocumentBuilderException, CorruptIndexException {
+ throws IOException, CorruptIndexException {
// add test documents
int numDocsToIndex = numDocsToIndex();
for (int doc=0; doc<numDocsToIndex; doc++) {
Modified: lucene/dev/branches/lucene2621/modules/facet/src/test/org/apache/lucene/facet/search/BaseTestTopK.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/modules/facet/src/test/org/apache/lucene/facet/search/BaseTestTopK.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/modules/facet/src/test/org/apache/lucene/facet/search/BaseTestTopK.java (original)
+++ lucene/dev/branches/lucene2621/modules/facet/src/test/org/apache/lucene/facet/search/BaseTestTopK.java Wed Nov 2 17:11:00 2011
@@ -4,7 +4,6 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.List;
-import org.apache.lucene.DocumentBuilder.DocumentBuilderException;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.RandomIndexWriter;
@@ -52,8 +51,7 @@ public abstract class BaseTestTopK exten
@Override
protected void populateIndex(RandomIndexWriter iw, TaxonomyWriter taxo,
- FacetIndexingParams iParams) throws IOException,
- DocumentBuilderException, CorruptIndexException {
+ FacetIndexingParams iParams) throws IOException, CorruptIndexException {
currDoc = -1;
super.populateIndex(iw, taxo, iParams);
}
Modified: lucene/dev/branches/lucene2621/modules/join/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/modules/join/build.xml?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/modules/join/build.xml (original)
+++ lucene/dev/branches/lucene2621/modules/join/build.xml Wed Nov 2 17:11:00 2011
@@ -5,10 +5,10 @@
</description>
<property name="build.dir" location="build/" />
- <import file="../../lucene/contrib/contrib-build.xml"/>
-
- <property name="build.dir" location="build/" />
<property name="dist.dir" location="dist/" />
+ <property name="maven.dist.dir" location="../dist/maven" />
+
+ <import file="../../lucene/contrib/contrib-build.xml"/>
<path id="classpath">
<pathelement path="${grouping.jar}"/>
@@ -20,10 +20,6 @@
<pathelement location="${build.dir}/classes/java"/>
</path>
- <property name="build.dir" location="build/" />
- <property name="dist.dir" location="dist/" />
- <property name="maven.dist.dir" location="../dist/maven" />
-
<target name="init" depends="contrib-build.init,jar-grouping"/>
<target name="dist-maven" depends="jar-core,javadocs,contrib-build.dist-maven" />
Modified: lucene/dev/branches/lucene2621/modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/AnalyzerQueryNodeProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/AnalyzerQueryNodeProcessor.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/AnalyzerQueryNodeProcessor.java (original)
+++ lucene/dev/branches/lucene2621/modules/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/AnalyzerQueryNodeProcessor.java Wed Nov 2 17:11:00 2011
@@ -203,12 +203,8 @@ public class AnalyzerQueryNodeProcessor
children.add(new FieldQueryNode(field, term, -1, -1));
}
- if (positionCount == 1)
- return new GroupQueryNode(
- new StandardBooleanQueryNode(children, true));
- else
- return new StandardBooleanQueryNode(children, false);
-
+ return new GroupQueryNode(
+ new StandardBooleanQueryNode(children, positionCount==1));
} else {
// phrase query:
MultiPhraseQueryNode mpq = new MultiPhraseQueryNode();
Modified: lucene/dev/branches/lucene2621/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java (original)
+++ lucene/dev/branches/lucene2621/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java Wed Nov 2 17:11:00 2011
@@ -359,8 +359,16 @@ public class TestQPHelper extends Lucene
BooleanQuery expected = new BooleanQuery();
expected.add(new TermQuery(new Term("field", "ä¸")), BooleanClause.Occur.SHOULD);
expected.add(new TermQuery(new Term("field", "å½")), BooleanClause.Occur.SHOULD);
-
assertEquals(expected, getQuery("ä¸å½", analyzer));
+
+ expected = new BooleanQuery();
+ expected.add(new TermQuery(new Term("field", "ä¸")), BooleanClause.Occur.MUST);
+ BooleanQuery inner = new BooleanQuery();
+ inner.add(new TermQuery(new Term("field", "ä¸")), BooleanClause.Occur.SHOULD);
+ inner.add(new TermQuery(new Term("field", "å½")), BooleanClause.Occur.SHOULD);
+ expected.add(inner, BooleanClause.Occur.MUST);
+ assertEquals(expected, getQuery("ä¸ AND ä¸å½", new SimpleCJKAnalyzer()));
+
}
public void testCJKBoostedTerm() throws Exception {
@@ -609,7 +617,7 @@ public class TestQPHelper extends Lucene
assertQueryEquals("drop AND stop AND roll", qpAnalyzer, "+drop +roll");
assertQueryEquals("term phrase term", qpAnalyzer,
- "term phrase1 phrase2 term");
+ "term (phrase1 phrase2) term");
assertQueryEquals("term AND NOT phrase term", qpAnalyzer,
"+term -(phrase1 phrase2) term");
Modified: lucene/dev/branches/lucene2621/modules/suggest/src/java/org/apache/lucene/search/spell/DirectSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/modules/suggest/src/java/org/apache/lucene/search/spell/DirectSpellChecker.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/modules/suggest/src/java/org/apache/lucene/search/spell/DirectSpellChecker.java (original)
+++ lucene/dev/branches/lucene2621/modules/suggest/src/java/org/apache/lucene/search/spell/DirectSpellChecker.java Wed Nov 2 17:11:00 2011
@@ -70,10 +70,7 @@ public class DirectSpellChecker {
* shortest of the two terms instead of the longest.
* </ul>
*/
- public static final StringDistance INTERNAL_LEVENSHTEIN = new StringDistance() {
- public float getDistance(String s1, String s2) {
- throw new UnsupportedOperationException("Not for external use.");
- }};
+ public static final StringDistance INTERNAL_LEVENSHTEIN = new LuceneLevenshteinDistance();
/** maximum edit distance for candidate terms */
private int maxEdits = LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE;
Modified: lucene/dev/branches/lucene2621/modules/suggest/src/test/org/apache/lucene/search/spell/TestDirectSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/modules/suggest/src/test/org/apache/lucene/search/spell/TestDirectSpellChecker.java?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/modules/suggest/src/test/org/apache/lucene/search/spell/TestDirectSpellChecker.java (original)
+++ lucene/dev/branches/lucene2621/modules/suggest/src/test/org/apache/lucene/search/spell/TestDirectSpellChecker.java Wed Nov 2 17:11:00 2011
@@ -29,7 +29,36 @@ import org.apache.lucene.util.English;
import org.apache.lucene.util.LuceneTestCase;
public class TestDirectSpellChecker extends LuceneTestCase {
+
+ public void testInternalLevenshteinDistance() throws Exception {
+ DirectSpellChecker spellchecker = new DirectSpellChecker();
+ Directory dir = newDirectory();
+ RandomIndexWriter writer = new RandomIndexWriter(random, dir,
+ new MockAnalyzer(random, MockTokenizer.KEYWORD, true));
+
+ String[] termsToAdd = { "metanoia", "metanoian", "metanoiai", "metanoias", "metanoið" };
+ for (int i = 0; i < termsToAdd.length; i++) {
+ Document doc = new Document();
+ doc.add(newField("repentance", termsToAdd[i], TextField.TYPE_UNSTORED));
+ writer.addDocument(doc);
+ }
+ IndexReader ir = writer.getReader();
+ String misspelled = "metanoix";
+ SuggestWord[] similar = spellchecker.suggestSimilar(new Term("repentance", misspelled), 4, ir, SuggestMode.SUGGEST_WHEN_NOT_IN_INDEX);
+ assertTrue(similar.length == 4);
+
+ StringDistance sd = spellchecker.getDistance();
+ assertTrue(sd instanceof LuceneLevenshteinDistance);
+ for(SuggestWord word : similar) {
+ assertTrue(word.score==sd.getDistance(word.string, misspelled));
+ assertTrue(word.score==sd.getDistance(misspelled, word.string));
+ }
+
+ ir.close();
+ writer.close();
+ dir.close();
+ }
public void testSimpleExamples() throws Exception {
DirectSpellChecker spellChecker = new DirectSpellChecker();
spellChecker.setMinQueryLength(0);
Modified: lucene/dev/branches/lucene2621/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/solr/CHANGES.txt?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/solr/CHANGES.txt (original)
+++ lucene/dev/branches/lucene2621/solr/CHANGES.txt Wed Nov 2 17:11:00 2011
@@ -56,6 +56,11 @@ Upgrading from Solr 3.5-dev
* FacetComponent no longer catches and embeds exceptions occurred during facet
processing, it throws HTTP 400 or 500 exceptions instead.
+
+* The VelocityResponseWriter is no longer built into the core. Its JAR and
+ dependencies now need to be added (via <lib> or solr/home lib inclusion),
+ and it needs to be registered in solrconfig.xml like this:
+ <queryResponseWriter name="velocity" class="solr.VelocityResponseWriter"/>
Detailed Change List
----------------------
@@ -257,6 +262,12 @@ Bug Fixes
* SOLR-2654: Directorys used by a SolrCore are now closed when they are no longer used.
(Mark Miller)
+* SOLR-2854: Now load URL content stream data (via stream.url) when called for during request handling,
+ rather than loading URL content streams automatically regardless of use.
+ (David Smiley and Ryan McKinley via ehatcher)
+
+
+
Other Changes
----------------------
@@ -334,6 +345,15 @@ Other Changes
* SOLR-2756: Maven configuration: Excluded transitive stax:stax-api dependency
from org.codehaus.woodstox:wstx-asl dependency. (David Smiley via Steve Rowe)
+* SOLR-2588: Moved VelocityResponseWriter back to contrib module in order to
+ remove it as a mandatory core dependency. (ehatcher)
+
+* SOLR-2718: Add ability to lazy load response writers, defined with startup="lazy".
+ (ehatcher)
+
+* SOLR-2862: More explicit lexical resources location logged if Carrot2 clustering
+ extension is used. Fixed solr. impl. of IResource and IResourceLookup. (Dawid Weiss)
+
Documentation
----------------------
@@ -360,6 +380,9 @@ New Features
* SOLR-2818: Added before/after count response parsing support for range facets in
SolrJ. (Bernhard Frauendienst via Martijn van Groningen)
+
+* SOLR-2276: Add support for cologne phonetic to PhoneticFilterFactory.
+ (Marc Pompl via rmuir)
Bug Fixes
----------------------
@@ -384,6 +407,10 @@ Bug Fixes
* SOLR-2791: Replication: abortfetch command is broken if replication was started
by fetchindex command instead of a regular poll (Yury Kats via shalin)
+* SOLR-2861: Fix extremely rare race condition on commit that can result
+ in a NPE (yonik)
+
+
Other Changes
----------------------
@@ -414,6 +441,11 @@ Bug Fixes
* SOLR-2792: Allow case insensitive Hunspell stemming (janhoy, rmuir)
+* SOLR-2862: More explicit lexical resources location logged if Carrot2 clustering
+ extension is used. Fixed solr. impl. of IResource and IResourceLookup. (Dawid Weiss)
+
+* SOLR-2849: Fix dependencies in Maven POMs. (David Smiley via Steve Rowe)
+
================== 3.4.0 ==================
Upgrading from Solr 3.3
Modified: lucene/dev/branches/lucene2621/solr/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/solr/common-build.xml?rev=1196701&r1=1196700&r2=1196701&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/solr/common-build.xml (original)
+++ lucene/dev/branches/lucene2621/solr/common-build.xml Wed Nov 2 17:11:00 2011
@@ -145,6 +145,8 @@
<arg value="-c" />
<arg value="${common-solr.dir}/contrib/uima/lib" />
<arg value="-c" />
+ <arg value="${common-solr.dir}/contrib/velocity/lib" />
+ <arg value="-c" />
<arg value="${common-solr.dir}/example/example-DIH/solr/db/lib" />
<arg value="-c" />
<arg value="${common-solr.dir}/example/example-DIH/solr/mail/lib" />