You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2014/11/30 12:07:19 UTC
svn commit: r1642535 [15/19] - in /lucene/dev/branches/lucene6005/lucene:
analysis/common/src/java/org/apache/lucene/collation/
analysis/common/src/test/org/apache/lucene/analysis/core/
analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/...
Modified: lucene/dev/branches/lucene6005/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java (original)
+++ lucene/dev/branches/lucene6005/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java Sun Nov 30 11:07:09 2014
@@ -33,10 +33,7 @@ import java.util.TreeSet;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.SortedDocValuesField;
-import org.apache.lucene.document.SortedSetDocValuesField;
-import org.apache.lucene.document.TextField;
+import org.apache.lucene.document.FieldTypes;
import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.DocsEnum;
@@ -86,56 +83,46 @@ public class TestJoinUtil extends Lucene
newIndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(newLogMergePolicy()));
// 0
- Document doc = new Document();
- doc.add(new TextField("description", "random text", Field.Store.NO));
- doc.add(new TextField("name", "name1", Field.Store.NO));
- doc.add(new TextField(idField, "1", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("1")));
+ Document doc = w.newDocument();
+ doc.addLargeText("description", "random text");
+ doc.addLargeText("name", "name1");
+ doc.addAtom(idField, new BytesRef("1"));
w.addDocument(doc);
// 1
- doc = new Document();
- doc.add(new TextField("price", "10.0", Field.Store.NO));
- doc.add(new TextField(idField, "2", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("2")));
- doc.add(new TextField(toField, "1", Field.Store.NO));
- doc.add(new SortedDocValuesField(toField, new BytesRef("1")));
+ doc = w.newDocument();
+ doc.addLargeText("price", "10.0");
+ doc.addAtom(idField, new BytesRef("2"));
+ doc.addAtom(toField, new BytesRef("1"));
w.addDocument(doc);
// 2
- doc = new Document();
- doc.add(new TextField("price", "20.0", Field.Store.NO));
- doc.add(new TextField(idField, "3", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("3")));
- doc.add(new TextField(toField, "1", Field.Store.NO));
- doc.add(new SortedDocValuesField(toField, new BytesRef("1")));
+ doc = w.newDocument();
+ doc.addLargeText("price", "20.0");
+ doc.addAtom(idField, new BytesRef("3"));
+ doc.addAtom(toField, new BytesRef("1"));
w.addDocument(doc);
// 3
- doc = new Document();
- doc.add(new TextField("description", "more random text", Field.Store.NO));
- doc.add(new TextField("name", "name2", Field.Store.NO));
- doc.add(new TextField(idField, "4", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("4")));
+ doc = w.newDocument();
+ doc.addLargeText("description", "more random text");
+ doc.addLargeText("name", "name2");
+ doc.addAtom(idField, new BytesRef("4"));
w.addDocument(doc);
w.commit();
// 4
- doc = new Document();
- doc.add(new TextField("price", "10.0", Field.Store.NO));
- doc.add(new TextField(idField, "5", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("5")));
- doc.add(new TextField(toField, "4", Field.Store.NO));
- doc.add(new SortedDocValuesField(toField, new BytesRef("4")));
+ doc = w.newDocument();
+ doc.addLargeText("price", "10.0");
+ doc.addAtom(idField, new BytesRef("5"));
+ doc.addAtom(toField, new BytesRef("4"));
w.addDocument(doc);
// 5
- doc = new Document();
- doc.add(new TextField("price", "20.0", Field.Store.NO));
- doc.add(new TextField(idField, "6", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("6")));
- doc.add(new TextField(toField, "4", Field.Store.NO));
- doc.add(new SortedDocValuesField(toField, new BytesRef("4")));
+ doc = w.newDocument();
+ doc.addLargeText("price", "20.0");
+ doc.addAtom(idField, new BytesRef("6"));
+ doc.addAtom(toField, new BytesRef("4"));
w.addDocument(doc);
IndexSearcher indexSearcher = new IndexSearcher(w.getReader());
@@ -184,24 +171,27 @@ public class TestJoinUtil extends Lucene
random(),
dir,
newIndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(newLogMergePolicy()));
+ if (multipleValues) {
+ FieldTypes fieldTypes = w.getFieldTypes();
+ fieldTypes.setMultiValued(toField);
+ }
// 0
- Document doc = new Document();
- doc.add(new TextField("description", "random text", Field.Store.NO));
- doc.add(new TextField("name", "name1", Field.Store.NO));
- doc.add(new TextField(idField, "0", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("0")));
+ Document doc = w.newDocument();
+ doc.addLargeText("description", "random text");
+ doc.addLargeText("name", "name1");
+ doc.addAtom(idField, new BytesRef("0"));
w.addDocument(doc);
- doc = new Document();
- doc.add(new TextField("price", "10.0", Field.Store.NO));
+ doc = w.newDocument();
+ doc.addLargeText("price", "10.0");
if (multipleValues) {
for(int i=0;i<300;i++) {
- doc.add(new SortedSetDocValuesField(toField, new BytesRef(""+i)));
+ doc.addAtom(toField, new BytesRef(""+i));
}
} else {
- doc.add(new SortedDocValuesField(toField, new BytesRef("0")));
+ doc.addAtom(toField, new BytesRef("0"));
}
w.addDocument(doc);
@@ -234,51 +224,45 @@ public class TestJoinUtil extends Lucene
newIndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(newLogMergePolicy()));
// 0
- Document doc = new Document();
- doc.add(new TextField("description", "random text", Field.Store.NO));
- doc.add(new TextField("name", "name1", Field.Store.NO));
- doc.add(new TextField(idField, "7", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("7")));
+ Document doc = w.newDocument();
+ doc.addLargeText("description", "random text");
+ doc.addLargeText("name", "name1");
+ doc.addAtom(idField, new BytesRef("7"));
w.addDocument(doc);
// 1
- doc = new Document();
- doc.add(new TextField("price", "10.0", Field.Store.NO));
- doc.add(new TextField(idField, "2", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("2")));
- doc.add(new TextField(toField, "7", Field.Store.NO));
+ doc = w.newDocument();
+ doc.addLargeText("price", "10.0");
+ doc.addAtom(idField, new BytesRef("2"));
+ doc.addLargeText(toField, "7");
w.addDocument(doc);
// 2
- doc = new Document();
- doc.add(new TextField("price", "20.0", Field.Store.NO));
- doc.add(new TextField(idField, "3", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("3")));
- doc.add(new TextField(toField, "7", Field.Store.NO));
+ doc = w.newDocument();
+ doc.addLargeText("price", "20.0");
+ doc.addAtom(idField, new BytesRef("3"));
+ doc.addLargeText(toField, "7");
w.addDocument(doc);
// 3
- doc = new Document();
- doc.add(new TextField("description", "more random text", Field.Store.NO));
- doc.add(new TextField("name", "name2", Field.Store.NO));
- doc.add(new TextField(idField, "0", Field.Store.NO));
+ doc = w.newDocument();
+ doc.addLargeText("description", "more random text");
+ doc.addLargeText("name", "name2");
w.addDocument(doc);
w.commit();
// 4
- doc = new Document();
- doc.add(new TextField("price", "10.0", Field.Store.NO));
- doc.add(new TextField(idField, "5", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("5")));
- doc.add(new TextField(toField, "0", Field.Store.NO));
+ doc = w.newDocument();
+ doc.addLargeText("price", "10.0");
+ doc.addAtom(idField, new BytesRef("5"));
+ doc.addLargeText(toField, "0");
w.addDocument(doc);
// 5
- doc = new Document();
- doc.add(new TextField("price", "20.0", Field.Store.NO));
- doc.add(new TextField(idField, "6", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("6")));
- doc.add(new TextField(toField, "0", Field.Store.NO));
+ doc = w.newDocument();
+ doc.addLargeText("price", "20.0");
+ doc.addAtom(idField, new BytesRef("6"));
+ doc.addLargeText(toField, "0");
w.addDocument(doc);
w.forceMerge(1);
@@ -328,56 +312,46 @@ public class TestJoinUtil extends Lucene
newIndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(newLogMergePolicy()));
// 0
- Document doc = new Document();
- doc.add(new TextField("description", "A random movie", Field.Store.NO));
- doc.add(new TextField("name", "Movie 1", Field.Store.NO));
- doc.add(new TextField(idField, "1", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("1")));
+ Document doc = w.newDocument();
+ doc.addLargeText("description", "A random movie");
+ doc.addLargeText("name", "Movie 1");
+ doc.addAtom(idField, new BytesRef("1"));
w.addDocument(doc);
// 1
- doc = new Document();
- doc.add(new TextField("subtitle", "The first subtitle of this movie", Field.Store.NO));
- doc.add(new TextField(idField, "2", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("2")));
- doc.add(new TextField(toField, "1", Field.Store.NO));
- doc.add(new SortedDocValuesField(toField, new BytesRef("1")));
+ doc = w.newDocument();
+ doc.addLargeText("subtitle", "The first subtitle of this movie");
+ doc.addAtom(idField, new BytesRef("2"));
+ doc.addAtom(toField, new BytesRef("1"));
w.addDocument(doc);
// 2
- doc = new Document();
- doc.add(new TextField("subtitle", "random subtitle; random event movie", Field.Store.NO));
- doc.add(new TextField(idField, "3", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("3")));
- doc.add(new TextField(toField, "1", Field.Store.NO));
- doc.add(new SortedDocValuesField(toField, new BytesRef("1")));
+ doc = w.newDocument();
+ doc.addLargeText("subtitle", "random subtitle; random event movie");
+ doc.addAtom(idField, new BytesRef("3"));
+ doc.addAtom(toField, new BytesRef("1"));
w.addDocument(doc);
// 3
- doc = new Document();
- doc.add(new TextField("description", "A second random movie", Field.Store.NO));
- doc.add(new TextField("name", "Movie 2", Field.Store.NO));
- doc.add(new TextField(idField, "4", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("4")));
+ doc = w.newDocument();
+ doc.addLargeText("description", "A second random movie");
+ doc.addLargeText("name", "Movie 2");
+ doc.addAtom(idField, new BytesRef("4"));
w.addDocument(doc);
w.commit();
// 4
- doc = new Document();
- doc.add(new TextField("subtitle", "a very random event happened during christmas night", Field.Store.NO));
- doc.add(new TextField(idField, "5", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("5")));
- doc.add(new TextField(toField, "4", Field.Store.NO));
- doc.add(new SortedDocValuesField(toField, new BytesRef("4")));
+ doc = w.newDocument();
+ doc.addLargeText("subtitle", "a very random event happened during christmas night");
+ doc.addAtom(idField, new BytesRef("5"));
+ doc.addAtom(toField, new BytesRef("4"));
w.addDocument(doc);
// 5
- doc = new Document();
- doc.add(new TextField("subtitle", "movie end movie test 123 test 123 random", Field.Store.NO));
- doc.add(new TextField(idField, "6", Field.Store.NO));
- doc.add(new SortedDocValuesField(idField, new BytesRef("6")));
- doc.add(new TextField(toField, "4", Field.Store.NO));
- doc.add(new SortedDocValuesField(toField, new BytesRef("4")));
+ doc = w.newDocument();
+ doc.addLargeText("subtitle", "movie end movie test 123 test 123 random");
+ doc.addAtom(idField, new BytesRef("6"));
+ doc.addAtom(toField, new BytesRef("4"));
w.addDocument(doc);
IndexSearcher indexSearcher = new IndexSearcher(w.getReader());
@@ -576,11 +550,17 @@ public class TestJoinUtil extends Lucene
String id = Integer.toString(i);
int randomI = random().nextInt(context.randomUniqueValues.length);
String value = context.randomUniqueValues[randomI];
- Document document = new Document();
- document.add(newTextField(random(), "id", id, Field.Store.NO));
- document.add(newTextField(random(), "value", value, Field.Store.NO));
-
boolean from = context.randomFrom[randomI];
+ RandomIndexWriter writer = from ? fromWriter : toWriter;
+ if (multipleValuesPerDocument) {
+ FieldTypes fieldTypes = writer.getFieldTypes();
+ fieldTypes.setMultiValued("from");
+ fieldTypes.setMultiValued("to");
+ }
+ Document document = writer.newDocument();
+ document.addLargeText("id", id);
+ document.addLargeText("value", value);
+
int numberOfLinkValues = multipleValuesPerDocument ? 2 + random().nextInt(10) : 1;
docs[i] = new RandomDoc(id, numberOfLinkValues, value, from);
for (int j = 0; j < numberOfLinkValues; j++) {
@@ -596,12 +576,7 @@ public class TestJoinUtil extends Lucene
context.fromDocuments.get(linkValue).add(docs[i]);
context.randomValueFromDocs.get(value).add(docs[i]);
- document.add(newTextField(random(), "from", linkValue, Field.Store.NO));
- if (multipleValuesPerDocument) {
- document.add(new SortedSetDocValuesField("from", new BytesRef(linkValue)));
- } else {
- document.add(new SortedDocValuesField("from", new BytesRef(linkValue)));
- }
+ document.addAtom("from", new BytesRef(linkValue));
} else {
if (!context.toDocuments.containsKey(linkValue)) {
context.toDocuments.put(linkValue, new ArrayList<RandomDoc>());
@@ -612,12 +587,7 @@ public class TestJoinUtil extends Lucene
context.toDocuments.get(linkValue).add(docs[i]);
context.randomValueToDocs.get(value).add(docs[i]);
- document.add(newTextField(random(), "to", linkValue, Field.Store.NO));
- if (multipleValuesPerDocument) {
- document.add(new SortedSetDocValuesField("to", new BytesRef(linkValue)));
- } else {
- document.add(new SortedDocValuesField("to", new BytesRef(linkValue)));
- }
+ document.addAtom("to", new BytesRef(linkValue));
}
}
Modified: lucene/dev/branches/lucene6005/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndexAgainstRAMDir.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndexAgainstRAMDir.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndexAgainstRAMDir.java (original)
+++ lucene/dev/branches/lucene6005/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndexAgainstRAMDir.java Sun Nov 30 11:07:09 2014
@@ -36,11 +36,8 @@ import org.apache.lucene.analysis.TokenF
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
-import org.apache.lucene.document.Document2;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.FieldType;
-import org.apache.lucene.document.TextField;
+import org.apache.lucene.document.FieldTypes;
import org.apache.lucene.index.CompositeReader;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.DocValuesType;
@@ -151,11 +148,9 @@ public class TestMemoryIndexAgainstRAMDi
Analyzer analyzer = randomAnalyzer();
IndexWriter writer = new IndexWriter(ramdir,
new IndexWriterConfig(analyzer).setCodec(TestUtil.alwaysPostingsFormat(TestUtil.getDefaultPostingsFormat())));
- Document doc = new Document();
- Field field1 = newTextField("foo", fooField.toString(), Field.Store.NO);
- Field field2 = newTextField("term", termField.toString(), Field.Store.NO);
- doc.add(field1);
- doc.add(field2);
+ Document doc = writer.newDocument();
+ doc.addLargeText("foo", fooField.toString());
+ doc.addLargeText("term", termField.toString());
writer.addDocument(doc);
writer.close();
@@ -432,8 +427,8 @@ public class TestMemoryIndexAgainstRAMDi
mockAnalyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH));
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random(), mockAnalyzer));
LineFileDocs lineFileDocs = new LineFileDocs(writer, random());
- Document2 nextDoc = lineFileDocs.nextDoc();
- Document doc = new Document();
+ Document nextDoc = lineFileDocs.nextDoc();
+ Document doc = writer.newDocument();
for (IndexableField field : nextDoc.getFields()) {
if (field.fieldType().indexOptions() != IndexOptions.NONE && field.stringValue() != null && field.fieldType().docValuesType() == DocValuesType.NONE) {
doc.add(field);
@@ -475,19 +470,19 @@ public class TestMemoryIndexAgainstRAMDi
mockAnalyzer.setOffsetGap(random().nextInt(100));
}
//index into a random directory
- FieldType type = new FieldType(TextField.TYPE_STORED);
- type.setStoreTermVectorOffsets(true);
- type.setStoreTermVectorPayloads(false);
- type.setStoreTermVectorPositions(true);
- type.setStoreTermVectors(true);
- type.freeze();
-
- Document doc = new Document();
- doc.add(new Field(field_name, "la la", type));
- doc.add(new Field(field_name, "foo bar foo bar foo", type));
-
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random(), mockAnalyzer));
+ FieldTypes fieldTypes = writer.getFieldTypes();
+ fieldTypes.enableTermVectors(field_name);
+ fieldTypes.enableTermVectorPositions(field_name);
+ fieldTypes.enableTermVectorOffsets(field_name);
+ fieldTypes.enableTermVectorPayloads(field_name);
+ fieldTypes.setMultiValued(field_name);
+
+ Document doc = writer.newDocument();
+ doc.addLargeText(field_name, "la la");
+ doc.addLargeText(field_name, "foo bar foo bar foo");
+
writer.updateDocument(new Term("id", "1"), doc);
writer.commit();
writer.close();
Modified: lucene/dev/branches/lucene6005/lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java (original)
+++ lucene/dev/branches/lucene6005/lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java Sun Nov 30 11:07:09 2014
@@ -24,7 +24,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexReader;
@@ -42,7 +41,7 @@ public class LazyDocument {
private final int docID;
// null until first field is loaded
- private Document2 doc;
+ private Document doc;
private Map<Integer,List<LazyField>> fields = new HashMap<>();
private Set<String> fieldNames = new HashSet<>();
@@ -63,7 +62,7 @@ public class LazyDocument {
* </p>
* <p>
* The lazy loading of field values from all instances of StorableField
- * objects returned by this method are all backed by a single Document2
+ * objects returned by this method are all backed by a single Document
* per LazyDocument instance.
* </p>
*/
@@ -93,7 +92,7 @@ public class LazyDocument {
* non-private for test only access
* @lucene.internal
*/
- synchronized Document2 getDocument() {
+ synchronized Document getDocument() {
if (doc == null) {
try {
doc = reader.document(docID, fieldNames);
@@ -106,7 +105,7 @@ public class LazyDocument {
// :TODO: synchronize to prevent redundent copying? (sync per field name?)
private void fetchRealValues(String name, int fieldNum) {
- Document2 d = getDocument();
+ Document d = getDocument();
List<LazyField> lazyValues = fields.get(fieldNum);
List<IndexableField> realValues = d.getFields(name);
@@ -166,7 +165,7 @@ public class LazyDocument {
}
@Override
- public TokenStream tokenStream(Analyzer analyzer, TokenStream reuse) {
+ public TokenStream tokenStream(TokenStream reuse) {
return null;
}
Modified: lucene/dev/branches/lucene6005/lucene/misc/src/java/org/apache/lucene/uninverting/FieldCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/misc/src/java/org/apache/lucene/uninverting/FieldCache.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/misc/src/java/org/apache/lucene/uninverting/FieldCache.java (original)
+++ lucene/dev/branches/lucene6005/lucene/misc/src/java/org/apache/lucene/uninverting/FieldCache.java Sun Nov 30 11:07:09 2014
@@ -21,8 +21,7 @@ import java.io.IOException;
import java.io.PrintStream;
import org.apache.lucene.analysis.NumericTokenStream;
-import org.apache.lucene.document.Document2;
-import org.apache.lucene.document.NumericDocValuesField;
+import org.apache.lucene.document.Document;
import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.index.IndexReader; // javadocs
import org.apache.lucene.index.LeafReader;
@@ -109,7 +108,7 @@ interface FieldCache {
public static final Parser DOCUMENT2_INT_PARSER = new Parser() {
@Override
public long parseValue(BytesRef term) {
- return Document2.bytesToInt(term);
+ return Document.bytesToInt(term);
}
@Override
@@ -150,7 +149,7 @@ interface FieldCache {
public static final Parser DOCUMENT2_FLOAT_PARSER = new Parser() {
@Override
public long parseValue(BytesRef term) {
- return Document2.sortableFloatBits(Document2.bytesToInt(term));
+ return Document.sortableFloatBits(Document.bytesToInt(term));
}
@Override
@@ -188,7 +187,7 @@ interface FieldCache {
public static final Parser DOCUMENT2_LONG_PARSER = new Parser() {
@Override
public long parseValue(BytesRef term) {
- return Document2.bytesToLong(term);
+ return Document.bytesToLong(term);
}
@Override
@@ -228,7 +227,7 @@ interface FieldCache {
public static final Parser DOCUMENT2_DOUBLE_PARSER = new Parser() {
@Override
public long parseValue(BytesRef term) {
- return Document2.sortableDoubleBits(Document2.bytesToLong(term));
+ return Document.sortableDoubleBits(Document.bytesToLong(term));
}
@Override
Modified: lucene/dev/branches/lucene6005/lucene/misc/src/java/org/apache/lucene/uninverting/UninvertingReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/misc/src/java/org/apache/lucene/uninverting/UninvertingReader.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/misc/src/java/org/apache/lucene/uninverting/UninvertingReader.java (original)
+++ lucene/dev/branches/lucene6005/lucene/misc/src/java/org/apache/lucene/uninverting/UninvertingReader.java Sun Nov 30 11:07:09 2014
@@ -21,11 +21,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;
-import org.apache.lucene.document.BinaryDocValuesField; // javadocs
-import org.apache.lucene.document.NumericDocValuesField; // javadocs
-import org.apache.lucene.document.SortedDocValuesField; // javadocs
-import org.apache.lucene.document.SortedSetDocValuesField; // javadocs
-import org.apache.lucene.document.StringField; // javadocs
import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.DocValuesType;
@@ -59,7 +54,7 @@ public class UninvertingReader extends F
*/
public static enum Type {
/**
- * Single-valued Integer, (e.g. indexed with {@link IntField})
+ * Single-valued Integer, (e.g. indexed with {@link Document2#addInt})
* <p>
* Fields with this type act as if they were indexed with
* {@link NumericDocValuesField}.
@@ -87,31 +82,31 @@ public class UninvertingReader extends F
*/
DOUBLE,
/**
- * Single-valued Binary, (e.g. indexed with {@link StringField})
+ * Single-valued Binary, (e.g. indexed with {@link Document2#addAtom})
* <p>
* Fields with this type act as if they were indexed with
- * {@link BinaryDocValuesField}.
+ * an unsorted {@link Document2#addBinary} field.
*/
BINARY,
/**
- * Single-valued Binary, (e.g. indexed with {@link StringField})
+ * Single-valued Binary, (e.g. indexed with {@link Document2#addAtom})
+ * without doc values.
* <p>
- * Fields with this type act as if they were indexed with
- * {@link SortedDocValuesField}.
+ * Fields with this type act as if they were indexed with doc values.
*/
SORTED,
/**
- * Multi-valued Binary, (e.g. indexed with {@link StringField})
+ * Multi-valued Binary, (e.g. indexed with {@link Document2#addAtom})
* <p>
* Fields with this type act as if they were indexed with
- * {@link SortedSetDocValuesField}.
+ * multi-valued {@link Document2#addAtom}.
*/
SORTED_SET_BINARY,
/**
- * Multi-valued Integer, (e.g. indexed with {@link IntField})
+ * Multi-valued Integer, (e.g. indexed with {@link Document2#addInt})
* <p>
* Fields with this type act as if they were indexed with
- * {@link SortedSetDocValuesField}.
+ * multi-valued {@link Document2#addInt}.
*/
SORTED_SET_INTEGER,
/**
Modified: lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/document/TestLazyDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/document/TestLazyDocument.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/document/TestLazyDocument.java (original)
+++ lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/document/TestLazyDocument.java Sun Nov 30 11:07:09 2014
@@ -17,9 +17,11 @@
package org.apache.lucene.document;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -56,17 +58,21 @@ public class TestLazyDocument extends Lu
Analyzer analyzer = new MockAnalyzer(random());
IndexWriter writer = new IndexWriter
(dir, newIndexWriterConfig(analyzer));
+ FieldTypes fieldTypes = writer.getFieldTypes();
+ for(String f : FIELDS) {
+ fieldTypes.setMultiValued(f);
+ }
try {
for (int docid = 0; docid < NUM_DOCS; docid++) {
- Document d = new Document();
- d.add(newStringField("docid", ""+docid, Field.Store.YES));
- d.add(newStringField("never_load", "fail", Field.Store.YES));
+ Document d = writer.newDocument();
+ d.addAtom("docid", ""+docid);
+ d.addAtom("never_load", "fail");
for (String f : FIELDS) {
for (int val = 0; val < NUM_VALUES; val++) {
- d.add(newStringField(f, docid+"_"+f+"_"+val, Field.Store.YES));
+ d.addAtom(f, docid+"_"+f+"_"+val);
}
}
- d.add(newStringField("load_later", "yes", Field.Store.YES));
+ d.addAtom("load_later", "yes");
writer.addDocument(d);
}
} finally {
@@ -83,34 +89,34 @@ public class TestLazyDocument extends Lu
ScoreDoc[] hits = searcher.search(q, 100).scoreDocs;
assertEquals("Too many docs", 1, hits.length);
LazyTestingStoredFieldVisitor visitor
- = new LazyTestingStoredFieldVisitor(new LazyDocument(reader, hits[0].doc),
+ = new LazyTestingStoredFieldVisitor(reader.getFieldTypes(), new LazyDocument(reader, hits[0].doc),
FIELDS);
reader.document(hits[0].doc, visitor);
- Document d = visitor.doc;
+ List<FieldValue> d = visitor.doc;
int numFieldValues = 0;
Map<String,Integer> fieldValueCounts = new HashMap<>();
// at this point, all FIELDS should be Lazy and unrealized
- for (IndexableField f : d) {
+ for (FieldValue f : d) {
numFieldValues++;
- if (f.name().equals("never_load")) {
+ if (f.name.equals("never_load")) {
fail("never_load was loaded");
}
- if (f.name().equals("load_later")) {
+ if (f.name.equals("load_later")) {
fail("load_later was loaded on first pass");
}
- if (f.name().equals("docid")) {
- assertFalse(f.name(), f instanceof LazyDocument.LazyField);
+ if (f.name.equals("docid")) {
+ assertFalse(f.name, f.value instanceof LazyDocument.LazyField);
} else {
- int count = fieldValueCounts.containsKey(f.name()) ?
- fieldValueCounts.get(f.name()) : 0;
+ int count = fieldValueCounts.containsKey(f.name) ?
+ fieldValueCounts.get(f.name) : 0;
count++;
- fieldValueCounts.put(f.name(), count);
- assertTrue(f.name() + " is " + f.getClass(),
- f instanceof LazyDocument.LazyField);
- LazyDocument.LazyField lf = (LazyDocument.LazyField) f;
- assertFalse(f.name() + " is loaded", lf.hasBeenLoaded());
+ fieldValueCounts.put(f.name, count);
+ assertTrue(f.name + " is " + f.value.getClass(),
+ f.value instanceof LazyDocument.LazyField);
+ LazyDocument.LazyField lf = (LazyDocument.LazyField) f.value;
+ assertFalse(f.name + " is loaded", lf.hasBeenLoaded());
}
}
if (VERBOSE) System.out.println("numFieldValues == " + numFieldValues);
@@ -124,34 +130,39 @@ public class TestLazyDocument extends Lu
// pick a single field name to load a single value
final String fieldName = FIELDS[random().nextInt(FIELDS.length)];
- final IndexableField[] fieldValues = d.getFields(fieldName);
+ List<FieldValue> fieldValues = new ArrayList<>();
+ for(FieldValue f : d) {
+ if (f.name.equals(fieldName)) {
+ fieldValues.add(f);
+ }
+ }
assertEquals("#vals in field: " + fieldName,
- NUM_VALUES, fieldValues.length);
- final int valNum = random().nextInt(fieldValues.length);
+ NUM_VALUES, fieldValues.size());
+ final int valNum = random().nextInt(fieldValues.size());
assertEquals(id + "_" + fieldName + "_" + valNum,
- fieldValues[valNum].stringValue());
+ ((LazyDocument.LazyField) fieldValues.get(valNum).value).stringValue());
// now every value of fieldName should be loaded
- for (IndexableField f : d) {
- if (f.name().equals("never_load")) {
+ for (FieldValue f : d) {
+ if (f.name.equals("never_load")) {
fail("never_load was loaded");
}
- if (f.name().equals("load_later")) {
+ if (f.name.equals("load_later")) {
fail("load_later was loaded too soon");
}
- if (f.name().equals("docid")) {
- assertFalse(f.name(), f instanceof LazyDocument.LazyField);
+ if (f.name.equals("docid")) {
+ assertFalse(f.name, f.value instanceof LazyDocument.LazyField);
} else {
- assertTrue(f.name() + " is " + f.getClass(),
- f instanceof LazyDocument.LazyField);
- LazyDocument.LazyField lf = (LazyDocument.LazyField) f;
- assertEquals(f.name() + " is loaded?",
+ assertTrue(f.name + " is " + f.value.getClass(),
+ f.value instanceof LazyDocument.LazyField);
+ LazyDocument.LazyField lf = (LazyDocument.LazyField) f.value;
+ assertEquals(f.name + " is loaded?",
lf.name().equals(fieldName), lf.hasBeenLoaded());
}
}
// use the same LazyDoc to ask for one more lazy field
- visitor = new LazyTestingStoredFieldVisitor(new LazyDocument(reader, hits[0].doc),
+ visitor = new LazyTestingStoredFieldVisitor(reader.getFieldTypes(), new LazyDocument(reader, hits[0].doc),
"load_later");
reader.document(hits[0].doc, visitor);
d = visitor.doc;
@@ -159,17 +170,17 @@ public class TestLazyDocument extends Lu
// ensure we have all the values we expect now, and that
// adding one more lazy field didn't "unload" the existing LazyField's
// we already loaded.
- for (IndexableField f : d) {
- if (f.name().equals("never_load")) {
+ for (FieldValue f : d) {
+ if (f.name.equals("never_load")) {
fail("never_load was loaded");
}
- if (f.name().equals("docid")) {
- assertFalse(f.name(), f instanceof LazyDocument.LazyField);
+ if (f.name.equals("docid")) {
+ assertFalse(f.name, f.value instanceof LazyDocument.LazyField);
} else {
- assertTrue(f.name() + " is " + f.getClass(),
- f instanceof LazyDocument.LazyField);
- LazyDocument.LazyField lf = (LazyDocument.LazyField) f;
- assertEquals(f.name() + " is loaded?",
+ assertTrue(f.name + " is " + f.value.getClass(),
+ f.value instanceof LazyDocument.LazyField);
+ LazyDocument.LazyField lf = (LazyDocument.LazyField) f.value;
+ assertEquals(f.name + " is loaded?",
lf.name().equals(fieldName), lf.hasBeenLoaded());
}
}
@@ -183,12 +194,21 @@ public class TestLazyDocument extends Lu
}
}
+ private static class FieldValue {
+ String name;
+ Object value;
+ public FieldValue(String name, Object value) {
+ this.name = name;
+ this.value = value;
+ }
+ }
+
private static class LazyTestingStoredFieldVisitor extends StoredFieldVisitor {
- public final Document doc = new Document();
+ public final List<FieldValue> doc = new ArrayList<>();
public final LazyDocument lazyDoc;
public final Set<String> lazyFieldNames;
- LazyTestingStoredFieldVisitor(LazyDocument l, String... fields) {
+ LazyTestingStoredFieldVisitor(FieldTypes fieldTypes, LazyDocument l, String... fields) {
lazyDoc = l;
lazyFieldNames = new HashSet<>(Arrays.asList(fields));
}
@@ -201,7 +221,7 @@ public class TestLazyDocument extends Lu
return Status.NO;
} else {
if (lazyFieldNames.contains(fieldInfo.name)) {
- doc.add(lazyDoc.getField(fieldInfo));
+ doc.add(new FieldValue(fieldInfo.name, lazyDoc.getField(fieldInfo)));
}
}
return Status.NO;
@@ -209,11 +229,7 @@ public class TestLazyDocument extends Lu
@Override
public void stringField(FieldInfo fieldInfo, String value) throws IOException {
- final FieldType ft = new FieldType(TextField.TYPE_STORED);
- ft.setStoreTermVectors(fieldInfo.hasVectors());
- ft.setOmitNorms(fieldInfo.omitsNorms());
- ft.setIndexOptions(fieldInfo.getIndexOptions());
- doc.add(new Field(fieldInfo.name, value, ft));
+ doc.add(new FieldValue(fieldInfo.name, value));
}
}
Modified: lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java (original)
+++ lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/TestIndexSplitter.java Sun Nov 30 11:07:09 2014
@@ -19,7 +19,6 @@ package org.apache.lucene.index;
import java.nio.file.Path;
import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockDirectoryWrapper;
Modified: lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java (original)
+++ lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java Sun Nov 30 11:07:09 2014
@@ -18,9 +18,7 @@ package org.apache.lucene.index;
*/
import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.document.Document2;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
@@ -36,11 +34,10 @@ public class TestMultiPassIndexSplitter
super.setUp();
dir = newDirectory();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE));
- Document doc;
for (int i = 0; i < NUM_DOCS; i++) {
- doc = new Document();
- doc.add(newStringField("id", i + "", Field.Store.YES));
- doc.add(newTextField("f", i + " " + i, Field.Store.YES));
+ Document doc = w.newDocument();
+ doc.addAtom("id", i + "");
+ doc.addLargeText("f", i + " " + i);
w.addDocument(doc);
if (i%3==0) w.commit();
}
@@ -71,7 +68,7 @@ public class TestMultiPassIndexSplitter
IndexReader ir;
ir = DirectoryReader.open(dirs[0]);
assertTrue(ir.numDocs() - NUM_DOCS / 3 <= 1); // rounding error
- Document2 doc = ir.document(0);
+ Document doc = ir.document(0);
assertEquals("0", doc.get("id"));
TermsEnum te = MultiFields.getTerms(ir, "id").iterator(null);
assertEquals(TermsEnum.SeekStatus.NOT_FOUND, te.seekCeil(new BytesRef("1")));
@@ -116,7 +113,7 @@ public class TestMultiPassIndexSplitter
IndexReader ir;
ir = DirectoryReader.open(dirs[0]);
assertTrue(ir.numDocs() - NUM_DOCS / 3 <= 1);
- Document2 doc = ir.document(0);
+ Document doc = ir.document(0);
assertEquals("0", doc.getString("id"));
int start = ir.numDocs();
ir.close();
Modified: lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/TestPKIndexSplitter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/TestPKIndexSplitter.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/TestPKIndexSplitter.java (original)
+++ lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/TestPKIndexSplitter.java Sun Nov 30 11:07:09 2014
@@ -25,7 +25,6 @@ import java.util.Locale;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.Bits;
@@ -39,12 +38,12 @@ public class TestPKIndexSplitter extends
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false))
.setOpenMode(OpenMode.CREATE).setMergePolicy(NoMergePolicy.INSTANCE));
for (int x = 0; x < 11; x++) {
- Document doc = createDocument(x, "1", 3, format);
+ Document doc = createDocument(w, x, "1", 3, format);
w.addDocument(doc);
if (x%3==0) w.commit();
}
for (int x = 11; x < 20; x++) {
- Document doc = createDocument(x, "2", 3, format);
+ Document doc = createDocument(w, x, "2", 3, format);
w.addDocument(doc);
if (x%3==0) w.commit();
}
@@ -98,20 +97,20 @@ public class TestPKIndexSplitter extends
}
}
- private Document createDocument(int n, String indexName,
+ private Document createDocument(IndexWriter w, int n, String indexName,
int numFields, NumberFormat format) {
StringBuilder sb = new StringBuilder();
- Document doc = new Document();
+ Document doc = w.newDocument();
String id = format.format(n);
- doc.add(newStringField("id", id, Field.Store.YES));
- doc.add(newStringField("indexname", indexName, Field.Store.YES));
+ doc.addAtom("id", id);
+ doc.addAtom("indexname", indexName);
sb.append("a");
sb.append(n);
- doc.add(newTextField("field1", sb.toString(), Field.Store.YES));
+ doc.addLargeText("field1", sb.toString());
sb.append(" b");
sb.append(n);
for (int i = 1; i < numFields; i++) {
- doc.add(newTextField("field" + (i + 1), sb.toString(), Field.Store.YES));
+ doc.addLargeText("field" + (i + 1), sb.toString());
}
return doc;
}
Modified: lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/sorter/SorterTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/sorter/SorterTestBase.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/sorter/SorterTestBase.java (original)
+++ lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/sorter/SorterTestBase.java Sun Nov 30 11:07:09 2014
@@ -29,23 +29,13 @@ import org.apache.lucene.analysis.TokenS
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
-import org.apache.lucene.document.BinaryDocValuesField;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field.Store;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.FieldType;
-import org.apache.lucene.document.NumericDocValuesField;
-import org.apache.lucene.document.SortedDocValuesField;
-import org.apache.lucene.document.SortedNumericDocValuesField;
-import org.apache.lucene.document.SortedSetDocValuesField;
-import org.apache.lucene.document.StringField;
-import org.apache.lucene.document.TextField;
+import org.apache.lucene.document.FieldTypes;
import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.DocsAndPositionsEnum;
import org.apache.lucene.index.DocsEnum;
import org.apache.lucene.index.FieldInvertState;
-import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
@@ -153,41 +143,33 @@ public abstract class SorterTestBase ext
protected static final String SORTED_DV_FIELD = "sorted";
protected static final String SORTED_SET_DV_FIELD = "sorted_set";
protected static final String TERM_VECTORS_FIELD = "term_vectors";
-
- private static final FieldType TERM_VECTORS_TYPE = new FieldType(TextField.TYPE_NOT_STORED);
- static {
- TERM_VECTORS_TYPE.setStoreTermVectors(true);
- TERM_VECTORS_TYPE.freeze();
- }
-
- private static final FieldType POSITIONS_TYPE = new FieldType(TextField.TYPE_NOT_STORED);
- static {
- POSITIONS_TYPE.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
- POSITIONS_TYPE.freeze();
- }
protected static Directory dir;
protected static LeafReader unsortedReader;
protected static LeafReader sortedReader;
protected static Integer[] sortedValues;
- private static Document doc(final int id, PositionsTokenStream positions) {
- final Document doc = new Document();
- doc.add(new StringField(ID_FIELD, Integer.toString(id), Store.YES));
- doc.add(new StringField(DOCS_ENUM_FIELD, DOCS_ENUM_TERM, Store.NO));
+ private static Document doc(RandomIndexWriter w, final int id, PositionsTokenStream positions) {
+ FieldTypes fieldTypes = w.getFieldTypes();
+ fieldTypes.disableSorting(BINARY_DV_FIELD);
+ fieldTypes.setMultiValued(SORTED_SET_DV_FIELD);
+ fieldTypes.setMultiValued(SORTED_NUMERIC_DV_FIELD);
+ fieldTypes.enableTermVectors(TERM_VECTORS_FIELD);
+
+ final Document doc = w.newDocument();
+ doc.addAtom(ID_FIELD, Integer.toString(id));
+ doc.addAtom(DOCS_ENUM_FIELD, DOCS_ENUM_TERM);
positions.setId(id);
- doc.add(new Field(DOC_POSITIONS_FIELD, positions, POSITIONS_TYPE));
- doc.add(new NumericDocValuesField(NUMERIC_DV_FIELD, id));
- TextField norms = new TextField(NORMS_FIELD, Integer.toString(id), Store.NO);
- norms.setBoost(Float.intBitsToFloat(id));
- doc.add(norms);
- doc.add(new BinaryDocValuesField(BINARY_DV_FIELD, new BytesRef(Integer.toString(id))));
- doc.add(new SortedDocValuesField(SORTED_DV_FIELD, new BytesRef(Integer.toString(id))));
- doc.add(new SortedSetDocValuesField(SORTED_SET_DV_FIELD, new BytesRef(Integer.toString(id))));
- doc.add(new SortedSetDocValuesField(SORTED_SET_DV_FIELD, new BytesRef(Integer.toString(id + 1))));
- doc.add(new SortedNumericDocValuesField(SORTED_NUMERIC_DV_FIELD, id));
- doc.add(new SortedNumericDocValuesField(SORTED_NUMERIC_DV_FIELD, id + 1));
- doc.add(new Field(TERM_VECTORS_FIELD, Integer.toString(id), TERM_VECTORS_TYPE));
+ doc.addLargeText(DOC_POSITIONS_FIELD, positions);
+ doc.addInt(NUMERIC_DV_FIELD, id);
+ doc.addLargeText(NORMS_FIELD, Integer.toString(id), Float.intBitsToFloat(id));
+ doc.addBinary(BINARY_DV_FIELD, new BytesRef(Integer.toString(id)));
+ doc.addAtom(SORTED_DV_FIELD, new BytesRef(Integer.toString(id)));
+ doc.addAtom(SORTED_SET_DV_FIELD, new BytesRef(Integer.toString(id)));
+ doc.addAtom(SORTED_SET_DV_FIELD, new BytesRef(Integer.toString(id + 1)));
+ doc.addInt(SORTED_NUMERIC_DV_FIELD, id);
+ doc.addInt(SORTED_NUMERIC_DV_FIELD, id + 1);
+ doc.addLargeText(TERM_VECTORS_FIELD, Integer.toString(id));
return doc;
}
@@ -210,7 +192,7 @@ public abstract class SorterTestBase ext
RandomIndexWriter writer = new RandomIndexWriter(random, dir, conf);
writer.setDoRandomForceMerge(false);
for (int id : ids) {
- writer.addDocument(doc(id, positions));
+ writer.addDocument(doc(writer, id, positions));
}
// delete some documents
writer.commit();
Modified: lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/sorter/TestBlockJoinSorter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/sorter/TestBlockJoinSorter.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/sorter/TestBlockJoinSorter.java (original)
+++ lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/sorter/TestBlockJoinSorter.java Sun Nov 30 11:07:09 2014
@@ -23,12 +23,9 @@ import java.util.List;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field.Store;
-import org.apache.lucene.document.NumericDocValuesField;
-import org.apache.lucene.document.StringField;
-import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
@@ -61,7 +58,6 @@ public class TestBlockJoinSorter extends
cached.or(iterator);
return new BitDocIdSet(cached);
}
-
}
public void test() throws IOException {
@@ -69,20 +65,17 @@ public class TestBlockJoinSorter extends
IndexWriterConfig cfg = newIndexWriterConfig(new MockAnalyzer(random()));
cfg.setMergePolicy(newLogMergePolicy());
final RandomIndexWriter writer = new RandomIndexWriter(random(), newDirectory(), cfg);
- final Document parentDoc = new Document();
- final NumericDocValuesField parentVal = new NumericDocValuesField("parent_val", 0L);
- parentDoc.add(parentVal);
- final StringField parent = new StringField("parent", "true", Store.YES);
- parentDoc.add(parent);
for (int i = 0; i < numParents; ++i) {
List<Document> documents = new ArrayList<>();
final int numChildren = random().nextInt(10);
for (int j = 0; j < numChildren; ++j) {
- final Document childDoc = new Document();
- childDoc.add(new NumericDocValuesField("child_val", random().nextInt(5)));
+ final Document childDoc = writer.newDocument();
+ childDoc.addInt("child_val", random().nextInt(5));
documents.add(childDoc);
}
- parentVal.setLongValue(random().nextInt(50));
+ final Document parentDoc = writer.newDocument();
+ parentDoc.addLong("parent_val", random().nextInt(50));
+ parentDoc.addAtom("parent", "true");
documents.add(parentDoc);
writer.addDocuments(documents);
}
Modified: lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/sorter/TestEarlyTermination.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/sorter/TestEarlyTermination.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/sorter/TestEarlyTermination.java (original)
+++ lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/sorter/TestEarlyTermination.java Sun Nov 30 11:07:09 2014
@@ -26,17 +26,14 @@ import java.util.Set;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field.Store;
-import org.apache.lucene.document.NumericDocValuesField;
-import org.apache.lucene.document.StringField;
-import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.SerialMergeScheduler;
import org.apache.lucene.index.Term;
-import org.apache.lucene.search.LeafCollector;
import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.LeafCollector;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
@@ -47,7 +44,6 @@ import org.apache.lucene.search.TopField
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
-
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
public class TestEarlyTermination extends LuceneTestCase {
@@ -65,11 +61,11 @@ public class TestEarlyTermination extend
sort = new Sort(new SortField("ndv1", SortField.Type.LONG));
}
- private Document randomDocument() {
- final Document doc = new Document();
- doc.add(new NumericDocValuesField("ndv1", random().nextInt(10)));
- doc.add(new NumericDocValuesField("ndv2", random().nextInt(10)));
- doc.add(new StringField("s", RandomPicks.randomFrom(random(), terms), Store.YES));
+ private Document randomDocument(RandomIndexWriter iw) {
+ final Document doc = iw.newDocument();
+ doc.addInt("ndv1", random().nextInt(10));
+ doc.addInt("ndv2", random().nextInt(10));
+ doc.addAtom("s", RandomPicks.randomFrom(random(), terms));
return doc;
}
@@ -89,7 +85,7 @@ public class TestEarlyTermination extend
iw = new RandomIndexWriter(new Random(seed), dir, iwc);
iw.setDoRandomForceMerge(false); // don't do this, it may happen anyway with MockRandomMP
for (int i = 0; i < numDocs; ++i) {
- final Document doc = randomDocument();
+ final Document doc = randomDocument(iw);
iw.addDocument(doc);
if (i == numDocs / 2 || (i != numDocs - 1 && random().nextInt(8) == 0)) {
iw.commit();
Modified: lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/sorter/TestSortingMergePolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/sorter/TestSortingMergePolicy.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/sorter/TestSortingMergePolicy.java (original)
+++ lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/index/sorter/TestSortingMergePolicy.java Sun Nov 30 11:07:09 2014
@@ -26,13 +26,14 @@ import java.util.Set;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field.Store;
-import org.apache.lucene.document.NumericDocValuesField;
-import org.apache.lucene.document.StringField;
-import org.apache.lucene.index.LeafReader;
+import org.apache.lucene.document.FieldTypes;
import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.DocValuesType;
+import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LogMergePolicy;
import org.apache.lucene.index.MergePolicy;
import org.apache.lucene.index.NumericDocValues;
@@ -45,7 +46,6 @@ import org.apache.lucene.search.SortFiel
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
-
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
public class TestSortingMergePolicy extends LuceneTestCase {
@@ -63,11 +63,34 @@ public class TestSortingMergePolicy exte
createRandomIndexes();
}
- private Document randomDocument() {
- final Document doc = new Document();
- doc.add(new NumericDocValuesField("ndv", random().nextLong()));
- doc.add(new StringField("s", RandomPicks.randomFrom(random(), terms), Store.YES));
- return doc;
+ private void addRandomDocument(RandomIndexWriter w1, RandomIndexWriter w2) throws IOException {
+ long num = random().nextLong();
+ String term = RandomPicks.randomFrom(random(), terms);
+
+ Document doc = w1.newDocument();
+ doc.addLong("ndv", num);
+ doc.addAtom("s", term);
+ w1.addDocument(doc);
+
+ doc = w2.newDocument();
+ doc.addLong("ndv", num);
+ doc.addAtom("s", term);
+ w2.addDocument(doc);
+ }
+
+ private void addRandomDocument(IndexWriter w1, IndexWriter w2) throws IOException {
+ long num = random().nextLong();
+ String term = RandomPicks.randomFrom(random(), terms);
+
+ Document doc = w1.newDocument();
+ doc.addLong("ndv", num);
+ doc.addAtom("s", term);
+ w1.addDocument(doc);
+
+ doc = w2.newDocument();
+ doc.addLong("ndv", num);
+ doc.addAtom("s", term);
+ w2.addDocument(doc);
}
static MergePolicy newSortingMergePolicy(Sort sort) {
@@ -107,16 +130,22 @@ public class TestSortingMergePolicy exte
final IndexWriterConfig iwc2 = newIndexWriterConfig(new MockAnalyzer(new Random(seed)));
iwc2.setMergePolicy(newSortingMergePolicy(sort));
final RandomIndexWriter iw1 = new RandomIndexWriter(new Random(seed), dir1, iwc1);
+ FieldTypes fieldTypes = iw1.getFieldTypes();
+ fieldTypes.setIndexOptions("ndv", IndexOptions.NONE);
+ fieldTypes.disableStored("ndv");
+ fieldTypes.setDocValuesType("s", DocValuesType.NONE);
final RandomIndexWriter iw2 = new RandomIndexWriter(new Random(seed), dir2, iwc2);
+ fieldTypes = iw2.getFieldTypes();
+ fieldTypes.setIndexOptions("ndv", IndexOptions.NONE);
+ fieldTypes.disableStored("ndv");
+ fieldTypes.setDocValuesType("s", DocValuesType.NONE);
for (int i = 0; i < numDocs; ++i) {
if (random().nextInt(5) == 0 && i != numDocs - 1) {
final String term = RandomPicks.randomFrom(random(), terms);
iw1.deleteDocuments(new Term("s", term));
iw2.deleteDocuments(new Term("s", term));
}
- final Document doc = randomDocument();
- iw1.addDocument(doc);
- iw2.addDocument(doc);
+ addRandomDocument(iw1, iw2);
if (random().nextInt(8) == 0) {
iw1.commit();
iw2.commit();
@@ -125,15 +154,13 @@ public class TestSortingMergePolicy exte
// Make sure we have something to merge
iw1.commit();
iw2.commit();
- final Document doc = randomDocument();
// NOTE: don't use RIW.addDocument directly, since it sometimes commits
// which may trigger a merge, at which case forceMerge may not do anything.
// With field updates this is a problem, since the updates can go into the
// single segment in the index, and threefore the index won't be sorted.
// This hurts the assumption of the test later on, that the index is sorted
// by SortingMP.
- iw1.w.addDocument(doc);
- iw2.w.addDocument(doc);
+ addRandomDocument(iw1.w, iw2.w);
// update NDV of docs belonging to one term (covers many documents)
final long value = random().nextLong();
Modified: lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java (original)
+++ lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java Sun Nov 30 11:07:09 2014
@@ -22,7 +22,7 @@ import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldTypes;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
@@ -174,58 +174,59 @@ public class TestHighFreqTerms extends L
/********************Testing Utils**********************************/
private static void indexDocs(IndexWriter writer) throws Exception {
- Random rnd = random();
-
+ FieldTypes fieldTypes = writer.getFieldTypes();
+ fieldTypes.disableExistsFilters();
+
/**
* Generate 10 documents where term n has a docFreq of n and a totalTermFreq of n*2 (squared).
*/
for (int i = 1; i <= 10; i++) {
- Document doc = new Document();
+ Document doc = writer.newDocument();
String content = getContent(i);
- doc.add(newTextField(rnd, "FIELD_1", content, Field.Store.YES));
+ doc.addLargeText("FIELD_1", content);
//add a different field
- doc.add(newTextField(rnd, "different_field", "diff", Field.Store.YES));
+ doc.addLargeText("different_field", "diff");
writer.addDocument(doc);
}
//add 10 more docs with the term "diff" this will make it have the highest docFreq if we don't ask for the
//highest freq terms for a specific field.
for (int i = 1; i <= 10; i++) {
- Document doc = new Document();
- doc.add(newTextField(rnd, "different_field", "diff", Field.Store.YES));
+ Document doc = writer.newDocument();
+ doc.addLargeText("different_field", "diff");
writer.addDocument(doc);
}
// add some docs where tf < df so we can see if sorting works
// highTF low df
int highTF = 200;
- Document doc = new Document();
+ Document doc = writer.newDocument();
String content = "";
for (int i = 0; i < highTF; i++) {
content += "highTF ";
}
- doc.add(newTextField(rnd, "FIELD_1", content, Field.Store.YES));
+ doc.addLargeText("FIELD_1", content);
writer.addDocument(doc);
// highTF medium df =5
int medium_df = 5;
for (int i = 0; i < medium_df; i++) {
int tf = 25;
- Document newdoc = new Document();
+ Document newdoc = writer.newDocument();
String newcontent = "";
for (int j = 0; j < tf; j++) {
newcontent += "highTFmedDF ";
}
- newdoc.add(newTextField(rnd, "FIELD_1", newcontent, Field.Store.YES));
+ newdoc.addLargeText("FIELD_1", newcontent);
writer.addDocument(newdoc);
}
// add a doc with high tf in field different_field
int targetTF =150;
- doc = new Document();
+ doc = writer.newDocument();
content = "";
for (int i = 0; i < targetTF; i++) {
content += "TF150 ";
}
- doc.add(newTextField(rnd, "different_field", content, Field.Store.YES));
+ doc.addLargeText("different_field", content);
writer.addDocument(doc);
writer.close();
Modified: lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/uninverting/TestDocTermOrds.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/uninverting/TestDocTermOrds.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/uninverting/TestDocTermOrds.java (original)
+++ lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/uninverting/TestDocTermOrds.java Sun Nov 30 11:07:09 2014
@@ -27,11 +27,8 @@ import java.util.Set;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.codecs.Codec;
-import org.apache.lucene.document.Document2;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldTypes;
-import org.apache.lucene.document.StringField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.IndexReader;
@@ -51,7 +48,6 @@ import org.apache.lucene.index.TermsEnum
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.NumericUtils;
import org.apache.lucene.util.StringHelper;
import org.apache.lucene.util.TestUtil;
@@ -66,16 +62,16 @@ public class TestDocTermOrds extends Luc
public void testSimple() throws Exception {
Directory dir = newDirectory();
final RandomIndexWriter w = new RandomIndexWriter(random(), dir, newIndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(newLogMergePolicy()));
- Document doc = new Document();
- Field field = newTextField("field", "", Field.Store.NO);
- doc.add(field);
- field.setStringValue("a b c");
+ Document doc = w.newDocument();
+ doc.addLargeText("field", "a b c");
w.addDocument(doc);
- field.setStringValue("d e f");
+ doc = w.newDocument();
+ doc.addLargeText("field", "d e f");
w.addDocument(doc);
- field.setStringValue("a f");
+ doc = w.newDocument();
+ doc.addLargeText("field", "a f");
w.addDocument(doc);
final IndexReader r = w.getReader();
@@ -142,7 +138,7 @@ public class TestDocTermOrds extends Luc
final Set<Integer> ordsForDocSet = new HashSet<>();
for(int id=0;id<NUM_DOCS;id++) {
- Document2 doc = w.newDocument();
+ Document doc = w.newDocument();
doc.addInt("id", id);
final int termCount = TestUtil.nextInt(random(), 0, 20 * RANDOM_MULTIPLIER);
@@ -241,7 +237,7 @@ public class TestDocTermOrds extends Luc
final Set<Integer> ordsForDocSet = new HashSet<>();
for(int id=0;id<NUM_DOCS;id++) {
- Document2 doc = w.newDocument();
+ Document doc = w.newDocument();
doc.addInt("id", id);
@@ -400,15 +396,17 @@ public class TestDocTermOrds extends Luc
public void testBackToTheFuture() throws Exception {
Directory dir = newDirectory();
IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(null));
-
- Document doc = new Document();
- doc.add(newStringField("foo", "bar", Field.Store.NO));
+ FieldTypes fieldTypes = iw.getFieldTypes();
+ fieldTypes.setMultiValued("foo");
+
+ Document doc = iw.newDocument();
+ doc.addAtom("foo", "bar");
iw.addDocument(doc);
- doc = new Document();
- doc.add(newStringField("foo", "baz", Field.Store.NO));
+ doc = iw.newDocument();
+ doc.addAtom("foo", "baz");
// we need a second value for a doc, or we don't actually test DocTermOrds!
- doc.add(newStringField("foo", "car", Field.Store.NO));
+ doc.addAtom("foo", "car");
iw.addDocument(doc);
DirectoryReader r1 = DirectoryReader.open(iw, true);
@@ -436,7 +434,7 @@ public class TestDocTermOrds extends Luc
fieldTypes.disableSorting("foo");
fieldTypes.setMultiValued("foo");
- Document2 doc = iw.newDocument();
+ Document doc = iw.newDocument();
doc.addInt("foo", 5);
iw.addDocument(doc);
@@ -464,10 +462,10 @@ public class TestDocTermOrds extends Luc
assertEquals(SortedSetDocValues.NO_MORE_ORDS, v.nextOrd());
BytesRef value = v.lookupOrd(0);
- assertEquals(-3, Document2.bytesToInt(value));
+ assertEquals(-3, Document.bytesToInt(value));
value = v.lookupOrd(1);
- assertEquals(5, Document2.bytesToInt(value));
+ assertEquals(5, Document.bytesToInt(value));
ir.close();
dir.close();
@@ -480,7 +478,7 @@ public class TestDocTermOrds extends Luc
fieldTypes.disableSorting("foo");
fieldTypes.setMultiValued("foo");
- Document2 doc = iw.newDocument();
+ Document doc = iw.newDocument();
doc.addLong("foo", 5);
iw.addDocument(doc);
@@ -508,10 +506,10 @@ public class TestDocTermOrds extends Luc
assertEquals(SortedSetDocValues.NO_MORE_ORDS, v.nextOrd());
BytesRef value = v.lookupOrd(0);
- assertEquals(-3, Document2.bytesToLong(value));
+ assertEquals(-3, Document.bytesToLong(value));
value = v.lookupOrd(1);
- assertEquals(5, Document2.bytesToLong(value));
+ assertEquals(5, Document.bytesToLong(value));
ir.close();
dir.close();
@@ -523,19 +521,21 @@ public class TestDocTermOrds extends Luc
IndexWriterConfig iwconfig = newIndexWriterConfig(analyzer);
iwconfig.setMergePolicy(newLogMergePolicy());
RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, iwconfig);
+ FieldTypes fieldTypes = iwriter.getFieldTypes();
+ fieldTypes.setMultiValued("field");
- Document doc = new Document();
- doc.add(new StringField("field", "hello", Field.Store.NO));
+ Document doc = iwriter.newDocument();
+ doc.addAtom("field", "hello");
iwriter.addDocument(doc);
- doc = new Document();
- doc.add(new StringField("field", "world", Field.Store.NO));
+ doc = iwriter.newDocument();
+ doc.addAtom("field", "world");
// we need a second value for a doc, or we don't actually test DocTermOrds!
- doc.add(new StringField("field", "hello", Field.Store.NO));
+ doc.addAtom("field", "hello");
iwriter.addDocument(doc);
- doc = new Document();
- doc.add(new StringField("field", "beer", Field.Store.NO));
+ doc = iwriter.newDocument();
+ doc.addAtom("field", "beer");
iwriter.addDocument(doc);
iwriter.forceMerge(1);
@@ -606,21 +606,24 @@ public class TestDocTermOrds extends Luc
IndexWriterConfig iwconfig = newIndexWriterConfig(null);
iwconfig.setMergePolicy(newLogMergePolicy());
IndexWriter iw = new IndexWriter(dir, iwconfig);
+ FieldTypes fieldTypes = iw.getFieldTypes();
+ fieldTypes.setMultiValued("foo");
+ fieldTypes.disableSorting("foo");
- Document doc = new Document();
- doc.add(new StringField("foo", "bar", Field.Store.NO));
+ Document doc = iw.newDocument();
+ doc.addAtom("foo", "bar");
iw.addDocument(doc);
- doc = new Document();
- doc.add(new StringField("foo", "baz", Field.Store.NO));
+ doc = iw.newDocument();
+ doc.addAtom("foo", "baz");
iw.addDocument(doc);
- doc = new Document();
+ doc = iw.newDocument();
iw.addDocument(doc);
- doc = new Document();
- doc.add(new StringField("foo", "baz", Field.Store.NO));
- doc.add(new StringField("foo", "baz", Field.Store.NO));
+ doc = iw.newDocument();
+ doc.addAtom("foo", "baz");
+ doc.addAtom("foo", "baz");
iw.addDocument(doc);
iw.forceMerge(1);
Modified: lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/uninverting/TestFieldCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/uninverting/TestFieldCache.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/uninverting/TestFieldCache.java (original)
+++ lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/uninverting/TestFieldCache.java Sun Nov 30 11:07:09 2014
@@ -28,16 +28,8 @@ import java.util.concurrent.atomic.Atomi
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.document.BinaryDocValuesField;
-import org.apache.lucene.document.Document2;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field.Store;
-import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldTypes;
-import org.apache.lucene.document.NumericDocValuesField;
-import org.apache.lucene.document.SortedDocValuesField;
-import org.apache.lucene.document.SortedSetDocValuesField;
-import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
@@ -56,7 +48,6 @@ import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.NumericUtils;
import org.apache.lucene.util.TestUtil;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -98,7 +89,7 @@ public class TestFieldCache extends Luce
System.out.println("TEST: setUp");
}
for (int i = 0; i < NUM_DOCS; i++){
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addLong("theLong", theLong--);
doc.addDouble("theDouble", theDouble--);
doc.addInt("theInt", theInt--);
@@ -156,7 +147,7 @@ public class TestFieldCache extends Luce
}
@Override
public long parseValue(BytesRef term) {
- return Document2.sortableDoubleBits(Document2.bytesToLong(term));
+ return Document.sortableDoubleBits(Document.bytesToLong(term));
}
}, false);
assertTrue(bos.toString(IOUtils.UTF_8).indexOf("WARNING") != -1);
@@ -438,7 +429,7 @@ public class TestFieldCache extends Luce
FieldTypes fieldTypes = iw.getFieldTypes();
fieldTypes.setMultiValued("sortedset");
fieldTypes.disableSorting("binary");
- Document2 doc = iw.newDocument();
+ Document doc = iw.newDocument();
doc.addBinary("binary", new BytesRef("binary value"));
doc.addBinary("sorted", new BytesRef("sorted value"));
doc.addInt("numeric", -42);
@@ -572,7 +563,7 @@ public class TestFieldCache extends Luce
public void testNonexistantFields() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
- Document doc = new Document();
+ Document doc = iw.newDocument();
iw.addDocument(doc);
DirectoryReader ir = iw.getReader();
iw.close();
@@ -620,7 +611,7 @@ public class TestFieldCache extends Luce
public void testNonIndexedFields() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
- Document2 doc = iw.newDocument();
+ Document doc = iw.newDocument();
doc.addStored("bogusbytes", "bogus");
doc.addStored("bogusshorts", "bogus");
doc.addStored("bogusints", "bogus");
@@ -702,7 +693,7 @@ public class TestFieldCache extends Luce
break;
}
values[i] = v;
- Document2 doc = iw.newDocument();
+ Document doc = iw.newDocument();
if (v == 0 && random().nextBoolean()) {
// missing
} else {
@@ -748,7 +739,7 @@ public class TestFieldCache extends Luce
break;
}
values[i] = v;
- Document2 doc = iw.newDocument();
+ Document doc = iw.newDocument();
if (v == 0 && random().nextBoolean()) {
// missing
} else {
Modified: lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/uninverting/TestFieldCacheReopen.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/uninverting/TestFieldCacheReopen.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/uninverting/TestFieldCacheReopen.java (original)
+++ lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/uninverting/TestFieldCacheReopen.java Sun Nov 30 11:07:09 2014
@@ -18,9 +18,7 @@ package org.apache.lucene.uninverting;
*/
import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.document.Document2;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldTypes;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriter;
@@ -46,7 +44,7 @@ public class TestFieldCacheReopen extend
FieldTypes fieldTypes = writer.getFieldTypes();
fieldTypes.disableSorting("number");
- Document2 doc = writer.newDocument();
+ Document doc = writer.newDocument();
doc.addInt("number", 17);
writer.addDocument(doc);
writer.commit();
Modified: lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/uninverting/TestFieldCacheSanityChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/uninverting/TestFieldCacheSanityChecker.java?rev=1642535&r1=1642534&r2=1642535&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/uninverting/TestFieldCacheSanityChecker.java (original)
+++ lucene/dev/branches/lucene6005/lucene/misc/src/test/org/apache/lucene/uninverting/TestFieldCacheSanityChecker.java Sun Nov 30 11:07:09 2014
@@ -19,9 +19,7 @@ package org.apache.lucene.uninverting;
import java.io.IOException;
import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.document.Document2;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldTypes;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriter;
@@ -68,14 +66,14 @@ public class TestFieldCacheSanityChecker
float theFloat = Float.MAX_VALUE;
for (int i = 0; i < NUM_DOCS; i++){
if (0 == i % 3) {
- Document2 doc = wA.newDocument();
+ Document doc = wA.newDocument();
doc.addLong("theLong", theLong--);
doc.addDouble("theDouble", theDouble--);
doc.addInt("theInt", theInt--);
doc.addFloat("theFloat", theFloat--);
wA.addDocument(doc);
} else {
- Document2 doc = wB.newDocument();
+ Document doc = wB.newDocument();
doc.addLong("theLong", theLong--);
doc.addDouble("theDouble", theDouble--);
doc.addInt("theInt", theInt--);