LUCENE-3969: Merged /lucene/dev/trunk:r1311219-1324765

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3969@1324945 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2012-04-11 19:41:06 +00:00
commit e8008068b2
77 changed files with 303 additions and 517 deletions

View File

@ -109,10 +109,10 @@
<classpathentry kind="lib" path="solr/lib/commons-lang-2.6.jar"/>
<classpathentry kind="lib" path="solr/lib/easymock-2.2.jar"/>
<classpathentry kind="lib" path="solr/lib/guava-r05.jar"/>
<classpathentry kind="lib" path="solr/lib/jcl-over-slf4j-1.6.1.jar"/>
<classpathentry kind="lib" path="solr/lib/log4j-over-slf4j-1.6.1.jar"/>
<classpathentry kind="lib" path="solr/lib/slf4j-api-1.6.1.jar"/>
<classpathentry kind="lib" path="solr/lib/slf4j-jdk14-1.6.1.jar"/>
<classpathentry kind="lib" path="solr/lib/jcl-over-slf4j-1.6.4.jar"/>
<classpathentry kind="lib" path="solr/lib/log4j-over-slf4j-1.6.4.jar"/>
<classpathentry kind="lib" path="solr/lib/slf4j-api-1.6.4.jar"/>
<classpathentry kind="lib" path="solr/lib/slf4j-jdk14-1.6.4.jar"/>
<classpathentry kind="lib" path="solr/lib/wstx-asl-3.2.7.jar"/>
<classpathentry kind="lib" path="solr/lib/zookeeper-3.3.4.jar"/>
<classpathentry kind="lib" path="solr/example/lib/jetty-continuation-8.1.2.v20120308.jar"/>

View File

@ -16,16 +16,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="file://$MODULE_DIR$/test-framework/lib" />
</CLASSES>
<JAVADOC />
<SOURCES />
<jarDirectory url="file://$MODULE_DIR$/test-framework/lib" recursive="false" />
</library>
</orderEntry>
<orderEntry type="library" scope="TEST" name="JUnit" level="project" />
</component>
</module>

View File

@ -11,6 +11,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="JUnit" level="project" />
<orderEntry type="library" name="Solr library" level="project" />
<orderEntry type="library" name="Solr DIH library" level="project" />
<orderEntry type="library" name="Solr extraction library" level="project" />

View File

@ -12,6 +12,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="JUnit" level="project" />
<orderEntry type="library" name="Solr library" level="project" />
<orderEntry type="library" name="Solr DIH library" level="project" />
<orderEntry type="module" module-name="solr" />

View File

@ -11,6 +11,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="JUnit" level="project" />
<orderEntry type="library" name="Solr library" level="project" />
<orderEntry type="library" name="Solr extraction library" level="project" />
<orderEntry type="module" module-name="solr" />

View File

@ -12,6 +12,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="JUnit" level="project" />
<orderEntry type="library" name="Solr library" level="project" />
<orderEntry type="library" name="Solr extraction library" level="project" />
<orderEntry type="module-library">

View File

@ -12,6 +12,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="JUnit" level="project" />
<orderEntry type="library" name="Solr library" level="project" />
<orderEntry type="module-library">
<library>

View File

@ -11,6 +11,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="JUnit" level="project" />
<orderEntry type="library" name="Solr library" level="project" />
<orderEntry type="library" name="Solr velocity library" level="project" />
<orderEntry type="module" module-name="solr" />

View File

@ -18,6 +18,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="JUnit" level="project" />
<orderEntry type="library" name="Solr library" level="project" />
<orderEntry type="library" name="Solr example library" level="project" />
<orderEntry type="module" module-name="kuromoji" />

View File

@ -43,8 +43,8 @@
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
<java.compat.version>1.6</java.compat.version>
<jetty.version>8.1.2.v20120308</jetty.version>
<slf4j.version>1.6.1</slf4j.version>
<tika.version>1.0</tika.version>
<slf4j.version>1.6.4</slf4j.version>
<tika.version>1.1</tika.version>
<httpcomponents.version>4.1.3</httpcomponents.version>
<tests.asserts.gracious>false</tests.asserts.gracious>

View File

@ -93,21 +93,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<directory>${build-directory}</directory>

View File

@ -72,21 +72,6 @@
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<directory>${build-directory}</directory>

View File

@ -63,6 +63,23 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<!-- If your tests don't use BaseDistributedSearchTestCase or SolrJettyTestBase,
you can exclude the three Jetty dependencies below. -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<directory>${build-directory}</directory>

32
dev-tools/scripts/crawl.maven.release.dist.sh Normal file → Executable file
View File

@ -1,7 +1,8 @@
#!/bin/sh
#
# Crawls all Maven release distribution artifacts at the given URL
# and downloads them to the current directory.
# Crawls all Maven release distribution artifacts at the given release RC URL
# and downloads them to ./lucene/ and ./solr/ after first creating these
# two directories in the current directory.
#
#
# Licensed to the Apache Software Foundation (ASF) under one or more
@ -21,9 +22,30 @@
#
if [ -z "$1" ] ; then
echo "Usage: $0 <RC-url-to-lucene-or-solr-maven-dist-dir>"
echo "Example: $0 'http://people.apache.org/~rmuir/staging_area/lucene-solr-3.6RC0-rev1309642/solr/maven/'"
echo "Usage: $0 <RC-URL>"
echo ""
echo "Example: $0 http://s.apache.org/lusolr36rc1"
exit 1;
fi
wget -r -np -l 0 -nH -erobots=off --cut-dirs=8 --reject="*.md5,*.sha1,maven-metadata.xml*,index.html*" "$1/"
# Resolve redirects, e.g. from URL shortening, e.g. http://s.apache.org/lusolr36rc1
RC_URL=`(echo "Location: $1" ; wget -l 1 --spider "$1" 2>&1) \
| perl -ne '$url=$1 if (/Location:\s*(\S+)/); END { print "$url" if ($url); }'`
if [ -d lucene ] ; then
echo "Please remove directory ./lucene/ before running this script."
exit 1;
elif [ -d solr ] ; then
echo "Please remove directory ./solr/ before running this script."
exit 1;
fi
mkdir lucene
cd lucene
wget -r -np -l 0 -nH -erobots=off --cut-dirs=8 \
--reject="*.md5,*.sha1,maven-metadata.xml*,index.html*" "${RC_URL}/lucene/maven/"
cd ..
mkdir solr
cd solr
wget -r -np -l 0 -nH -erobots=off --cut-dirs=8 \
--reject="*.md5,*.sha1,maven-metadata.xml*,index.html*" "${RC_URL}/solr/maven/"
cd ..

0
dev-tools/scripts/write.stage.maven.build.xml.pl Normal file → Executable file
View File

View File

@ -259,6 +259,9 @@ Changes in backwards compatibility policy
* LUCENE-2000: clone() now returns covariant types where possible. (ryan)
* LUCENE-3970: Rename Fields.getUniqueFieldCount -> .size() and
Terms.getUniqueTermCount -> .size(). (Iulius Curt via Mike McCandless)
Changes in Runtime Behavior
* LUCENE-2846: omitNorms now behaves like omitTermFrequencyAndPositions, if you

