You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2011/09/29 23:49:50 UTC
svn commit: r1177441 [4/6] - in /lucene/dev/branches/solrcloud: ./
dev-tools/idea/lucene/contrib/ lucene/
lucene/contrib/demo/src/java/org/apache/lucene/demo/
lucene/contrib/demo/src/java/org/apache/lucene/demo/xmlparser/
lucene/contrib/highlighter/src...
Modified: lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/index/DocHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/index/DocHelper.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/index/DocHelper.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/index/DocHelper.java Thu Sep 29 21:49:45 2011
@@ -46,7 +46,7 @@ class DocHelper {
public static Field textField1;
static {
customType = new FieldType(TextField.TYPE_STORED);
- textField1 = new Field(TEXT_FIELD_1_KEY, customType, FIELD_1_TEXT);
+ textField1 = new Field(TEXT_FIELD_1_KEY, FIELD_1_TEXT, customType);
}
public static final FieldType customType2;
@@ -60,7 +60,7 @@ class DocHelper {
customType2.setStoreTermVectors(true);
customType2.setStoreTermVectorPositions(true);
customType2.setStoreTermVectorOffsets(true);
- textField2 = new Field(TEXT_FIELD_2_KEY, customType2, FIELD_2_TEXT);
+ textField2 = new Field(TEXT_FIELD_2_KEY, FIELD_2_TEXT, customType2);
}
public static final FieldType customType3;
@@ -71,14 +71,14 @@ class DocHelper {
static {
customType3 = new FieldType(TextField.TYPE_STORED);
customType3.setOmitNorms(true);
- textField3 = new Field(TEXT_FIELD_3_KEY, customType3, FIELD_3_TEXT);
+ textField3 = new Field(TEXT_FIELD_3_KEY, FIELD_3_TEXT, customType3);
}
public static final String KEYWORD_TEXT = "Keyword";
public static final String KEYWORD_FIELD_KEY = "keyField";
public static Field keyField;
static {
- keyField = new Field(KEYWORD_FIELD_KEY, StringField.TYPE_STORED, KEYWORD_TEXT);
+ keyField = new Field(KEYWORD_FIELD_KEY, KEYWORD_TEXT, StringField.TYPE_STORED);
}
public static final FieldType customType5;
@@ -89,7 +89,7 @@ class DocHelper {
customType5 = new FieldType(TextField.TYPE_STORED);
customType5.setOmitNorms(true);
customType5.setTokenized(false);
- noNormsField = new Field(NO_NORMS_KEY, customType5, NO_NORMS_TEXT);
+ noNormsField = new Field(NO_NORMS_KEY, NO_NORMS_TEXT, customType5);
}
public static final FieldType customType6;
@@ -99,7 +99,7 @@ class DocHelper {
static {
customType6 = new FieldType(TextField.TYPE_STORED);
customType6.setIndexOptions(IndexOptions.DOCS_ONLY);
- noTFField = new Field(NO_TF_KEY, customType6, NO_TF_TEXT);
+ noTFField = new Field(NO_TF_KEY, NO_TF_TEXT, customType6);
}
public static final FieldType customType7;
@@ -109,13 +109,13 @@ class DocHelper {
static {
customType7 = new FieldType();
customType7.setStored(true);
- unIndField = new Field(UNINDEXED_FIELD_KEY, customType7, UNINDEXED_FIELD_TEXT);
+ unIndField = new Field(UNINDEXED_FIELD_KEY, UNINDEXED_FIELD_TEXT, customType7);
}
public static final String UNSTORED_1_FIELD_TEXT = "unstored field text";
public static final String UNSTORED_FIELD_1_KEY = "unStoredField1";
- public static Field unStoredField1 = new Field(UNSTORED_FIELD_1_KEY, TextField.TYPE_UNSTORED, UNSTORED_1_FIELD_TEXT);
+ public static Field unStoredField1 = new Field(UNSTORED_FIELD_1_KEY, UNSTORED_1_FIELD_TEXT, TextField.TYPE_UNSTORED);
public static final FieldType customType8;
public static final String UNSTORED_2_FIELD_TEXT = "unstored field text";
@@ -124,7 +124,7 @@ class DocHelper {
static {
customType8 = new FieldType(TextField.TYPE_UNSTORED);
customType8.setStoreTermVectors(true);
- unStoredField2 = new Field(UNSTORED_FIELD_2_KEY, customType8, UNSTORED_2_FIELD_TEXT);
+ unStoredField2 = new Field(UNSTORED_FIELD_2_KEY, UNSTORED_2_FIELD_TEXT, customType8);
}
public static final String LAZY_FIELD_BINARY_KEY = "lazyFieldBinary";
@@ -133,7 +133,7 @@ class DocHelper {
public static final String LAZY_FIELD_KEY = "lazyField";
public static final String LAZY_FIELD_TEXT = "These are some field bytes";
- public static Field lazyField = new Field(LAZY_FIELD_KEY, customType, LAZY_FIELD_TEXT);
+ public static Field lazyField = new Field(LAZY_FIELD_KEY, LAZY_FIELD_TEXT, customType);
public static final String LARGE_LAZY_FIELD_KEY = "largeLazyField";
public static String LARGE_LAZY_FIELD_TEXT;
@@ -142,13 +142,13 @@ class DocHelper {
//From Issue 509
public static final String FIELD_UTF1_TEXT = "field one \u4e00text";
public static final String TEXT_FIELD_UTF1_KEY = "textField1Utf8";
- public static Field textUtfField1 = new Field(TEXT_FIELD_UTF1_KEY, customType, FIELD_UTF1_TEXT);
+ public static Field textUtfField1 = new Field(TEXT_FIELD_UTF1_KEY, FIELD_UTF1_TEXT, customType);
public static final String FIELD_UTF2_TEXT = "field field field \u4e00two text";
//Fields will be lexicographically sorted. So, the order is: field, text, two
public static final int [] FIELD_UTF2_FREQS = {3, 1, 1};
public static final String TEXT_FIELD_UTF2_KEY = "textField2Utf8";
- public static Field textUtfField2 = new Field(TEXT_FIELD_UTF2_KEY, customType2, FIELD_UTF2_TEXT);
+ public static Field textUtfField2 = new Field(TEXT_FIELD_UTF2_KEY, FIELD_UTF2_TEXT, customType2);
@@ -200,7 +200,7 @@ class DocHelper {
lazyFieldBinary = new BinaryField(LAZY_FIELD_BINARY_KEY, LAZY_FIELD_BINARY_BYTES);
fields[fields.length - 2] = lazyFieldBinary;
LARGE_LAZY_FIELD_TEXT = buffer.toString();
- largeLazyField = new Field(LARGE_LAZY_FIELD_KEY, customType, LARGE_LAZY_FIELD_TEXT);
+ largeLazyField = new Field(LARGE_LAZY_FIELD_KEY, LARGE_LAZY_FIELD_TEXT, customType);
fields[fields.length - 1] = largeLazyField;
for (int i=0; i<fields.length; i++) {
IndexableField f = fields[i];
@@ -304,15 +304,15 @@ class DocHelper {
customType1.setStoreTermVectorOffsets(true);
final Document doc = new Document();
- doc.add(new Field("id", customType1, Integer.toString(n)));
- doc.add(new Field("indexname", customType1, indexName));
+ doc.add(new Field("id", Integer.toString(n), customType1));
+ doc.add(new Field("indexname", indexName, customType1));
sb.append("a");
sb.append(n);
- doc.add(new Field("field1", customType, sb.toString()));
+ doc.add(new Field("field1", sb.toString(), customType));
sb.append(" b");
sb.append(n);
for (int i = 1; i < numFields; i++) {
- doc.add(new Field("field" + (i + 1), customType, sb.toString()));
+ doc.add(new Field("field" + (i + 1), sb.toString(), customType));
}
return doc;
}
Modified: lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java Thu Sep 29 21:49:45 2011
@@ -616,17 +616,22 @@ public abstract class ThreadedIndexingAn
assertEquals("index=" + writer.segString() + " addCount=" + addCount + " delCount=" + delCount, addCount.get() - delCount.get(), s.getIndexReader().numDocs());
releaseSearcher(s);
- if (es != null) {
- es.shutdown();
- es.awaitTermination(1, TimeUnit.SECONDS);
- }
-
writer.commit();
+
assertEquals("index=" + writer.segString() + " addCount=" + addCount + " delCount=" + delCount, addCount.get() - delCount.get(), writer.numDocs());
assertFalse(writer.anyNonBulkMerges);
doClose();
writer.close(false);
+
+ // Cannot shutdown until after writer is closed because
+ // writer has merged segment warmer that uses IS to run
+ // searches, and that IS may be using this es!
+ if (es != null) {
+ es.shutdown();
+ es.awaitTermination(1, TimeUnit.SECONDS);
+ }
+
_TestUtil.checkIndex(dir);
dir.close();
_TestUtil.rmDir(tempDir);
Modified: lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/util/LineFileDocs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/util/LineFileDocs.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/util/LineFileDocs.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/util/LineFileDocs.java Thu Sep 29 21:49:45 2011
@@ -128,16 +128,16 @@ public class LineFileDocs implements Clo
ft.setStoreTermVectorOffsets(true);
ft.setStoreTermVectorPositions(true);
- titleTokenized = new Field("titleTokenized", ft, "");
+ titleTokenized = new Field("titleTokenized", "", ft);
doc.add(titleTokenized);
- body = new Field("body", ft, "");
+ body = new Field("body", "", ft);
doc.add(body);
- id = new Field("docid", StringField.TYPE_STORED, "");
+ id = new Field("docid", "", StringField.TYPE_STORED);
doc.add(id);
- date = new Field("date", StringField.TYPE_STORED, "");
+ date = new Field("date", "", StringField.TYPE_STORED);
doc.add(date);
}
}
Modified: lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java Thu Sep 29 21:49:45 2011
@@ -1159,7 +1159,7 @@ public abstract class LuceneTestCase ext
public static Field newField(Random random, String name, String value, FieldType type) {
if (usually(random) || !type.indexed()) {
// most of the time, don't modify the params
- return new Field(name, type, value);
+ return new Field(name, value, type);
}
FieldType newType = new FieldType(type);
@@ -1186,7 +1186,7 @@ public abstract class LuceneTestCase ext
}
*/
- return new Field(name, newType, value);
+ return new Field(name, value, newType);
}
/** return a random Locale from the available locales on the system */
Modified: lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java Thu Sep 29 21:49:45 2011
@@ -513,10 +513,7 @@ public class _TestUtil {
for(IndexableField f : doc1) {
Field field1 = (Field) f;
- Field field2 = new Field(field1.name(),
- field1.fieldType(),
- field1.stringValue()
- );
+ Field field2 = new Field(field1.name(), field1.stringValue(), field1.fieldType());
doc2.add(field2);
}
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java Thu Sep 29 21:49:45 2011
@@ -101,7 +101,7 @@ public class TestMockAnalyzer extends Ba
String testString = "t";
Analyzer analyzer = new MockAnalyzer(random);
- TokenStream stream = analyzer.reusableTokenStream("dummy", new StringReader(testString));
+ TokenStream stream = analyzer.tokenStream("dummy", new StringReader(testString));
stream.reset();
while (stream.incrementToken()) {
// consume
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java Thu Sep 29 21:49:45 2011
@@ -38,7 +38,7 @@ public class TestBinaryDocument extends
FieldType ft = new FieldType();
ft.setStored(true);
IndexableField binaryFldStored = new BinaryField("binaryStored", binaryValStored.getBytes());
- IndexableField stringFldStored = new Field("stringStored", ft, binaryValStored);
+ IndexableField stringFldStored = new Field("stringStored", binaryValStored, ft);
Document doc = new Document();
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/document/TestDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/document/TestDocument.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/document/TestDocument.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/document/TestDocument.java Thu Sep 29 21:49:45 2011
@@ -42,7 +42,7 @@ public class TestDocument extends Lucene
FieldType ft = new FieldType();
ft.setStored(true);
- IndexableField stringFld = new Field("string", ft, binaryVal);
+ IndexableField stringFld = new Field("string", binaryVal, ft);
IndexableField binaryFld = new BinaryField("binary", binaryVal.getBytes());
IndexableField binaryFld2 = new BinaryField("binary", binaryVal2.getBytes());
@@ -121,20 +121,20 @@ public class TestDocument extends Lucene
public void testConstructorExceptions() {
FieldType ft = new FieldType();
ft.setStored(true);
- new Field("name", ft, "value"); // okay
+ new Field("name", "value", ft); // okay
new StringField("name", "value"); // okay
try {
- new Field("name", new FieldType(), "value");
+ new Field("name", "value", new FieldType());
fail();
} catch (IllegalArgumentException e) {
// expected exception
}
- new Field("name", ft, "value"); // okay
+ new Field("name", "value", ft); // okay
try {
FieldType ft2 = new FieldType();
ft2.setStored(true);
ft2.setStoreTermVectors(true);
- new Field("name", ft2, "value");
+ new Field("name", "value", ft2);
fail();
} catch (IllegalArgumentException e) {
// expected exception
@@ -178,17 +178,29 @@ public class TestDocument extends Lucene
reader.close();
dir.close();
}
+
+ public void testGetValues() {
+ Document doc = makeDocumentWithFields();
+ assertEquals(new String[] {"test1", "test2"},
+ doc.getValues("keyword"));
+ assertEquals(new String[] {"test1", "test2"},
+ doc.getValues("text"));
+ assertEquals(new String[] {"test1", "test2"},
+ doc.getValues("unindexed"));
+ assertEquals(new String[0],
+ doc.getValues("nope"));
+ }
private Document makeDocumentWithFields() {
Document doc = new Document();
FieldType stored = new FieldType();
stored.setStored(true);
- doc.add(new Field("keyword", StringField.TYPE_STORED, "test1"));
- doc.add(new Field("keyword", StringField.TYPE_STORED, "test2"));
- doc.add(new Field("text", TextField.TYPE_STORED, "test1"));
- doc.add(new Field("text", TextField.TYPE_STORED, "test2"));
- doc.add(new Field("unindexed", stored, "test1"));
- doc.add(new Field("unindexed", stored, "test2"));
+ doc.add(new Field("keyword", "test1", StringField.TYPE_STORED));
+ doc.add(new Field("keyword", "test2", StringField.TYPE_STORED));
+ doc.add(new Field("text", "test1", TextField.TYPE_STORED));
+ doc.add(new Field("text", "test2", TextField.TYPE_STORED));
+ doc.add(new Field("unindexed", "test1", stored));
+ doc.add(new Field("unindexed", "test2", stored));
doc
.add(new TextField("unstored", "test1"));
doc
@@ -227,10 +239,10 @@ public class TestDocument extends Lucene
public void testFieldSetValue() throws Exception {
- Field field = new Field("id", StringField.TYPE_STORED, "id1");
+ Field field = new Field("id", "id1", StringField.TYPE_STORED);
Document doc = new Document();
doc.add(field);
- doc.add(new Field("keyword", StringField.TYPE_STORED, "test"));
+ doc.add(new Field("keyword", "test", StringField.TYPE_STORED));
Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
@@ -266,7 +278,7 @@ public class TestDocument extends Lucene
public void testFieldSetValueChangeBinary() {
Field field1 = new BinaryField("field1", new byte[0]);
- Field field2 = new Field("field2", TextField.TYPE_STORED, "");
+ Field field2 = new Field("field2", "", TextField.TYPE_STORED);
try {
field1.setValue("abc");
fail("did not hit expected exception");
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/Test2BPostings.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/Test2BPostings.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/Test2BPostings.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/Test2BPostings.java Thu Sep 29 21:49:45 2011
@@ -66,7 +66,7 @@ public class Test2BPostings extends Luce
FieldType ft = new FieldType(TextField.TYPE_UNSTORED);
ft.setOmitNorms(true);
ft.setIndexOptions(IndexOptions.DOCS_ONLY);
- Field field = new Field("field", ft, new MyTokenStream());
+ Field field = new Field("field", new MyTokenStream(), ft);
doc.add(field);
final int numDocs = (Integer.MAX_VALUE / 26) + 1;
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/Test2BTerms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/Test2BTerms.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/Test2BTerms.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/Test2BTerms.java Thu Sep 29 21:49:45 2011
@@ -180,7 +180,7 @@ public class Test2BTerms extends LuceneT
FieldType customType = new FieldType(TextField.TYPE_STORED);
customType.setIndexOptions(IndexOptions.DOCS_ONLY);
customType.setOmitNorms(true);
- Field field = new Field("field", customType, ts);
+ Field field = new Field("field", ts, customType);
doc.add(field);
//w.setInfoStream(System.out);
final int numDocs = (int) (TERM_COUNT/TERMS_PER_DOC);
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java Thu Sep 29 21:49:45 2011
@@ -1059,7 +1059,7 @@ public class TestAddIndexes extends Luce
Document d = new Document();
FieldType customType = new FieldType(TextField.TYPE_STORED);
customType.setStoreTermVectors(true);
- d.add(new Field("c", customType, "v"));
+ d.add(new Field("c", "v", customType));
w.addDocument(d);
w.close();
}
@@ -1097,7 +1097,7 @@ public class TestAddIndexes extends Luce
new MockAnalyzer(random)).setMergePolicy(lmp2);
IndexWriter w2 = new IndexWriter(src, conf2);
Document doc = new Document();
- doc.add(new Field("c", TextField.TYPE_STORED, "some text"));
+ doc.add(new Field("c", "some text", TextField.TYPE_STORED));
w2.addDocument(doc);
doc = new Document();
doc.add(new StringField("d", "delete"));
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java Thu Sep 29 21:49:45 2011
@@ -95,7 +95,7 @@ public class TestAtomicUpdate extends Lu
// Update all 100 docs...
for(int i=0; i<100; i++) {
Document d = new Document();
- d.add(new Field("id", StringField.TYPE_STORED, Integer.toString(i)));
+ d.add(new Field("id", Integer.toString(i), StringField.TYPE_STORED));
d.add(new TextField("contents", English.intToEnglish(i+10*count)));
writer.updateDocument(new Term("id", Integer.toString(i)), d);
}
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java Thu Sep 29 21:49:45 2011
@@ -597,15 +597,15 @@ public class TestBackwardsCompatibility
{
Document doc = new Document();
doc.add(new TextField("content", "aaa"));
- doc.add(new Field("id", StringField.TYPE_STORED, Integer.toString(id)));
+ doc.add(new Field("id", Integer.toString(id), StringField.TYPE_STORED));
FieldType customType2 = new FieldType(TextField.TYPE_STORED);
customType2.setStoreTermVectors(true);
customType2.setStoreTermVectorPositions(true);
customType2.setStoreTermVectorOffsets(true);
- doc.add(new Field("autf8", customType2, "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd"));
- doc.add(new Field("utf8", customType2, "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd"));
- doc.add(new Field("content2", customType2, "here is more content with aaa aaa aaa"));
- doc.add(new Field("fie\u2C77ld", customType2, "field with non-ascii name"));
+ doc.add(new Field("autf8", "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", customType2));
+ doc.add(new Field("utf8", "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", customType2));
+ doc.add(new Field("content2", "here is more content with aaa aaa aaa", customType2));
+ doc.add(new Field("fie\u2C77ld", "field with non-ascii name", customType2));
// add numeric fields, to test if flex preserves encoding
doc.add(new NumericField("trieInt", 4).setIntValue(id));
doc.add(new NumericField("trieLong", 4).setLongValue(id));
@@ -616,12 +616,12 @@ public class TestBackwardsCompatibility
Document doc = new Document();
FieldType customType = new FieldType(TextField.TYPE_STORED);
customType.setIndexOptions(IndexOptions.DOCS_ONLY);
- Field f = new Field("content3", customType, "aaa");
+ Field f = new Field("content3", "aaa", customType);
doc.add(f);
FieldType customType2 = new FieldType();
customType2.setStored(true);
customType2.setIndexOptions(IndexOptions.DOCS_ONLY);
- f = new Field("content4", customType2, "aaa");
+ f = new Field("content4", "aaa", customType2);
doc.add(f);
writer.addDocument(doc);
}
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestBinaryTerms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestBinaryTerms.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestBinaryTerms.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestBinaryTerms.java Thu Sep 29 21:49:45 2011
@@ -51,7 +51,7 @@ public class TestBinaryTerms extends Luc
Document doc = new Document();
FieldType customType = new FieldType();
customType.setStored(true);
- doc.add(new Field("id", customType, "" + i));
+ doc.add(new Field("id", "" + i, customType));
doc.add(new TextField("bytes", tokenStream));
iw.addDocument(doc);
}
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java Thu Sep 29 21:49:45 2011
@@ -39,8 +39,8 @@ public class TestConsistentFieldNumbers
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(NoMergePolicy.COMPOUND_FILES));
Document d1 = new Document();
- d1.add(new Field("f1", StringField.TYPE_STORED, "first field"));
- d1.add(new Field("f2", StringField.TYPE_STORED, "second field"));
+ d1.add(new Field("f1", "first field", StringField.TYPE_STORED));
+ d1.add(new Field("f2", "second field", StringField.TYPE_STORED));
writer.addDocument(d1);
if (i == 1) {
@@ -54,7 +54,7 @@ public class TestConsistentFieldNumbers
FieldType customType2 = new FieldType(TextField.TYPE_STORED);
customType2.setStoreTermVectors(true);
d2.add(new TextField("f2", "second field"));
- d2.add(new Field("f1", customType2, "first field"));
+ d2.add(new Field("f1", "first field", customType2));
d2.add(new TextField("f3", "third field"));
d2.add(new TextField("f4", "fourth field"));
writer.addDocument(d2);
@@ -102,8 +102,8 @@ public class TestConsistentFieldNumbers
IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(NoMergePolicy.COMPOUND_FILES));
Document d1 = new Document();
- d1.add(new Field("f1", TextField.TYPE_STORED, "first field"));
- d1.add(new Field("f2", TextField.TYPE_STORED, "second field"));
+ d1.add(new Field("f1", "first field", TextField.TYPE_STORED));
+ d1.add(new Field("f2", "second field", TextField.TYPE_STORED));
writer.addDocument(d1);
writer.close();
@@ -112,10 +112,10 @@ public class TestConsistentFieldNumbers
Document d2 = new Document();
FieldType customType2 = new FieldType(TextField.TYPE_STORED);
customType2.setStoreTermVectors(true);
- d2.add(new Field("f2", TextField.TYPE_STORED, "second field"));
- d2.add(new Field("f1", customType2, "first field"));
- d2.add(new Field("f3", TextField.TYPE_STORED, "third field"));
- d2.add(new Field("f4", TextField.TYPE_STORED, "fourth field"));
+ d2.add(new Field("f2", "second field", TextField.TYPE_STORED));
+ d2.add(new Field("f1", "first field", customType2));
+ d2.add(new Field("f3", "third field", TextField.TYPE_STORED));
+ d2.add(new Field("f4", "fourth field", TextField.TYPE_STORED));
writer.addDocument(d2);
writer.close();
@@ -168,8 +168,8 @@ public class TestConsistentFieldNumbers
TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(
NoMergePolicy.NO_COMPOUND_FILES));
Document d = new Document();
- d.add(new Field("f1", TextField.TYPE_STORED, "d1 first field"));
- d.add(new Field("f2", TextField.TYPE_STORED, "d1 second field"));
+ d.add(new Field("f1", "d1 first field", TextField.TYPE_STORED));
+ d.add(new Field("f2", "d1 second field", TextField.TYPE_STORED));
writer.addDocument(d);
writer.close();
SegmentInfos sis = new SegmentInfos();
@@ -188,7 +188,7 @@ public class TestConsistentFieldNumbers
random.nextBoolean() ? NoMergePolicy.NO_COMPOUND_FILES
: NoMergePolicy.COMPOUND_FILES));
Document d = new Document();
- d.add(new Field("f1", TextField.TYPE_STORED, "d2 first field"));
+ d.add(new Field("f1", "d2 first field", TextField.TYPE_STORED));
d.add(new BinaryField("f3", new byte[] { 1, 2, 3 }));
writer.addDocument(d);
writer.close();
@@ -212,8 +212,8 @@ public class TestConsistentFieldNumbers
random.nextBoolean() ? NoMergePolicy.NO_COMPOUND_FILES
: NoMergePolicy.COMPOUND_FILES));
Document d = new Document();
- d.add(new Field("f1", TextField.TYPE_STORED, "d3 first field"));
- d.add(new Field("f2", TextField.TYPE_STORED, "d3 second field"));
+ d.add(new Field("f1", "d3 first field", TextField.TYPE_STORED));
+ d.add(new Field("f2", "d3 second field", TextField.TYPE_STORED));
d.add(new BinaryField("f3", new byte[] { 1, 2, 3, 4, 5 }));
writer.addDocument(d);
writer.close();
@@ -385,22 +385,22 @@ public class TestConsistentFieldNumbers
customType15.setStoreTermVectorPositions(true);
switch (mode) {
- case 0: return new Field(fieldName, customType, "some text");
+ case 0: return new Field(fieldName, "some text", customType);
case 1: return new TextField(fieldName, "some text");
- case 2: return new Field(fieldName, customType2, "some text");
- case 3: return new Field(fieldName, customType3, "some text");
- case 4: return new Field(fieldName, customType4, "some text");
- case 5: return new Field(fieldName, customType5, "some text");
- case 6: return new Field(fieldName, customType6, "some text");
- case 7: return new Field(fieldName, customType7, "some text");
- case 8: return new Field(fieldName, customType8, "some text");
- case 9: return new Field(fieldName, customType9, "some text");
- case 10: return new Field(fieldName, customType10, "some text");
- case 11: return new Field(fieldName, customType11, "some text");
- case 12: return new Field(fieldName, customType12, "some text");
- case 13: return new Field(fieldName, customType13, "some text");
- case 14: return new Field(fieldName, customType14, "some text");
- case 15: return new Field(fieldName, customType15, "some text");
+ case 2: return new Field(fieldName, "some text", customType2);
+ case 3: return new Field(fieldName, "some text", customType3);
+ case 4: return new Field(fieldName, "some text", customType4);
+ case 5: return new Field(fieldName, "some text", customType5);
+ case 6: return new Field(fieldName, "some text", customType6);
+ case 7: return new Field(fieldName, "some text", customType7);
+ case 8: return new Field(fieldName, "some text", customType8);
+ case 9: return new Field(fieldName, "some text", customType9);
+ case 10: return new Field(fieldName, "some text", customType10);
+ case 11: return new Field(fieldName, "some text", customType11);
+ case 12: return new Field(fieldName, "some text", customType12);
+ case 13: return new Field(fieldName, "some text", customType13);
+ case 14: return new Field(fieldName, "some text", customType14);
+ case 15: return new Field(fieldName, "some text", customType15);
default: return null;
}
}
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java Thu Sep 29 21:49:45 2011
@@ -23,6 +23,7 @@ import java.util.*;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.DocumentStoredFieldVisitor;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.NumericField;
@@ -303,8 +304,8 @@ public class TestFieldsReader extends Lu
Document doc = new Document();
FieldType onlyStored = new FieldType();
onlyStored.setStored(true);
- doc.add(new Field("field", onlyStored, "value"));
- doc.add(new Field("field2", StringField.TYPE_STORED, "value"));
+ doc.add(new Field("field", "value", onlyStored));
+ doc.add(new Field("field2", "value", StringField.TYPE_STORED));
w.addDocument(doc);
IndexReader r = w.getReader();
w.close();
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestGlobalFieldNumbers.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestGlobalFieldNumbers.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestGlobalFieldNumbers.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestGlobalFieldNumbers.java Thu Sep 29 21:49:45 2011
@@ -50,8 +50,8 @@ public class TestGlobalFieldNumbers exte
new MockAnalyzer(random));
IndexWriter writer = new IndexWriter(dir, config);
Document d = new Document();
- d.add(new Field("f1", TextField.TYPE_STORED, "d1 first field"));
- d.add(new Field("f2", TextField.TYPE_STORED, "d1 second field"));
+ d.add(new Field("f1", "d1 first field", TextField.TYPE_STORED));
+ d.add(new Field("f2", "d1 second field", TextField.TYPE_STORED));
writer.addDocument(d);
for (String string : writer.getIndexFileNames()) {
assertFalse(string.endsWith(".fnx"));
@@ -65,7 +65,7 @@ public class TestGlobalFieldNumbers exte
assertFNXFiles(dir, "1.fnx");
d = new Document();
- d.add(new Field("f1", TextField.TYPE_STORED, "d2 first field"));
+ d.add(new Field("f1", "d2 first field", TextField.TYPE_STORED));
d.add(new BinaryField("f3", new byte[] { 1, 2, 3 }));
writer.addDocument(d);
writer.commit();
@@ -83,8 +83,8 @@ public class TestGlobalFieldNumbers exte
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document d = new Document();
- d.add(new Field("f1", TextField.TYPE_STORED, "d3 first field"));
- d.add(new Field("f2", TextField.TYPE_STORED, "d3 second field"));
+ d.add(new Field("f1", "d3 first field", TextField.TYPE_STORED));
+ d.add(new Field("f2", "d3 second field", TextField.TYPE_STORED));
d.add(new BinaryField("f3", new byte[] { 1, 2, 3, 4, 5 }));
writer.addDocument(d);
writer.close();
@@ -117,13 +117,13 @@ public class TestGlobalFieldNumbers exte
new MockAnalyzer(random));
IndexWriter writer = new IndexWriter(dir, config);
Document d = new Document();
- d.add(new Field("f1", TextField.TYPE_STORED, "d1 first field"));
- d.add(new Field("f2", TextField.TYPE_STORED, "d1 second field"));
+ d.add(new Field("f1", "d1 first field", TextField.TYPE_STORED));
+ d.add(new Field("f2", "d1 second field", TextField.TYPE_STORED));
writer.addDocument(d);
writer.commit();
assertFNXFiles(dir, "1.fnx");
d = new Document();
- d.add(new Field("f1", TextField.TYPE_STORED, "d2 first field"));
+ d.add(new Field("f1", "d2 first field", TextField.TYPE_STORED));
d.add(new BinaryField("f3", new byte[] { 1, 2, 3 }));
writer.addDocument(d);
writer.commit();
@@ -158,13 +158,13 @@ public class TestGlobalFieldNumbers exte
TEST_VERSION_CURRENT, new MockAnalyzer(random)).setIndexDeletionPolicy(
new KeepAllDeletionPolicy()));
Document d = new Document();
- d.add(new Field("f1", TextField.TYPE_STORED, "d1 first field"));
- d.add(new Field("f2", TextField.TYPE_STORED, "d1 second field"));
+ d.add(new Field("f1", "d1 first field", TextField.TYPE_STORED));
+ d.add(new Field("f2", "d1 second field", TextField.TYPE_STORED));
writer.addDocument(d);
writer.commit();
assertFNXFiles(dir, "1.fnx");
d = new Document();
- d.add(new Field("f1", TextField.TYPE_STORED, "d2 first field"));
+ d.add(new Field("f1", "d2 first field", TextField.TYPE_STORED));
d.add(new BinaryField("f3", new byte[] { 1, 2, 3 }));
writer.addDocument(d);
writer.commit();
@@ -179,8 +179,8 @@ public class TestGlobalFieldNumbers exte
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document d = new Document();
- d.add(new Field("f1", TextField.TYPE_STORED, "d3 first field"));
- d.add(new Field("f2", TextField.TYPE_STORED, "d3 second field"));
+ d.add(new Field("f1", "d3 first field", TextField.TYPE_STORED));
+ d.add(new Field("f2", "d3 second field", TextField.TYPE_STORED));
d.add(new BinaryField("f3", new byte[] { 1, 2, 3, 4, 5 }));
writer.addDocument(d);
writer.close();
@@ -204,13 +204,13 @@ public class TestGlobalFieldNumbers exte
TEST_VERSION_CURRENT, new MockAnalyzer(random)).setIndexDeletionPolicy(
new KeepAllDeletionPolicy()));
Document d = new Document();
- d.add(new Field("f1", TextField.TYPE_STORED, "d1 first field"));
- d.add(new Field("f2", TextField.TYPE_STORED, "d1 second field"));
+ d.add(new Field("f1", "d1 first field", TextField.TYPE_STORED));
+ d.add(new Field("f2", "d1 second field", TextField.TYPE_STORED));
writer.addDocument(d);
writer.commit();
assertFNXFiles(dir, "1.fnx");
d = new Document();
- d.add(new Field("f1", TextField.TYPE_STORED, "d2 first field"));
+ d.add(new Field("f1", "d2 first field", TextField.TYPE_STORED));
d.add(new BinaryField("f3", new byte[] { 1, 2, 3 }));
writer.addDocument(d);
assertFNXFiles(dir, "1.fnx");
@@ -224,7 +224,7 @@ public class TestGlobalFieldNumbers exte
new KeepAllDeletionPolicy()).setIndexCommit(listCommits.get(0)));
d = new Document();
- d.add(new Field("f1", TextField.TYPE_STORED, "d2 first field"));
+ d.add(new Field("f1", "d2 first field", TextField.TYPE_STORED));
d.add(new BinaryField("f3", new byte[] { 1, 2, 3 }));
writer.addDocument(d);
writer.commit();
@@ -475,7 +475,7 @@ public class TestGlobalFieldNumbers exte
}
Document d = new Document();
- d.add(new Field("f1", TextField.TYPE_STORED, "d1 first field"));
+ d.add(new Field("f1", "d1 first field", TextField.TYPE_STORED));
writer.addDocument(d);
writer.prepareCommit();
// the fnx file should still be under control of the SIS
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexReader.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexReader.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexReader.java Thu Sep 29 21:49:45 2011
@@ -27,6 +27,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
+import java.util.Random;
import java.util.Set;
import java.util.SortedSet;
import org.junit.Assume;
@@ -151,9 +152,9 @@ public class TestIndexReader extends Luc
FieldType customType3 = new FieldType();
customType3.setStored(true);
- doc.add(new Field("keyword",StringField.TYPE_STORED,"test1"));
- doc.add(new Field("text",TextField.TYPE_STORED,"test1"));
- doc.add(new Field("unindexed",customType3,"test1"));
+ doc.add(new Field("keyword", "test1", StringField.TYPE_STORED));
+ doc.add(new Field("text", "test1", TextField.TYPE_STORED));
+ doc.add(new Field("unindexed", "test1", customType3));
doc.add(new TextField("unstored","test1"));
writer.addDocument(doc);
@@ -177,18 +178,18 @@ public class TestIndexReader extends Luc
int mergeFactor = ((LogMergePolicy) writer.getConfig().getMergePolicy()).getMergeFactor();
for (int i = 0; i < 5*mergeFactor; i++) {
doc = new Document();
- doc.add(new Field("keyword",StringField.TYPE_STORED,"test1"));
- doc.add(new Field("text",TextField.TYPE_STORED, "test1"));
- doc.add(new Field("unindexed",customType3,"test1"));
+ doc.add(new Field("keyword", "test1", StringField.TYPE_STORED));
+ doc.add(new Field("text", "test1", TextField.TYPE_STORED));
+ doc.add(new Field("unindexed", "test1", customType3));
doc.add(new TextField("unstored","test1"));
writer.addDocument(doc);
}
// new fields are in some different segments (we hope)
for (int i = 0; i < 5*mergeFactor; i++) {
doc = new Document();
- doc.add(new Field("keyword2",StringField.TYPE_STORED,"test1"));
- doc.add(new Field("text2",TextField.TYPE_STORED, "test1"));
- doc.add(new Field("unindexed2",customType3,"test1"));
+ doc.add(new Field("keyword2", "test1", StringField.TYPE_STORED));
+ doc.add(new Field("text2", "test1", TextField.TYPE_STORED));
+ doc.add(new Field("unindexed2", "test1", customType3));
doc.add(new TextField("unstored2","test1"));
writer.addDocument(doc);
}
@@ -209,11 +210,11 @@ public class TestIndexReader extends Luc
for (int i = 0; i < 5*mergeFactor; i++) {
doc = new Document();
- doc.add(new Field("tvnot",TextField.TYPE_STORED,"tvnot"));
- doc.add(new Field("termvector",customType5,"termvector"));
- doc.add(new Field("tvoffset",customType6,"tvoffset"));
- doc.add(new Field("tvposition",customType7,"tvposition"));
- doc.add(new Field("tvpositionoffset",customType8, "tvpositionoffset"));
+ doc.add(new Field("tvnot", "tvnot", TextField.TYPE_STORED));
+ doc.add(new Field("termvector", "termvector", customType5));
+ doc.add(new Field("tvoffset", "tvoffset", customType6));
+ doc.add(new Field("tvposition", "tvposition", customType7));
+ doc.add(new Field("tvpositionoffset", "tvpositionoffset", customType8));
writer.addDocument(doc);
}
@@ -302,11 +303,11 @@ public class TestIndexReader extends Luc
customType8.setStoreTermVectorPositions(true);
for (int i = 0; i < 5 * mergeFactor; i++) {
Document doc = new Document();
- doc.add(new Field("tvnot",TextField.TYPE_STORED,"one two two three three three"));
- doc.add(new Field("termvector",customType5,"one two two three three three"));
- doc.add(new Field("tvoffset",customType6,"one two two three three three"));
- doc.add(new Field("tvposition",customType7,"one two two three three three"));
- doc.add(new Field("tvpositionoffset",customType8, "one two two three three three"));
+ doc.add(new Field("tvnot", "one two two three three three", TextField.TYPE_STORED));
+ doc.add(new Field("termvector", "one two two three three three", customType5));
+ doc.add(new Field("tvoffset", "one two two three three three", customType6));
+ doc.add(new Field("tvposition", "one two two three three three", customType7));
+ doc.add(new Field("tvpositionoffset", "one two two three three three", customType8));
writer.addDocument(doc);
}
@@ -1403,4 +1404,70 @@ public class TestIndexReader extends Luc
r.close();
dir.close();
}
+
+ public void testTryIncRef() throws CorruptIndexException, LockObtainFailedException, IOException {
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));
+ writer.addDocument(new Document());
+ writer.commit();
+ IndexReader r = IndexReader.open(dir);
+ assertTrue(r.tryIncRef());
+ r.decRef();
+ r.close();
+ assertFalse(r.tryIncRef());
+ writer.close();
+ dir.close();
+ }
+
+ public void testStressTryIncRef() throws CorruptIndexException, LockObtainFailedException, IOException, InterruptedException {
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));
+ writer.addDocument(new Document());
+ writer.commit();
+ IndexReader r = IndexReader.open(dir);
+ int numThreads = atLeast(2);
+
+ IncThread[] threads = new IncThread[numThreads];
+ for (int i = 0; i < threads.length; i++) {
+ threads[i] = new IncThread(r, random);
+ threads[i].start();
+ }
+ Thread.sleep(100);
+
+ assertTrue(r.tryIncRef());
+ r.decRef();
+ r.close();
+
+ for (int i = 0; i < threads.length; i++) {
+ threads[i].join();
+ assertNull(threads[i].failed);
+ }
+ assertFalse(r.tryIncRef());
+ writer.close();
+ dir.close();
+ }
+
+ static class IncThread extends Thread {
+ final IndexReader toInc;
+ final Random random;
+ Throwable failed;
+
+ IncThread(IndexReader toInc, Random random) {
+ this.toInc = toInc;
+ this.random = random;
+ }
+
+ @Override
+ public void run() {
+ try {
+ while (toInc.tryIncRef()) {
+ assertFalse(toInc.hasDeletions());
+ toInc.decRef();
+ }
+ assertFalse(toInc.tryIncRef());
+ } catch (Throwable e) {
+ failed = e;
+ }
+ }
+ }
}
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java Thu Sep 29 21:49:45 2011
@@ -40,8 +40,6 @@ import org.apache.lucene.search.IndexSea
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.similarities.DefaultSimilarity;
-import org.apache.lucene.search.similarities.Similarity;
-import org.apache.lucene.search.similarities.SimilarityProvider;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BitVector;
@@ -969,13 +967,13 @@ public class TestIndexReaderReopen exten
customType2.setOmitNorms(true);
FieldType customType3 = new FieldType();
customType3.setStored(true);
- doc.add(new Field("field1", TextField.TYPE_STORED, sb.toString()));
- doc.add(new Field("fielda", customType2, sb.toString()));
- doc.add(new Field("fieldb", customType3, sb.toString()));
+ doc.add(new Field("field1", sb.toString(), TextField.TYPE_STORED));
+ doc.add(new Field("fielda", sb.toString(), customType2));
+ doc.add(new Field("fieldb", sb.toString(), customType3));
sb.append(" b");
sb.append(n);
for (int i = 1; i < numFields; i++) {
- doc.add(new Field("field" + (i+1), TextField.TYPE_STORED, sb.toString()));
+ doc.add(new Field("field" + (i+1), sb.toString(), TextField.TYPE_STORED));
}
return doc;
}
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java Thu Sep 29 21:49:45 2011
@@ -304,7 +304,7 @@ public class TestIndexWriter extends Luc
int lastFlushCount = -1;
for(int j=1;j<52;j++) {
Document doc = new Document();
- doc.add(new Field("field", storedTextType, "aaa" + j));
+ doc.add(new Field("field", "aaa" + j, storedTextType));
writer.addDocument(doc);
_TestUtil.syncConcurrentMerges(writer);
int flushCount = writer.getFlushCount();
@@ -358,7 +358,7 @@ public class TestIndexWriter extends Luc
for(int j=1;j<52;j++) {
Document doc = new Document();
- doc.add(new Field("field", storedTextType, "aaa" + j));
+ doc.add(new Field("field", "aaa" + j, storedTextType));
writer.addDocument(doc);
}
@@ -1236,7 +1236,7 @@ public class TestIndexWriter extends Luc
customType.setTokenized(true);
customType.setIndexed(true);
- Field f = new Field("binary", customType, b, 10, 17);
+ Field f = new Field("binary", b, 10, 17, customType);
f.setTokenStream(new MockTokenizer(new StringReader("doc1field1"), MockTokenizer.WHITESPACE, false));
FieldType customType2 = new FieldType(TextField.TYPE_STORED);
@@ -1685,10 +1685,10 @@ public class TestIndexWriter extends Luc
for (int i=0; i<2; i++) {
Document doc = new Document();
- doc.add(new Field("id", customType3, Integer.toString(i)+BIG));
- doc.add(new Field("str", customType2, Integer.toString(i)+BIG));
- doc.add(new Field("str2", storedTextType, Integer.toString(i)+BIG));
- doc.add(new Field("str3", customType, Integer.toString(i)+BIG));
+ doc.add(new Field("id", Integer.toString(i)+BIG, customType3));
+ doc.add(new Field("str", Integer.toString(i)+BIG, customType2));
+ doc.add(new Field("str2", Integer.toString(i)+BIG, storedTextType));
+ doc.add(new Field("str3", Integer.toString(i)+BIG, customType));
indexWriter.addDocument(doc);
}
@@ -1805,7 +1805,7 @@ public class TestIndexWriter extends Luc
doc = new Document();
FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
customType.setTokenized(false);
- Field contentField = new Field("content", customType, "");
+ Field contentField = new Field("content", "", customType);
doc.add(contentField);
w = new RandomIndexWriter(random, dir);
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java Thu Sep 29 21:49:45 2011
@@ -1264,7 +1264,7 @@ public class TestIndexWriterExceptions e
}
Document document = new Document();
- document.add(new Field("field", TextField.TYPE_STORED, "a field"));
+ document.add(new Field("field", "a field", TextField.TYPE_STORED));
w.addDocument(document);
for (int i = 0; i < numDocs; i++) {
@@ -1284,7 +1284,7 @@ public class TestIndexWriterExceptions e
}
}
document = new Document();
- document.add(new Field("field", TextField.TYPE_STORED, "a field"));
+ document.add(new Field("field", "a field", TextField.TYPE_STORED));
w.addDocument(document);
w.close();
IndexReader reader = IndexReader.open(dir);
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexableField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexableField.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexableField.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestIndexableField.java Thu Sep 29 21:49:45 2011
@@ -171,8 +171,8 @@ public class TestIndexableField extends
if (numeric()) {
return new NumericField(name()).setIntValue(counter).tokenStream(analyzer);
}
- return readerValue() != null ? analyzer.reusableTokenStream(name(), readerValue()) :
- analyzer.reusableTokenStream(name(), new StringReader(stringValue()));
+ return readerValue() != null ? analyzer.tokenStream(name(), readerValue()) :
+ analyzer.tokenStream(name(), new StringReader(stringValue()));
}
}
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestLongPostings.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestLongPostings.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestLongPostings.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestLongPostings.java Thu Sep 29 21:49:45 2011
@@ -47,7 +47,7 @@ public class TestLongPostings extends Lu
if (other != null && s.equals(other)) {
continue;
}
- final TokenStream ts = a.reusableTokenStream("foo", new StringReader(s));
+ final TokenStream ts = a.tokenStream("foo", new StringReader(s));
final TermToBytesRefAttribute termAtt = ts.getAttribute(TermToBytesRefAttribute.class);
final BytesRef termBytes = termAtt.getBytesRef();
ts.reset();
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestOmitNorms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestOmitNorms.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestOmitNorms.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestOmitNorms.java Thu Sep 29 21:49:45 2011
@@ -227,22 +227,22 @@ public class TestOmitNorms extends Lucen
public void testOmitNormsCombos() throws IOException {
// indexed with norms
FieldType customType = new FieldType(TextField.TYPE_STORED);
- Field norms = new Field("foo", customType, "a");
+ Field norms = new Field("foo", "a", customType);
// indexed without norms
FieldType customType1 = new FieldType(TextField.TYPE_STORED);
customType1.setOmitNorms(true);
- Field noNorms = new Field("foo", customType1, "a");
+ Field noNorms = new Field("foo", "a", customType1);
// not indexed, but stored
FieldType customType2 = new FieldType();
customType2.setStored(true);
- Field noIndex = new Field("foo", customType2, "a");
+ Field noIndex = new Field("foo", "a", customType2);
// not indexed but stored, omitNorms is set
FieldType customType3 = new FieldType();
customType3.setStored(true);
customType3.setOmitNorms(true);
- Field noNormsNoIndex = new Field("foo", customType3, "a");
+ Field noNormsNoIndex = new Field("foo", "a", customType3);
// not indexed nor stored (doesnt exist at all, we index a different field instead)
- Field emptyNorms = new Field("bar", customType, "a");
+ Field emptyNorms = new Field("bar", "a", customType);
assertNotNull(getNorms("foo", norms, norms));
assertNull(getNorms("foo", norms, noNorms));
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestPayloads.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestPayloads.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestPayloads.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestPayloads.java Thu Sep 29 21:49:45 2011
@@ -611,14 +611,14 @@ public class TestPayloads extends Lucene
RandomIndexWriter writer = new RandomIndexWriter(random, dir,
new MockAnalyzer(random, MockTokenizer.WHITESPACE, true));
Document doc = new Document();
- doc.add(new Field("hasMaybepayload", TextField.TYPE_STORED, "here we go"));
+ doc.add(new Field("hasMaybepayload", "here we go", TextField.TYPE_STORED));
writer.addDocument(doc);
writer.close();
writer = new RandomIndexWriter(random, dir,
new MockAnalyzer(random, MockTokenizer.WHITESPACE, true));
doc = new Document();
- doc.add(new Field("hasMaybepayload2", TextField.TYPE_STORED, "here we go"));
+ doc.add(new Field("hasMaybepayload2", "here we go", TextField.TYPE_STORED));
writer.addDocument(doc);
writer.addDocument(doc);
writer.optimize();
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestSameTokenSamePosition.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestSameTokenSamePosition.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestSameTokenSamePosition.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestSameTokenSamePosition.java Thu Sep 29 21:49:45 2011
@@ -41,7 +41,7 @@ public class TestSameTokenSamePosition e
Directory dir = newDirectory();
RandomIndexWriter riw = new RandomIndexWriter(random, dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new BugReproAnalyzer()));
Document doc = new Document();
- doc.add(new Field("eng", TextField.TYPE_STORED, "Six drunken" /*This shouldn't matter. */));
+ doc.add(new Field("eng", "Six drunken", TextField.TYPE_STORED /*This shouldn't matter. */));
riw.addDocument(doc);
riw.close();
dir.close();
@@ -54,7 +54,7 @@ public class TestSameTokenSamePosition e
Directory dir = newDirectory();
RandomIndexWriter riw = new RandomIndexWriter(random, dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new BugReproAnalyzer()));
Document doc = new Document();
- doc.add(new Field("eng", TextField.TYPE_STORED, "Six drunken" /*This shouldn't matter. */));
+ doc.add(new Field("eng", "Six drunken", TextField.TYPE_STORED /*This shouldn't matter. */));
for (int i = 0; i < 100; i++) {
riw.addDocument(doc);
}
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestSegmentInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestSegmentInfo.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestSegmentInfo.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestSegmentInfo.java Thu Sep 29 21:49:45 2011
@@ -32,7 +32,7 @@ public class TestSegmentInfo extends Luc
IndexWriter writer = new IndexWriter(dir, conf);
writer.setInfoStream(VERBOSE ? System.out : null);
Document doc = new Document();
- doc.add(new Field("a", TextField.TYPE_STORED, "value"));
+ doc.add(new Field("a", "value", TextField.TYPE_STORED));
writer.addDocument(doc);
writer.close();
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java Thu Sep 29 21:49:45 2011
@@ -117,7 +117,7 @@ public class TestTermVectorsReader exten
else {
customType.setStoreTermVectors(true);
}
- doc.add(new Field(testFields[i], customType, ""));
+ doc.add(new Field(testFields[i], "", customType));
}
//Create 5 documents for testing, they all have the same
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestTermVectorsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestTermVectorsWriter.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestTermVectorsWriter.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/TestTermVectorsWriter.java Thu Sep 29 21:49:45 2011
@@ -136,14 +136,14 @@ public class TestTermVectorsWriter exten
Analyzer analyzer = new MockAnalyzer(random);
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, analyzer));
Document doc = new Document();
- TokenStream stream = analyzer.reusableTokenStream("field", new StringReader("abcd "));
+ TokenStream stream = analyzer.tokenStream("field", new StringReader("abcd "));
stream.reset(); // TODO: wierd to reset before wrapping with CachingTokenFilter... correct?
stream = new CachingTokenFilter(stream);
FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
customType.setStoreTermVectors(true);
customType.setStoreTermVectorPositions(true);
customType.setStoreTermVectorOffsets(true);
- Field f = new Field("field", customType, stream);
+ Field f = new Field("field", stream, customType);
doc.add(f);
doc.add(f);
w.addDocument(doc);
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/values/TestDocValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/values/TestDocValues.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/values/TestDocValues.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/values/TestDocValues.java Thu Sep 29 21:49:45 2011
@@ -188,7 +188,7 @@ public class TestDocValues extends Lucen
w.add(1, minMax[i][1]);
w.finish(2);
assertEquals(0, trackBytes.get());
- IndexDocValues r = Ints.getValues(dir, "test", 2, newIOContext(random));
+ IndexDocValues r = Ints.getValues(dir, "test", 2, ValueType.VAR_INTS, newIOContext(random));
Source source = getSource(r);
assertEquals(i + " with min: " + minMax[i][0] + " max: " + minMax[i][1],
expectedTypes[i], source.type());
@@ -229,7 +229,7 @@ public class TestDocValues extends Lucen
w.add(i, (long) sourceArray[i]);
}
w.finish(sourceArray.length);
- IndexDocValues r = Ints.getValues(dir, "test", sourceArray.length, newIOContext(random));
+ IndexDocValues r = Ints.getValues(dir, "test", sourceArray.length, ValueType.FIXED_INTS_8, newIOContext(random));
Source source = r.getSource();
assertTrue(source.hasArray());
byte[] loaded = ((byte[])source.getArray());
@@ -250,7 +250,7 @@ public class TestDocValues extends Lucen
w.add(i, (long) sourceArray[i]);
}
w.finish(sourceArray.length);
- IndexDocValues r = Ints.getValues(dir, "test", sourceArray.length, newIOContext(random));
+ IndexDocValues r = Ints.getValues(dir, "test", sourceArray.length, ValueType.FIXED_INTS_16, newIOContext(random));
Source source = r.getSource();
assertTrue(source.hasArray());
short[] loaded = ((short[])source.getArray());
@@ -271,7 +271,7 @@ public class TestDocValues extends Lucen
w.add(i, sourceArray[i]);
}
w.finish(sourceArray.length);
- IndexDocValues r = Ints.getValues(dir, "test", sourceArray.length, newIOContext(random));
+ IndexDocValues r = Ints.getValues(dir, "test", sourceArray.length, ValueType.FIXED_INTS_64, newIOContext(random));
Source source = r.getSource();
assertTrue(source.hasArray());
long[] loaded = ((long[])source.getArray());
@@ -292,7 +292,7 @@ public class TestDocValues extends Lucen
w.add(i, (long) sourceArray[i]);
}
w.finish(sourceArray.length);
- IndexDocValues r = Ints.getValues(dir, "test", sourceArray.length, newIOContext(random));
+ IndexDocValues r = Ints.getValues(dir, "test", sourceArray.length, ValueType.FIXED_INTS_32, newIOContext(random));
Source source = r.getSource();
assertTrue(source.hasArray());
int[] loaded = ((int[])source.getArray());
@@ -363,7 +363,7 @@ public class TestDocValues extends Lucen
w.finish(NUM_VALUES + additionalDocs);
assertEquals(0, trackBytes.get());
- IndexDocValues r = Ints.getValues(dir, "test", NUM_VALUES + additionalDocs, newIOContext(random));
+ IndexDocValues r = Ints.getValues(dir, "test", NUM_VALUES + additionalDocs, type, newIOContext(random));
for (int iter = 0; iter < 2; iter++) {
Source s = getSource(r);
assertEquals(type, s.type());
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/index/values/TestDocValuesIndexing.java Thu Sep 29 21:49:45 2011
@@ -25,9 +25,9 @@ import java.util.EnumSet;
import java.util.List;
import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.document.IndexDocValuesField;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.IndexDocValuesField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.CorruptIndexException;
@@ -37,6 +37,7 @@ import org.apache.lucene.index.IndexWrit
import org.apache.lucene.index.LogDocMergePolicy;
import org.apache.lucene.index.LogMergePolicy;
import org.apache.lucene.index.MultiPerDocValues;
+import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.codecs.CodecProvider;
import org.apache.lucene.index.codecs.PerDocValues;
@@ -45,10 +46,10 @@ import org.apache.lucene.search.*;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.FixedBitSet;
import org.apache.lucene.util.FloatsRef;
import org.apache.lucene.util.LongsRef;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.FixedBitSet;
import org.apache.lucene.util._TestUtil;
import org.junit.Before;
@@ -535,7 +536,7 @@ public class TestDocValuesIndexing exten
}
}
doc.removeFields("id");
- doc.add(new Field("id", StringField.TYPE_STORED, idBase + i));
+ doc.add(new Field("id", idBase + i, StringField.TYPE_STORED));
w.addDocument(doc);
if (i % 7 == 0) {
@@ -562,4 +563,64 @@ public class TestDocValuesIndexing exten
}
return deleted;
}
+
+ public void testMultiValuedIndexDocValuesField() throws Exception {
+ assumeFalse("cannot work with preflex codec", CodecProvider.getDefault().getDefaultFieldCodec().equals("PreFlex"));
+ Directory d = newDirectory();
+ RandomIndexWriter w = new RandomIndexWriter(random, d);
+ Document doc = new Document();
+ IndexDocValuesField f = new IndexDocValuesField("field");
+ f.setInt(17);
+ // Index doc values are single-valued so we should not
+ // be able to add same field more than once:
+ doc.add(f);
+ doc.add(f);
+ try {
+ w.addDocument(doc);
+ fail("didn't hit expected exception");
+ } catch (IllegalArgumentException iae) {
+ // expected
+ }
+
+ doc = new Document();
+ doc.add(f);
+ w.addDocument(doc);
+ w.optimize();
+ IndexReader r = w.getReader();
+ w.close();
+ assertEquals(17, r.getSequentialSubReaders()[0].perDocValues().docValues("field").load().getInt(0));
+ r.close();
+ d.close();
+ }
+
+ public void testDifferentTypedDocValuesField() throws Exception {
+ assumeFalse("cannot work with preflex codec", CodecProvider.getDefault().getDefaultFieldCodec().equals("PreFlex"));
+ Directory d = newDirectory();
+ RandomIndexWriter w = new RandomIndexWriter(random, d);
+ Document doc = new Document();
+ IndexDocValuesField f = new IndexDocValuesField("field");
+ f.setInt(17);
+ // Index doc values are single-valued so we should not
+ // be able to add same field more than once:
+ doc.add(f);
+ IndexDocValuesField f2 = new IndexDocValuesField("field");
+ f2.setFloat(22.0);
+ doc.add(f2);
+ try {
+ w.addDocument(doc);
+ fail("didn't hit expected exception");
+ } catch (IllegalArgumentException iae) {
+ // expected
+ }
+
+ doc = new Document();
+ doc.add(f);
+ w.addDocument(doc);
+ w.optimize();
+ IndexReader r = w.getReader();
+ w.close();
+ assertEquals(17, r.getSequentialSubReaders()[0].perDocValues().docValues("field").load().getInt(0));
+ r.close();
+ d.close();
+ }
}
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java Thu Sep 29 21:49:45 2011
@@ -636,7 +636,7 @@ public class TestPhraseQuery extends Luc
break;
}
}
- TokenStream ts = analyzer.reusableTokenStream("ignore", new StringReader(term));
+ TokenStream ts = analyzer.tokenStream("ignore", new StringReader(term));
CharTermAttribute termAttr = ts.addAttribute(CharTermAttribute.class);
ts.reset();
while(ts.incrementToken()) {
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java Thu Sep 29 21:49:45 2011
@@ -16,14 +16,19 @@ package org.apache.lucene.search;
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import java.util.HashSet;
+import java.util.Set;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.English;
import org.apache.lucene.util.LuceneTestCase;
public class TestQueryWrapperFilter extends LuceneTestCase {
@@ -80,4 +85,71 @@ public class TestQueryWrapperFilter exte
reader.close();
dir.close();
}
+
+ public void testRandom() throws Exception {
+ final Directory d = newDirectory();
+ final RandomIndexWriter w = new RandomIndexWriter(random, d);
+ w.w.getConfig().setMaxBufferedDocs(17);
+ final int numDocs = atLeast(100);
+ final Set<String> aDocs = new HashSet<String>();
+ for(int i=0;i<numDocs;i++) {
+ final Document doc = new Document();
+ final String v;
+ if (random.nextInt(5) == 4) {
+ v = "a";
+ aDocs.add(""+i);
+ } else {
+ v = "b";
+ }
+ final Field f = newField("field", v, StringField.TYPE_UNSTORED);
+ doc.add(f);
+ doc.add(newField("id", ""+i, StringField.TYPE_STORED));
+ w.addDocument(doc);
+ }
+
+ final int numDelDocs = atLeast(10);
+ for(int i=0;i<numDelDocs;i++) {
+ final String delID = ""+random.nextInt(numDocs);
+ w.deleteDocuments(new Term("id", delID));
+ aDocs.remove(delID);
+ }
+
+ final IndexReader r = w.getReader();
+ w.close();
+ final TopDocs hits = new IndexSearcher(r).search(new MatchAllDocsQuery(),
+ new QueryWrapperFilter(new TermQuery(new Term("field", "a"))),
+ numDocs);
+ assertEquals(aDocs.size(), hits.totalHits);
+ for(ScoreDoc sd: hits.scoreDocs) {
+ assertTrue(aDocs.contains(r.document(sd.doc).get("id")));
+ }
+ r.close();
+ d.close();
+ }
+
+ public void testThousandDocuments() throws Exception {
+ Directory dir = newDirectory();
+ RandomIndexWriter writer = new RandomIndexWriter(random, dir);
+ for (int i = 0; i < 1000; i++) {
+ Document doc = new Document();
+ doc.add(newField("field", English.intToEnglish(i), StringField.TYPE_UNSTORED));
+ writer.addDocument(doc);
+ }
+
+ IndexReader reader = writer.getReader();
+ writer.close();
+
+ IndexSearcher searcher = newSearcher(reader);
+
+ for (int i = 0; i < 1000; i++) {
+ TermQuery termQuery = new TermQuery(new Term("field", English.intToEnglish(i)));
+ QueryWrapperFilter qwf = new QueryWrapperFilter(termQuery);
+ TopDocs td = searcher.search(new MatchAllDocsQuery(), qwf, 10);
+ assertEquals(1, td.totalHits);
+ }
+
+ searcher.close();
+ reader.close();
+ dir.close();
+ }
}
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestSearchAfter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestSearchAfter.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestSearchAfter.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestSearchAfter.java Thu Sep 29 21:49:45 2011
@@ -18,7 +18,7 @@ package org.apache.lucene.search;
*/
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.StringField;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
@@ -43,8 +43,8 @@ public class TestSearchAfter extends Luc
int numDocs = atLeast(200);
for (int i = 0; i < numDocs; i++) {
Document document = new Document();
- document.add(newField("english", English.intToEnglish(i), StringField.TYPE_UNSTORED));
- document.add(newField("oddeven", (i % 2 == 0) ? "even" : "odd", StringField.TYPE_UNSTORED));
+ document.add(newField("english", English.intToEnglish(i), TextField.TYPE_UNSTORED));
+ document.add(newField("oddeven", (i % 2 == 0) ? "even" : "odd", TextField.TYPE_UNSTORED));
iw.addDocument(document);
}
reader = iw.getReader();
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java Thu Sep 29 21:49:45 2011
@@ -162,7 +162,7 @@ public class TestSloppyPhraseQuery exten
Document doc = new Document();
FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
customType.setOmitNorms(true);
- Field f = new Field("f", customType, docText);
+ Field f = new Field("f", docText, customType);
doc.add(f);
return doc;
}
@@ -237,7 +237,7 @@ public class TestSloppyPhraseQuery exten
RandomIndexWriter iw = new RandomIndexWriter(random, dir);
FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
customType.setOmitNorms(true);
- Field f = new Field("lyrics", customType, "");
+ Field f = new Field("lyrics", "", customType);
Document doc = new Document();
doc.add(f);
f.setValue("drug drug");
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestSort.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestSort.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestSort.java Thu Sep 29 21:49:45 2011
@@ -132,7 +132,7 @@ public class TestSort extends LuceneTest
for (int i=0; i<data.length; ++i) {
if (((i%2)==0 && even) || ((i%2)==1 && odd)) {
Document doc = new Document();
- doc.add (new Field ("tracer", ft1, data[i][0]));
+ doc.add (new Field ("tracer", data[i][0], ft1));
doc.add (new TextField ("contents", data[i][1]));
if (data[i][2] != null) {
Field f = new StringField ("int", data[i][2]);
@@ -196,12 +196,12 @@ public class TestSort extends LuceneTest
for (int i=0; i<NUM_STRINGS; i++) {
Document doc = new Document();
String num = getRandomCharString(getRandomNumber(2, 8), 48, 52);
- doc.add (new Field ("tracer", customType, num));
+ doc.add (new Field ("tracer", num, customType));
//doc.add (new Field ("contents", Integer.toString(i), Field.Store.NO, Field.Index.ANALYZED));
doc.add (new StringField ("string", num));
String num2 = getRandomCharString(getRandomNumber(1, 4), 48, 50);
doc.add (new StringField ("string2", num2));
- doc.add (new Field ("tracer2", customType, num2));
+ doc.add (new Field ("tracer2", num2, customType));
for(IndexableField f : doc.getFields()) {
((Field) f).setBoost(2.0f);
}
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestTermVectors.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestTermVectors.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestTermVectors.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/TestTermVectors.java Thu Sep 29 21:49:45 2011
@@ -67,9 +67,9 @@ public class TestTermVectors extends Luc
} else {
ft.setStoreTermVectors(true);
}
- doc.add(new Field("field", ft, English.intToEnglish(i)));
+ doc.add(new Field("field", English.intToEnglish(i), ft));
//test no term vectors too
- doc.add(new Field("noTV", TextField.TYPE_STORED, English.intToEnglish(i)));
+ doc.add(new Field("noTV", English.intToEnglish(i), TextField.TYPE_STORED));
writer.addDocument(doc);
}
reader = writer.getReader();
Modified: lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java (original)
+++ lucene/dev/branches/solrcloud/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java Thu Sep 29 21:49:45 2011
@@ -125,9 +125,9 @@ public class PayloadHelper {
// writer.infoStream = System.out;
for (int i = 0; i < numDocs; i++) {
Document doc = new Document();
- doc.add(new Field(FIELD, TextField.TYPE_STORED, English.intToEnglish(i)));
- doc.add(new Field(MULTI_FIELD, TextField.TYPE_STORED, English.intToEnglish(i) + " " + English.intToEnglish(i)));
- doc.add(new Field(NO_PAYLOAD_FIELD, TextField.TYPE_STORED, English.intToEnglish(i)));
+ doc.add(new Field(FIELD, English.intToEnglish(i), TextField.TYPE_STORED));
+ doc.add(new Field(MULTI_FIELD, English.intToEnglish(i) + " " + English.intToEnglish(i), TextField.TYPE_STORED));
+ doc.add(new Field(NO_PAYLOAD_FIELD, English.intToEnglish(i), TextField.TYPE_STORED));
writer.addDocument(doc);
}
reader = IndexReader.open(writer, true);
Modified: lucene/dev/branches/solrcloud/modules/analysis/common/src/java/org/apache/lucene/analysis/standard/ClassicAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/analysis/common/src/java/org/apache/lucene/analysis/standard/ClassicAnalyzer.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/analysis/common/src/java/org/apache/lucene/analysis/standard/ClassicAnalyzer.java (original)
+++ lucene/dev/branches/solrcloud/modules/analysis/common/src/java/org/apache/lucene/analysis/standard/ClassicAnalyzer.java Thu Sep 29 21:49:45 2011
@@ -101,7 +101,7 @@ public final class ClassicAnalyzer exten
* Set maximum allowed token length. If a token is seen
* that exceeds this length then it is discarded. This
* setting only takes effect the next time tokenStream or
- * reusableTokenStream is called.
+ * tokenStream is called.
*/
public void setMaxTokenLength(int length) {
maxTokenLength = length;
Modified: lucene/dev/branches/solrcloud/modules/analysis/common/src/java/org/apache/lucene/analysis/standard/StandardAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/analysis/common/src/java/org/apache/lucene/analysis/standard/StandardAnalyzer.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/analysis/common/src/java/org/apache/lucene/analysis/standard/StandardAnalyzer.java (original)
+++ lucene/dev/branches/solrcloud/modules/analysis/common/src/java/org/apache/lucene/analysis/standard/StandardAnalyzer.java Thu Sep 29 21:49:45 2011
@@ -102,7 +102,7 @@ public final class StandardAnalyzer exte
* Set maximum allowed token length. If a token is seen
* that exceeds this length then it is discarded. This
* setting only takes effect the next time tokenStream or
- * reusableTokenStream is called.
+ * tokenStream is called.
*/
public void setMaxTokenLength(int length) {
maxTokenLength = length;
Modified: lucene/dev/branches/solrcloud/modules/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMap.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMap.java?rev=1177441&r1=1177440&r2=1177441&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMap.java (original)
+++ lucene/dev/branches/solrcloud/modules/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMap.java Thu Sep 29 21:49:45 2011
@@ -115,7 +115,7 @@ public class SynonymMap {
* separates by {@link SynonymMap#WORD_SEPARATOR}.
* reuse and its chars must not be null. */
public static CharsRef analyze(Analyzer analyzer, String text, CharsRef reuse) throws IOException {
- TokenStream ts = analyzer.reusableTokenStream("", new StringReader(text));
+ TokenStream ts = analyzer.tokenStream("", new StringReader(text));
CharTermAttribute termAtt = ts.addAttribute(CharTermAttribute.class);
PositionIncrementAttribute posIncAtt = ts.addAttribute(PositionIncrementAttribute.class);
ts.reset();