Index: .
===================================================================
--- . (revision 1377246)
+++ . (working copy)
Property changes on: .
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312:r1357905-1377246
Index: dev-tools
===================================================================
--- dev-tools (revision 1377246)
+++ dev-tools (working copy)
Property changes on: dev-tools
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/dev-tools:r1357905-1377246
Index: lucene
===================================================================
--- lucene (revision 1377246)
+++ lucene (working copy)
Property changes on: lucene
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene:r1357905-1377246
Index: lucene/analysis
===================================================================
--- lucene/analysis (revision 1377246)
+++ lucene/analysis (working copy)
Property changes on: lucene/analysis
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/analysis:r1357905-1377246
Index: lucene/analysis/common
===================================================================
--- lucene/analysis/common (revision 1377246)
+++ lucene/analysis/common (working copy)
Property changes on: lucene/analysis/common
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/analysis/common:r1357905-1377246
Index: lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java
===================================================================
--- lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java (revision 1377246)
+++ lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java (working copy)
@@ -25,6 +25,7 @@
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.TopDocs;
@@ -79,7 +80,7 @@
IndexSearcher indexSearcher = new IndexSearcher(directoryReader);
TopDocs result = indexSearcher.search(new MatchAllDocsQuery(), 1);
assertTrue(result.totalHits > 0);
- Document d = indexSearcher.doc(result.scoreDocs[0].doc);
+ StoredDocument d = indexSearcher.doc(result.scoreDocs[0].doc);
assertNotNull(d);
assertNotNull(d.getField("title"));
assertEquals(dummyTitle, d.getField("title").stringValue());
@@ -99,7 +100,7 @@
directoryReader = DirectoryReader.open(dir);
indexSearcher = new IndexSearcher(directoryReader);
result = indexSearcher.search(new MatchAllDocsQuery(), 2);
- Document d1 = indexSearcher.doc(result.scoreDocs[1].doc);
+ StoredDocument d1 = indexSearcher.doc(result.scoreDocs[1].doc);
assertNotNull(d1);
assertNotNull(d1.getField("title"));
assertEquals(dogmasTitle, d1.getField("title").stringValue());
Index: lucene/benchmark
===================================================================
--- lucene/benchmark (revision 1377246)
+++ lucene/benchmark (working copy)
Property changes on: lucene/benchmark
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/benchmark:r1357905-1377246
Index: lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/DocMaker.java
===================================================================
--- lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/DocMaker.java (revision 1377246)
+++ lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/DocMaker.java (working copy)
@@ -226,11 +226,12 @@
final DocState ds = getDocState();
final Document doc = reuseFields ? ds.doc : new Document();
- doc.getFields().clear();
+ doc.clear();
// Set ID_FIELD
FieldType ft = new FieldType(valType);
ft.setIndexed(true);
+ ft.setStored(true);
Field idField = ds.getField(ID_FIELD, ft);
int id;
Index: lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/BenchmarkHighlighter.java
===================================================================
--- lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/BenchmarkHighlighter.java (revision 1377246)
+++ lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/BenchmarkHighlighter.java (working copy)
@@ -20,11 +20,12 @@
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.StoredDocument;
/**
* Abstract class for benchmarking highlighting performance
*/
public abstract class BenchmarkHighlighter {
public abstract int doHighlight( IndexReader reader, int doc, String field,
- Document document, Analyzer analyzer, String text ) throws Exception ;
+ StoredDocument document, Analyzer analyzer, String text ) throws Exception ;
}
Index: lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java
===================================================================
--- lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java (revision 1377246)
+++ lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java (working copy)
@@ -32,6 +32,8 @@
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.MultiFields;
+import org.apache.lucene.index.StorableField;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.search.Collector;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.MultiTermQuery;
@@ -96,7 +98,7 @@
// optionally warm and add num docs traversed to count
if (withWarm()) {
- Document doc = null;
+ StoredDocument doc = null;
Bits liveDocs = MultiFields.getLiveDocs(reader);
for (int m = 0; m < reader.maxDoc(); m++) {
if (null == liveDocs || liveDocs.get(m)) {
@@ -142,7 +144,7 @@
System.out.println("numDocs() = " + reader.numDocs());
for(int i=0;i 0 && m < numHighlight) {
Collection fieldsToHighlight = getFieldsToHighlight(document);
@@ -193,7 +195,7 @@
}
- protected Document retrieveDoc(IndexReader ir, int id) throws IOException {
+ protected StoredDocument retrieveDoc(IndexReader ir, int id) throws IOException {
return ir.document(id);
}
@@ -296,10 +298,10 @@
* @param document The Document
* @return A Collection of Field names (Strings)
*/
- protected Collection getFieldsToHighlight(Document document) {
- List fields = document.getFields();
+ protected Collection getFieldsToHighlight(StoredDocument document) {
+ List fields = document.getFields();
Set result = new HashSet(fields.size());
- for (final IndexableField f : fields) {
+ for (final StorableField f : fields) {
result.add(f.name());
}
return result;
Index: lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTokensTask.java
===================================================================
--- lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTokensTask.java (revision 1377246)
+++ lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTokensTask.java (working copy)
@@ -26,6 +26,7 @@
import org.apache.lucene.benchmark.byTask.PerfRunData;
import org.apache.lucene.benchmark.byTask.feeds.DocMaker;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
import org.apache.lucene.document.IntField;
import org.apache.lucene.document.LongField;
import org.apache.lucene.document.FloatField;
@@ -68,7 +69,7 @@
@Override
public int doLogic() throws Exception {
- List fields = doc.getFields();
+ List fields = doc.getFields();
Analyzer analyzer = getRunData().getAnalyzer();
int tokenCount = 0;
for(final IndexableField field : fields) {
Index: lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetHighlightTask.java
===================================================================
--- lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetHighlightTask.java (revision 1377246)
+++ lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetHighlightTask.java (working copy)
@@ -22,6 +22,7 @@
import org.apache.lucene.benchmark.byTask.PerfRunData;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.highlight.Highlighter;
import org.apache.lucene.search.highlight.QueryScorer;
@@ -101,7 +102,7 @@
return new BenchmarkHighlighter(){
@Override
public int doHighlight(IndexReader reader, int doc, String field,
- Document document, Analyzer analyzer, String text) throws Exception {
+ StoredDocument document, Analyzer analyzer, String text) throws Exception {
TokenStream ts = TokenSources.getAnyTokenStream(reader, doc, field, document, analyzer);
TextFragment[] frag = highlighter.getBestTextFragments(ts, text, mergeContiguous, maxFrags);
return frag != null ? frag.length : 0;
@@ -110,7 +111,7 @@
}
@Override
- protected Collection getFieldsToHighlight(Document document) {
+ protected Collection getFieldsToHighlight(StoredDocument document) {
Collection result = super.getFieldsToHighlight(document);
//if stored is false, then result will be empty, in which case just get all the param fields
if (paramFields.isEmpty() == false && result.isEmpty() == false) {
Index: lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetLoadFieldSelectorTask.java
===================================================================
--- lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetLoadFieldSelectorTask.java (revision 1377246)
+++ lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetLoadFieldSelectorTask.java (working copy)
@@ -25,6 +25,7 @@
import org.apache.lucene.document.Document;
import org.apache.lucene.document.DocumentStoredFieldVisitor;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.StoredDocument;
/**
* Search and Traverse and Retrieve docs task using a
@@ -54,7 +55,7 @@
@Override
- protected Document retrieveDoc(IndexReader ir, int id) throws IOException {
+ protected StoredDocument retrieveDoc(IndexReader ir, int id) throws IOException {
if (fieldsToLoad == null) {
return ir.document(id);
} else {
Index: lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetVectorHighlightTask.java
===================================================================
--- lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetVectorHighlightTask.java (revision 1377246)
+++ lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetVectorHighlightTask.java (working copy)
@@ -21,6 +21,7 @@
import org.apache.lucene.benchmark.byTask.PerfRunData;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.vectorhighlight.FastVectorHighlighter;
import org.apache.lucene.search.vectorhighlight.FieldQuery;
@@ -99,7 +100,7 @@
return new BenchmarkHighlighter(){
@Override
public int doHighlight(IndexReader reader, int doc, String field,
- Document document, Analyzer analyzer, String text) throws Exception {
+ StoredDocument document, Analyzer analyzer, String text) throws Exception {
final FieldQuery fq = highlighter.getFieldQuery( myq, reader);
String[] fragments = highlighter.getBestFragments(fq, reader, doc, field, fragSize, maxFrags);
return fragments != null ? fragments.length : 0;
@@ -108,7 +109,7 @@
}
@Override
- protected Collection getFieldsToHighlight(Document document) {
+ protected Collection getFieldsToHighlight(StoredDocument document) {
Collection result = super.getFieldsToHighlight(document);
//if stored is false, then result will be empty, in which case just get all the param fields
if (paramFields.isEmpty() == false && result.isEmpty() == false) {
Index: lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/WriteLineDocTask.java
===================================================================
--- lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/WriteLineDocTask.java (revision 1377246)
+++ lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/WriteLineDocTask.java (working copy)
@@ -33,6 +33,7 @@
import org.apache.lucene.benchmark.byTask.utils.StreamUtils;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.StorableField;
/**
* A task which writes documents, one line per document. Each line is in the
@@ -172,7 +173,7 @@
boolean sufficient = !checkSufficientFields;
for (int i=0; i0 && sufficientFields[i];
Index: lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CountingHighlighterTestTask.java
===================================================================
--- lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CountingHighlighterTestTask.java (revision 1377246)
+++ lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CountingHighlighterTestTask.java (working copy)
@@ -28,6 +28,7 @@
import org.apache.lucene.search.Query;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.StoredDocument;
import java.io.IOException;
@@ -44,8 +45,8 @@
}
@Override
- protected Document retrieveDoc(IndexReader ir, int id) throws IOException {
- Document document = ir.document(id);
+ protected StoredDocument retrieveDoc(IndexReader ir, int id) throws IOException {
+ StoredDocument document = ir.document(id);
if (document != null) {
numDocsRetrieved++;
}
@@ -57,7 +58,7 @@
highlighter = new Highlighter(new SimpleHTMLFormatter(), new QueryScorer(q));
return new BenchmarkHighlighter() {
@Override
- public int doHighlight(IndexReader reader, int doc, String field, Document document, Analyzer analyzer, String text) throws Exception {
+ public int doHighlight(IndexReader reader, int doc, String field, StoredDocument document, Analyzer analyzer, String text) throws Exception {
TokenStream ts = TokenSources.getAnyTokenStream(reader, doc, field, document, analyzer);
TextFragment[] frag = highlighter.getBestTextFragments(ts, text, mergeContiguous, maxFrags);
numHighlightedResults += frag != null ? frag.length : 0;
Index: lucene/build.xml
===================================================================
--- lucene/build.xml (revision 1377246)
+++ lucene/build.xml (working copy)
Property changes on: lucene/build.xml
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/build.xml:r1357905-1377246
Index: lucene/CHANGES.txt
===================================================================
--- lucene/CHANGES.txt (revision 1377246)
+++ lucene/CHANGES.txt (working copy)
Property changes on: lucene/CHANGES.txt
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/CHANGES.txt:r1357905-1377246
Index: lucene/common-build.xml
===================================================================
--- lucene/common-build.xml (revision 1377246)
+++ lucene/common-build.xml (working copy)
Property changes on: lucene/common-build.xml
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/common-build.xml:r1357905-1377246
Index: lucene/core
===================================================================
--- lucene/core (revision 1377246)
+++ lucene/core (working copy)
Property changes on: lucene/core
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/core:r1357905-1377246
Index: lucene/core/src/java/org/apache/lucene/analysis/package.html
===================================================================
--- lucene/core/src/java/org/apache/lucene/analysis/package.html (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/analysis/package.html (working copy)
@@ -168,7 +168,7 @@
At indexing, as a consequence of
- {@link org.apache.lucene.index.IndexWriter#addDocument(Iterable) addDocument(doc)},
+ {@link org.apache.lucene.index.IndexWriter#addDocument(IndexDocument) addDocument(doc)},
the Analyzer in effect for indexing is invoked for each indexed field of the added document.
@@ -241,7 +241,7 @@
Field Section Boundaries
- When {@link org.apache.lucene.document.Document#add(org.apache.lucene.index.IndexableField) document.add(field)}
+ When {@link org.apache.lucene.document.Document#add(org.apache.lucene.document.Field) document.add(field)}
is called multiple times for the same field name, we could say that each such call creates a new
section for that field in that document.
In fact, a separate call to
Index: lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java (working copy)
@@ -28,21 +28,23 @@
import org.apache.lucene.document.PackedLongDocValuesField;
import org.apache.lucene.document.ShortDocValuesField;
import org.apache.lucene.document.SortedBytesDocValuesField;
+import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.StraightBytesDocValuesField;
import org.apache.lucene.index.AtomicReader;
import org.apache.lucene.index.DocValues.Source;
import org.apache.lucene.index.DocValues.Type;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.StorableField;
import org.apache.lucene.index.MergeState;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
/**
- * Abstract API that consumes {@link IndexableField}s.
+ * Abstract API that consumes {@link StorableField}s.
* {@link DocValuesConsumer} are always associated with a specific field and
* segments. Concrete implementations of this API write the given
- * {@link IndexableField} into a implementation specific format depending on
+ * {@link StorableField} into a implementation specific format depending on
* the fields meta-data.
*
* @lucene.experimental
@@ -53,7 +55,7 @@
protected abstract Type getType();
/**
- * Adds the given {@link IndexableField} instance to this
+ * Adds the given {@link StorableField} instance to this
* {@link DocValuesConsumer}
*
* @param docID
@@ -64,7 +66,7 @@
* @throws IOException
* if an {@link IOException} occurs
*/
- public abstract void add(int docID, IndexableField value)
+ public abstract void add(int docID, StorableField value)
throws IOException;
/**
@@ -73,7 +75,7 @@
* @param docCount
* the total number of documents in this {@link DocValuesConsumer}.
* Must be greater than or equal the last given docID to
- * {@link #add(int, IndexableField)}.
+ * {@link #add(int, StorableField)}.
* @throws IOException
*/
public abstract void finish(int docCount) throws IOException;
@@ -136,7 +138,7 @@
assert source != null;
int docID = docBase;
final Type type = getType();
- final Field scratchField;
+ final StoredField scratchField;
switch(type) {
case VAR_INTS:
scratchField = new PackedLongDocValuesField("", (long) 0);
@@ -202,7 +204,7 @@
* ID must always be greater than the previous ID or 0 if called the
* first time.
*/
- protected void mergeDoc(Field scratchField, Source source, int docID, int sourceDoc)
+ protected void mergeDoc(StoredField scratchField, Source source, int docID, int sourceDoc)
throws IOException {
switch(getType()) {
case BYTES_FIXED_DEREF:
Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsWriter.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsWriter.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsWriter.java (working copy)
@@ -29,6 +29,8 @@
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.MergeState;
import org.apache.lucene.index.SegmentReader;
+import org.apache.lucene.index.StorableField;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
@@ -131,7 +133,7 @@
IndexFileNames.segmentFileName(segment, "", FIELDS_INDEX_EXTENSION));
}
- public void writeField(FieldInfo info, IndexableField field) throws IOException {
+ public void writeField(FieldInfo info, StorableField field) throws IOException {
fieldsStream.writeVInt(info.number);
int bits = 0;
final BytesRef bytes;
@@ -297,7 +299,7 @@
// on the fly?
// NOTE: it's very important to first assign to doc then pass it to
// fieldsWriter.addDocument; see LUCENE-1282
- Document doc = reader.document(j);
+ StoredDocument doc = reader.document(j);
addDocument(doc, mergeState.fieldInfos);
docCount++;
mergeState.checkAbort.work(300);
@@ -324,7 +326,7 @@
for (; docCount < maxDoc; docCount++) {
// NOTE: it's very important to first assign to doc then pass it to
// fieldsWriter.addDocument; see LUCENE-1282
- Document doc = reader.document(docCount);
+ StoredDocument doc = reader.document(docCount);
addDocument(doc, mergeState.fieldInfos);
mergeState.checkAbort.work(300);
}
Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Bytes.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Bytes.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Bytes.java (working copy)
@@ -30,6 +30,7 @@
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.IndexFileNames;
import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.StorableField;
import org.apache.lucene.store.DataOutput;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
@@ -420,7 +421,7 @@
}
@Override
- public void add(int docID, IndexableField value) throws IOException {
+ public void add(int docID, StorableField value) throws IOException {
BytesRef bytes = value.binaryValue();
assert bytes != null;
if (bytes.length == 0) { // default value - skip it
Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/FixedStraightBytesImpl.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/FixedStraightBytesImpl.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/FixedStraightBytesImpl.java (working copy)
@@ -22,12 +22,12 @@
import org.apache.lucene.codecs.lucene40.values.Bytes.BytesReaderBase;
import org.apache.lucene.codecs.lucene40.values.Bytes.BytesSourceBase;
import org.apache.lucene.codecs.lucene40.values.Bytes.BytesWriterBase;
+import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.StraightBytesDocValuesField;
-import org.apache.lucene.document.Field;
import org.apache.lucene.index.DocValues.Source;
import org.apache.lucene.index.DocValues.Type;
import org.apache.lucene.index.DocValues;
-import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.StorableField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
@@ -74,7 +74,7 @@
}
@Override
- public void add(int docID, IndexableField value) throws IOException {
+ public void add(int docID, StorableField value) throws IOException {
final BytesRef bytes = value.binaryValue();
assert bytes != null;
assert lastDocID < docID;
@@ -201,7 +201,7 @@
}
@Override
- protected void mergeDoc(Field scratchField, Source source, int docID, int sourceDoc) throws IOException {
+ protected void mergeDoc(StoredField scratchField, Source source, int docID, int sourceDoc) throws IOException {
assert lastDocID < docID;
setMergeBytes(source, sourceDoc);
if (size == -1) {
Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Floats.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Floats.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Floats.java (working copy)
@@ -24,6 +24,7 @@
import org.apache.lucene.index.DocValues.Type;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.StorableField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
@@ -88,7 +89,7 @@
}
@Override
- public void add(int docID, IndexableField value) throws IOException {
+ public void add(int docID, StorableField value) throws IOException {
template.toBytes(value.numericValue().doubleValue(), bytesRef);
bytesSpareField.setBytesValue(bytesRef);
super.add(docID, bytesSpareField);
Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Ints.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Ints.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Ints.java (working copy)
@@ -25,6 +25,7 @@
import org.apache.lucene.index.DocValues.Type;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.StorableField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
@@ -112,7 +113,7 @@
}
@Override
- public void add(int docID, IndexableField value) throws IOException {
+ public void add(int docID, StorableField value) throws IOException {
template.toBytes(value.numericValue().longValue(), bytesRef);
bytesSpareField.setBytesValue(bytesRef);
super.add(docID, bytesSpareField);
Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/PackedIntValues.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/PackedIntValues.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/PackedIntValues.java (working copy)
@@ -26,6 +26,7 @@
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.IndexFileNames;
import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.StorableField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
@@ -126,7 +127,7 @@
}
@Override
- public void add(int docID, IndexableField docValue) throws IOException {
+ public void add(int docID, StorableField docValue) throws IOException {
final long v = docValue.numericValue().longValue();
assert lastDocId < docID;
if (!started) {
Index: lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/VarStraightBytesImpl.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/VarStraightBytesImpl.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/VarStraightBytesImpl.java (working copy)
@@ -22,11 +22,11 @@
import org.apache.lucene.codecs.lucene40.values.Bytes.BytesReaderBase;
import org.apache.lucene.codecs.lucene40.values.Bytes.BytesSourceBase;
import org.apache.lucene.codecs.lucene40.values.Bytes.BytesWriterBase;
-import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.DocValues.Source;
import org.apache.lucene.index.DocValues.Type;
import org.apache.lucene.index.DocValues;
-import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.StorableField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
@@ -86,7 +86,7 @@
}
@Override
- public void add(int docID, IndexableField value) throws IOException {
+ public void add(int docID, StorableField value) throws IOException {
final BytesRef bytes = value.binaryValue();
assert bytes != null;
assert !merge;
@@ -156,7 +156,7 @@
}
@Override
- protected void mergeDoc(Field scratchField, Source source, int docID, int sourceDoc) throws IOException {
+ protected void mergeDoc(StoredField scratchField, Source source, int docID, int sourceDoc) throws IOException {
assert merge;
assert lastDocID < docID;
source.getBytes(sourceDoc, bytesRef);
Index: lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesConsumer.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesConsumer.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesConsumer.java (working copy)
@@ -21,7 +21,7 @@
import org.apache.lucene.codecs.DocValuesConsumer;
import org.apache.lucene.index.DocValues.Type;
import org.apache.lucene.index.IndexFileNames;
-import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.StorableField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexOutput;
@@ -72,7 +72,7 @@
}
@Override
- public void add(int docID, IndexableField value) throws IOException {
+ public void add(int docID, StorableField value) throws IOException {
assert docID >= 0;
final int ord, vSize;
switch (type) {
Index: lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsWriter.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsWriter.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsWriter.java (working copy)
@@ -23,7 +23,7 @@
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.IndexFileNames;
-import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.StorableField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexOutput;
@@ -89,7 +89,7 @@
}
@Override
- public void writeField(FieldInfo info, IndexableField field) throws IOException {
+ public void writeField(FieldInfo info, StorableField field) throws IOException {
write(FIELD);
write(Integer.toString(info.number));
newLine();
Index: lucene/core/src/java/org/apache/lucene/codecs/StoredFieldsWriter.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/codecs/StoredFieldsWriter.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/codecs/StoredFieldsWriter.java (working copy)
@@ -19,13 +19,13 @@
import java.io.Closeable;
import java.io.IOException;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.index.AtomicReader;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.FieldInfos;
-import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.MergeState;
+import org.apache.lucene.index.StorableField;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.util.Bits;
+import org.apache.lucene.index.AtomicReader;
/**
* Codec API for writing stored fields:
@@ -33,7 +33,7 @@
*
*
For every document, {@link #startDocument(int)} is called,
* informing the Codec how many fields will be written.
- *
{@link #writeField(FieldInfo, IndexableField)} is called for
+ *
{@link #writeField(FieldInfo, StorableField)} is called for
* each field in the document.
*
After all documents have been written, {@link #finish(FieldInfos, int)}
* is called for verification/sanity-checks.
@@ -45,14 +45,14 @@
public abstract class StoredFieldsWriter implements Closeable {
/** Called before writing the stored fields of the document.
- * {@link #writeField(FieldInfo, IndexableField)} will be called
+ * {@link #writeField(FieldInfo, StorableField)} will be called
* numStoredFields times. Note that this is
* called even if the document has no stored fields, in
* this case numStoredFields will be zero. */
public abstract void startDocument(int numStoredFields) throws IOException;
/** Writes a single stored field. */
- public abstract void writeField(FieldInfo info, IndexableField field) throws IOException;
+ public abstract void writeField(FieldInfo info, StorableField field) throws IOException;
/** Aborts writing entirely, implementation should remove
* any partially-written files, etc. */
@@ -69,7 +69,7 @@
/** Merges in the stored fields from the readers in
* mergeState. The default implementation skips
* over deleted documents, and uses {@link #startDocument(int)},
- * {@link #writeField(FieldInfo, IndexableField)}, and {@link #finish(FieldInfos, int)},
+ * {@link #writeField(FieldInfo, StorableField)}, and {@link #finish(FieldInfos, int)},
* returning the number of documents that were written.
* Implementations can override this method for more sophisticated
* merging (bulk-byte copying, etc). */
@@ -89,7 +89,7 @@
// on the fly?
// NOTE: it's very important to first assign to doc then pass it to
// fieldsWriter.addDocument; see LUCENE-1282
- Document doc = reader.document(i);
+ StoredDocument doc = reader.document(i);
addDocument(doc, mergeState.fieldInfos);
docCount++;
mergeState.checkAbort.work(300);
@@ -100,20 +100,16 @@
}
/** sugar method for startDocument() + writeField() for every stored field in the document */
- protected final void addDocument(Iterable extends IndexableField> doc, FieldInfos fieldInfos) throws IOException {
+ protected final void addDocument(Iterable extends StorableField> doc, FieldInfos fieldInfos) throws IOException {
int storedCount = 0;
- for (IndexableField field : doc) {
- if (field.fieldType().stored()) {
- storedCount++;
- }
+ for (StorableField field : doc) {
+ storedCount++;
}
startDocument(storedCount);
- for (IndexableField field : doc) {
- if (field.fieldType().stored()) {
+ for (StorableField field : doc) {
writeField(fieldInfos.fieldInfo(field.name()), field);
- }
}
}
}
Index: lucene/core/src/java/org/apache/lucene/document/ByteDocValuesField.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/document/ByteDocValuesField.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/document/ByteDocValuesField.java (working copy)
@@ -36,7 +36,7 @@
* @see DocValues for further information
* */
-public class ByteDocValuesField extends Field {
+public class ByteDocValuesField extends StoredField {
public static final FieldType TYPE = new FieldType();
static {
Index: lucene/core/src/java/org/apache/lucene/document/DerefBytesDocValuesField.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/document/DerefBytesDocValuesField.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/document/DerefBytesDocValuesField.java (working copy)
@@ -41,7 +41,7 @@
* @see DocValues for further information
* */
-public class DerefBytesDocValuesField extends Field {
+public class DerefBytesDocValuesField extends StoredField {
// TODO: ideally indexer figures out var vs fixed on its own!?
public static final FieldType TYPE_FIXED_LEN = new FieldType();
Index: lucene/core/src/java/org/apache/lucene/document/Document.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/document/Document.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/document/Document.java (working copy)
@@ -19,11 +19,15 @@
import java.util.*;
+import org.apache.lucene.index.IndexDocument;
import org.apache.lucene.index.IndexReader; // for javadoc
import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.StorableField;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.search.IndexSearcher; // for javadoc
import org.apache.lucene.search.ScoreDoc; // for javadoc
import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.FilterIterator;
/** Documents are the unit of indexing and search.
*
@@ -38,18 +42,38 @@
* ScoreDoc#doc} or {@link IndexReader#document(int)}.
*/
-public final class Document implements Iterable {
+public final class Document implements IndexDocument{
- private final List fields = new ArrayList();
+ private final List fields = new ArrayList();
+
+ //private final List fields
/** Constructs a new document with no fields. */
public Document() {}
+
- @Override
- public Iterator iterator() {
- return fields.iterator();
- }
+ /**
+ * Creates a Document from StoredDocument so it that can be used e.g. for another
+ * round of indexing.
+ *
+ */
+ public Document(StoredDocument storedDoc) {
+ for (StorableField field : storedDoc.getFields()) {
+ Field newField = new Field(field.name(), (FieldType) field.fieldType());
+
+ newField.fieldsData = field.stringValue();
+ if (newField.fieldsData == null)
+ newField.fieldsData = field.numericValue();
+ if (newField.fieldsData == null)
+ newField.fieldsData = field.binaryValue();
+ if (newField.fieldsData == null)
+ newField.fieldsData = field.readerValue();
+
+ add(newField);
+ }
+ }
+
/**
*
Adds a field to a document. Several fields may be added with
* the same name. In this case, if the fields are indexed, their text is
@@ -60,7 +84,7 @@
* a document has to be deleted from an index and a new changed version of that
* document has to be added.
*/
- public final void add(IndexableField field) {
+ public final void add(Field field) {
fields.add(field);
}
@@ -75,9 +99,9 @@
* document has to be added.
*/
public final void removeField(String name) {
- Iterator it = fields.iterator();
+ Iterator it = fields.iterator();
while (it.hasNext()) {
- IndexableField field = it.next();
+ Field field = it.next();
if (field.name().equals(name)) {
it.remove();
return;
@@ -95,9 +119,9 @@
* document has to be added.
*/
public final void removeFields(String name) {
- Iterator it = fields.iterator();
+ Iterator it = fields.iterator();
while (it.hasNext()) {
- IndexableField field = it.next();
+ Field field = it.next();
if (field.name().equals(name)) {
it.remove();
}
@@ -116,7 +140,10 @@
*/
public final BytesRef[] getBinaryValues(String name) {
final List result = new ArrayList();
- for (IndexableField field : fields) {
+ Iterator it = storedFieldsIterator();
+
+ while (it.hasNext()) {
+ StorableField field = it.next();
if (field.name().equals(name)) {
final BytesRef bytes = field.binaryValue();
if (bytes != null) {
@@ -138,7 +165,10 @@
* @return a byte[] containing the binary field value or null
*/
public final BytesRef getBinaryValue(String name) {
- for (IndexableField field : fields) {
+ Iterator it = storedFieldsIterator();
+
+ while (it.hasNext()) {
+ StorableField field = it.next();
if (field.name().equals(name)) {
final BytesRef bytes = field.binaryValue();
if (bytes != null) {
@@ -153,8 +183,8 @@
* null. If multiple fields exists with this name, this method returns the
* first value added.
*/
- public final IndexableField getField(String name) {
- for (IndexableField field : fields) {
+ public final Field getField(String name) {
+ for (Field field : fields) {
if (field.name().equals(name)) {
return field;
}
@@ -170,15 +200,15 @@
* @param name the name of the field
* @return a Fieldable[] array
*/
- public IndexableField[] getFields(String name) {
- List result = new ArrayList();
- for (IndexableField field : fields) {
+ public Field[] getFields(String name) {
+ List result = new ArrayList();
+ for (Field field : fields) {
if (field.name().equals(name)) {
result.add(field);
}
}
- return result.toArray(new IndexableField[result.size()]);
+ return result.toArray(new Field[result.size()]);
}
/** Returns a List of all the fields in a document.
@@ -186,9 +216,11 @@
* not available in documents retrieved from the
* index, e.g. {@link IndexSearcher#doc(int)} or {@link
* IndexReader#document(int)}.
+ *
+ * @return an immutable List[Field]
*/
- public final List getFields() {
- return fields;
+ public final List getFields() {
+ return Collections.unmodifiableList(fields);
}
private final static String[] NO_STRINGS = new String[0];
@@ -205,7 +237,10 @@
*/
public final String[] getValues(String name) {
List result = new ArrayList();
- for (IndexableField field : fields) {
+ Iterator it = storedFieldsIterator();
+
+ while (it.hasNext()) {
+ StorableField field = it.next();
if (field.name().equals(name) && field.stringValue() != null) {
result.add(field.stringValue());
}
@@ -227,7 +262,10 @@
* the actual numeric field instance back, use {@link #getField}.
*/
public final String get(String name) {
- for (IndexableField field : fields) {
+ Iterator it = storedFieldsIterator();
+
+ while (it.hasNext()) {
+ StorableField field = it.next();
if (field.name().equals(name) && field.stringValue() != null) {
return field.stringValue();
}
@@ -249,4 +287,54 @@
buffer.append(">");
return buffer.toString();
}
+
+ /** Obtains all indexed fields in document */
+ @Override
+ public Iterable extends IndexableField> indexableFields() {
+ Iterator it = indexedFieldsIterator();
+
+ List result = new ArrayList();
+ while(it.hasNext()) {
+ result.add(it.next());
+ }
+
+ return result;
+ }
+
+
+ /** Obtains all stored fields in document. */
+ @Override
+ public Iterable extends StorableField> storableFields() {
+ Iterator it = storedFieldsIterator();
+
+ List result = new ArrayList();
+ while(it.hasNext()) {
+ result.add(it.next());
+ }
+
+ return result;
+ }
+
+ private Iterator storedFieldsIterator() {
+ return new FilterIterator(fields.iterator()) {
+ @Override
+ protected boolean predicateFunction(Field field) {
+ return field.type.stored();
+ }
+ };
+ }
+
+ private Iterator indexedFieldsIterator() {
+ return new FilterIterator(fields.iterator()) {
+ @Override
+ protected boolean predicateFunction(Field field) {
+ return field.type.indexed();
+ }
+ };
+ }
+
+ /** Removes all the fields from document. */
+ public void clear() {
+ fields.clear();
+ }
}
Index: lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java (working copy)
@@ -23,6 +23,7 @@
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.index.StoredFieldVisitor;
/** A {@link StoredFieldVisitor} that creates a {@link
@@ -35,7 +36,7 @@
* @lucene.experimental */
public class DocumentStoredFieldVisitor extends StoredFieldVisitor {
- private final Document doc = new Document();
+ private final StoredDocument doc = new StoredDocument();
private final Set fieldsToAdd;
/** Load only fields named in the provided Set<String>. */
@@ -68,7 +69,7 @@
ft.setIndexed(fieldInfo.isIndexed());
ft.setOmitNorms(fieldInfo.omitsNorms());
ft.setIndexOptions(fieldInfo.getIndexOptions());
- doc.add(new Field(fieldInfo.name, value, ft));
+ doc.add(new StoredField(fieldInfo.name, value, ft));
}
@Override
@@ -96,7 +97,7 @@
return fieldsToAdd == null || fieldsToAdd.contains(fieldInfo.name) ? Status.YES : Status.NO;
}
- public Document getDocument() {
+ public StoredDocument getDocument() {
return doc;
}
}
Index: lucene/core/src/java/org/apache/lucene/document/DoubleDocValuesField.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/document/DoubleDocValuesField.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/document/DoubleDocValuesField.java (working copy)
@@ -36,7 +36,7 @@
* @see DocValues for further information
* */
-public class DoubleDocValuesField extends Field {
+public class DoubleDocValuesField extends StoredField {
public static final FieldType TYPE = new FieldType();
static {
Index: lucene/core/src/java/org/apache/lucene/document/Field.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/document/Field.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/document/Field.java (working copy)
@@ -30,6 +30,7 @@
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.IndexableFieldType;
import org.apache.lucene.index.Norm; // javadocs
+import org.apache.lucene.index.StorableField;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.index.FieldInvertState; // javadocs
@@ -58,7 +59,7 @@
* Field it is used in. It is strongly recommended that no
* changes be made after Field instantiation.
*/
-public class Field implements IndexableField {
+public class Field implements IndexableField, StorableField {
protected final FieldType type;
protected final String name;
Index: lucene/core/src/java/org/apache/lucene/document/FieldType.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/document/FieldType.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/document/FieldType.java (working copy)
@@ -26,7 +26,7 @@
/**
* Describes the properties of a field.
*/
-public class FieldType implements IndexableFieldType {
+public class FieldType implements IndexableFieldType {
/** Data type of the numeric value
* @since 3.2
@@ -42,10 +42,10 @@
private boolean storeTermVectorPayloads;
private boolean omitNorms;
private IndexOptions indexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
- private DocValues.Type docValueType;
private NumericType numericType;
private boolean frozen;
private int numericPrecisionStep = NumericUtils.PRECISION_STEP_DEFAULT;
+ private DocValues.Type docValueType;
public FieldType(FieldType ref) {
this.indexed = ref.indexed();
@@ -161,16 +161,6 @@
this.indexOptions = value;
}
- public void setDocValueType(DocValues.Type type) {
- checkIfFrozen();
- docValueType = type;
- }
-
- @Override
- public DocValues.Type docValueType() {
- return docValueType;
- }
-
public void setNumericType(NumericType type) {
checkIfFrozen();
numericType = type;
@@ -246,4 +236,17 @@
return result.toString();
}
+
+ /* from StorableFieldType */
+
+ @Override
+ public DocValues.Type docValueType() {
+ return docValueType;
+ }
+
+ public void setDocValueType(DocValues.Type type) {
+ checkIfFrozen();
+ docValueType = type;
+ this.stored = true;
+ }
}
Index: lucene/core/src/java/org/apache/lucene/document/FloatDocValuesField.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/document/FloatDocValuesField.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/document/FloatDocValuesField.java (working copy)
@@ -35,7 +35,7 @@
* @see DocValues for further information
* */
-public class FloatDocValuesField extends Field {
+public class FloatDocValuesField extends StoredField {
public static final FieldType TYPE = new FieldType();
static {
Index: lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java (working copy)
@@ -35,7 +35,7 @@
* @see DocValues for further information
* */
-public class IntDocValuesField extends Field {
+public class IntDocValuesField extends StoredField {
public static final FieldType TYPE = new FieldType();
static {
Index: lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java (working copy)
@@ -35,7 +35,7 @@
* @see DocValues for further information
* */
-public class LongDocValuesField extends Field {
+public class LongDocValuesField extends StoredField {
public static final FieldType TYPE = new FieldType();
static {
Index: lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java (working copy)
@@ -39,11 +39,12 @@
* @see DocValues for further information
* */
-public class PackedLongDocValuesField extends Field {
+public class PackedLongDocValuesField extends StoredField {
public static final FieldType TYPE = new FieldType();
static {
TYPE.setDocValueType(DocValues.Type.VAR_INTS);
+ TYPE.setStored(true);
TYPE.freeze();
}
Index: lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java (working copy)
@@ -36,7 +36,7 @@
* @see DocValues for further information
* */
-public class ShortDocValuesField extends Field {
+public class ShortDocValuesField extends StoredField {
public static final FieldType TYPE = new FieldType();
static {
Index: lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java (working copy)
@@ -37,7 +37,7 @@
* @see DocValues for further information
* */
-public class SortedBytesDocValuesField extends Field {
+public class SortedBytesDocValuesField extends StoredField {
// TODO: ideally indexer figures out var vs fixed on its own!?
public static final FieldType TYPE_FIXED_LEN = new FieldType();
Index: lucene/core/src/java/org/apache/lucene/document/StoredField.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/document/StoredField.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/document/StoredField.java (working copy)
@@ -1,6 +1,7 @@
package org.apache.lucene.document;
import org.apache.lucene.index.IndexReader; // javadocs
+import org.apache.lucene.index.StorableField;
import org.apache.lucene.search.IndexSearcher; // javadocs
import org.apache.lucene.util.BytesRef;
@@ -24,7 +25,7 @@
/** A field whose value is stored so that {@link
* IndexSearcher#doc} and {@link IndexReader#document} will
* return the field and its value. */
-public final class StoredField extends Field {
+public class StoredField extends Field {
public final static FieldType TYPE;
static {
@@ -33,6 +34,14 @@
TYPE.freeze();
}
+ protected StoredField(String name, FieldType type) {
+ super(name, type);
+ }
+
+ public StoredField(String name, BytesRef bytes, FieldType type) {
+ super(name, bytes, type);
+ }
+
public StoredField(String name, byte[] value) {
super(name, value, TYPE);
}
@@ -48,6 +57,10 @@
public StoredField(String name, String value) {
super(name, value, TYPE);
}
+
+ public StoredField(String name, String value, FieldType type) {
+ super(name, value, type);
+ }
// TODO: not great but maybe not a big problem?
public StoredField(String name, int value) {
Index: lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java (working copy)
@@ -40,7 +40,7 @@
* @see DocValues for further information
* */
-public class StraightBytesDocValuesField extends Field {
+public class StraightBytesDocValuesField extends StoredField {
// TODO: ideally indexer figures out var vs fixed on its own!?
public static final FieldType TYPE_FIXED_LEN = new FieldType();
Index: lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/CheckIndex.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/index/CheckIndex.java (working copy)
@@ -1180,7 +1180,7 @@
for (int j = 0; j < info.info.getDocCount(); ++j) {
// Intentionally pull even deleted documents to
// make sure they too are not corrupt:
- Document doc = reader.document(j);
+ StoredDocument doc = reader.document(j);
if (liveDocs == null || liveDocs.get(j)) {
status.docCount++;
status.totFields += doc.getFields().size();
Index: lucene/core/src/java/org/apache/lucene/index/DocFieldProcessor.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/DocFieldProcessor.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/index/DocFieldProcessor.java (working copy)
@@ -28,6 +28,7 @@
import org.apache.lucene.codecs.DocValuesConsumer;
import org.apache.lucene.codecs.FieldInfosWriter;
import org.apache.lucene.codecs.PerDocConsumer;
+import org.apache.lucene.document.FieldType;
import org.apache.lucene.index.DocumentsWriterPerThread.DocState;
import org.apache.lucene.index.TypePromoter.TypeCompatibility;
import org.apache.lucene.store.IOContext;
@@ -218,58 +219,21 @@
// seen before (eg suddenly turning on norms or
// vectors, etc.):
- for(IndexableField field : docState.doc) {
+ for(IndexableField field : docState.doc.indexableFields()) {
final String fieldName = field.name();
+ IndexableFieldType ft = field.fieldType();
- // Make sure we have a PerField allocated
- final int hashPos = fieldName.hashCode() & hashMask;
- DocFieldProcessorPerField fp = fieldHash[hashPos];
- while(fp != null && !fp.fieldInfo.name.equals(fieldName)) {
- fp = fp.next;
- }
+ DocFieldProcessorPerField fp = processField(fieldInfos, thisFieldGen, fieldName, ft);
- if (fp == null) {
-
- // TODO FI: we need to genericize the "flags" that a
- // field holds, and, how these flags are merged; it
- // needs to be more "pluggable" such that if I want
- // to have a new "thing" my Fields can do, I can
- // easily add it
- FieldInfo fi = fieldInfos.addOrUpdate(fieldName, field.fieldType());
-
- fp = new DocFieldProcessorPerField(this, fi);
- fp.next = fieldHash[hashPos];
- fieldHash[hashPos] = fp;
- totalFieldCount++;
-
- if (totalFieldCount >= fieldHash.length/2) {
- rehash();
- }
- } else {
- fieldInfos.addOrUpdate(fp.fieldInfo.name, field.fieldType());
- }
-
- if (thisFieldGen != fp.lastGen) {
-
- // First time we're seeing this field for this doc
- fp.fieldCount = 0;
-
- if (fieldCount == fields.length) {
- final int newSize = fields.length*2;
- DocFieldProcessorPerField newArray[] = new DocFieldProcessorPerField[newSize];
- System.arraycopy(fields, 0, newArray, 0, fieldCount);
- fields = newArray;
- }
-
- fields[fieldCount++] = fp;
- fp.lastGen = thisFieldGen;
- }
-
fp.addField(field);
+ }
+ for (StorableField field: docState.doc.storableFields()) {
+ final String fieldName = field.name();
+ IndexableFieldType ft = field.fieldType();
- if (field.fieldType().stored()) {
- fieldsWriter.addField(field, fp.fieldInfo);
- }
+ DocFieldProcessorPerField fp = processField(fieldInfos, thisFieldGen, fieldName, ft);
+ fieldsWriter.addField(field, fp.fieldInfo);
+
final DocValues.Type dvType = field.fieldType().docValueType();
if (dvType != null) {
DocValuesConsumerHolder docValuesConsumer = docValuesConsumer(dvType,
@@ -313,6 +277,54 @@
}
}
+ private DocFieldProcessorPerField processField(FieldInfos.Builder fieldInfos,
+ final int thisFieldGen, final String fieldName, IndexableFieldType ft) {
+ // Make sure we have a PerField allocated
+ final int hashPos = fieldName.hashCode() & hashMask;
+ DocFieldProcessorPerField fp = fieldHash[hashPos];
+ while(fp != null && !fp.fieldInfo.name.equals(fieldName)) {
+ fp = fp.next;
+ }
+
+ if (fp == null) {
+
+ // TODO FI: we need to genericize the "flags" that a
+ // field holds, and, how these flags are merged; it
+ // needs to be more "pluggable" such that if I want
+ // to have a new "thing" my Fields can do, I can
+ // easily add it
+ FieldInfo fi = fieldInfos.addOrUpdate(fieldName, ft);
+
+ fp = new DocFieldProcessorPerField(this, fi);
+ fp.next = fieldHash[hashPos];
+ fieldHash[hashPos] = fp;
+ totalFieldCount++;
+
+ if (totalFieldCount >= fieldHash.length/2) {
+ rehash();
+ }
+ } else {
+ fieldInfos.addOrUpdate(fp.fieldInfo.name, ft);
+ }
+
+ if (thisFieldGen != fp.lastGen) {
+
+ // First time we're seeing this field for this doc
+ fp.fieldCount = 0;
+
+ if (fieldCount == fields.length) {
+ final int newSize = fields.length*2;
+ DocFieldProcessorPerField newArray[] = new DocFieldProcessorPerField[newSize];
+ System.arraycopy(fields, 0, newArray, 0, fieldCount);
+ fields = newArray;
+ }
+
+ fields[fieldCount++] = fp;
+ fp.lastGen = thisFieldGen;
+ }
+ return fp;
+ }
+
private static final Comparator fieldsComp = new Comparator() {
public int compare(DocFieldProcessorPerField o1, DocFieldProcessorPerField o2) {
return o1.fieldInfo.name.compareTo(o2.fieldInfo.name);
Index: lucene/core/src/java/org/apache/lucene/index/DocInverterPerField.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/DocInverterPerField.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/index/DocInverterPerField.java (working copy)
@@ -75,7 +75,7 @@
// TODO FI: this should be "genericized" to querying
// consumer if it wants to see this particular field
// tokenized.
- if (fieldType.indexed() && doInvert) {
+ if (doInvert) {
final boolean analyzed = fieldType.tokenized() && docState.analyzer != null;
// if the field omits norms, the boost cannot be indexed.
Index: lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java (working copy)
@@ -321,7 +321,7 @@
return maybeMerge;
}
- boolean updateDocuments(final Iterable extends Iterable extends IndexableField>> docs, final Analyzer analyzer,
+ boolean updateDocuments(final Iterable extends IndexDocument> docs, final Analyzer analyzer,
final Term delTerm) throws IOException {
boolean maybeMerge = preUpdate();
@@ -352,7 +352,7 @@
return postUpdate(flushingDWPT, maybeMerge);
}
- boolean updateDocument(final Iterable extends IndexableField> doc, final Analyzer analyzer,
+ boolean updateDocument(final IndexDocument doc, final Analyzer analyzer,
final Term delTerm) throws IOException {
boolean maybeMerge = preUpdate();
Index: lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java (working copy)
@@ -94,7 +94,7 @@
InfoStream infoStream;
Similarity similarity;
int docID;
- Iterable extends IndexableField> doc;
+ IndexDocument doc;
String maxTermPrefix;
DocState(DocumentsWriterPerThread docWriter, InfoStream infoStream) {
@@ -225,7 +225,7 @@
return retval;
}
- public void updateDocument(Iterable extends IndexableField> doc, Analyzer analyzer, Term delTerm) throws IOException {
+ public void updateDocument(IndexDocument doc, Analyzer analyzer, Term delTerm) throws IOException {
assert writer.testPoint("DocumentsWriterPerThread addDocument start");
assert deleteQueue != null;
docState.doc = doc;
@@ -278,7 +278,7 @@
}
}
- public int updateDocuments(Iterable extends Iterable extends IndexableField>> docs, Analyzer analyzer, Term delTerm) throws IOException {
+ public int updateDocuments(Iterable extends IndexDocument> docs, Analyzer analyzer, Term delTerm) throws IOException {
assert writer.testPoint("DocumentsWriterPerThread addDocuments start");
assert deleteQueue != null;
docState.analyzer = analyzer;
@@ -290,7 +290,7 @@
}
int docCount = 0;
try {
- for(Iterable extends IndexableField> doc : docs) {
+ for(IndexDocument doc : docs) {
docState.doc = doc;
docState.docID = numDocsInRAM;
docCount++;
Index: lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java (working copy)
@@ -103,12 +103,7 @@
@Override
boolean start(IndexableField[] fields, int count) {
- for(int i=0;i indexableFields();
+
+ /** Obtains all storable fields in document */
+ public Iterable extends StorableField> storableFields();
+}
Index: lucene/core/src/java/org/apache/lucene/index/IndexDocument.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/IndexDocument.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/index/IndexDocument.java (working copy)
Property changes on: lucene/core/src/java/org/apache/lucene/index/IndexDocument.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Date Author Id Revision HeadURL
\ No newline at end of property
Index: lucene/core/src/java/org/apache/lucene/index/IndexReader.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/IndexReader.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/index/IndexReader.java (working copy)
@@ -341,7 +341,7 @@
// TODO: we need a separate StoredField, so that the
// Document returned here contains that class not
// IndexableField
- public final Document document(int docID) throws IOException {
+ public final StoredDocument document(int docID) throws IOException {
final DocumentStoredFieldVisitor visitor = new DocumentStoredFieldVisitor();
document(docID, visitor);
return visitor.getDocument();
@@ -352,8 +352,10 @@
* fields. Note that this is simply sugar for {@link
* DocumentStoredFieldVisitor#DocumentStoredFieldVisitor(Set)}.
*/
- public final Document document(int docID, Set fieldsToLoad) throws IOException {
- final DocumentStoredFieldVisitor visitor = new DocumentStoredFieldVisitor(fieldsToLoad);
+ public final StoredDocument document(int docID, Set fieldsToLoad)
+ throws IOException {
+ final DocumentStoredFieldVisitor visitor = new DocumentStoredFieldVisitor(
+ fieldsToLoad);
document(docID, visitor);
return visitor.getDocument();
}
Index: lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/IndexWriter.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/index/IndexWriter.java (working copy)
@@ -69,10 +69,10 @@
new index if there is not already an index at the provided path
and otherwise open the existing index.
-
In either case, documents are added with {@link #addDocument(Iterable)
+
In either case, documents are added with {@link #addDocument(IndexDocument)
addDocument} and removed with {@link #deleteDocuments(Term)} or {@link
#deleteDocuments(Query)}. A document can be updated with {@link
- #updateDocument(Term, Iterable) updateDocument} (which just deletes
+ #updateDocument(Term, IndexDocument) updateDocument} (which just deletes
and then adds the entire document). When finished adding, deleting
and updating documents, {@link #close() close} should be called.
@@ -1088,7 +1088,7 @@
* @throws CorruptIndexException if the index is corrupt
* @throws IOException if there is a low-level IO error
*/
- public void addDocument(Iterable extends IndexableField> doc) throws IOException {
+ public void addDocument(IndexDocument doc) throws IOException {
addDocument(doc, analyzer);
}
@@ -1096,7 +1096,7 @@
* Adds a document to this index, using the provided analyzer instead of the
* value of {@link #getAnalyzer()}.
*
- *
See {@link #addDocument(Iterable)} for details on
+ *
See {@link #addDocument(IndexDocument)} for details on
* index and IndexWriter state after an Exception, and
* flushing/merging temporary free space requirements.
*
@@ -1107,7 +1107,7 @@
* @throws CorruptIndexException if the index is corrupt
* @throws IOException if there is a low-level IO error
*/
- public void addDocument(Iterable extends IndexableField> doc, Analyzer analyzer) throws IOException {
+ public void addDocument(IndexDocument doc, Analyzer analyzer) throws IOException {
updateDocument(null, doc, analyzer);
}
@@ -1132,7 +1132,7 @@
* perhaps to obtain better index compression), in which case
* you may need to fully re-index your documents at that time.
*
- *
See {@link #addDocument(Iterable)} for details on
+ *
See {@link #addDocument(IndexDocument)} for details on
* index and IndexWriter state after an Exception, and
* flushing/merging temporary free space requirements.
*
@@ -1152,7 +1152,7 @@
*
* @lucene.experimental
*/
- public void addDocuments(Iterable extends Iterable extends IndexableField>> docs) throws IOException {
+ public void addDocuments(Iterable extends IndexDocument> docs) throws IOException {
addDocuments(docs, analyzer);
}
@@ -1167,7 +1167,7 @@
*
* @lucene.experimental
*/
- public void addDocuments(Iterable extends Iterable extends IndexableField>> docs, Analyzer analyzer) throws IOException {
+ public void addDocuments(Iterable extends IndexDocument> docs, Analyzer analyzer) throws IOException {
updateDocuments(null, docs, analyzer);
}
@@ -1184,7 +1184,7 @@
*
* @lucene.experimental
*/
- public void updateDocuments(Term delTerm, Iterable extends Iterable extends IndexableField>> docs) throws IOException {
+ public void updateDocuments(Term delTerm, Iterable extends IndexDocument> docs) throws IOException {
updateDocuments(delTerm, docs, analyzer);
}
@@ -1202,7 +1202,7 @@
*
* @lucene.experimental
*/
- public void updateDocuments(Term delTerm, Iterable extends Iterable extends IndexableField>> docs, Analyzer analyzer) throws IOException {
+ public void updateDocuments(Term delTerm, Iterable extends IndexDocument> docs, Analyzer analyzer) throws IOException {
ensureOpen();
try {
boolean success = false;
@@ -1399,7 +1399,7 @@
* @throws CorruptIndexException if the index is corrupt
* @throws IOException if there is a low-level IO error
*/
- public void updateDocument(Term term, Iterable extends IndexableField> doc) throws IOException {
+ public void updateDocument(Term term, IndexDocument doc) throws IOException {
ensureOpen();
updateDocument(term, doc, getAnalyzer());
}
@@ -1422,7 +1422,7 @@
* @throws CorruptIndexException if the index is corrupt
* @throws IOException if there is a low-level IO error
*/
- public void updateDocument(Term term, Iterable extends IndexableField> doc, Analyzer analyzer)
+ public void updateDocument(Term term, IndexDocument doc, Analyzer analyzer)
throws IOException {
ensureOpen();
try {
Index: lucene/core/src/java/org/apache/lucene/index/Norm.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/Norm.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/index/Norm.java (working copy)
@@ -26,13 +26,14 @@
import org.apache.lucene.document.PackedLongDocValuesField;
import org.apache.lucene.document.ShortDocValuesField;
import org.apache.lucene.document.SortedBytesDocValuesField;
+import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.StraightBytesDocValuesField;
import org.apache.lucene.index.DocValues.Type;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.util.BytesRef;
/**
- * Stores the normalization value computed in
+ * Stores the normalization value with {@link StorableField} computed in
* {@link Similarity#computeNorm(FieldInvertState, Norm)} per field.
* Normalization values must be consistent within a single field, different
* value types are not permitted within a single field. All values set must be
@@ -43,13 +44,13 @@
* @lucene.internal
*/
public final class Norm {
- private Field field;
+ private StoredField field;
private BytesRef spare;
/**
- * Returns the {@link IndexableField} representation for this norm
+ * Returns the {@link StorableField} representation for this norm
*/
- public IndexableField field() {
+ public StorableField field() {
return field;
}
Index: lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java (working copy)
@@ -51,7 +51,7 @@
similarity.computeNorm(fieldState, norm);
if (norm.type() != null) {
- IndexableField field = norm.field();
+ StorableField field = norm.field();
// some similarity might not compute any norms
DocValuesConsumer consumer = getConsumer(norm.type());
consumer.add(docState.docID, field);
Index: lucene/core/src/java/org/apache/lucene/index/PersistentSnapshotDeletionPolicy.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/PersistentSnapshotDeletionPolicy.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/index/PersistentSnapshotDeletionPolicy.java (working copy)
@@ -26,6 +26,7 @@
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.Version;
@@ -67,13 +68,13 @@
int numDocs = r.numDocs();
// index is allowed to have exactly one document or 0.
if (numDocs == 1) {
- Document doc = r.document(r.maxDoc() - 1);
+ StoredDocument doc = r.document(r.maxDoc() - 1);
if (doc.getField(SNAPSHOTS_ID) == null) {
throw new IllegalStateException("directory is not a valid snapshots store!");
}
- doc.removeField(SNAPSHOTS_ID);
- for (IndexableField f : doc) {
- snapshots.put(f.name(), f.stringValue());
+ for (StorableField f : doc) {
+ if (!f.name().equals(SNAPSHOTS_ID))
+ snapshots.put(f.name(), f.stringValue());
}
} else if (numDocs != 0) {
throw new IllegalStateException(
@@ -184,14 +185,12 @@
private void persistSnapshotInfos(String id, String segment) throws IOException {
writer.deleteAll();
Document d = new Document();
- FieldType ft = new FieldType();
- ft.setStored(true);
- d.add(new Field(SNAPSHOTS_ID, "", ft));
+ d.add(new StoredField(SNAPSHOTS_ID, ""));
for (Entry e : super.getSnapshots().entrySet()) {
- d.add(new Field(e.getKey(), e.getValue(), ft));
+ d.add(new StoredField(e.getKey(), e.getValue()));
}
if (id != null) {
- d.add(new Field(id, segment, ft));
+ d.add(new StoredField(id, segment));
}
writer.addDocument(d);
writer.commit();
Index: lucene/core/src/java/org/apache/lucene/index/StorableField.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/StorableField.java (revision 0)
+++ lucene/core/src/java/org/apache/lucene/index/StorableField.java (working copy)
@@ -0,0 +1,42 @@
+package org.apache.lucene.index;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Reader;
+
+import org.apache.lucene.util.BytesRef;
+
+/** Represents a single stored field in lucene document. These fields
+ * are contained in document retrieved from IndexReader.
+ *
+ * @lucene.experimental */
+
+public interface StorableField extends GeneralField {
+
+ /** Non-null if this field has a binary value */
+ public BytesRef binaryValue();
+
+ /** Non-null if this field has a string value */
+ public String stringValue();
+
+ /** Non-null if this field has a Reader value */
+ public Reader readerValue();
+
+ /** Non-null if this field has a numeric value */
+ public Number numericValue();
+}
Index: lucene/core/src/java/org/apache/lucene/index/StorableField.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/StorableField.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/index/StorableField.java (working copy)
Property changes on: lucene/core/src/java/org/apache/lucene/index/StorableField.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Date Author Id Revision HeadURL
\ No newline at end of property
Index: lucene/core/src/java/org/apache/lucene/index/StorableFieldType.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/StorableFieldType.java (revision 0)
+++ lucene/core/src/java/org/apache/lucene/index/StorableFieldType.java (working copy)
@@ -0,0 +1,31 @@
+package org.apache.lucene.index;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// TODO: Move some properties from IndexableFieldType here, those regarding stored fields.
+
+/**
+ * Describes the properties of a stored field.
+ * @lucene.experimental
+ */
+public interface StorableFieldType {
+
+ /** DocValues type; if non-null then the field's value
+ * will be indexed into docValues */
+ public DocValues.Type docValueType();
+}
Index: lucene/core/src/java/org/apache/lucene/index/StorableFieldType.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/StorableFieldType.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/index/StorableFieldType.java (working copy)
Property changes on: lucene/core/src/java/org/apache/lucene/index/StorableFieldType.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Date Author Id Revision HeadURL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: lucene/core/src/java/org/apache/lucene/index/StoredDocument.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/StoredDocument.java (revision 0)
+++ lucene/core/src/java/org/apache/lucene/index/StoredDocument.java (working copy)
@@ -0,0 +1,191 @@
+package org.apache.lucene.index;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.DoubleField;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.FloatField;
+import org.apache.lucene.document.IntField;
+import org.apache.lucene.document.LongField;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.util.BytesRef;
+
+/**
+* StoredDocument is retrieved from IndexReader containing only stored fields from indexed {@link IndexDocument}.
+*/
+public class StoredDocument implements Iterable{
+
+ private final List fields = new ArrayList();
+
+
+ public final void add(StorableField field) {
+ fields.add(field);
+ }
+
+ public StorableField[] getFields(String name) {
+ List result = new ArrayList();
+ for (StorableField field : fields) {
+ if (field.name().equals(name)) {
+ result.add(field);
+ }
+ }
+
+ return result.toArray(new StorableField[result.size()]);
+ }
+
+ /** Returns a field with the given name if any exist in this document, or
+ * null. If multiple fields exists with this name, this method returns the
+ * first value added.
+ */
+ public final StorableField getField(String name) {
+ for (StorableField field : fields) {
+ if (field.name().equals(name)) {
+ return field;
+ }
+ }
+ return null;
+ }
+
+
+ /** Returns a List of all the fields in a document.
+ *
Note that fields which are not stored are
+ * not available in documents retrieved from the
+ * index, e.g. {@link IndexSearcher#doc(int)} or {@link
+ * IndexReader#document(int)}.
+ *
+ * @return an immutable List[StorableField]
+ */
+ public final List getFields() {
+ return fields;
+ }
+
+ @Override
+ public Iterator iterator() {
+ return this.fields.iterator();
+ }
+
+ /**
+ * Returns an array of byte arrays for of the fields that have the name specified
+ * as the method parameter. This method returns an empty
+ * array when there are no matching fields. It never
+ * returns null.
+ *
+ * @param name the name of the field
+ * @return a byte[][] of binary field values
+ */
+ public final BytesRef[] getBinaryValues(String name) {
+ final List result = new ArrayList();
+ for (StorableField field : fields) {
+ if (field.name().equals(name)) {
+ final BytesRef bytes = field.binaryValue();
+ if (bytes != null) {
+ result.add(bytes);
+ }
+ }
+ }
+
+ return result.toArray(new BytesRef[result.size()]);
+ }
+
+ /**
+ * Returns an array of bytes for the first (or only) field that has the name
+ * specified as the method parameter. This method will return null
+ * if no binary fields with the specified name are available.
+ * There may be non-binary fields with the same name.
+ *
+ * @param name the name of the field.
+ * @return a byte[] containing the binary field value or null
+ */
+ public final BytesRef getBinaryValue(String name) {
+ for (StorableField field : fields) {
+ if (field.name().equals(name)) {
+ final BytesRef bytes = field.binaryValue();
+ if (bytes != null) {
+ return bytes;
+ }
+ }
+ }
+ return null;
+ }
+ private final static String[] NO_STRINGS = new String[0];
+
+ /**
+ * Returns an array of values of the field specified as the method parameter.
+ * This method returns an empty array when there are no
+ * matching fields. It never returns null.
+ * For {@link IntField}, {@link LongField}, {@link
+ * FloatField} and {@link DoubleField} it returns the string value of the number. If you want
+ * the actual numeric field instances back, use {@link #getFields}.
+ * @param name the name of the field
+ * @return a String[] of field values
+ */
+ public final String[] getValues(String name) {
+ List result = new ArrayList();
+ for (StorableField field : fields) {
+ if (field.name().equals(name) && field.stringValue() != null) {
+ result.add(field.stringValue());
+ }
+ }
+
+ if (result.size() == 0) {
+ return NO_STRINGS;
+ }
+
+ return result.toArray(new String[result.size()]);
+ }
+
+ /** Returns the string value of the field with the given name if any exist in
+ * this document, or null. If multiple fields exist with this name, this
+ * method returns the first value added. If only binary fields with this name
+ * exist, returns null.
+ * For {@link IntField}, {@link LongField}, {@link
+ * FloatField} and {@link DoubleField} it returns the string value of the number. If you want
+ * the actual numeric field instance back, use {@link #getField}.
+ */
+ public final String get(String name) {
+ for (StorableField field : fields) {
+ if (field.name().equals(name) && field.stringValue() != null) {
+ return field.stringValue();
+ }
+ }
+ return null;
+ }
+
+ /** Prints the fields of a document for human consumption. */
+ @Override
+ public final String toString() {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("StoredDocument<");
+ for (int i = 0; i < fields.size(); i++) {
+ StorableField field = fields.get(i);
+ buffer.append(field.toString());
+ if (i != fields.size()-1)
+ buffer.append(" ");
+ }
+ buffer.append(">");
+ return buffer.toString();
+ }
+}
Index: lucene/core/src/java/org/apache/lucene/index/StoredDocument.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/StoredDocument.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/index/StoredDocument.java (working copy)
Property changes on: lucene/core/src/java/org/apache/lucene/index/StoredDocument.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Date Author Id Revision HeadURL
\ No newline at end of property
Index: lucene/core/src/java/org/apache/lucene/index/StoredFieldsConsumer.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/index/StoredFieldsConsumer.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/index/StoredFieldsConsumer.java (working copy)
@@ -44,12 +44,12 @@
}
private int numStoredFields;
- private IndexableField[] storedFields;
+ private StorableField[] storedFields;
private FieldInfo[] fieldInfos;
public void reset() {
numStoredFields = 0;
- storedFields = new IndexableField[1];
+ storedFields = new StorableField[1];
fieldInfos = new FieldInfo[1];
}
@@ -126,10 +126,10 @@
assert docWriter.writer.testPoint("StoredFieldsWriter.finishDocument end");
}
- public void addField(IndexableField field, FieldInfo fieldInfo) {
+ public void addField(StorableField field, FieldInfo fieldInfo) {
if (numStoredFields == storedFields.length) {
int newSize = ArrayUtil.oversize(numStoredFields + 1, RamUsageEstimator.NUM_BYTES_OBJECT_REF);
- IndexableField[] newArray = new IndexableField[newSize];
+ StorableField[] newArray = new StorableField[newSize];
System.arraycopy(storedFields, 0, newArray, 0, numStoredFields);
storedFields = newArray;
Index: lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java (working copy)
@@ -39,6 +39,7 @@
import org.apache.lucene.index.MultiFields;
import org.apache.lucene.index.IndexReaderContext;
import org.apache.lucene.index.ReaderUtil;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.index.StoredFieldVisitor;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermContext;
@@ -181,7 +182,7 @@
}
/** Sugar for .getIndexReader().document(docID) */
- public Document doc(int docID) throws IOException {
+ public StoredDocument doc(int docID) throws IOException {
return reader.document(docID);
}
@@ -191,7 +192,7 @@
}
/** Sugar for .getIndexReader().document(docID, fieldsToLoad) */
- public final Document document(int docID, Set fieldsToLoad) throws IOException {
+ public final StoredDocument document(int docID, Set fieldsToLoad) throws IOException {
return reader.document(docID, fieldsToLoad);
}
Index: lucene/core/src/java/org/apache/lucene/search/NRTManager.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/search/NRTManager.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/search/NRTManager.java (working copy)
@@ -27,6 +27,7 @@
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexDocument;
import org.apache.lucene.index.SegmentInfoPerCommit;
import org.apache.lucene.index.IndexReader; // javadocs
import org.apache.lucene.index.IndexWriter;
@@ -154,25 +155,25 @@
this.writer = writer;
}
- public long updateDocument(Term t, Iterable extends IndexableField> d, Analyzer a) throws IOException {
+ public long updateDocument(Term t, IndexDocument d, Analyzer a) throws IOException {
writer.updateDocument(t, d, a);
// Return gen as of when indexing finished:
return indexingGen.get();
}
- public long updateDocument(Term t, Iterable extends IndexableField> d) throws IOException {
+ public long updateDocument(Term t, IndexDocument d) throws IOException {
writer.updateDocument(t, d);
// Return gen as of when indexing finished:
return indexingGen.get();
}
- public long updateDocuments(Term t, Iterable extends Iterable extends IndexableField>> docs, Analyzer a) throws IOException {
+ public long updateDocuments(Term t, Iterable extends IndexDocument> docs, Analyzer a) throws IOException {
writer.updateDocuments(t, docs, a);
// Return gen as of when indexing finished:
return indexingGen.get();
}
- public long updateDocuments(Term t, Iterable extends Iterable extends IndexableField>> docs) throws IOException {
+ public long updateDocuments(Term t, Iterable extends IndexDocument> docs) throws IOException {
writer.updateDocuments(t, docs);
// Return gen as of when indexing finished:
return indexingGen.get();
@@ -208,25 +209,25 @@
return indexingGen.get();
}
- public long addDocument(Iterable extends IndexableField> d, Analyzer a) throws IOException {
+ public long addDocument(IndexDocument d, Analyzer a) throws IOException {
writer.addDocument(d, a);
// Return gen as of when indexing finished:
return indexingGen.get();
}
- public long addDocuments(Iterable extends Iterable extends IndexableField>> docs, Analyzer a) throws IOException {
+ public long addDocuments(Iterable extends IndexDocument> docs, Analyzer a) throws IOException {
writer.addDocuments(docs, a);
// Return gen as of when indexing finished:
return indexingGen.get();
}
- public long addDocument(Iterable extends IndexableField> d) throws IOException {
+ public long addDocument(IndexDocument d) throws IOException {
writer.addDocument(d);
// Return gen as of when indexing finished:
return indexingGen.get();
}
- public long addDocuments(Iterable extends Iterable extends IndexableField>> docs) throws IOException {
+ public long addDocuments(Iterable extends IndexDocument> docs) throws IOException {
writer.addDocuments(docs);
// Return gen as of when indexing finished:
return indexingGen.get();
Index: lucene/core/src/java/org/apache/lucene/util/packed/BulkOperation.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/util/packed/BulkOperation.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/util/packed/BulkOperation.java (working copy)
@@ -200,4 +200,4 @@
return iterations;
}
}
-}
+}
\ No newline at end of file
Index: lucene/core/src/java/org/apache/lucene/util/packed/Packed64SingleBlock.java
===================================================================
--- lucene/core/src/java/org/apache/lucene/util/packed/Packed64SingleBlock.java (revision 1377246)
+++ lucene/core/src/java/org/apache/lucene/util/packed/Packed64SingleBlock.java (working copy)
@@ -581,4 +581,4 @@
}
-}
+}
\ No newline at end of file
Index: lucene/core/src/java/overview.html
===================================================================
--- lucene/core/src/java/overview.html (revision 1377246)
+++ lucene/core/src/java/overview.html (working copy)
@@ -130,7 +130,7 @@
Create an {@link org.apache.lucene.index.IndexWriter IndexWriter}
-and add documents to it with {@link org.apache.lucene.index.IndexWriter#addDocument(Iterable) addDocument()};
+and add documents to it with {@link org.apache.lucene.index.IndexWriter#addDocument(org.apache.lucene.index.IndexDocument) addDocument()};
Call QueryParser.parse()
Index: lucene/core/src/test/org/apache/lucene/codecs/appending/TestAppendingCodec.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/codecs/appending/TestAppendingCodec.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/codecs/appending/TestAppendingCodec.java (working copy)
@@ -32,6 +32,7 @@
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.MultiFields;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum.SeekStatus;
import org.apache.lucene.index.TermsEnum;
@@ -128,7 +129,7 @@
writer.close();
IndexReader reader = DirectoryReader.open(dir, 1);
assertEquals(2, reader.numDocs());
- Document doc2 = reader.document(0);
+ StoredDocument doc2 = reader.document(0);
assertEquals(text, doc2.get("f"));
Fields fields = MultiFields.getFields(reader);
Terms terms = fields.terms("f");
Index: lucene/core/src/test/org/apache/lucene/codecs/lucene40/values/TestDocValues.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/codecs/lucene40/values/TestDocValues.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/codecs/lucene40/values/TestDocValues.java (working copy)
@@ -28,12 +28,14 @@
import org.apache.lucene.codecs.lucene40.values.Bytes;
import org.apache.lucene.codecs.lucene40.values.Floats;
import org.apache.lucene.codecs.lucene40.values.Ints;
+import org.apache.lucene.document.FieldType;
import org.apache.lucene.index.DocValues.SortedSource;
import org.apache.lucene.index.DocValues.Source;
import org.apache.lucene.index.DocValues.Type;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.IndexableFieldType;
+import org.apache.lucene.index.StorableField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.Counter;
@@ -438,22 +440,12 @@
return getSource(values).asSortedSource();
}
- public static class DocValueHolder implements IndexableField {
+ public static class DocValueHolder implements StorableField {
BytesRef bytes;
Number numberValue;
Comparator comp;
@Override
- public TokenStream tokenStream(Analyzer a) {
- return null;
- }
-
- @Override
- public float boost() {
- return 0.0f;
- }
-
- @Override
public String name() {
return "test";
}
@@ -479,7 +471,7 @@
}
@Override
- public IndexableFieldType fieldType() {
+ public FieldType fieldType() {
return null;
}
}
Index: lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java (working copy)
@@ -3,6 +3,7 @@
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.RandomIndexWriter;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
@@ -37,8 +38,8 @@
{
FieldType ft = new FieldType();
ft.setStored(true);
- IndexableField binaryFldStored = new StoredField("binaryStored", binaryValStored.getBytes("UTF-8"));
- IndexableField stringFldStored = new Field("stringStored", binaryValStored, ft);
+ StoredField binaryFldStored = new StoredField("binaryStored", binaryValStored.getBytes("UTF-8"));
+ Field stringFldStored = new Field("stringStored", binaryValStored, ft);
Document doc = new Document();
@@ -56,7 +57,7 @@
/** open a reader and fetch the document */
IndexReader reader = writer.getReader();
- Document docFromReader = reader.document(0);
+ StoredDocument docFromReader = reader.document(0);
assertTrue(docFromReader != null);
/** fetch the binary stored field and compare it's content with the original one */
@@ -75,8 +76,8 @@
}
public void testCompressionTools() throws Exception {
- IndexableField binaryFldCompressed = new StoredField("binaryCompressed", CompressionTools.compress(binaryValCompressed.getBytes("UTF-8")));
- IndexableField stringFldCompressed = new StoredField("stringCompressed", CompressionTools.compressString(binaryValCompressed));
+ StoredField binaryFldCompressed = new StoredField("binaryCompressed", CompressionTools.compress(binaryValCompressed.getBytes("UTF-8")));
+ StoredField stringFldCompressed = new StoredField("stringCompressed", CompressionTools.compressString(binaryValCompressed));
Document doc = new Document();
@@ -90,7 +91,7 @@
/** open a reader and fetch the document */
IndexReader reader = writer.getReader();
- Document docFromReader = reader.document(0);
+ StoredDocument docFromReader = reader.document(0);
assertTrue(docFromReader != null);
/** fetch the binary compressed field and compare it's content with the original one */
Index: lucene/core/src/test/org/apache/lucene/document/TestDocument.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/document/TestDocument.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/document/TestDocument.java (working copy)
@@ -18,6 +18,7 @@
*/
import java.io.StringReader;
+import java.util.List;
import org.apache.lucene.analysis.EmptyTokenizer;
import org.apache.lucene.analysis.MockAnalyzer;
@@ -27,6 +28,8 @@
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.RandomIndexWriter;
+import org.apache.lucene.index.StorableField;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
@@ -50,9 +53,9 @@
FieldType ft = new FieldType();
ft.setStored(true);
- IndexableField stringFld = new Field("string", binaryVal, ft);
- IndexableField binaryFld = new StoredField("binary", binaryVal.getBytes("UTF-8"));
- IndexableField binaryFld2 = new StoredField("binary", binaryVal2.getBytes("UTF-8"));
+ Field stringFld = new Field("string", binaryVal, ft);
+ StoredField binaryFld = new StoredField("binary", binaryVal.getBytes("UTF-8"));
+ StoredField binaryFld2 = new StoredField("binary", binaryVal2.getBytes("UTF-8"));
doc.add(stringFld);
doc.add(binaryFld);
@@ -124,7 +127,7 @@
// siltenlty ignored
assertEquals(0, doc.getFields().size());
}
-
+
public void testConstructorExceptions() {
FieldType ft = new FieldType();
ft.setStored(true);
@@ -147,6 +150,34 @@
// expected exception
}
}
+
+ public void testClearDocument() {
+ Document doc = makeDocumentWithFields();
+ assertEquals(8, doc.getFields().size());
+ doc.clear();
+ assertEquals(0, doc.getFields().size());
+ }
+
+ public void testGetFieldsImmutable() {
+ Document doc = makeDocumentWithFields();
+ assertEquals(8, doc.getFields().size());
+ List fields = doc.getFields();
+ try {
+ fields.add( new StringField("name", "value", Field.Store.NO) );
+ fail("Document.getFields() should return immutable List");
+ }
+ catch (UnsupportedOperationException e) {
+ // OK
+ }
+
+ try {
+ fields.clear();
+ fail("Document.getFields() should return immutable List");
+ }
+ catch (UnsupportedOperationException e) {
+ // OK
+ }
+ }
/**
* Tests {@link Document#getValues(String)} method for a brand new Document
@@ -179,7 +210,7 @@
ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
assertEquals(1, hits.length);
- doAssert(searcher.doc(hits[0].doc), true);
+ doAssert(searcher.doc(hits[0].doc));
writer.close();
reader.close();
dir.close();
@@ -214,11 +245,14 @@
return doc;
}
+ private void doAssert(StoredDocument doc) {
+ doAssert(new Document(doc), true);
+ }
private void doAssert(Document doc, boolean fromIndex) {
- IndexableField[] keywordFieldValues = doc.getFields("keyword");
- IndexableField[] textFieldValues = doc.getFields("text");
- IndexableField[] unindexedFieldValues = doc.getFields("unindexed");
- IndexableField[] unstoredFieldValues = doc.getFields("unstored");
+ StorableField[] keywordFieldValues = doc.getFields("keyword");
+ StorableField[] textFieldValues = doc.getFields("text");
+ StorableField[] unindexedFieldValues = doc.getFields("unindexed");
+ StorableField[] unstoredFieldValues = doc.getFields("unstored");
assertTrue(keywordFieldValues.length == 2);
assertTrue(textFieldValues.length == 2);
@@ -268,7 +302,7 @@
assertEquals(3, hits.length);
int result = 0;
for (int i = 0; i < 3; i++) {
- Document doc2 = searcher.doc(hits[i].doc);
+ StoredDocument doc2 = searcher.doc(hits[i].doc);
Field f = (Field) doc2.getField("id");
if (f.stringValue().equals("id1")) result |= 1;
else if (f.stringValue().equals("id2")) result |= 2;
Index: lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java (working copy)
@@ -1246,7 +1246,7 @@
w.close();
assertEquals(2, r3.numDocs());
for(int docID=0;docID<2;docID++) {
- Document d = r3.document(docID);
+ StoredDocument d = r3.document(docID);
if (d.get("id").equals("1")) {
assertEquals("doc1 field1", d.get("f1"));
} else {
Index: lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (working copy)
@@ -329,13 +329,13 @@
for(int i=0;i<35;i++) {
if (liveDocs.get(i)) {
- Document d = reader.document(i);
- List fields = d.getFields();
+ StoredDocument d = reader.document(i);
+ List fields = d.getFields();
boolean isProxDoc = d.getField("content3") == null;
if (isProxDoc) {
final int numFields = is40Index ? 7 : 5;
assertEquals(numFields, fields.size());
- IndexableField f = d.getField("id");
+ StorableField f = d.getField("id");
assertEquals(""+i, f.stringValue());
f = d.getField("utf8");
@@ -406,7 +406,7 @@
ScoreDoc[] hits = searcher.search(new TermQuery(new Term(new String("content"), "aaa")), null, 1000).scoreDocs;
// First document should be #0
- Document d = searcher.getIndexReader().document(hits[0].doc);
+ StoredDocument d = searcher.getIndexReader().document(hits[0].doc);
assertEquals("didn't get the right document first", "0", d.get("id"));
doTestHits(hits, 34, searcher.getIndexReader());
@@ -459,7 +459,7 @@
IndexReader reader = DirectoryReader.open(dir);
IndexSearcher searcher = new IndexSearcher(reader);
ScoreDoc[] hits = searcher.search(new TermQuery(new Term("content", "aaa")), null, 1000).scoreDocs;
- Document d = searcher.getIndexReader().document(hits[0].doc);
+ StoredDocument d = searcher.getIndexReader().document(hits[0].doc);
assertEquals("wrong first document", "0", d.get("id"));
doTestHits(hits, 44, searcher.getIndexReader());
reader.close();
@@ -485,7 +485,7 @@
IndexSearcher searcher = new IndexSearcher(reader);
ScoreDoc[] hits = searcher.search(new TermQuery(new Term("content", "aaa")), null, 1000).scoreDocs;
assertEquals("wrong number of hits", 34, hits.length);
- Document d = searcher.doc(hits[0].doc);
+ StoredDocument d = searcher.doc(hits[0].doc);
assertEquals("wrong first document", "0", d.get("id"));
reader.close();
@@ -753,7 +753,7 @@
for (int id=10; id<15; id++) {
ScoreDoc[] hits = searcher.search(NumericRangeQuery.newIntRange("trieInt", 4, Integer.valueOf(id), Integer.valueOf(id), true, true), 100).scoreDocs;
assertEquals("wrong number of hits", 1, hits.length);
- Document d = searcher.doc(hits[0].doc);
+ StoredDocument d = searcher.doc(hits[0].doc);
assertEquals(String.valueOf(id), d.get("id"));
hits = searcher.search(NumericRangeQuery.newLongRange("trieLong", 4, Long.valueOf(id), Long.valueOf(id), true, true), 100).scoreDocs;
Index: lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java (working copy)
@@ -74,7 +74,7 @@
assertEquals(Type.FLOAT_32, normValues.getType());
float[] norms = (float[]) source.getArray();
for (int i = 0; i < open.maxDoc(); i++) {
- Document document = open.document(i);
+ StoredDocument document = open.document(i);
float expected = Float.parseFloat(document.get(floatTestField));
assertEquals(expected, norms[i], 0.0f);
}
Index: lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java (working copy)
@@ -61,10 +61,10 @@
assertTrue(reader != null);
assertTrue(reader instanceof StandardDirectoryReader);
- Document newDoc1 = reader.document(0);
+ StoredDocument newDoc1 = reader.document(0);
assertTrue(newDoc1 != null);
assertTrue(DocHelper.numFields(newDoc1) == DocHelper.numFields(doc1) - DocHelper.unstored.size());
- Document newDoc2 = reader.document(1);
+ StoredDocument newDoc2 = reader.document(1);
assertTrue(newDoc2 != null);
assertTrue(DocHelper.numFields(newDoc2) == DocHelper.numFields(doc2) - DocHelper.unstored.size());
Terms vector = reader.getTermVectors(0).terms(DocHelper.TEXT_FIELD_2_KEY);
@@ -386,11 +386,11 @@
writer.addDocument(doc);
writer.close();
DirectoryReader reader = DirectoryReader.open(dir);
- Document doc2 = reader.document(reader.maxDoc() - 1);
- IndexableField[] fields = doc2.getFields("bin1");
+ StoredDocument doc2 = reader.document(reader.maxDoc() - 1);
+ StorableField[] fields = doc2.getFields("bin1");
assertNotNull(fields);
assertEquals(1, fields.length);
- IndexableField b1 = fields[0];
+ StorableField b1 = fields[0];
assertTrue(b1.binaryValue() != null);
BytesRef bytesRef = b1.binaryValue();
assertEquals(bin.length, bytesRef.length);
@@ -595,13 +595,13 @@
// check stored fields
for (int i = 0; i < index1.maxDoc(); i++) {
if (liveDocs1 == null || liveDocs1.get(i)) {
- Document doc1 = index1.document(i);
- Document doc2 = index2.document(i);
- List field1 = doc1.getFields();
- List field2 = doc2.getFields();
+ StoredDocument doc1 = index1.document(i);
+ StoredDocument doc2 = index2.document(i);
+ List field1 = doc1.getFields();
+ List field2 = doc2.getFields();
assertEquals("Different numbers of fields for doc " + i + ".", field1.size(), field2.size());
- Iterator itField1 = field1.iterator();
- Iterator itField2 = field2.iterator();
+ Iterator itField1 = field1.iterator();
+ Iterator itField2 = field2.iterator();
while (itField1.hasNext()) {
Field curField1 = (Field) itField1.next();
Field curField2 = (Field) itField2.next();
@@ -1082,7 +1082,7 @@
Set fieldsToLoad = new HashSet();
assertEquals(0, r.document(0, fieldsToLoad).getFields().size());
fieldsToLoad.add("field1");
- Document doc2 = r.document(0, fieldsToLoad);
+ StoredDocument doc2 = r.document(0, fieldsToLoad);
assertEquals(1, doc2.getFields().size());
assertEquals("foobar", doc2.get("field1"));
r.close();
Index: lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java (working copy)
@@ -122,7 +122,7 @@
if (i>0) {
int k = i-1;
int n = j + k*M;
- Document prevItereationDoc = reader.document(n);
+ StoredDocument prevItereationDoc = reader.document(n);
assertNotNull(prevItereationDoc);
String id = prevItereationDoc.get("id");
assertEquals(k+"_"+j, id);
Index: lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java (working copy)
@@ -122,7 +122,7 @@
for(int id=0;id comp = new Comparator() {
+ Comparator comp = new Comparator() {
@Override
- public int compare(IndexableField arg0, IndexableField arg1) {
+ public int compare(StorableField arg0, StorableField arg1) {
return arg0.name().compareTo(arg1.name());
}
};
Collections.sort(leftDoc.getFields(), comp);
Collections.sort(rightDoc.getFields(), comp);
- Iterator leftIterator = leftDoc.iterator();
- Iterator rightIterator = rightDoc.iterator();
+ Iterator leftIterator = leftDoc.iterator();
+ Iterator rightIterator = rightDoc.iterator();
while (leftIterator.hasNext()) {
assertTrue(info, rightIterator.hasNext());
assertStoredField(leftIterator.next(), rightIterator.next());
@@ -569,7 +569,7 @@
/**
* checks that two stored fields are equivalent
*/
- public void assertStoredField(IndexableField leftField, IndexableField rightField) {
+ public void assertStoredField(StorableField leftField, StorableField rightField) {
assertEquals(info, leftField.name(), rightField.name());
assertEquals(info, leftField.binaryValue(), rightField.binaryValue());
assertEquals(info, leftField.stringValue(), rightField.stringValue());
Index: lucene/core/src/test/org/apache/lucene/index/TestFieldInfos.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestFieldInfos.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/index/TestFieldInfos.java (working copy)
@@ -47,7 +47,7 @@
//Positive test of FieldInfos
assertTrue(testDoc != null);
FieldInfos.Builder builder = new FieldInfos.Builder();
- for (IndexableField field : testDoc) {
+ for (IndexableField field : testDoc.getFields()) {
builder.addOrUpdate(field.name(), field.fieldType());
}
FieldInfos fieldInfos = builder.finish();
Index: lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java (working copy)
@@ -55,7 +55,7 @@
public static void beforeClass() throws Exception {
fieldInfos = new FieldInfos.Builder();
DocHelper.setupDoc(testDoc);
- for (IndexableField field : testDoc) {
+ for (IndexableField field : testDoc.getFields()) {
fieldInfos.addOrUpdate(field.name(), field.fieldType());
}
dir = newDirectory();
@@ -79,7 +79,7 @@
assertTrue(dir != null);
assertTrue(fieldInfos != null);
IndexReader reader = DirectoryReader.open(dir);
- Document doc = reader.document(0);
+ StoredDocument doc = reader.document(0);
assertTrue(doc != null);
assertTrue(doc.getField(DocHelper.TEXT_FIELD_1_KEY) != null);
@@ -104,7 +104,7 @@
DocumentStoredFieldVisitor visitor = new DocumentStoredFieldVisitor(DocHelper.TEXT_FIELD_3_KEY);
reader.document(0, visitor);
- final List fields = visitor.getDocument().getFields();
+ final List fields = visitor.getDocument().getFields();
assertEquals(1, fields.size());
assertEquals(DocHelper.TEXT_FIELD_3_KEY, fields.get(0).name());
reader.close();
@@ -279,7 +279,7 @@
doc.add(sf);
answers[id] = answer;
typeAnswers[id] = typeAnswer;
- FieldType ft = new FieldType(IntField.TYPE_NOT_STORED);
+ FieldType ft = new FieldType(IntField.TYPE_STORED);
ft.setNumericPrecisionStep(Integer.MAX_VALUE);
doc.add(new IntField("id", id, ft));
w.addDocument(doc);
@@ -293,7 +293,7 @@
final AtomicReader sub = ctx.reader();
final int[] ids = FieldCache.DEFAULT.getInts(sub, "id", false);
for(int docID=0;docID storableFields() {
+ return new Iterable() {
@Override
- public IndexableField next() {
- assert fieldUpto < fieldCount;
- if (fieldUpto == 0) {
- fieldUpto = 1;
- return newStringField("id", ""+finalDocCount, Field.Store.YES);
- } else {
- return new MyField(finalBaseCount + (fieldUpto++-1));
- }
- }
+ public Iterator iterator() {
+ return new Iterator() {
+ int fieldUpto = 0;
+ private StorableField next = null;
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
+ @Override
+ public boolean hasNext() {
+
+ if (fieldUpto == fieldCount) return false;
+
+ next = null;
+ if (fieldUpto == 0) {
+ fieldUpto = 1;
+ next = newStringField("id", ""+finalDocCount, Field.Store.YES);
+ } else {
+ next = new MyField(finalBaseCount + (fieldUpto++-1));
+ }
+
+ if (next != null && next.fieldType().stored()) return true;
+ else return this.hasNext();
+ }
+
+ @Override
+ public StorableField next() {
+ assert fieldUpto <= fieldCount;
+ if (next == null && !hasNext()) {
+ return null;
+ }
+ else {
+ return next;
+ }
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
}
};
}
- });
+ };
+
+ w.addDocument(d);
}
final IndexReader r = w.getReader();
@@ -223,10 +288,11 @@
if (VERBOSE) {
System.out.println("TEST: verify doc id=" + id + " (" + fieldsPerDoc[id] + " fields) counter=" + counter);
}
+
final TopDocs hits = s.search(new TermQuery(new Term("id", ""+id)), 1);
assertEquals(1, hits.totalHits);
final int docID = hits.scoreDocs[0].doc;
- final Document doc = s.doc(docID);
+ final StoredDocument doc = s.doc(docID);
final int endCounter = counter + fieldsPerDoc[id];
while(counter < endCounter) {
final String name = "f" + counter;
@@ -245,7 +311,7 @@
// stored:
if (stored) {
- IndexableField f = doc.getField(name);
+ StorableField f = doc.getField(name);
assertNotNull("doc " + id + " doesn't have field f" + counter, f);
if (binary) {
assertNotNull("doc " + id + " doesn't have field f" + counter, f);
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java (working copy)
@@ -908,8 +908,8 @@
w.close();
IndexReader ir = DirectoryReader.open(dir);
- Document doc2 = ir.document(0);
- IndexableField f2 = doc2.getField("binary");
+ StoredDocument doc2 = ir.document(0);
+ StorableField f2 = doc2.getField("binary");
b = f2.binaryValue().bytes;
assertTrue(b != null);
assertEquals(17, b.length, 17);
@@ -1165,8 +1165,8 @@
w.close();
IndexReader ir = DirectoryReader.open(dir);
- Document doc2 = ir.document(0);
- IndexableField f3 = doc2.getField("binary");
+ StoredDocument doc2 = ir.document(0);
+ StorableField f3 = doc2.getField("binary");
b = f3.binaryValue().bytes;
assertTrue(b != null);
assertEquals(17, b.length, 17);
@@ -1207,8 +1207,8 @@
doc.add(newField("zzz", "1 2 3", customType));
w.addDocument(doc);
IndexReader r = w.getReader();
- Document doc2 = r.document(0);
- Iterator it = doc2.getFields().iterator();
+ StoredDocument doc2 = r.document(0);
+ Iterator it = doc2.getFields().iterator();
assertTrue(it.hasNext());
Field f = (Field) it.next();
assertEquals(f.name(), "zzz");
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (working copy)
@@ -1556,50 +1556,46 @@
try {
doc = new Document();
// try to boost with norms omitted
- List list = new ArrayList();
- list.add(new IndexableField() {
-
+ IndexDocument docList = new IndexDocument() {
+
+ List list = new ArrayList();
+ List storedList = new ArrayList();
+
@Override
- public String name() {
- return "foo";
- }
+ public Iterable extends IndexableField> indexableFields() {
+ if (list.size() == 0) {
+ list.add(new IndexableField() {
+ @Override
+ public String name() {
+ return "foo";
+ }
- @Override
- public IndexableFieldType fieldType() {
- return StringField.TYPE_NOT_STORED;
- }
+ @Override
+ public IndexableFieldType fieldType() {
+ return StringField.TYPE_NOT_STORED;
+ }
- @Override
- public float boost() {
- return 5f;
- }
+ @Override
+ public float boost() {
+ return 5f;
+ }
- @Override
- public BytesRef binaryValue() {
- return null;
+ @Override
+ public TokenStream tokenStream(Analyzer analyzer) throws IOException {
+ return null;
+ }
+ });
+ }
+ return list;
}
@Override
- public String stringValue() {
- return "baz";
+ public Iterable extends StorableField> storableFields() {
+ return storedList;
}
-
- @Override
- public Reader readerValue() {
- return null;
- }
-
- @Override
- public Number numericValue() {
- return null;
- }
-
- @Override
- public TokenStream tokenStream(Analyzer analyzer) throws IOException {
- return null;
- }
- });
- iw.addDocument(list);
+
+ };
+ iw.addDocument(docList);
fail("didn't get any exception, boost silently discarded");
} catch (UnsupportedOperationException expected) {
// expected
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java (working copy)
@@ -84,7 +84,7 @@
int max = reader.maxDoc();
for (int i = 0; i < max; i++)
{
- Document temp = reader.document(i);
+ StoredDocument temp = reader.document(i);
//System.out.println("doc "+i+"="+temp.getField("count").stringValue());
//compare the index doc number to the value that it should be
if (!temp.getField("count").stringValue().equals((i + startAt) + ""))
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java (working copy)
@@ -141,7 +141,7 @@
String id10 = r1.document(10).getField("id").stringValue();
- Document newDoc = r1.document(10);
+ Document newDoc = new Document(r1.document(10));
newDoc.removeField("id");
newDoc.add(newStringField("id", Integer.toString(8000), Field.Store.YES));
writer.updateDocument(new Term("id", id10), newDoc);
@@ -271,9 +271,9 @@
assertEquals(100, index2df);
// verify the docs are from different indexes
- Document doc5 = r1.document(5);
+ StoredDocument doc5 = r1.document(5);
assertEquals("index1", doc5.get("indexname"));
- Document doc150 = r1.document(150);
+ StoredDocument doc150 = r1.document(150);
assertEquals("index2", doc150.get("indexname"));
r1.close();
writer.close();
Index: lucene/core/src/test/org/apache/lucene/index/TestIndexWriterUnicode.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestIndexWriterUnicode.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/index/TestIndexWriterUnicode.java (working copy)
@@ -259,7 +259,7 @@
w.close();
IndexReader ir = DirectoryReader.open(dir);
- Document doc2 = ir.document(0);
+ StoredDocument doc2 = ir.document(0);
for(int i=0;i tokens = new ArrayList();
final int numTokens = atLeast(100);
//final int numTokens = atLeast(20);
Index: lucene/core/src/test/org/apache/lucene/index/TestRandomStoredFields.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestRandomStoredFields.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/index/TestRandomStoredFields.java (working copy)
@@ -121,7 +121,7 @@
}
TopDocs hits = s.search(new TermQuery(new Term("id", testID)), 1);
assertEquals(1, hits.totalHits);
- Document doc = r.document(hits.scoreDocs[0].doc);
+ StoredDocument doc = r.document(hits.scoreDocs[0].doc);
Document docExp = docs.get(testID);
for(int i=0;i= 1);
- Document result = reader.document(0);
+ StoredDocument result = reader.document(0);
assertTrue(result != null);
//There are 2 unstored fields on the document that are not preserved across writing
assertTrue(DocHelper.numFields(result) == DocHelper.numFields(testDoc) - DocHelper.unstored.size());
- List fields = result.getFields();
- for (final IndexableField field : fields ) {
+ List fields = result.getFields();
+ for (final StorableField field : fields ) {
assertTrue(field != null);
assertTrue(DocHelper.nameValues.containsKey(field.name()));
}
Index: lucene/core/src/test/org/apache/lucene/index/TestStressIndexing2.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/index/TestStressIndexing2.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/index/TestStressIndexing2.java (working copy)
@@ -133,8 +133,8 @@
static Term idTerm = new Term("id","");
IndexingThread[] threads;
- static Comparator fieldNameComparator = new Comparator() {
- public int compare(IndexableField o1, IndexableField o2) {
+ static Comparator fieldNameComparator = new Comparator() {
+ public int compare(GeneralField o1, GeneralField o2) {
return o1.name().compareTo(o2.name());
}
};
@@ -250,7 +250,7 @@
Iterator iter = docs.values().iterator();
while (iter.hasNext()) {
Document d = iter.next();
- ArrayList fields = new ArrayList();
+ ArrayList fields = new ArrayList();
fields.addAll(d.getFields());
// put fields in same order each time
Collections.sort(fields, fieldNameComparator);
@@ -287,7 +287,7 @@
Bits liveDocs = sub.getLiveDocs();
System.out.println(" " + ((SegmentReader) sub).getSegmentInfo());
for(int docID=0;docID ff1 = d1.getFields();
- List ff2 = d2.getFields();
+ public static void verifyEquals(StoredDocument d1, StoredDocument d2) {
+ List ff1 = d1.getFields();
+ List ff2 = d2.getFields();
Collections.sort(ff1, fieldNameComparator);
Collections.sort(ff2, fieldNameComparator);
@@ -583,8 +583,8 @@
assertEquals(ff1 + " : " + ff2, ff1.size(), ff2.size());
for (int i=0; i> docs) throws Exception {
+ protected void updateDocuments(Term id, List extends IndexDocument> docs) throws Exception {
final long gen = genWriter.updateDocuments(id, docs);
// Randomly verify the update "took":
@@ -99,7 +100,7 @@
}
@Override
- protected void addDocuments(Term id, List extends Iterable extends IndexableField>> docs) throws Exception {
+ protected void addDocuments(Term id, List extends IndexDocument> docs) throws Exception {
final long gen = genWriter.addDocuments(docs);
// Randomly verify the add "took":
if (random().nextInt(20) == 2) {
@@ -121,7 +122,7 @@
}
@Override
- protected void addDocument(Term id, Iterable extends IndexableField> doc) throws Exception {
+ protected void addDocument(Term id, IndexDocument doc) throws Exception {
final long gen = genWriter.addDocument(doc);
// Randomly verify the add "took":
@@ -144,7 +145,7 @@
}
@Override
- protected void updateDocument(Term id, Iterable extends IndexableField> doc) throws Exception {
+ protected void updateDocument(Term id, IndexDocument doc) throws Exception {
final long gen = genWriter.updateDocument(id, doc);
// Randomly verify the udpate "took":
if (random().nextInt(20) == 2) {
@@ -373,7 +374,7 @@
}
public void updateDocument(Term term,
- Iterable extends IndexableField> doc, Analyzer analyzer)
+ IndexDocument doc, Analyzer analyzer)
throws IOException {
super.updateDocument(term, doc, analyzer);
try {
Index: lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java (working copy)
@@ -29,6 +29,7 @@
import org.apache.lucene.index.MultiFields;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.SlowCompositeReaderWrapper;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.store.Directory;
@@ -173,7 +174,7 @@
ScoreDoc[] sd = topDocs.scoreDocs;
assertNotNull(sd);
assertEquals("Score doc count"+type, count, sd.length );
- Document doc=searcher.doc(sd[0].doc);
+ StoredDocument doc=searcher.doc(sd[0].doc);
assertEquals("First doc"+type, 2*distance+startOffset, doc.getField(field).numericValue().intValue());
doc=searcher.doc(sd[sd.length-1].doc);
assertEquals("Last doc"+type, (1+count)*distance+startOffset, doc.getField(field).numericValue().intValue());
@@ -226,7 +227,7 @@
ScoreDoc[] sd = topDocs.scoreDocs;
assertNotNull(sd);
assertEquals("Score doc count", count, sd.length );
- Document doc=searcher.doc(sd[0].doc);
+ StoredDocument doc=searcher.doc(sd[0].doc);
assertEquals("First doc", startOffset, doc.getField(field).numericValue().intValue());
doc=searcher.doc(sd[sd.length-1].doc);
assertEquals("Last doc", (count-1)*distance+startOffset, doc.getField(field).numericValue().intValue());
@@ -266,7 +267,7 @@
ScoreDoc[] sd = topDocs.scoreDocs;
assertNotNull(sd);
assertEquals("Score doc count", noDocs-count, sd.length );
- Document doc=searcher.doc(sd[0].doc);
+ StoredDocument doc=searcher.doc(sd[0].doc);
assertEquals("First doc", count*distance+startOffset, doc.getField(field).numericValue().intValue());
doc=searcher.doc(sd[sd.length-1].doc);
assertEquals("Last doc", (noDocs-1)*distance+startOffset, doc.getField(field).numericValue().intValue());
Index: lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java (working copy)
@@ -29,6 +29,7 @@
import org.apache.lucene.index.MultiFields;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.SlowCompositeReaderWrapper;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.store.Directory;
@@ -182,7 +183,7 @@
ScoreDoc[] sd = topDocs.scoreDocs;
assertNotNull(sd);
assertEquals("Score doc count"+type, count, sd.length );
- Document doc=searcher.doc(sd[0].doc);
+ StoredDocument doc=searcher.doc(sd[0].doc);
assertEquals("First doc"+type, 2*distance+startOffset, doc.getField(field).numericValue().longValue() );
doc=searcher.doc(sd[sd.length-1].doc);
assertEquals("Last doc"+type, (1+count)*distance+startOffset, doc.getField(field).numericValue().longValue() );
@@ -241,7 +242,7 @@
ScoreDoc[] sd = topDocs.scoreDocs;
assertNotNull(sd);
assertEquals("Score doc count", count, sd.length );
- Document doc=searcher.doc(sd[0].doc);
+ StoredDocument doc=searcher.doc(sd[0].doc);
assertEquals("First doc", startOffset, doc.getField(field).numericValue().longValue() );
doc=searcher.doc(sd[sd.length-1].doc);
assertEquals("Last doc", (count-1)*distance+startOffset, doc.getField(field).numericValue().longValue() );
@@ -286,7 +287,7 @@
ScoreDoc[] sd = topDocs.scoreDocs;
assertNotNull(sd);
assertEquals("Score doc count", noDocs-count, sd.length );
- Document doc=searcher.doc(sd[0].doc);
+ StoredDocument doc=searcher.doc(sd[0].doc);
assertEquals("First doc", count*distance+startOffset, doc.getField(field).numericValue().longValue() );
doc=searcher.doc(sd[sd.length-1].doc);
assertEquals("Last doc", (noDocs-1)*distance+startOffset, doc.getField(field).numericValue().longValue() );
Index: lucene/core/src/test/org/apache/lucene/search/TestPhraseQuery.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestPhraseQuery.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/search/TestPhraseQuery.java (working copy)
@@ -74,7 +74,7 @@
Document doc = new Document();
doc.add(newTextField("field", "one two three four five", Field.Store.YES));
doc.add(newTextField("repeated", "this is a repeated field - first part", Field.Store.YES));
- IndexableField repeatedField = newTextField("repeated", "second part of a repeated field", Field.Store.YES);
+ Field repeatedField = newTextField("repeated", "second part of a repeated field", Field.Store.YES);
doc.add(repeatedField);
doc.add(newTextField("palindrome", "one two three two one", Field.Store.YES));
writer.addDocument(doc);
Index: lucene/core/src/test/org/apache/lucene/search/TestSort.java
===================================================================
--- lucene/core/src/test/org/apache/lucene/search/TestSort.java (revision 1377246)
+++ lucene/core/src/test/org/apache/lucene/search/TestSort.java (working copy)
@@ -50,6 +50,8 @@
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.MultiReader;
import org.apache.lucene.index.RandomIndexWriter;
+import org.apache.lucene.index.StorableField;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.FieldValueHitQueue.Entry;
@@ -523,9 +525,9 @@
boolean fail = false;
final String fieldSuffix = sort.getSort()[0].getField().endsWith("_fixed") ? "_fixed" : "";
for (int x = 0; x < n; ++x) {
- Document doc2 = searcher.doc(result[x].doc);
- IndexableField[] v = doc2.getFields("tracer" + fieldSuffix);
- IndexableField[] v2 = doc2.getFields("tracer2" + fieldSuffix);
+ StoredDocument doc2 = searcher.doc(result[x].doc);
+ StorableField[] v = doc2.getFields("tracer" + fieldSuffix);
+ StorableField[] v2 = doc2.getFields("tracer2" + fieldSuffix);
for (int j = 0; j < v.length; ++j) {
buff.append(v[j] + "(" + v2[j] + ")(" + result[x].doc+")\n");
if (last != null) {
@@ -1230,8 +1232,8 @@
StringBuilder buff = new StringBuilder(10);
int n = result.length;
for (int i=0; i 94 && i < 105) ) {
- Document d = searcher.doc(hits[i].doc);
+ StoredDocument d = searcher.doc(hits[i].doc);
out.println(i + " " + d.get(ID_FIELD));
}
}
@@ -137,7 +137,7 @@
assertEquals("total results", expectedCount, hits.length);
for (int i = 0 ; i < hits.length; i++) {
if (i < 10 || (i > 94 && i < 105) ) {
- Document d = searcher.doc(hits[i].doc);
+ StoredDocument d = searcher.doc(hits[i].doc);
assertEquals("check " + i, String.valueOf(i), d.get(ID_FIELD));
}
}
Index: lucene/demo
===================================================================
--- lucene/demo (revision 1377246)
+++ lucene/demo (working copy)
Property changes on: lucene/demo
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/demo:r1357905-1377246
Index: lucene/demo/src/java/org/apache/lucene/demo/SearchFiles.java
===================================================================
--- lucene/demo/src/java/org/apache/lucene/demo/SearchFiles.java (revision 1377246)
+++ lucene/demo/src/java/org/apache/lucene/demo/SearchFiles.java (working copy)
@@ -29,6 +29,7 @@
import org.apache.lucene.document.Document;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
@@ -178,7 +179,7 @@
continue;
}
- Document doc = searcher.doc(hits[i].doc);
+ StoredDocument doc = searcher.doc(hits[i].doc);
String path = doc.get("path");
if (path != null) {
System.out.println((i+1) + ". " + path);
Index: lucene/demo/src/java/org/apache/lucene/demo/xmlparser/FormBasedXmlQueryDemo.java
===================================================================
--- lucene/demo/src/java/org/apache/lucene/demo/xmlparser/FormBasedXmlQueryDemo.java (revision 1377246)
+++ lucene/demo/src/java/org/apache/lucene/demo/xmlparser/FormBasedXmlQueryDemo.java (working copy)
@@ -41,6 +41,7 @@
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.queryparser.xml.CorePlusExtensionsParser;
import org.apache.lucene.queryparser.xml.QueryTemplateManager;
import org.apache.lucene.search.IndexSearcher;
@@ -112,7 +113,7 @@
//and package the results and forward to JSP
if (topDocs != null) {
ScoreDoc[] sd = topDocs.scoreDocs;
- Document[] results = new Document[sd.length];
+ StoredDocument[] results = new StoredDocument[sd.length];
for (int i = 0; i < results.length; i++) {
results[i] = searcher.doc(sd[i].doc);
request.setAttribute("results", results);
Index: lucene/facet
===================================================================
--- lucene/facet (revision 1377246)
+++ lucene/facet (working copy)
Property changes on: lucene/facet
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/facet:r1357905-1377246
Index: lucene/grouping
===================================================================
--- lucene/grouping (revision 1377246)
+++ lucene/grouping (working copy)
Property changes on: lucene/grouping
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/grouping:r1357905-1377246
Index: lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java
===================================================================
--- lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java (revision 1377246)
+++ lucene/grouping/src/test/org/apache/lucene/search/grouping/TestGrouping.java (working copy)
@@ -594,7 +594,7 @@
Document doc = new Document();
docs.add(doc);
if (groupValue.group != null) {
- doc.add(newStringField("group", groupValue.group.utf8ToString(), Field.Store.NO));
+ doc.add(newStringField("group", groupValue.group.utf8ToString(), Field.Store.YES));
}
doc.add(newStringField("sort1", groupValue.sort1.utf8ToString(), Field.Store.NO));
doc.add(newStringField("sort2", groupValue.sort2.utf8ToString(), Field.Store.NO));
Index: lucene/highlighter
===================================================================
--- lucene/highlighter (revision 1377246)
+++ lucene/highlighter (working copy)
Property changes on: lucene/highlighter
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/highlighter:r1357905-1377246
Index: lucene/highlighter/src/java/org/apache/lucene/search/highlight/TokenSources.java
===================================================================
--- lucene/highlighter/src/java/org/apache/lucene/search/highlight/TokenSources.java (revision 1377246)
+++ lucene/highlighter/src/java/org/apache/lucene/search/highlight/TokenSources.java (working copy)
@@ -35,6 +35,7 @@
import org.apache.lucene.index.DocsAndPositionsEnum;
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.search.DocIdSetIterator;
@@ -58,7 +59,7 @@
* and get the vector from
* @param docId The docId to retrieve.
* @param field The field to retrieve on the document
- * @param doc The document to fall back on
+ * @param document The document to fall back on
* @param analyzer The analyzer to use for creating the TokenStream if the
* vector doesn't exist
* @return The {@link org.apache.lucene.analysis.TokenStream} for the
@@ -68,7 +69,7 @@
*/
public static TokenStream getAnyTokenStream(IndexReader reader, int docId,
- String field, Document doc, Analyzer analyzer) throws IOException {
+ String field, StoredDocument document, Analyzer analyzer) throws IOException {
TokenStream ts = null;
Fields vectors = reader.getTermVectors(docId);
@@ -81,7 +82,7 @@
// No token info stored so fall back to analyzing raw content
if (ts == null) {
- ts = getTokenStream(doc, field, analyzer);
+ ts = getTokenStream(document, field, analyzer);
}
return ts;
}
@@ -291,11 +292,11 @@
// convenience method
public static TokenStream getTokenStream(IndexReader reader, int docId,
String field, Analyzer analyzer) throws IOException {
- Document doc = reader.document(docId);
+ StoredDocument doc = reader.document(docId);
return getTokenStream(doc, field, analyzer);
}
-
- public static TokenStream getTokenStream(Document doc, String field,
+
+ public static TokenStream getTokenStream(StoredDocument doc, String field,
Analyzer analyzer) {
String contents = doc.get(field);
if (contents == null) {
Index: lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
===================================================================
--- lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java (revision 1377246)
+++ lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java (working copy)
@@ -42,6 +42,7 @@
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
@@ -97,7 +98,7 @@
for (int i = 0; i < hits.scoreDocs.length; i++) {
- Document doc = searcher.doc(hits.scoreDocs[i].doc);
+ StoredDocument doc = searcher.doc(hits.scoreDocs[i].doc);
String storedField = doc.get(FIELD_NAME);
TokenStream stream = TokenSources.getAnyTokenStream(searcher
@@ -1656,7 +1657,7 @@
TopDocs hits = searcher.search(query, null, 10);
for( int i = 0; i < hits.totalHits; i++ ){
- Document doc = searcher.doc( hits.scoreDocs[i].doc );
+ StoredDocument doc = searcher.doc( hits.scoreDocs[i].doc );
String result = h.getBestFragment( a, "t_text1", doc.get( "t_text1" ));
if (VERBOSE) System.out.println("result:" + result);
assertEquals("more random words for second field", result);
Index: lucene/ivy-settings.xml
===================================================================
--- lucene/ivy-settings.xml (revision 1377246)
+++ lucene/ivy-settings.xml (working copy)
Property changes on: lucene/ivy-settings.xml
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene2510/lucene/ivy-settings.xml:r1364862-1365496
Merged /lucene/dev/branches/lucene3312/lucene/ivy-settings.xml:r1357905-1377246
Merged /lucene/dev/branches/branch_4x/lucene/ivy-settings.xml:r1353701,1355203,1356608,1359358,1363876,1364063,1364069,1367391,1367489,1367833,1368975,1369226
Merged /lucene/dev/branches/lucene4199/lucene/ivy-settings.xml:r1358548-1359191
Index: lucene/join
===================================================================
--- lucene/join (revision 1377246)
+++ lucene/join (working copy)
Property changes on: lucene/join
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/join:r1357905-1377246
Index: lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
===================================================================
--- lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java (revision 1377246)
+++ lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java (working copy)
@@ -119,11 +119,11 @@
assertEquals(1, group.totalHits);
assertFalse(Float.isNaN(group.score));
- Document childDoc = s.doc(group.scoreDocs[0].doc);
+ StoredDocument childDoc = s.doc(group.scoreDocs[0].doc);
//System.out.println(" doc=" + group.scoreDocs[0].doc);
assertEquals("java", childDoc.get("skill"));
assertNotNull(group.groupValue);
- Document parentDoc = s.doc(group.groupValue);
+ StoredDocument parentDoc = s.doc(group.groupValue);
assertEquals("Lisa", parentDoc.get("name"));
@@ -247,7 +247,7 @@
}
}
- private Document getParentDoc(IndexReader reader, Filter parents, int childDocID) throws IOException {
+ private StoredDocument getParentDoc(IndexReader reader, Filter parents, int childDocID) throws IOException {
final List leaves = reader.leaves();
final int subIndex = ReaderUtil.subIndex(childDocID, leaves);
final AtomicReaderContext leaf = leaves.get(subIndex);
@@ -563,7 +563,7 @@
System.out.println("\nTEST: normal index gets " + results.totalHits + " hits");
final ScoreDoc[] hits = results.scoreDocs;
for(int hitIDX=0;hitIDX group = groupDocs[joinGroupUpto++];
final ScoreDoc[] groupHits = group.scoreDocs;
assertNotNull(group.groupValue);
- final Document parentDoc = joinR.document(group.groupValue);
+ final StoredDocument parentDoc = joinR.document(group.groupValue);
final String parentID = parentDoc.get("parentID");
//System.out.println("GROUP groupDoc=" + group.groupDoc + " parent=" + parentDoc);
assertNotNull(parentID);
assertTrue(groupHits.length > 0);
for(int hitIDX=0;hitIDX group = jobResults.groups[0];
assertEquals(1, group.totalHits);
- Document childJobDoc = s.doc(group.scoreDocs[0].doc);
+ StoredDocument childJobDoc = s.doc(group.scoreDocs[0].doc);
//System.out.println(" doc=" + group.scoreDocs[0].doc);
assertEquals("java", childJobDoc.get("skill"));
assertNotNull(group.groupValue);
- Document parentDoc = s.doc(group.groupValue);
+ StoredDocument parentDoc = s.doc(group.groupValue);
assertEquals("Lisa", parentDoc.get("name"));
}
@@ -933,10 +933,10 @@
final GroupDocs qGroup = qualificationResults.groups[0];
assertEquals(1, qGroup.totalHits);
- Document childQualificationDoc = s.doc(qGroup.scoreDocs[0].doc);
+ StoredDocument childQualificationDoc = s.doc(qGroup.scoreDocs[0].doc);
assertEquals("maths", childQualificationDoc.get("qualification"));
assertNotNull(qGroup.groupValue);
- Document parentDoc = s.doc(qGroup.groupValue);
+ StoredDocument parentDoc = s.doc(qGroup.groupValue);
assertEquals("Lisa", parentDoc.get("name"));
Index: lucene/memory
===================================================================
--- lucene/memory (revision 1377246)
+++ lucene/memory (working copy)
Property changes on: lucene/memory
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/memory:r1357905-1377246
Index: lucene/MIGRATE.txt
===================================================================
--- lucene/MIGRATE.txt (revision 1377246)
+++ lucene/MIGRATE.txt (working copy)
Property changes on: lucene/MIGRATE.txt
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene4199/lucene/MIGRATE.txt:r1358548-1359191
Merged /lucene/dev/branches/lucene3312/lucene/MIGRATE.txt:r1357905-1377246
Merged /lucene/dev/branches/branch_4x/lucene/MIGRATE.txt:r1353701,1355203,1356608
Index: lucene/misc
===================================================================
--- lucene/misc (revision 1377246)
+++ lucene/misc (working copy)
Property changes on: lucene/misc
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/misc:r1357905-1377246
Index: lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java
===================================================================
--- lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java (revision 1377246)
+++ lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java (working copy)
@@ -25,8 +25,9 @@
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.IndexableFieldType;
+import org.apache.lucene.index.StorableField;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.util.BytesRef;
/** Defers actually loading a field's value until you ask
@@ -38,7 +39,7 @@
private final int docID;
// null until first field is loaded
- private Document doc;
+ private StoredDocument doc;
private Map fields = new HashMap();
@@ -47,7 +48,7 @@
this.docID = docID;
}
- public IndexableField getField(FieldInfo fieldInfo) {
+ public StorableField getField(FieldInfo fieldInfo) {
Integer num = fields.get(fieldInfo.number);
if (num == null) {
num = 0;
@@ -59,7 +60,7 @@
return new LazyField(fieldInfo.name, num);
}
- private synchronized Document getDocument() {
+ private synchronized StoredDocument getDocument() {
if (doc == null) {
try {
doc = reader.document(docID);
@@ -71,7 +72,7 @@
return doc;
}
- private class LazyField implements IndexableField {
+ private class LazyField implements StorableField {
private String name;
private int num;
@@ -86,11 +87,6 @@
}
@Override
- public float boost() {
- return 1.0f;
- }
-
- @Override
public BytesRef binaryValue() {
if (num == 0) {
return getDocument().getField(name).binaryValue();
@@ -134,14 +130,5 @@
return getDocument().getFields(name)[num].fieldType();
}
}
-
- @Override
- public TokenStream tokenStream(Analyzer analyzer) throws IOException {
- if (num == 0) {
- return getDocument().getField(name).tokenStream(analyzer);
- } else {
- return getDocument().getFields(name)[num].tokenStream(analyzer);
- }
- }
}
}
Index: lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java
===================================================================
--- lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java (revision 1377246)
+++ lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java (working copy)
@@ -68,7 +68,7 @@
IndexReader ir;
ir = DirectoryReader.open(dirs[0]);
assertTrue(ir.numDocs() - NUM_DOCS / 3 <= 1); // rounding error
- Document doc = ir.document(0);
+ StoredDocument 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")));
@@ -113,7 +113,7 @@
IndexReader ir;
ir = DirectoryReader.open(dirs[0]);
assertTrue(ir.numDocs() - NUM_DOCS / 3 <= 1);
- Document doc = ir.document(0);
+ StoredDocument doc = ir.document(0);
assertEquals("0", doc.get("id"));
int start = ir.numDocs();
ir.close();
Index: lucene/module-build.xml
===================================================================
--- lucene/module-build.xml (revision 1377246)
+++ lucene/module-build.xml (working copy)
Property changes on: lucene/module-build.xml
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/branch_4x/lucene/module-build.xml:r1353701,1355203,1356608,1359358,1363876,1364063,1364069,1367391,1367489,1367833,1368975,1369226
Merged /lucene/dev/branches/lucene4199/lucene/module-build.xml:r1358548-1359191
Merged /lucene/dev/branches/lucene2510/lucene/module-build.xml:r1364862-1365496
Merged /lucene/dev/branches/lucene3312/lucene/module-build.xml:r1357905-1377246
Index: lucene/queries
===================================================================
--- lucene/queries (revision 1377246)
+++ lucene/queries (working copy)
Property changes on: lucene/queries
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/queries:r1357905-1377246
Index: lucene/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java
===================================================================
--- lucene/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java (revision 1377246)
+++ lucene/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java (working copy)
@@ -26,6 +26,8 @@
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.MultiFields;
+import org.apache.lucene.index.StorableField;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
@@ -715,9 +717,9 @@
// field does not store term vector info
if (vector == null) {
- Document d = ir.document(docNum);
- IndexableField fields[] = d.getFields(fieldName);
- for (IndexableField field : fields) {
+ StoredDocument d = ir.document(docNum);
+ StorableField[] fields = d.getFields(fieldName);
+ for (StorableField field : fields) {
final String stringValue = field.stringValue();
if (stringValue != null) {
addTermFrequencies(new StringReader(stringValue), termFreqMap, fieldName);
Index: lucene/queryparser
===================================================================
--- lucene/queryparser (revision 1377246)
+++ lucene/queryparser (working copy)
Property changes on: lucene/queryparser
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/queryparser:r1357905-1377246
Index: lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
===================================================================
--- lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java (revision 1377246)
+++ lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java (working copy)
@@ -26,6 +26,7 @@
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
@@ -100,7 +101,7 @@
TopDocs td = searcher.search(q, 10);
ScoreDoc[] sd = td.scoreDocs;
for (int i = 0; i < sd.length; i++) {
- Document doc = searcher.doc(sd[i].doc);
+ StoredDocument doc = searcher.doc(sd[i].doc);
String id = doc.get("id");
assertTrue(qString + "matched doc#" + id + " not expected", expecteds
.contains(id));
Index: lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java
===================================================================
--- lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java (revision 1377246)
+++ lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java (working copy)
@@ -28,6 +28,7 @@
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.search.DisjunctionMaxQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
@@ -232,7 +233,7 @@
System.out.println("=========" + qType + "============");
ScoreDoc[] scoreDocs = hits.scoreDocs;
for (int i = 0; i < Math.min(numDocs, hits.totalHits); i++) {
- Document ldoc = searcher.doc(scoreDocs[i].doc);
+ StoredDocument ldoc = searcher.doc(scoreDocs[i].doc);
System.out.println("[" + ldoc.get("date") + "]" + ldoc.get("contents"));
}
System.out.println();
Index: lucene/sandbox
===================================================================
--- lucene/sandbox (revision 1377246)
+++ lucene/sandbox (working copy)
Property changes on: lucene/sandbox
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/branch_4x/lucene/sandbox:r1353701,1355203,1356608
Merged /lucene/dev/branches/lucene4199/lucene/sandbox:r1358548-1359191
Merged /lucene/dev/branches/lucene3312/lucene/sandbox:r1357905-1377246
Index: lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java
===================================================================
--- lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java (revision 1377246)
+++ lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java (working copy)
@@ -87,7 +87,7 @@
ScoreDoc[] hits = searcher.search(tq, df, 1000).scoreDocs;
for (ScoreDoc hit : hits) {
- Document d = searcher.doc(hit.doc);
+ StoredDocument d = searcher.doc(hit.doc);
String url = d.get(KEY_FIELD);
assertFalse("No duplicate urls should be returned", results.contains(url));
results.add(url);
@@ -101,7 +101,7 @@
boolean dupsFound = false;
for (ScoreDoc hit : hits) {
- Document d = searcher.doc(hit.doc);
+ StoredDocument d = searcher.doc(hit.doc);
String url = d.get(KEY_FIELD);
if (!dupsFound)
dupsFound = results.contains(url);
@@ -118,7 +118,7 @@
assertTrue("Filtered searching should have found some matches", hits.length > 0);
for (ScoreDoc hit : hits) {
- Document d = searcher.doc(hit.doc);
+ StoredDocument d = searcher.doc(hit.doc);
String url = d.get(KEY_FIELD);
assertFalse("No duplicate urls should be returned", results.contains(url));
results.add(url);
@@ -132,7 +132,7 @@
ScoreDoc[] hits = searcher.search(tq, df, 1000).scoreDocs;
assertTrue("Filtered searching should have found some matches", hits.length > 0);
for (ScoreDoc hit : hits) {
- Document d = searcher.doc(hit.doc);
+ StoredDocument d = searcher.doc(hit.doc);
String url = d.get(KEY_FIELD);
DocsEnum td = _TestUtil.docs(random(), reader,
KEY_FIELD,
@@ -156,7 +156,7 @@
ScoreDoc[] hits = searcher.search(tq, df, 1000).scoreDocs;
assertTrue("Filtered searching should have found some matches", hits.length > 0);
for (ScoreDoc hit : hits) {
- Document d = searcher.doc(hit.doc);
+ StoredDocument d = searcher.doc(hit.doc);
String url = d.get(KEY_FIELD);
DocsEnum td = _TestUtil.docs(random(), reader,
KEY_FIELD,
Index: lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java
===================================================================
--- lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java (revision 1377246)
+++ lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java (working copy)
@@ -23,6 +23,7 @@
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
@@ -88,7 +89,7 @@
TopDocs topDocs = searcher.search(flt, 1);
ScoreDoc[] sd = topDocs.scoreDocs;
assertTrue("score docs must match 1 doc", (sd != null) && (sd.length > 0));
- Document doc = searcher.doc(sd[0].doc);
+ StoredDocument doc = searcher.doc(sd[0].doc);
assertEquals("Should match most similar not most rare variant", "2", doc.get("id"));
}
@@ -104,7 +105,7 @@
TopDocs topDocs = searcher.search(flt, 1);
ScoreDoc[] sd = topDocs.scoreDocs;
assertTrue("score docs must match 1 doc", (sd != null) && (sd.length > 0));
- Document doc = searcher.doc(sd[0].doc);
+ StoredDocument doc = searcher.doc(sd[0].doc);
assertEquals("Should match most similar when using 2 words", "2", doc.get("id"));
}
@@ -119,7 +120,7 @@
TopDocs topDocs = searcher.search(flt, 1);
ScoreDoc[] sd = topDocs.scoreDocs;
assertTrue("score docs must match 1 doc", (sd != null) && (sd.length > 0));
- Document doc = searcher.doc(sd[0].doc);
+ StoredDocument doc = searcher.doc(sd[0].doc);
assertEquals("Should match most similar when using 2 words", "2", doc.get("id"));
}
Index: lucene/spatial
===================================================================
--- lucene/spatial (revision 1377246)
+++ lucene/spatial (working copy)
Property changes on: lucene/spatial
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/spatial:r1357905-1377246
Index: lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java
===================================================================
--- lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java (revision 1377246)
+++ lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java (working copy)
@@ -92,11 +92,11 @@
//---------------------------------
@Override
- public IndexableField[] createIndexableFields(Shape shape) {
+ public Field[] createIndexableFields(Shape shape) {
Rectangle bbox = shape.getBoundingBox();
FieldType doubleFieldType = new FieldType(DoubleField.TYPE_NOT_STORED);
doubleFieldType.setNumericPrecisionStep(precisionStep);
- IndexableField[] fields = new IndexableField[5];
+ Field[] fields = new Field[5];
fields[0] = new DoubleField(field_minX, bbox.getMinX(), doubleFieldType);
fields[1] = new DoubleField(field_maxX, bbox.getMaxX(), doubleFieldType);
fields[2] = new DoubleField(field_minY, bbox.getMinY(), doubleFieldType);
Index: lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java
===================================================================
--- lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java (revision 1377246)
+++ lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java (working copy)
@@ -63,7 +63,7 @@
}
@Override
- public IndexableField[] createIndexableFields(Shape shape) {
+ public Field[] createIndexableFields(Shape shape) {
int detailLevel = grid.getMaxLevelForPrecision(shape,distErrPct);
List cells = grid.getNodes(shape, detailLevel, true);//true=intermediates cells
//If shape isn't a point, add a full-resolution center-point so that
@@ -79,7 +79,7 @@
// http://code.google.com/p/lucene-spatial-playground/issues/detail?id=4
Field field = new Field(getFieldName(), new CellTokenStream(cells.iterator()), FIELD_TYPE);
- return new IndexableField[]{field};
+ return new Field[]{field};
}
/* Indexed, tokenized, not stored. */
Index: lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java
===================================================================
--- lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java (revision 1377246)
+++ lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java (working copy)
@@ -19,6 +19,8 @@
import com.spatial4j.core.context.SpatialContext;
import com.spatial4j.core.shape.Shape;
+
+import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.queries.function.FunctionQuery;
import org.apache.lucene.queries.function.ValueSource;
@@ -97,7 +99,7 @@
*
* @return Not null nor will it have null elements.
*/
- public abstract IndexableField[] createIndexableFields(Shape shape);
+ public abstract Field[] createIndexableFields(Shape shape);
/**
* The value source yields a number that is proportional to the distance between the query shape and indexed data.
Index: lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java
===================================================================
--- lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java (revision 1377246)
+++ lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java (working copy)
@@ -24,6 +24,7 @@
import com.spatial4j.core.shape.Rectangle;
import com.spatial4j.core.shape.Shape;
import org.apache.lucene.document.DoubleField;
+import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.queries.function.FunctionQuery;
@@ -77,12 +78,12 @@
}
@Override
- public IndexableField[] createIndexableFields(Shape shape) {
+ public Field[] createIndexableFields(Shape shape) {
if( shape instanceof Point ) {
Point point = (Point)shape;
FieldType doubleFieldType = new FieldType(DoubleField.TYPE_NOT_STORED);
doubleFieldType.setNumericPrecisionStep(precisionStep);
- IndexableField[] f = new IndexableField[2];
+ Field[] f = new Field[2];
f[0] = new DoubleField(fieldNameX, point.getX(), doubleFieldType);
f[1] = new DoubleField(fieldNameY, point.getY(), doubleFieldType);
return f;
@@ -90,7 +91,7 @@
if( !ignoreIncompatibleGeometry ) {
throw new IllegalArgumentException( "TwoDoublesStrategy can not index: "+shape );
}
- return new IndexableField[0]; // nothing (solr does not support null)
+ return new Field[0]; // nothing (solr does not support null)
}
@Override
Index: lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java
===================================================================
--- lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java (revision 1377246)
+++ lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java (working copy)
@@ -194,7 +194,7 @@
private Document newDoc(String id, Shape shape) {
Document doc = new Document();
doc.add(new StringField("id", id, Field.Store.YES));
- for (IndexableField f : strategy.createIndexableFields(shape)) {
+ for (Field f : strategy.createIndexableFields(shape)) {
doc.add(f);
}
if (storeShape)
Index: lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java
===================================================================
--- lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java (revision 1377246)
+++ lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java (working copy)
@@ -154,7 +154,7 @@
private Document newDoc(String id, Shape shape) {
Document doc = new Document();
doc.add(new StringField("id", id, Field.Store.YES));
- for (IndexableField f : strategy.createIndexableFields(shape)) {
+ for (Field f : strategy.createIndexableFields(shape)) {
doc.add(f);
}
if (storeShape)
Index: lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java
===================================================================
--- lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java (revision 1377246)
+++ lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java (working copy)
@@ -46,7 +46,7 @@
Document losAngeles = new Document();
losAngeles.add(new StringField("name", "Los Angeles", Field.Store.YES));
- for (IndexableField field : prefixGridStrategy.createIndexableFields(point)) {
+ for (Field field : prefixGridStrategy.createIndexableFields(point)) {
losAngeles.add(field);
}
losAngeles.add(new StoredField(prefixGridStrategy.getFieldName(), ctx.toString(point)));
Index: lucene/spatial/src/test/org/apache/lucene/spatial/SpatialExample.java
===================================================================
--- lucene/spatial/src/test/org/apache/lucene/spatial/SpatialExample.java (revision 1377246)
+++ lucene/spatial/src/test/org/apache/lucene/spatial/SpatialExample.java (working copy)
@@ -124,7 +124,7 @@
//Potentially more than one shape in this field is supported by some
// strategies; see the javadocs of the SpatialStrategy impl to see.
for (Shape shape : shapes) {
- for (IndexableField f : strategy.createIndexableFields(shape)) {
+ for (Field f : strategy.createIndexableFields(shape)) {
doc.add(f);
}
//store it too; the format is up to you
Index: lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java
===================================================================
--- lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java (revision 1377246)
+++ lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java (working copy)
@@ -20,6 +20,7 @@
import org.apache.lucene.document.Document;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.RandomIndexWriter;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
@@ -130,11 +131,11 @@
protected static class SearchResult {
public float score;
- public Document document;
+ public StoredDocument document;
- public SearchResult(float score, Document document) {
+ public SearchResult(float score, StoredDocument storedDocument) {
this.score = score;
- this.document = document;
+ this.document = storedDocument;
}
@Override
Index: lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java
===================================================================
--- lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java (revision 1377246)
+++ lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java (working copy)
@@ -85,7 +85,7 @@
document.add(new StringField("id", data.id, Field.Store.YES));
document.add(new StringField("name", data.name, Field.Store.YES));
Shape shape = ctx.readShape(data.shape);
- for (IndexableField f : strategy.createIndexableFields(shape)) {
+ for (Field f : strategy.createIndexableFields(shape)) {
document.add(f);
}
if (storeShape)
Index: lucene/suggest
===================================================================
--- lucene/suggest (revision 1377246)
+++ lucene/suggest (working copy)
Property changes on: lucene/suggest
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/suggest:r1357905-1377246
Index: lucene/test-framework
===================================================================
--- lucene/test-framework (revision 1377246)
+++ lucene/test-framework (working copy)
Property changes on: lucene/test-framework
___________________________________________________________________
Modified: svn:mergeinfo
Merged /lucene/dev/branches/lucene3312/lucene/test-framework:r1357905-1377246
Index: lucene/test-framework/src/java/org/apache/lucene/analysis/CollationTestBase.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/analysis/CollationTestBase.java (revision 1377246)
+++ lucene/test-framework/src/java/org/apache/lucene/analysis/CollationTestBase.java (working copy)
@@ -34,6 +34,8 @@
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.StorableField;
+import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
@@ -238,8 +240,8 @@
StringBuilder buff = new StringBuilder(10);
int n = result.length;
for (int i = 0 ; i < n ; ++i) {
- Document doc = searcher.doc(result[i].doc);
- IndexableField[] v = doc.getFields("tracer");
+ StoredDocument doc = searcher.doc(result[i].doc);
+ StorableField[] v = doc.getFields("tracer");
for (int j = 0 ; j < v.length ; ++j) {
buff.append(v[j].stringValue());
}
Index: lucene/test-framework/src/java/org/apache/lucene/index/DocHelper.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/index/DocHelper.java (revision 1377246)
+++ lucene/test-framework/src/java/org/apache/lucene/index/DocHelper.java (working copy)
@@ -290,6 +290,10 @@
public static int numFields(Document doc) {
return doc.getFields().size();
}
+
+ public static int numFields(StoredDocument doc) {
+ return doc.getFields().size();
+ }
public static Document createDocument(int n, String indexName, int numFields) {
StringBuilder sb = new StringBuilder();
Index: lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java (revision 1377246)
+++ lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java (working copy)
@@ -139,13 +139,13 @@
/**
* Adds a Document.
- * @see IndexWriter#addDocument(Iterable)
+ * @see IndexWriter#addDocument(org.apache.lucene.index.IndexDocument)
*/
- public void addDocument(final Iterable doc) throws IOException {
+ public void addDocument(final IndexDocument doc) throws IOException {
addDocument(doc, w.getAnalyzer());
}
- public void addDocument(final Iterable doc, Analyzer a) throws IOException {
+ public void addDocument(final IndexDocument doc, Analyzer a) throws IOException {
if (doDocValues && doc instanceof Document) {
randomPerDocFieldValues((Document) doc);
}
@@ -154,11 +154,11 @@
// (but we need to clone them), and only when
// getReader, commit, etc. are called, we do an
// addDocuments? Would be better testing.
- w.addDocuments(new Iterable>() {
+ w.addDocuments(new Iterable() {
@Override
- public Iterator> iterator() {
- return new Iterator>() {
+ public Iterator iterator() {
+ return new Iterator() {
boolean done;
@Override
@@ -172,7 +172,7 @@
}
@Override
- public Iterable next() {
+ public IndexDocument next() {
if (done) {
throw new IllegalStateException();
}
@@ -273,30 +273,30 @@
}
}
- public void addDocuments(Iterable extends Iterable extends IndexableField>> docs) throws IOException {
+ public void addDocuments(Iterable extends IndexDocument> docs) throws IOException {
w.addDocuments(docs);
maybeCommit();
}
- public void updateDocuments(Term delTerm, Iterable extends Iterable extends IndexableField>> docs) throws IOException {
+ public void updateDocuments(Term delTerm, Iterable extends IndexDocument> docs) throws IOException {
w.updateDocuments(delTerm, docs);
maybeCommit();
}
/**
* Updates a document.
- * @see IndexWriter#updateDocument(Term, Iterable)
+ * @see IndexWriter#updateDocument(Term, org.apache.lucene.index.IndexDocument)
*/
- public void updateDocument(Term t, final Iterable doc) throws IOException {
+ public void updateDocument(Term t, final IndexDocument doc) throws IOException {
if (doDocValues) {
randomPerDocFieldValues((Document) doc);
}
if (r.nextInt(5) == 3) {
- w.updateDocuments(t, new Iterable>() {
+ w.updateDocuments(t, new Iterable() {
@Override
- public Iterator> iterator() {
- return new Iterator>() {
+ public Iterator iterator() {
+ return new Iterator() {
boolean done;
@Override
@@ -310,7 +310,7 @@
}
@Override
- public Iterable next() {
+ public IndexDocument next() {
if (done) {
throw new IllegalStateException();
}
Index: lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java (revision 1377246)
+++ lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java (working copy)
@@ -89,19 +89,19 @@
return in;
}
- protected void updateDocuments(Term id, List extends Iterable extends IndexableField>> docs) throws Exception {
+ protected void updateDocuments(Term id, List extends IndexDocument> docs) throws Exception {
writer.updateDocuments(id, docs);
}
- protected void addDocuments(Term id, List extends Iterable extends IndexableField>> docs) throws Exception {
+ protected void addDocuments(Term id, List extends IndexDocument> docs) throws Exception {
writer.addDocuments(docs);
}
- protected void addDocument(Term id, Iterable extends IndexableField> doc) throws Exception {
+ protected void addDocument(Term id, IndexDocument doc) throws Exception {
writer.addDocument(doc);
}
- protected void updateDocument(Term term, Iterable extends IndexableField> doc) throws Exception {
+ protected void updateDocument(Term term, IndexDocument doc) throws Exception {
writer.updateDocument(term, doc);
}
@@ -464,7 +464,7 @@
final int inc = Math.max(1, maxDoc/50);
for(int docID=0;docID getDocumentFieldsInfo( Document doc, int docId, IndexReader reader,
+ private static SimpleOrderedMap