View File

@ -759,7 +759,7 @@ public class MemoryIndex {
}
@Override
public long getUniqueTermCount() {
public long size() {
return info.sortedTerms.length;
}
@ -785,7 +785,7 @@ public class MemoryIndex {
}
@Override
public int getUniqueFieldCount() {
public int size() {
return sortedFields.length;
}
}

View File

@ -202,7 +202,7 @@ public class BlockTermsReader extends FieldsProducer {
}
@Override
public int getUniqueFieldCount() {
public int size() {
return fields.size();
}
@ -261,7 +261,7 @@ public class BlockTermsReader extends FieldsProducer {
}
@Override
public long getUniqueTermCount() {
public long size() {
return numTerms;
}

View File

@ -216,7 +216,7 @@ public class BlockTreeTermsReader extends FieldsProducer {
}
@Override
public int getUniqueFieldCount() {
public int size() {
return fields.size();
}
@ -455,7 +455,7 @@ public class BlockTreeTermsReader extends FieldsProducer {
}
@Override
public long getUniqueTermCount() {
public long size() {
return numTerms;
}

View File

@ -166,17 +166,17 @@ public abstract class TermVectorsWriter implements Closeable {
/** Safe (but, slowish) default method to write every
* vector field in the document. This default
* implementation requires that the vectors implement
* both Fields.getUniqueFieldCount and
* Terms.getUniqueTermCount. */
* both Fields.size and
* Terms.size. */
protected final void addAllDocVectors(Fields vectors, FieldInfos fieldInfos) throws IOException {
if (vectors == null) {
startDocument(0);
return;
}
final int numFields = vectors.getUniqueFieldCount();
final int numFields = vectors.size();
if (numFields == -1) {
throw new IllegalStateException("vectors.getUniqueFieldCount() must be implemented (it returned -1)");
throw new IllegalStateException("vectors.size() must be implemented (it returned -1)");
}
startDocument(numFields);
@ -195,9 +195,9 @@ public abstract class TermVectorsWriter implements Closeable {
// FieldsEnum shouldn't lie...
continue;
}
final int numTerms = (int) terms.getUniqueTermCount();
final int numTerms = (int) terms.size();
if (numTerms == -1) {
throw new IllegalStateException("vector.getUniqueTermCount() must be implemented (it returned -1)");
throw new IllegalStateException("terms.size() must be implemented (it returned -1)");
}
final TermsEnum termsEnum = terms.iterator(null);

View File

@ -161,7 +161,7 @@ class Lucene3xFields extends FieldsProducer {
}
@Override
public int getUniqueFieldCount() {
public int size() {
return preTerms.size();
}
@ -246,7 +246,7 @@ class Lucene3xFields extends FieldsProducer {
}
@Override
public long getUniqueTermCount() throws IOException {
public long size() throws IOException {
return -1;
}

View File

@ -270,7 +270,7 @@ class Lucene3xTermVectorsReader extends TermVectorsReader {
}
@Override
public int getUniqueFieldCount() {
public int size() {
if (fieldNumbers == null) {
return 0;
} else {
@ -307,7 +307,7 @@ class Lucene3xTermVectorsReader extends TermVectorsReader {
}
@Override
public long getUniqueTermCount() {
public long size() {
return numTerms;
}
@ -660,7 +660,7 @@ class Lucene3xTermVectorsReader extends TermVectorsReader {
}
if (tvx != null) {
Fields fields = new TVFields(docID);
if (fields.getUniqueFieldCount() == 0) {
if (fields.size() == 0) {
// TODO: we can improve writer here, eg write 0 into
// tvx file, so we know on first read from tvx that
// this doc has no TVs

View File

@ -300,7 +300,7 @@ public class Lucene40TermVectorsReader extends TermVectorsReader {
}
@Override
public int getUniqueFieldCount() {
public int size() {
if (fieldNumbers == null) {
return 0;
} else {
@ -335,7 +335,7 @@ public class Lucene40TermVectorsReader extends TermVectorsReader {
}
@Override
public long getUniqueTermCount() {
public long size() {
return numTerms;
}
@ -674,7 +674,7 @@ public class Lucene40TermVectorsReader extends TermVectorsReader {
}
if (tvx != null) {
Fields fields = new TVFields(docID);
if (fields.getUniqueFieldCount() == 0) {
if (fields.size() == 0) {
// TODO: we can improve writer here, eg write 0 into
// tvx file, so we know on first read from tvx that
// this doc has no TVs

View File

@ -824,7 +824,7 @@ public class MemoryPostingsFormat extends PostingsFormat {
}
@Override
public long getUniqueTermCount() throws IOException {
public long size() throws IOException {
return termCount;
}
@ -888,7 +888,7 @@ public class MemoryPostingsFormat extends PostingsFormat {
}
@Override
public int getUniqueFieldCount() {
public int size() {
return fields.size();
}

View File

@ -248,7 +248,7 @@ public abstract class PerFieldPostingsFormat extends PostingsFormat {
}
@Override
public int getUniqueFieldCount() {
public int size() {
return fields.size();
}

View File

@ -596,7 +596,7 @@ class SimpleTextFieldsReader extends FieldsProducer {
}
@Override
public long getUniqueTermCount() {
public long size() {
return (long) termCount;
}
@ -641,7 +641,7 @@ class SimpleTextFieldsReader extends FieldsProducer {
}
@Override
public int getUniqueFieldCount() {
public int size() {
return -1;
}

View File

@ -257,7 +257,7 @@ public class SimpleTextTermVectorsReader extends TermVectorsReader {
}
@Override
public int getUniqueFieldCount() throws IOException {
public int size() throws IOException {
return fields.size();
}
}
@ -281,7 +281,7 @@ public class SimpleTextTermVectorsReader extends TermVectorsReader {
}
@Override
public long getUniqueTermCount() throws IOException {
public long size() throws IOException {
return terms.size();
}

View File

@ -1051,7 +1051,7 @@ public class CheckIndex {
long termCount = -1;
if (status.termCount-termCountStart > 0) {
termCount = fields.terms(field).getUniqueTermCount();
termCount = fields.terms(field).size();
if (termCount != -1 && termCount != status.termCount - termCountStart) {
throw new RuntimeException("termCount mismatch " + termCount + " vs " + (status.termCount - termCountStart));
@ -1104,7 +1104,7 @@ public class CheckIndex {
}
}
int fieldCount = fields.getUniqueFieldCount();
int fieldCount = fields.size();
if (fieldCount != -1) {
if (fieldCount < 0) {

View File

@ -36,7 +36,7 @@ public abstract class Fields {
* measure isn't stored by the codec. Note that, just like
* other term measures, this measure does not take deleted
* documents into account. */
public abstract int getUniqueFieldCount() throws IOException;
public abstract int size() throws IOException;
/** Returns the number of terms for all fields, or -1 if this
* measure isn't stored by the codec. Note that, just like
@ -53,7 +53,7 @@ public abstract class Fields {
}
Terms terms = terms(field);
if (terms != null) {
final long termCount = terms.getUniqueTermCount();
final long termCount = terms.size();
if (termCount == -1) {
return -1;
}

View File

@ -56,8 +56,8 @@ public class FilterAtomicReader extends AtomicReader {
}
@Override
public int getUniqueFieldCount() throws IOException {
return in.getUniqueFieldCount();
public int size() throws IOException {
return in.size();
}
@Override
@ -86,8 +86,8 @@ public class FilterAtomicReader extends AtomicReader {
}
@Override
public long getUniqueTermCount() throws IOException {
return in.getUniqueTermCount();
public long size() throws IOException {
return in.size();
}
@Override

View File

@ -228,7 +228,7 @@ public final class MultiFields extends Fields {
}
@Override
public int getUniqueFieldCount() {
public int size() {
return -1;
}

View File

@ -96,7 +96,7 @@ public final class MultiTerms extends Terms {
}
@Override
public long getUniqueTermCount() throws IOException {
public long size() throws IOException {
return -1;
}

View File

@ -197,7 +197,7 @@ public final class ParallelAtomicReader extends AtomicReader {
}
@Override
public int getUniqueFieldCount() throws IOException {
public int size() throws IOException {
return fields.size();
}
}

View File

@ -81,7 +81,7 @@ public abstract class Terms {
* measure isn't stored by the codec. Note that, just like
* other term measures, this measure does not take deleted
* documents into account. */
public abstract long getUniqueTermCount() throws IOException;
public abstract long size() throws IOException;
/** Returns the sum of {@link TermsEnum#totalTermFreq} for
* all terms in this field, or -1 if this measure isn't

View File

@ -1114,7 +1114,7 @@ class FieldCacheImpl implements FieldCache {
// is fine -- GrowableWriter will reallocate as needed
long numUniqueTerms = 0;
try {
numUniqueTerms = terms.getUniqueTermCount();
numUniqueTerms = terms.size();
} catch (UnsupportedOperationException uoe) {
numUniqueTerms = -1;
}
@ -1165,7 +1165,7 @@ class FieldCacheImpl implements FieldCache {
if (termOrd == termOrdToBytesOffset.size()) {
// NOTE: this code only runs if the incoming
// reader impl doesn't implement
// getUniqueTermCount (which should be uncommon)
// size (which should be uncommon)
termOrdToBytesOffset = termOrdToBytesOffset.resize(ArrayUtil.oversize(1+termOrd, 1));
}
termOrdToBytesOffset.set(termOrd, bytes.copyUsingLengthPrefix(term));
@ -1252,7 +1252,7 @@ class FieldCacheImpl implements FieldCache {
// is fine -- GrowableWriter will reallocate as needed
long numUniqueTerms = 0;
try {
numUniqueTerms = terms.getUniqueTermCount();
numUniqueTerms = terms.size();
} catch (UnsupportedOperationException uoe) {
numUniqueTerms = -1;
}

View File

@ -21,7 +21,6 @@ import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.lucene40.Lucene40PostingsFormat;
import org.apache.lucene.index.AtomicReader;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.DocsEnum;
@ -63,7 +62,7 @@ public class TestReuseDocsEnum extends LuceneTestCase {
enums.put(docs, true);
}
assertEquals(terms.getUniqueTermCount(), enums.size());
assertEquals(terms.size(), enums.size());
}
}.run();
IOUtils.close(writer, open, dir);
@ -100,7 +99,7 @@ public class TestReuseDocsEnum extends LuceneTestCase {
docs = iterator.docs(new Bits.MatchNoBits(open.maxDoc()), docs, random.nextBoolean());
enums.put(docs, true);
}
assertEquals(terms.getUniqueTermCount(), enums.size());
assertEquals(terms.size(), enums.size());
enums.clear();
iterator = terms.iterator(null);
@ -141,7 +140,7 @@ public class TestReuseDocsEnum extends LuceneTestCase {
docs = iterator.docs(null, randomDocsEnum("body", term, sequentialSubReaders2, bits), random.nextBoolean());
enums.put(docs, true);
}
assertEquals(terms.getUniqueTermCount(), enums.size());
assertEquals(terms.size(), enums.size());
iterator = terms.iterator(null);
enums.clear();
@ -150,7 +149,7 @@ public class TestReuseDocsEnum extends LuceneTestCase {
docs = iterator.docs(bits, randomDocsEnum("body", term, sequentialSubReaders2, bits), random.nextBoolean());
enums.put(docs, true);
}
assertEquals(terms.getUniqueTermCount(), enums.size());
assertEquals(terms.size(), enums.size());
}
IOUtils.close(writer, firstReader, secondReader, dir);
}

View File

@ -21,7 +21,6 @@ import java.io.StringReader;
import org.apache.lucene.analysis.EmptyTokenizer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.DocsAndPositionsEnum;
import org.apache.lucene.index.Fields;
@ -345,7 +344,7 @@ public class TestDocument extends LuceneTestCase {
Fields tvFields = r.getTermVectors(0);
Terms tvs = tvFields.terms(field);
assertNotNull(tvs);
assertEquals(2, tvs.getUniqueTermCount());
assertEquals(2, tvs.size());
TermsEnum tvsEnum = tvs.iterator(null);
assertEquals(new BytesRef("abc"), tvsEnum.next());
final DocsAndPositionsEnum dpEnum = tvsEnum.docsAndPositions(null, null, false);

View File

@ -290,11 +290,11 @@ public class TestDocumentWriter extends LuceneTestCase {
// f1
Terms tfv1 = reader.getTermVectors(0).terms("f1");
assertNotNull(tfv1);
assertEquals("the 'with_tv' setting should rule!",2,tfv1.getUniqueTermCount());
assertEquals("the 'with_tv' setting should rule!",2,tfv1.size());
// f2
Terms tfv2 = reader.getTermVectors(0).terms("f2");
assertNotNull(tfv2);
assertEquals("the 'with_tv' setting should rule!",2,tfv2.getUniqueTermCount());
assertEquals("the 'with_tv' setting should rule!",2,tfv2.size());
reader.close();
}

View File

@ -184,8 +184,8 @@ public class TestDuelingCodecs extends LuceneTestCase {
* checks that top-level statistics on Fields are the same
*/
public void assertFieldStatistics(Fields leftFields, Fields rightFields) throws Exception {
if (leftFields.getUniqueFieldCount() != -1 && rightFields.getUniqueFieldCount() != -1) {
assertEquals(info, leftFields.getUniqueFieldCount(), rightFields.getUniqueFieldCount());
if (leftFields.size() != -1 && rightFields.size() != -1) {
assertEquals(info, leftFields.size(), rightFields.size());
}
if (leftFields.getUniqueTermCount() != -1 && rightFields.getUniqueTermCount() != -1) {
@ -238,8 +238,8 @@ public class TestDuelingCodecs extends LuceneTestCase {
if (leftTerms.getSumTotalTermFreq() != -1 && rightTerms.getSumTotalTermFreq() != -1) {
assertEquals(info, leftTerms.getSumTotalTermFreq(), rightTerms.getSumTotalTermFreq());
}
if (leftTerms.getUniqueTermCount() != -1 && rightTerms.getUniqueTermCount() != -1) {
assertEquals(info, leftTerms.getUniqueTermCount(), rightTerms.getUniqueTermCount());
if (leftTerms.size() != -1 && rightTerms.size() != -1) {
assertEquals(info, leftTerms.size(), rightTerms.size());
}
}

View File

@ -19,10 +19,8 @@ package org.apache.lucene.index;
import java.io.IOException;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.TextField;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
@ -120,7 +118,7 @@ public class TestSegmentMerger extends LuceneTestCase {
Terms vector = mergedReader.getTermVectors(0).terms(DocHelper.TEXT_FIELD_2_KEY);
assertNotNull(vector);
assertEquals(3, vector.getUniqueTermCount());
assertEquals(3, vector.size());
TermsEnum termsEnum = vector.iterator(null);
int i = 0;

View File

@ -193,7 +193,7 @@ public class TestSegmentReader extends LuceneTestCase {
public void testTermVectors() throws IOException {
Terms result = reader.getTermVectors(0).terms(DocHelper.TEXT_FIELD_2_KEY);
assertNotNull(result);
assertEquals(3, result.getUniqueTermCount());
assertEquals(3, result.size());
TermsEnum termsEnum = result.iterator(null);
while(termsEnum.next() != null) {
String term = termsEnum.term().utf8ToString();
@ -204,6 +204,6 @@ public class TestSegmentReader extends LuceneTestCase {
Fields results = reader.getTermVectors(0);
assertTrue(results != null);
assertEquals("We do not have 3 term freq vectors", 3, results.getUniqueFieldCount());
assertEquals("We do not have 3 term freq vectors", 3, results.size());
}
}

View File

@ -600,7 +600,7 @@ public class TestStressIndexing2 extends LuceneTestCase {
public static void verifyEquals(Fields d1, Fields d2) throws IOException {
if (d1 == null) {
assertTrue(d2 == null || d2.getUniqueFieldCount() == 0);
assertTrue(d2 == null || d2.size() == 0);
return;
}
assertTrue(d2 != null);

View File

@ -204,7 +204,7 @@ public class TestTermVectorsReader extends LuceneTestCase {
for (int j = 0; j < 5; j++) {
Terms vector = reader.get(j).terms(testFields[0]);
assertNotNull(vector);
assertEquals(testTerms.length, vector.getUniqueTermCount());
assertEquals(testTerms.length, vector.size());
TermsEnum termsEnum = vector.iterator(null);
for (int i = 0; i < testTerms.length; i++) {
final BytesRef text = termsEnum.next();
@ -223,7 +223,7 @@ public class TestTermVectorsReader extends LuceneTestCase {
for (int j = 0; j < 5; j++) {
Terms vector = reader.get(j).terms(testFields[0]);
assertNotNull(vector);
assertEquals(testTerms.length, vector.getUniqueTermCount());
assertEquals(testTerms.length, vector.size());
TermsEnum termsEnum = vector.iterator(null);
DocsEnum docsEnum = null;
for (int i = 0; i < testTerms.length; i++) {
@ -250,7 +250,7 @@ public class TestTermVectorsReader extends LuceneTestCase {
BytesRef[] terms;
Terms vector = reader.get(0).terms(testFields[0]);
assertNotNull(vector);
assertEquals(testTerms.length, vector.getUniqueTermCount());
assertEquals(testTerms.length, vector.size());
TermsEnum termsEnum = vector.iterator(null);
DocsAndPositionsEnum dpEnum = null;
for (int i = 0; i < testTerms.length; i++) {
@ -287,7 +287,7 @@ public class TestTermVectorsReader extends LuceneTestCase {
Terms freqVector = reader.get(0).terms(testFields[1]); //no pos, no offset
assertNotNull(freqVector);
assertEquals(testTerms.length, freqVector.getUniqueTermCount());
assertEquals(testTerms.length, freqVector.size());
termsEnum = freqVector.iterator(null);
assertNotNull(termsEnum);
for (int i = 0; i < testTerms.length; i++) {
@ -306,7 +306,7 @@ public class TestTermVectorsReader extends LuceneTestCase {
assertNotNull(vector);
TermsEnum termsEnum = vector.iterator(null);
assertNotNull(termsEnum);
assertEquals(testTerms.length, vector.getUniqueTermCount());
assertEquals(testTerms.length, vector.size());
DocsAndPositionsEnum dpEnum = null;
for (int i = 0; i < testTerms.length; i++) {
final BytesRef text = termsEnum.next();

View File

@ -119,7 +119,7 @@ public final class FieldCacheRewriteMethod extends MultiTermQuery.RewriteMethod
}
@Override
public long getUniqueTermCount() throws IOException {
public long size() throws IOException {
return -1;
}
});

View File

@ -98,7 +98,7 @@ public class TestTermVectors extends LuceneTestCase {
for (int i = 0; i < hits.length; i++) {
Fields vectors = searcher.reader.getTermVectors(hits[i].doc);
assertNotNull(vectors);
assertEquals("doc=" + hits[i].doc + " tv=" + vectors, 1, vectors.getUniqueFieldCount());
assertEquals("doc=" + hits[i].doc + " tv=" + vectors, 1, vectors.size());
}
Terms vector;
vector = searcher.reader.getTermVectors(hits[0].doc).terms("noTV");
@ -121,13 +121,13 @@ public class TestTermVectors extends LuceneTestCase {
IndexReader reader = writer.getReader();
writer.close();
Fields v = reader.getTermVectors(0);
assertEquals(4, v.getUniqueFieldCount());
assertEquals(4, v.size());
String[] expectedFields = new String[]{"a", "b", "c", "x"};
int[] expectedPositions = new int[]{1, 2, 0};
FieldsEnum fieldsEnum = v.iterator();
for(int i=0;i<expectedFields.length;i++) {
assertEquals(expectedFields[i], fieldsEnum.next());
assertEquals(3, v.terms(expectedFields[i]).getUniqueTermCount());
assertEquals(3, v.terms(expectedFields[i]).size());
DocsAndPositionsEnum dpEnum = null;
Terms terms = fieldsEnum.terms();
@ -166,7 +166,7 @@ public class TestTermVectors extends LuceneTestCase {
for (int i = 0; i < hits.length; i++) {
Fields vectors = searcher.reader.getTermVectors(hits[i].doc);
assertNotNull(vectors);
assertEquals(1, vectors.getUniqueFieldCount());
assertEquals(1, vectors.size());
TermsEnum termsEnum = vectors.terms("field").iterator(null);
assertNotNull(termsEnum.next());
@ -205,7 +205,7 @@ public class TestTermVectors extends LuceneTestCase {
for (int i = 0; i < hits.length; i++) {
Fields vectors = searcher.reader.getTermVectors(hits[i].doc);
assertNotNull(vectors);
assertEquals(1, vectors.getUniqueFieldCount());
assertEquals(1, vectors.size());
}
}
@ -303,7 +303,7 @@ public class TestTermVectors extends LuceneTestCase {
Terms vector = knownSearcher.reader.getTermVectors(hits[1].doc).terms("field");
assertNotNull(vector);
//System.out.println("Vector: " + vector);
assertEquals(10, vector.getUniqueTermCount());
assertEquals(10, vector.size());
TermsEnum termsEnum = vector.iterator(null);
while(termsEnum.next() != null) {
String term = termsEnum.term().utf8ToString();
@ -371,7 +371,7 @@ public class TestTermVectors extends LuceneTestCase {
Fields vectors = searcher.reader.getTermVectors(hits[i].doc);
assertNotNull(vectors);
assertEquals(1, vectors.getUniqueFieldCount());
assertEquals(1, vectors.size());
}
reader.close();
}
@ -418,10 +418,10 @@ public class TestTermVectors extends LuceneTestCase {
Fields vectors = searcher.reader.getTermVectors(hits[0].doc);
assertNotNull(vectors);
assertEquals(1, vectors.getUniqueFieldCount());
assertEquals(1, vectors.size());
Terms vector = vectors.terms("field");
assertNotNull(vector);
assertEquals(1, vector.getUniqueTermCount());
assertEquals(1, vector.size());
TermsEnum termsEnum = vector.iterator(null);
assertNotNull(termsEnum.next());
assertEquals("one", termsEnum.term().utf8ToString());

View File

@ -109,7 +109,7 @@ public class RAMOnlyPostingsFormat extends PostingsFormat {
}
@Override
public int getUniqueFieldCount() {
public int size() {
return fieldToTerms.size();
}
@ -135,7 +135,7 @@ public class RAMOnlyPostingsFormat extends PostingsFormat {
}
@Override
public long getUniqueTermCount() {
public long size() {
return termToDocs.size();
}

View File

@ -130,7 +130,7 @@ public final class FieldFilterAtomicReader extends FilterAtomicReader {
}
@Override
public int getUniqueFieldCount() throws IOException {
public int size() throws IOException {
// TODO: add faster implementation!
int c = 0;
final FieldsEnum it = iterator();

View File

@ -30,7 +30,6 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DocsAndPositionsEnum;
import org.apache.lucene.index.DocsEnum;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Terms;
@ -106,7 +105,7 @@ public class TestTeeSinkTokenFilter extends BaseTokenStreamTestCase {
IndexReader r = IndexReader.open(dir);
Terms vector = r.getTermVectors(0).terms("field");
assertEquals(1, vector.getUniqueTermCount());
assertEquals(1, vector.size());
TermsEnum termsEnum = vector.iterator(null);
termsEnum.next();
assertEquals(2, termsEnum.totalTermFreq());

View File

@ -447,7 +447,11 @@ public class TestSynonymMapFilter extends BaseTokenStreamTestCase {
checkRandomData(random, analyzer, 1000*RANDOM_MULTIPLIER);
}
}
// NOTE: this is an invalid test... SynFilter today can't
// properly consume a graph... we can re-enable this once
// we fix that...
/*
// Adds MockGraphTokenFilter before SynFilter:
public void testRandom2GraphBefore() throws Exception {
final int numIters = atLeast(10);
@ -472,6 +476,7 @@ public class TestSynonymMapFilter extends BaseTokenStreamTestCase {
checkRandomData(random, analyzer, 1000*RANDOM_MULTIPLIER);
}
}
*/
// Adds MockGraphTokenFilter after SynFilter:
public void testRandom2GraphAfter() throws Exception {

View File

@ -752,7 +752,7 @@ public class TestPerfTasksLogic extends BenchmarkTestCase {
IndexReader reader = IndexReader.open(dir);
Fields tfv = reader.getTermVectors(0);
assertNotNull(tfv);
assertTrue(tfv.getUniqueFieldCount() > 0);
assertTrue(tfv.size() > 0);
reader.close();
}

View File

@ -482,6 +482,9 @@ Other Changes
* SOLR-3329: Dropped getSourceID() from SolrInfoMBean and using
getClass().getPackage().getSpecificationVersion() for Version. (ryan)
* SOLR-3302: Upgraded SLF4j to version 1.6.4 (hossman)
* SOLR-3322: Add more context to IndexReaderFactory.newReader (ab)
Documentation
----------------------

View File

@ -244,7 +244,14 @@ Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
Copyright 2004 Sun Microsystems, Inc. (Rome JAR)
Copyright 2002-2008 by John Cowan (TagSoup -- http://ccil.org/~cowan/XML/tagsoup/)
Copyright (C) 1999-2007 Shigeru Chiba. All Rights Reserved.
(Javassist, MPL licensed: http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/)
Copyright (C) 1994-2007 by the Xiph.org Foundation, http://www.xiph.org/ (OggVorbis)
Scannotation (C) Bill Burke
=========================================================================
== Language Detection Notices ==
=========================================================================

View File

@ -25,14 +25,14 @@
<dependency org="org.apache.httpcomponents" name="httpcore" rev="4.1.4" transitive="false"/>
<dependency org="org.apache.httpcomponents" name="httpclient" rev="4.1.3" transitive="false"/>
<dependency org="org.apache.httpcomponents" name="httpmime" rev="4.1.3" transitive="false"/>
<dependency org="org.slf4j" name="jcl-over-slf4j" rev="1.6.1" transitive="false"/>
<dependency org="org.slf4j" name="jcl-over-slf4j" rev="1.6.4" transitive="false"/>
<dependency org="commons-io" name="commons-io" rev="2.1" transitive="false"/>
<dependency org="commons-lang" name="commons-lang" rev="2.6" transitive="false"/>
<dependency org="com.google.guava" name="guava" rev="r05" transitive="false"/>
<dependency org="org.codehaus.woodstox" name="wstx-asl" rev="3.2.7" transitive="false"/>
<dependency org="org.easymock" name="easymock" rev="2.2" transitive="false"/>
<dependency org="org.slf4j" name="slf4j-api" rev="1.6.1" transitive="false"/>
<dependency org="org.slf4j" name="slf4j-jdk14" rev="1.6.1" transitive="false"/>
<dependency org="org.slf4j" name="slf4j-api" rev="1.6.4" transitive="false"/>
<dependency org="org.slf4j" name="slf4j-jdk14" rev="1.6.4" transitive="false"/>
<dependency org="com.spatial4j" name="spatial4j" rev="0.2" transitive="false"/>
<dependency org="javax.servlet" name="javax.servlet-api" rev="3.0.1" transitive="false"/>
<exclude org="*" ext="*" matcher="regexp" type="${ivy.exclude.types}"/>

View File

@ -58,9 +58,13 @@ public abstract class IndexReaderFactory implements NamedListInitializedPlugin {
* Creates a new IndexReader instance using the given Directory.
*
* @param indexDir indexDir index location
* @param core {@link SolrCore} instance where this reader will be used. NOTE:
* this SolrCore instance may not be fully configured yet, but basic things like
* {@link SolrCore#getCoreDescriptor()}, {@link SolrCore#getSchema()} and
* {@link SolrCore#getSolrConfig()} are valid.
* @return An IndexReader instance
* @throws IOException
*/
public abstract DirectoryReader newReader(Directory indexDir)
public abstract DirectoryReader newReader(Directory indexDir, SolrCore core)
throws IOException;
}

View File

@ -30,7 +30,7 @@ import org.apache.lucene.store.Directory;
public class StandardIndexReaderFactory extends IndexReaderFactory {
@Override
public DirectoryReader newReader(Directory indexDir) throws IOException {
public DirectoryReader newReader(Directory indexDir, SolrCore core) throws IOException {
return DirectoryReader.open(indexDir, termInfosIndexDivisor);
}
}

View File

@ -595,7 +595,7 @@ public class LukeRequestHandler extends RequestHandlerBase
if (freq > tiq.minFreq) {
UnicodeUtil.UTF8toUTF16(text, spare);
String t = spare.toString();
tiq.distinctTerms = new Long(terms.getUniqueTermCount()).intValue();
tiq.distinctTerms = new Long(terms.size()).intValue();
tiq.add(new TopTermQueue.TermInfo(new Term(field, t), termsEnum.docFreq()));
if (tiq.size() > numTerms) { // if tiq full

View File

@ -17,7 +17,6 @@
package org.apache.solr.handler.admin;
import org.apache.commons.io.IOUtils;
import org.apache.solr.cloud.ZkSolrResourceLoader;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
@ -38,7 +37,6 @@ import org.apache.zookeeper.KeeperException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.util.Date;
@ -88,11 +86,9 @@ public class ShowFileRequestHandler extends RequestHandlerBase
protected Set<String> hiddenFiles;
private static ShowFileRequestHandler instance;
public ShowFileRequestHandler()
{
super();
instance = this; // used so that getFileContents can access hiddenFiles
}
@Override
@ -281,30 +277,7 @@ public class ShowFileRequestHandler extends RequestHandlerBase
rsp.setHttpCaching(false);
}
/**
* This is a utility function that lets you get the contents of an admin file
*
* It is only used so that we can get rid of "/admin/get-file.jsp" and include
* "admin-extra.html" in "/admin/index.html" using jsp scriptlets
*/
public static String getFileContents(SolrCore core, String path )
{
if( instance != null && instance.hiddenFiles != null ) {
if( instance.hiddenFiles.contains( path ) ) {
return ""; // ignore it...
}
}
InputStream input = null;
try {
input = core.getResourceLoader().openResource(path);
return IOUtils.toString( input, "UTF-8" );
} catch( Exception ex ) {
} finally {
IOUtils.closeQuietly(input);
}
return "";
}
//////////////////////// SolrInfoMBeans methods //////////////////////
@Override

View File

@ -177,7 +177,7 @@ public class SolrInfoMBeanHandler extends RequestHandlerBase {
// Something in the category changed
// Now iterate the real beans
NamedList<NamedList<Object>> cat = new NamedList<NamedList<Object>>();
NamedList<NamedList<Object>> cat = new SimpleOrderedMap<NamedList<Object>>();
for(int j=0;j<ref_cat.size();j++) {
String name = ref_cat.getName(j);
NamedList<Object> ref_bean = ref_cat.get(name);
@ -205,7 +205,7 @@ public class SolrInfoMBeanHandler extends RequestHandlerBase {
}
public NamedList diffNamedList(NamedList ref, NamedList now) {
NamedList out = new NamedList();
NamedList out = new SimpleOrderedMap();
for(int i=0; i<ref.size(); i++) {
String name = ref.getName(i);
Object r = ref.getVal(i);

View File

@ -117,7 +117,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
public SolrIndexSearcher(SolrCore core, String path, IndexSchema schema, SolrIndexConfig config, String name, boolean enableCache, DirectoryFactory directoryFactory) throws IOException {
// we don't need to reserve the directory because we get it from the factory
this(core, schema,name, core.getIndexReaderFactory().newReader(directoryFactory.get(path, config.lockType)), true, enableCache, false, directoryFactory);
this(core, schema,name, core.getIndexReaderFactory().newReader(directoryFactory.get(path, config.lockType), core), true, enableCache, false, directoryFactory);
}
public SolrIndexSearcher(SolrCore core, IndexSchema schema, String name, DirectoryReader r, boolean closeReader, boolean enableCache, boolean reserveDirectory, DirectoryFactory directoryFactory) throws IOException {

View File

@ -1,316 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.solr.handler.admin.LogLevelHandler;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
/**
* Admin JDK Logger level report and selection servlet.
*
* @since solr 1.3
* @deprecated {@link LogLevelHandler} this servlet will be removed before solr 4.0
*/
public final class LogLevelSelection extends HttpServlet {
@Override
public void init() throws ServletException {
}
/**
* Processes an HTTP GET request and changes the logging level as
* specified.
*/
@Override
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Output page
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.write("<html><head>\n");
out.write("<title>Solr Admin: JDK Log Level Selector</title>\n");
out.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"solr-admin.css\" />");
out.write("</head><body>\n");
out.write("<a href=\".\"><img border=\"0\" align=\"right\" height=\"78\" width=\"142\" src=\"img/solr.png\" alt=\"Solr\"></a>");
out.write("<h1 style='margin-bottom:5px;'>JDK Log Level Selector</h1>");
out.write("<h2 style='color:#AA0000; margin-top:0px;'>This will be removed before Solr 4.0. See <a href='/#/logging'>logging</a></h1>");
out.write("<p>Below is the complete JDK Log hierarchy with " +
"intermediate logger/categories synthesized. " +
"The effective logging level is shown to the " +
"far right. If a logger has unset level, then " +
"the effective level is that of the nearest ancestor " +
"with a level setting. Note that this only shows " +
"JDK Log levels.</p>\n");
out.write("<form method='POST'>\n");
out.write("<input type='submit' name='submit' value='set' " +
"class='button'>\n");
out.write("<input type='submit' name='submit' value='cancel' " +
"class='button'>\n");
out.write("<br><br>\n");
out.write("<table cellspacing='2' cellpadding='2'>");
out.write("<tr bgcolor='#CCCCFF'>" +
"<th align=left>Logger/Category name<br>" +
"<th colspan=9>Level</th>" +
"</tr><tr bgcolor='#CCCCFF'>" +
"<td bgcolor='#AAAAAA'>" +
"(Dark rows don't yet exist.)</td>");
for (int j = 0; j < LEVELS.length; ++j) {
out.write("<th align=left>");
if (LEVELS[j] != null) out.write(LEVELS[j].toString());
else out.write("unset");
out.write("</th>");
}
out.write("<th align=left>Effective</th>\n");
out.write("</tr>\n");
Iterator iWrappers = buildWrappers().iterator();
while (iWrappers.hasNext()) {
LogWrapper wrapper = (LogWrapper) iWrappers.next();
out.write("<tr");
if (wrapper.logger == null) {
out.write(" bgcolor='#AAAAAA'");
}
//out.write( ( wrapper.logger != null ) ? "#DDDDDD" : "#AAAAAA" );
out.write("><td>");
if ("".equals(wrapper.name)) {
out.write("root");
} else {
out.write(wrapper.name);
}
out.write("</td>\n");
for (int j = 0; j < LEVELS.length; ++j) {
out.write("<td align=center>");
if (!wrapper.name.equals("root") ||
(LEVELS[j] != null)) {
out.write("<input type='radio' name='");
if ("".equals(wrapper.name)) {
out.write("root");
} else {
out.write(wrapper.name);
}
out.write("' value='");
if (LEVELS[j] != null) out.write(LEVELS[j].toString());
else out.write("unset");
out.write('\'');
if (LEVELS[j] == wrapper.level()) out.write(" checked");
out.write('>');
}
out.write("</td>\n");
}
out.write("<td align=center>");
if (wrapper.logger != null) {
out.write(getEffectiveLevel(wrapper.logger).toString());
}
out.write("</td></tr>\n");
}
out.write("</table>\n");
out.write("<br>\n");
out.write("<input type='submit' name='submit' value='set' " +
"class='button'>\n");
out.write("<input type='submit' name='submit' value='cancel' " +
"class='button'>\n");
out.write("</form>\n");
out.write("</body></html>\n");
}
@Override
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
if (request.getParameter("submit").equals("set")) {
Map paramMap = request.getParameterMap();
Iterator iParams = paramMap.entrySet().iterator();
while (iParams.hasNext()) {
Map.Entry p = (Map.Entry) iParams.next();
String name = (String) p.getKey();
String value = ((String[]) p.getValue())[0];
if (name.equals("submit")) continue;
Logger logger;
LogManager logManager = LogManager.getLogManager();
if ("root".equals(name)) {
logger = logManager.getLogger("");
} else logger = logManager.getLogger(name);
if ("unset".equals(value)) {
if ((logger != null) && (logger.getLevel() != null)) {
logger.setLevel(null);
log.info("Unset log level on '" + name + "'.");
}
} else {
Level level = Level.parse(value);
if (logger == null) logger = Logger.getLogger(name);
if (logger.getLevel() != level) {
logger.setLevel(level);
log.info("Set '" + name + "' to " +
level + " level.");
}
}
}
} else {
log.fine("Selection form cancelled");
}
// Redirect back to standard get page.
response.sendRedirect(request.getRequestURI());
}
private Collection buildWrappers() {
// Use tree to get sorted results
SortedSet<LogWrapper> roots = new TreeSet<LogWrapper>();
roots.add(LogWrapper.ROOT);
LogManager logManager = LogManager.getLogManager();
Enumeration<String> loggerNames = logManager.getLoggerNames();
while (loggerNames.hasMoreElements()) {
String name = loggerNames.nextElement();
Logger logger = Logger.getLogger(name);
LogWrapper wrapper = new LogWrapper(logger);
roots.remove(wrapper); // Make sure add occurs
roots.add(wrapper);
while (true) {
int dot = name.lastIndexOf(".");
if (dot < 0) break;
name = name.substring(0, dot);
roots.add(new LogWrapper(name)); // if not already
}
}
return roots;
}
private Level getEffectiveLevel(Logger logger) {
Level level = logger.getLevel();
if (level != null) {
return level;
}
for (Level l : LEVELS) {
if (l == null) {
// avoid NPE
continue;
}
if (logger.isLoggable(l)) {
// return first level loggable
return l;
}
}
return Level.OFF;
}
private static class LogWrapper
implements Comparable {
public static LogWrapper ROOT =
new LogWrapper(LogManager.getLogManager().getLogger(""));
public LogWrapper(Logger logger) {
this.logger = logger;
this.name = logger.getName();
}
public LogWrapper(String name) {
this.name = name;
}
public int compareTo(Object other) {
if (this.equals(other)) return 0;
if (this == ROOT) return -1;
if (other == ROOT) return 1;
return name.compareTo(((LogWrapper) other).name);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
LogWrapper other = (LogWrapper) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
public Level level() {
if (logger != null) return logger.getLevel();
return null;
}
public Logger logger = null;
public String name;
}
private static Level[] LEVELS = {
null, // aka unset
Level.FINEST,
Level.FINE,
Level.CONFIG,
Level.INFO,
Level.WARNING,
Level.SEVERE,
Level.OFF
// Level.ALL -- ignore. It is useless.
};
private Logger log = Logger.getLogger(getClass().getName());
}

View File

@ -0,0 +1,67 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.servlet;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* A Simple redirection servlet to help us deprecate old UI elements
*/
public class RedirectServlet extends HttpServlet{
static final String CONTEXT_KEY = "${context}";
String destination;
int code = HttpServletResponse.SC_MOVED_PERMANENTLY;
public void init(ServletConfig config) throws ServletException {
super.init(config);
destination = config.getInitParameter("destination");
if(destination==null) {
throw new ServletException("RedirectServlet missing destination configuration");
}
if( "false".equals(config.getInitParameter("permanent") )) {
code = HttpServletResponse.SC_MOVED_TEMPORARILY;
}
// Replace the context key
if(destination.startsWith(CONTEXT_KEY)) {
destination = config.getServletContext().getContextPath()
+destination.substring(CONTEXT_KEY.length());
}
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException,IOException {
res.setStatus(code);
res.setHeader("Location", destination);
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException,IOException {
doGet(req,res);
}
}

View File

@ -358,7 +358,9 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
// Thread.sleep(10000000000L);
}
protected void queryPartialResults(final List<String> upShards, List<SolrServer> upClients, Object... q) throws Exception {
protected void queryPartialResults(final List<String> upShards,
final List<SolrServer> upClients,
Object... q) throws Exception {
final ModifiableSolrParams params = new ModifiableSolrParams();
@ -385,8 +387,8 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
@Override
public void run() {
for (int j = 0; j < stress; j++) {
int which = r.nextInt(clients.size());
SolrServer client = clients.get(which);
int which = r.nextInt(upClients.size());
SolrServer client = upClients.get(which);
try {
QueryResponse rsp = client.query(new ModifiableSolrParams(params));
if (verifyStress) {

View File

@ -93,7 +93,7 @@ public class OverseerTest extends SolrTestCaseJ4 {
public void close(){
try {
deleteNode(ZkStateReader.LIVE_NODES_ZKNODE + "/" + "node1");
deleteNode(ZkStateReader.LIVE_NODES_ZKNODE + "/" + nodeName);
zkClient.close();
} catch (InterruptedException e) {
//e.printStackTrace();
@ -127,7 +127,7 @@ public class OverseerTest extends SolrTestCaseJ4 {
ZkStateReader.toJSON(coreStates.values().toArray(
new CoreState[coreStates.size()])), true);
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 30; i++) {
String shardId = getShardId(coreName);
if (shardId != null) {
try {
@ -154,9 +154,9 @@ public class OverseerTest extends SolrTestCaseJ4 {
collection);
if (slices != null) {
for (Slice slice : slices.values()) {
if (slice.getShards().containsKey(nodeName + "_" + coreName))
;
return slice.getName();
if (slice.getShards().containsKey(nodeName + "_" + coreName)) {
return slice.getName();
}
}
}
return null;

View File

@ -61,7 +61,7 @@ public class AlternateDirectoryTest extends SolrTestCaseJ4 {
static volatile boolean newReaderCalled = false;
@Override
public DirectoryReader newReader(Directory indexDir) throws IOException {
public DirectoryReader newReader(Directory indexDir, SolrCore core) throws IOException {
TestIndexReaderFactory.newReaderCalled = true;
return DirectoryReader.open(indexDir);
}

View File

@ -933,7 +933,7 @@
<!-- JSON Update Request Handler
http://wiki.apache.org/solr/UpdateJSON
-->
<requestHandler name="/update/json" class="solr.JsonUpdateRequestHandler" startup="lazy">
<requestHandler name="/update/json" class="solr.JsonUpdateRequestHandler">
<lst name="defaults">
<str name="wt">json</str>
<str name="indent">true</str>

View File

@ -3,7 +3,7 @@
<title>#param('title')</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="#{url_for_solr}/js/lib/jquery-1.4.3.min.js"></script>
<script type="text/javascript" src="#{url_for_solr}/js/lib/jquery-1.7.2.min.js"></script>
<link rel="stylesheet" type="text/css" href="#{url_for_solr}/admin/file?file=/velocity/main.css&contentType=text/css"/>
<link rel="stylesheet" href="#{url_for_solr}/admin/file?file=/velocity/jquery.autocomplete.css&contentType=text/css" type="text/css" />
<script type="text/javascript" src="#{url_for_solr}/admin/file?file=/velocity/jquery.autocomplete.js&contentType=text/javascript"></script>

View File

@ -1 +0,0 @@
99c61095a14dfc9e47a086068033c286bf236475

View File

@ -0,0 +1 @@
aad8e9df65ebb68e3ba6f269e3312707f7f1065f

View File

@ -1 +0,0 @@
2083595b098f183da3c0cabf2819eb083a510a9e

View File

@ -0,0 +1 @@
ddfe7c1606881837039903db7bee486c1336c15e

View File

@ -1 +0,0 @@
6f3b8a24bf970f17289b234284c94f43eb42f0e4

View File

@ -0,0 +1 @@
2396d74b12b905f780ed7966738bb78438e8371a

View File

@ -1 +0,0 @@
251899d8c17e29ed4c53d98c88e54241a14d9591

View File

@ -0,0 +1 @@
6b32bc7c42b2509525ce812cb49bf96e7bf64141

View File

@ -21,15 +21,15 @@
<dependencies>
<dependency org="org.apache.zookeeper" name="zookeeper" rev="3.3.4" transitive="false"/>
<dependency org="org.slf4j" name="log4j-over-slf4j" rev="1.6.1" transitive="false"/>
<dependency org="org.slf4j" name="log4j-over-slf4j" rev="1.6.4" transitive="false"/>
<dependency org="org.apache.httpcomponents" name="httpcore" rev="4.1.4" transitive="false"/>
<dependency org="org.apache.httpcomponents" name="httpclient" rev="4.1.3" transitive="false"/>
<dependency org="org.apache.httpcomponents" name="httpmime" rev="4.1.3" transitive="false"/>
<dependency org="commons-io" name="commons-io" rev="2.1" transitive="false"/>
<dependency org="org.slf4j" name="jcl-over-slf4j" rev="1.6.1" transitive="false"/>
<dependency org="org.slf4j" name="jcl-over-slf4j" rev="1.6.4" transitive="false"/>
<dependency org="org.codehaus.woodstox" name="wstx-asl" rev="3.2.7" transitive="false"/>
<dependency org="org.slf4j" name="slf4j-api" rev="1.6.1" transitive="false"/>
<dependency org="org.slf4j" name="slf4j-jdk14" rev="1.6.1" transitive="false"/>
<dependency org="org.slf4j" name="slf4j-api" rev="1.6.4" transitive="false"/>
<dependency org="org.slf4j" name="slf4j-jdk14" rev="1.6.4" transitive="false"/>
<exclude org="*" ext="*" matcher="regexp" type="${ivy.exclude.types}"/>
</dependencies>
</ivy-module>

View File

@ -83,11 +83,6 @@
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Logging</servlet-name>
<servlet-class>org.apache.solr.servlet.LogLevelSelection</servlet-class>
</servlet>
<servlet>
<servlet-name>Zookeeper</servlet-name>
<servlet-class>org.apache.solr.servlet.ZookeeperInfoServlet</servlet-class>
@ -97,13 +92,54 @@
<servlet-name>LoadAdminUI</servlet-name>
<servlet-class>org.apache.solr.servlet.LoadAdminUiServlet</servlet-class>
</servlet>
<!-- Will be removed before 4.0 release! -->
<!-- Remove in Solr 5.0 -->
<!-- This sends SC_MOVED_PERMANENTLY (301) for resources that changed in 4.0 -->
<servlet>
<servlet-name>RedirectOldAdminUI</servlet-name>
<servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class>
<init-param>
<param-name>destination</param-name>
<param-value>${context}/#/</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>RedirectOldZookeeper</servlet-name>
<servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class>
<init-param>
<param-name>destination</param-name>
<param-value>${context}/zookeeper</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>RedirectLogging</servlet-name>
<servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class>
<init-param>
<param-name>destination</param-name>
<param-value>${context}/#/~logging</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Logging</servlet-name>
<servlet-name>RedirectOldAdminUI</servlet-name>
<url-pattern>/admin/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RedirectOldAdminUI</servlet-name>
<url-pattern>/admin</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RedirectOldZookeeper</servlet-name>
<url-pattern>/zookeeper.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RedirectLogging</servlet-name>
<url-pattern>/logging</url-pattern>
</servlet-mapping>
<!-- Servlet Mapping -->
<servlet-mapping>
<servlet-name>Zookeeper</servlet-name>
<url-pattern>/zookeeper</url-pattern>
@ -113,7 +149,7 @@
<servlet-name>LoadAdminUI</servlet-name>
<url-pattern>/admin.html</url-pattern>
</servlet-mapping>
<mime-mapping>
<extension>.xsl</extension>
<!-- per http://www.w3.org/TR/2006/PR-xslt20-20061121/ -->