From 1b8048415a6fa655664c0f5012b9095ea04a659e Mon Sep 17 00:00:00 2001
From: Uwe Schindler
Date: Thu, 5 Jul 2012 20:53:09 +0000
Subject: [PATCH 01/13] Create branch for LUCENE-3312
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3312@1357905 13f79535-47bb-0310-9956-ffa450edef68
From 1db6d571ebaac087d7a6ba783cdfb9d6e0050b8c Mon Sep 17 00:00:00 2001
From: Uwe Schindler
Date: Thu, 5 Jul 2012 21:37:19 +0000
Subject: [PATCH 02/13] Commit lucene-3312-patch-06.patch (merged to current
trunk and formatting changes in IR removed)
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3312@1357938 13f79535-47bb-0310-9956-ffa450edef68
---
.../lucene/codecs/DocValuesConsumer.java | 16 +-
.../lucene/codecs/StoredFieldsWriter.java | 34 +--
.../lucene40/Lucene40StoredFieldsWriter.java | 8 +-
.../lucene/codecs/lucene40/values/Bytes.java | 3 +-
.../values/FixedStraightBytesImpl.java | 8 +-
.../lucene/codecs/lucene40/values/Floats.java | 3 +-
.../lucene/codecs/lucene40/values/Ints.java | 3 +-
.../lucene40/values/PackedIntValues.java | 3 +-
.../lucene40/values/VarStraightBytesImpl.java | 8 +-
.../SimpleTextDocValuesConsumer.java | 4 +-
.../SimpleTextStoredFieldsWriter.java | 4 +-
.../lucene/document/ByteDocValuesField.java | 2 +-
.../document/DerefBytesDocValuesField.java | 2 +-
.../org/apache/lucene/document/Document.java | 97 +++++++--
.../document/DocumentStoredFieldVisitor.java | 9 +-
.../lucene/document/DoubleDocValuesField.java | 2 +-
.../apache/lucene/document/DoubleField.java | 1 -
.../org/apache/lucene/document/Field.java | 3 +-
.../org/apache/lucene/document/FieldType.java | 27 +--
.../lucene/document/FloatDocValuesField.java | 2 +-
.../apache/lucene/document/FloatField.java | 1 -
.../lucene/document/IntDocValuesField.java | 2 +-
.../org/apache/lucene/document/IntField.java | 1 -
.../lucene/document/LongDocValuesField.java | 2 +-
.../document/PackedLongDocValuesField.java | 2 +-
.../lucene/document/ShortDocValuesField.java | 2 +-
.../document/SortedBytesDocValuesField.java | 2 +-
.../lucene/document/StoredDocument.java | 201 ++++++++++++++++++
.../apache/lucene/document/StoredField.java | 12 +-
.../document/StraightBytesDocValuesField.java | 2 +-
.../org/apache/lucene/index/CheckIndex.java | 3 +-
.../lucene/index/DocFieldProcessor.java | 15 +-
.../lucene/index/DocInverterPerField.java | 2 +-
.../apache/lucene/index/DocumentsWriter.java | 4 +-
.../index/DocumentsWriterPerThread.java | 8 +-
.../org/apache/lucene/index/FieldInfos.java | 2 +-
.../index/FreqProxTermsWriterPerField.java | 7 +-
.../apache/lucene/index/IndexDocument.java | 26 +++
.../org/apache/lucene/index/IndexReader.java | 9 +-
.../org/apache/lucene/index/IndexWriter.java | 16 +-
.../apache/lucene/index/IndexableField.java | 20 +-
.../lucene/index/IndexableFieldType.java | 10 -
.../java/org/apache/lucene/index/Norm.java | 5 +-
.../lucene/index/NormsConsumerPerField.java | 4 +-
.../PersistentSnapshotDeletionPolicy.java | 14 +-
.../apache/lucene/index/StorableField.java | 44 ++++
.../lucene/index/StorableFieldType.java | 25 +++
.../lucene/index/StoredFieldsConsumer.java | 8 +-
.../index/TermVectorsConsumerPerField.java | 2 +-
.../apache/lucene/search/IndexSearcher.java | 5 +-
.../org/apache/lucene/search/NRTManager.java | 17 +-
.../apache/lucene/util/FilterIterator.java | 68 ++++++
52 files changed, 611 insertions(+), 169 deletions(-)
create mode 100644 lucene/core/src/java/org/apache/lucene/document/StoredDocument.java
create mode 100644 lucene/core/src/java/org/apache/lucene/index/IndexDocument.java
create mode 100644 lucene/core/src/java/org/apache/lucene/index/StorableField.java
create mode 100644 lucene/core/src/java/org/apache/lucene/index/StorableFieldType.java
create mode 100644 lucene/core/src/java/org/apache/lucene/util/FilterIterator.java
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java b/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java
index 4e1e5362b5e..c052dc3caa9 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/DocValuesConsumer.java
@@ -28,21 +28,23 @@ import org.apache.lucene.document.LongDocValuesField;
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 @@ public abstract class DocValuesConsumer {
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 @@ public abstract class DocValuesConsumer {
* @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 @@ public abstract class DocValuesConsumer {
* @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 @@ public abstract class DocValuesConsumer {
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 @@ public abstract class DocValuesConsumer {
* 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:
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/StoredFieldsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/StoredFieldsWriter.java
index 7e67b50c070..cb55a414fa5 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/StoredFieldsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/StoredFieldsWriter.java
@@ -1,5 +1,17 @@
package org.apache.lucene.codecs;
+import java.io.Closeable;
+import java.io.IOException;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.StoredDocument;
+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.util.Bits;
+
/**
* Copyright 2004 The Apache Software Foundation
*
@@ -33,7 +45,7 @@ import org.apache.lucene.util.Bits;
*
*
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 +57,14 @@ import org.apache.lucene.util.Bits;
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 +81,7 @@ public abstract class StoredFieldsWriter implements Closeable {
/** 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(int)},
* returning the number of documents that were written.
* Implementations can override this method for more sophisticated
* merging (bulk-byte copying, etc). */
@@ -89,7 +101,7 @@ public abstract class StoredFieldsWriter implements Closeable {
// 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 +112,16 @@ public abstract class StoredFieldsWriter implements Closeable {
}
/** 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);
- }
}
}
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsWriter.java
index ed699cdfabb..2d33fe8a0a3 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/Lucene40StoredFieldsWriter.java
@@ -22,6 +22,7 @@ import org.apache.lucene.codecs.CodecUtil;
import org.apache.lucene.codecs.StoredFieldsReader;
import org.apache.lucene.codecs.StoredFieldsWriter;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.AtomicReader;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.FieldInfos;
@@ -29,6 +30,7 @@ import org.apache.lucene.index.IndexFileNames;
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.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
@@ -131,7 +133,7 @@ public final class Lucene40StoredFieldsWriter extends StoredFieldsWriter {
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 @@ public final class Lucene40StoredFieldsWriter extends StoredFieldsWriter {
// 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 @@ public final class Lucene40StoredFieldsWriter extends StoredFieldsWriter {
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);
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Bytes.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Bytes.java
index cbec979bd78..dd7599e2bc8 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Bytes.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Bytes.java
@@ -30,6 +30,7 @@ import org.apache.lucene.index.DocValues.Type;
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 @@ public final class Bytes {
}
@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
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/FixedStraightBytesImpl.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/FixedStraightBytesImpl.java
index bc072adc586..0ba456afdeb 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/FixedStraightBytesImpl.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/FixedStraightBytesImpl.java
@@ -22,12 +22,12 @@ import java.io.IOException;
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 @@ class FixedStraightBytesImpl {
}
@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 @@ class FixedStraightBytesImpl {
}
@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) {
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Floats.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Floats.java
index c8a96fd5440..e8724a3df5a 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Floats.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Floats.java
@@ -24,6 +24,7 @@ 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;
@@ -88,7 +89,7 @@ public class Floats {
}
@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);
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Ints.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Ints.java
index 2d937f6b25d..33ef01f5c4f 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Ints.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/Ints.java
@@ -25,6 +25,7 @@ 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;
@@ -112,7 +113,7 @@ public final class Ints {
}
@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);
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/PackedIntValues.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/PackedIntValues.java
index c40534f0af2..13cacf9a199 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/PackedIntValues.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/PackedIntValues.java
@@ -26,6 +26,7 @@ import org.apache.lucene.index.DocValues.Type;
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 @@ class PackedIntValues {
}
@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) {
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/VarStraightBytesImpl.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/VarStraightBytesImpl.java
index 126c11da02d..7efe24c807c 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/VarStraightBytesImpl.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene40/values/VarStraightBytesImpl.java
@@ -22,11 +22,11 @@ import java.io.IOException;
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 @@ class VarStraightBytesImpl {
}
@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 @@ class VarStraightBytesImpl {
}
@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);
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesConsumer.java b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesConsumer.java
index f662b220cbe..96aac281faa 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesConsumer.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextDocValuesConsumer.java
@@ -21,7 +21,7 @@ import org.apache.lucene.codecs.DocValuesArraySource;
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 @@ public class SimpleTextDocValuesConsumer extends DocValuesConsumer {
}
@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) {
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsWriter.java
index 3d38879e5c0..6a9b223c2a5 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsWriter.java
@@ -23,7 +23,7 @@ import org.apache.lucene.codecs.StoredFieldsWriter;
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 @@ public class SimpleTextStoredFieldsWriter extends StoredFieldsWriter {
}
@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();
diff --git a/lucene/core/src/java/org/apache/lucene/document/ByteDocValuesField.java b/lucene/core/src/java/org/apache/lucene/document/ByteDocValuesField.java
index 915f5f15c4e..707ec2e8bc4 100644
--- a/lucene/core/src/java/org/apache/lucene/document/ByteDocValuesField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/ByteDocValuesField.java
@@ -36,7 +36,7 @@ import org.apache.lucene.index.DocValues;
* @see DocValues for further information
* */
-public class ByteDocValuesField extends Field {
+public class ByteDocValuesField extends StoredField {
public static final FieldType TYPE = new FieldType();
static {
diff --git a/lucene/core/src/java/org/apache/lucene/document/DerefBytesDocValuesField.java b/lucene/core/src/java/org/apache/lucene/document/DerefBytesDocValuesField.java
index 99d68291463..a4f9ab2f763 100644
--- a/lucene/core/src/java/org/apache/lucene/document/DerefBytesDocValuesField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/DerefBytesDocValuesField.java
@@ -41,7 +41,7 @@ import org.apache.lucene.util.BytesRef;
* @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();
diff --git a/lucene/core/src/java/org/apache/lucene/document/Document.java b/lucene/core/src/java/org/apache/lucene/document/Document.java
index da8424b54c4..4f3251ee551 100644
--- a/lucene/core/src/java/org/apache/lucene/document/Document.java
+++ b/lucene/core/src/java/org/apache/lucene/document/Document.java
@@ -19,11 +19,16 @@ package org.apache.lucene.document;
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.search.IndexSearcher; // for javadoc
import org.apache.lucene.search.ScoreDoc; // for javadoc
import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.FilterIterator;
+
+import com.google.common.collect.AbstractIterator;
/** Documents are the unit of indexing and search.
*
@@ -38,18 +43,15 @@ import org.apache.lucene.util.BytesRef;
* 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();
- }
-
+
/**
*
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 +62,7 @@ public final class Document implements Iterable {
* 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 +77,9 @@ public final class Document implements Iterable {
* 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 +97,9 @@ public final class Document implements Iterable {
* 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 +118,10 @@ public final class Document implements Iterable {
*/
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 +143,10 @@ public final class Document implements Iterable {
* @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) {
@@ -188,7 +196,12 @@ public final class Document implements Iterable {
* IndexReader#document(int)}.
*/
public final List getFields() {
- return fields;
+ List result = new ArrayList();
+ for (IndexableField field : fields) {
+ result.add(field);
+ }
+
+ return result;
}
private final static String[] NO_STRINGS = new String[0];
@@ -205,7 +218,10 @@ public final class Document implements Iterable {
*/
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 +243,10 @@ public final class Document implements Iterable {
* 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 +268,46 @@ public final class Document implements Iterable {
buffer.append(">");
return buffer.toString();
}
+
+ @Override
+ public Iterable extends IndexableField> indexableFields() {
+ Iterator it = indexedFieldsIterator();
+
+ List result = new ArrayList();
+ while(it.hasNext()) {
+ result.add(it.next());
+ }
+
+ return result;
+ }
+
+ @Override
+ public Iterable extends StorableField> storableFields() {
+ Iterator it = storedFieldsIterator();
+
+ List result = new ArrayList();
+ while(it.hasNext()) {
+ result.add(it.next());
+ }
+
+ return result;
+ }
+
+ public Iterator storedFieldsIterator() {
+ return new FilterIterator(fields.iterator()) {
+ @Override
+ protected boolean predicateFunction(Field field) {
+ return field.type.stored();
+ }
+ };
+ }
+
+ public Iterator indexedFieldsIterator() {
+ return new FilterIterator(fields.iterator()) {
+ @Override
+ protected boolean predicateFunction(Field field) {
+ return field.type.indexed();
+ }
+ };
+ }
}
diff --git a/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java b/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java
index 275dc94374f..9b72651c5fa 100644
--- a/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java
+++ b/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java
@@ -34,7 +34,7 @@ import org.apache.lucene.index.StoredFieldVisitor;
* @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>. */
@@ -62,12 +62,15 @@ public class DocumentStoredFieldVisitor extends StoredFieldVisitor {
@Override
public void stringField(FieldInfo fieldInfo, String value) throws IOException {
+ /*
final FieldType ft = new FieldType(TextField.TYPE_STORED);
ft.setStoreTermVectors(fieldInfo.hasVectors());
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));
+ //doc.add(new Field(fieldInfo.name, value, ft));
}
@Override
@@ -95,7 +98,7 @@ public class DocumentStoredFieldVisitor extends StoredFieldVisitor {
return fieldsToAdd == null || fieldsToAdd.contains(fieldInfo.name) ? Status.YES : Status.NO;
}
- public Document getDocument() {
+ public StoredDocument getDocument() {
return doc;
}
}
diff --git a/lucene/core/src/java/org/apache/lucene/document/DoubleDocValuesField.java b/lucene/core/src/java/org/apache/lucene/document/DoubleDocValuesField.java
index 1a0c225ee38..c7d0fb113ed 100644
--- a/lucene/core/src/java/org/apache/lucene/document/DoubleDocValuesField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/DoubleDocValuesField.java
@@ -36,7 +36,7 @@ import org.apache.lucene.index.DocValues;
* @see DocValues for further information
* */
-public class DoubleDocValuesField extends Field {
+public class DoubleDocValuesField extends StoredField {
public static final FieldType TYPE = new FieldType();
static {
diff --git a/lucene/core/src/java/org/apache/lucene/document/DoubleField.java b/lucene/core/src/java/org/apache/lucene/document/DoubleField.java
index 32a01460d38..17fb53374d5 100644
--- a/lucene/core/src/java/org/apache/lucene/document/DoubleField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/DoubleField.java
@@ -116,7 +116,6 @@ public final class DoubleField extends Field {
public static final FieldType TYPE_NOT_STORED = new FieldType();
static {
- TYPE_NOT_STORED.setIndexed(true);
TYPE_NOT_STORED.setTokenized(true);
TYPE_NOT_STORED.setOmitNorms(true);
TYPE_NOT_STORED.setIndexOptions(IndexOptions.DOCS_ONLY);
diff --git a/lucene/core/src/java/org/apache/lucene/document/Field.java b/lucene/core/src/java/org/apache/lucene/document/Field.java
index 47cd3e44f27..e12f86008d4 100644
--- a/lucene/core/src/java/org/apache/lucene/document/Field.java
+++ b/lucene/core/src/java/org/apache/lucene/document/Field.java
@@ -31,6 +31,7 @@ import org.apache.lucene.index.IndexWriter; // javadocs
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
@@ -59,7 +60,7 @@ import org.apache.lucene.index.FieldInvertState; // javadocs
* 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;
diff --git a/lucene/core/src/java/org/apache/lucene/document/FieldType.java b/lucene/core/src/java/org/apache/lucene/document/FieldType.java
index 07cf30d11e5..facfcc75728 100644
--- a/lucene/core/src/java/org/apache/lucene/document/FieldType.java
+++ b/lucene/core/src/java/org/apache/lucene/document/FieldType.java
@@ -20,13 +20,14 @@ package org.apache.lucene.document;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.FieldInfo.IndexOptions;
import org.apache.lucene.index.IndexableFieldType;
+import org.apache.lucene.index.StorableFieldType;
import org.apache.lucene.search.NumericRangeQuery; // javadocs
import org.apache.lucene.util.NumericUtils;
/**
* Describes the properties of a field.
*/
-public class FieldType implements IndexableFieldType {
+public class FieldType implements IndexableFieldType, StorableFieldType {
/** Data type of the numeric value
* @since 3.2
@@ -41,10 +42,10 @@ public class FieldType implements IndexableFieldType {
private boolean storeTermVectorPositions;
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();
@@ -150,16 +151,6 @@ public class FieldType implements IndexableFieldType {
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;
@@ -238,4 +229,16 @@ public class FieldType implements IndexableFieldType {
return result.toString();
}
+
+ /* from StorableFieldType */
+
+ @Override
+ public DocValues.Type docValueType() {
+ return docValueType;
+ }
+
+ public void setDocValueType(DocValues.Type type) {
+ checkIfFrozen();
+ docValueType = type;
+ }
}
diff --git a/lucene/core/src/java/org/apache/lucene/document/FloatDocValuesField.java b/lucene/core/src/java/org/apache/lucene/document/FloatDocValuesField.java
index 6add5e56866..178a82a0ec3 100644
--- a/lucene/core/src/java/org/apache/lucene/document/FloatDocValuesField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/FloatDocValuesField.java
@@ -35,7 +35,7 @@ import org.apache.lucene.index.DocValues;
* @see DocValues for further information
* */
-public class FloatDocValuesField extends Field {
+public class FloatDocValuesField extends StoredField {
public static final FieldType TYPE = new FieldType();
static {
diff --git a/lucene/core/src/java/org/apache/lucene/document/FloatField.java b/lucene/core/src/java/org/apache/lucene/document/FloatField.java
index dcb5ea76cfc..9ac68f7b91f 100644
--- a/lucene/core/src/java/org/apache/lucene/document/FloatField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/FloatField.java
@@ -116,7 +116,6 @@ public final class FloatField extends Field {
public static final FieldType TYPE_NOT_STORED = new FieldType();
static {
- TYPE_NOT_STORED.setIndexed(true);
TYPE_NOT_STORED.setTokenized(true);
TYPE_NOT_STORED.setOmitNorms(true);
TYPE_NOT_STORED.setIndexOptions(IndexOptions.DOCS_ONLY);
diff --git a/lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java b/lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java
index 7b10662a7e3..0193e6909b0 100644
--- a/lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/IntDocValuesField.java
@@ -35,7 +35,7 @@ import org.apache.lucene.index.DocValues;
* @see DocValues for further information
* */
-public class IntDocValuesField extends Field {
+public class IntDocValuesField extends StoredField {
public static final FieldType TYPE = new FieldType();
static {
diff --git a/lucene/core/src/java/org/apache/lucene/document/IntField.java b/lucene/core/src/java/org/apache/lucene/document/IntField.java
index 648da431b78..7250d75fc25 100644
--- a/lucene/core/src/java/org/apache/lucene/document/IntField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/IntField.java
@@ -116,7 +116,6 @@ public final class IntField extends Field {
public static final FieldType TYPE_NOT_STORED = new FieldType();
static {
- TYPE_NOT_STORED.setIndexed(true);
TYPE_NOT_STORED.setTokenized(true);
TYPE_NOT_STORED.setOmitNorms(true);
TYPE_NOT_STORED.setIndexOptions(IndexOptions.DOCS_ONLY);
diff --git a/lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java b/lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java
index 0b78eb93c4a..2a3f22caac1 100644
--- a/lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/LongDocValuesField.java
@@ -35,7 +35,7 @@ import org.apache.lucene.index.DocValues;
* @see DocValues for further information
* */
-public class LongDocValuesField extends Field {
+public class LongDocValuesField extends StoredField {
public static final FieldType TYPE = new FieldType();
static {
diff --git a/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java b/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java
index eceff093ab5..c1e72b3c8eb 100644
--- a/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java
@@ -39,7 +39,7 @@ import org.apache.lucene.index.AtomicReader; // javadocs
* @see DocValues for further information
* */
-public class PackedLongDocValuesField extends Field {
+public class PackedLongDocValuesField extends StoredField {
public static final FieldType TYPE = new FieldType();
static {
diff --git a/lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java b/lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java
index 2b08803197e..79c0bdee403 100644
--- a/lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/ShortDocValuesField.java
@@ -36,7 +36,7 @@ import org.apache.lucene.index.DocValues;
* @see DocValues for further information
* */
-public class ShortDocValuesField extends Field {
+public class ShortDocValuesField extends StoredField {
public static final FieldType TYPE = new FieldType();
static {
diff --git a/lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java b/lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java
index 07892ced7c6..f8e9ce991f7 100644
--- a/lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/SortedBytesDocValuesField.java
@@ -37,7 +37,7 @@ import org.apache.lucene.util.BytesRef;
* @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();
diff --git a/lucene/core/src/java/org/apache/lucene/document/StoredDocument.java b/lucene/core/src/java/org/apache/lucene/document/StoredDocument.java
new file mode 100644
index 00000000000..a2eab0b0931
--- /dev/null
+++ b/lucene/core/src/java/org/apache/lucene/document/StoredDocument.java
@@ -0,0 +1,201 @@
+package org.apache.lucene.document;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.lucene.index.StorableField;
+import org.apache.lucene.util.BytesRef;
+
+/**
+ * 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.
+ */
+
+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()]);
+ }
+
+ public final StorableField getField(String name) {
+ for (StorableField field : fields) {
+ if (field.name().equals(name)) {
+ return field;
+ }
+ }
+ return null;
+ }
+
+ public final void removeField(String name) {
+ Iterator it = fields.iterator();
+ while (it.hasNext()) {
+ StorableField field = it.next();
+ if (field.name().equals(name)) {
+ it.remove();
+ return;
+ }
+ }
+ }
+
+ /**
+ *
Removes all fields with the given name from the document.
+ * If there is no field with the specified name, the document remains unchanged.
+ *
Note that the removeField(s) methods like the add method only make sense
+ * prior to adding a document to an index. These methods cannot
+ * be used to change the content of an existing index! In order to achieve this,
+ * a document has to be deleted from an index and a new changed version of that
+ * document has to be added.
+ */
+ public final void removeFields(String name) {
+ Iterator it = fields.iterator();
+ while (it.hasNext()) {
+ StorableField field = it.next();
+ if (field.name().equals(name)) {
+ it.remove();
+ }
+ }
+ }
+
+ 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;
+ }
+
+ public Document asIndexable() {
+ Document doc = new Document();
+
+ for (StorableField field : fields) {
+ Field newField = new Field(field.name(), 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();
+
+ doc.add(newField);
+ }
+
+ return doc;
+ }
+}
diff --git a/lucene/core/src/java/org/apache/lucene/document/StoredField.java b/lucene/core/src/java/org/apache/lucene/document/StoredField.java
index 692768a5a8c..d5e046a87f8 100644
--- a/lucene/core/src/java/org/apache/lucene/document/StoredField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/StoredField.java
@@ -24,7 +24,7 @@ import org.apache.lucene.util.BytesRef;
/** 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 +33,16 @@ public final class StoredField extends Field {
TYPE.freeze();
}
+ protected StoredField(String name, FieldType type) {
+ super(name, type);
+ this.type.setStored(true);
+ }
+
+ public StoredField(String name, BytesRef bytes, FieldType type) {
+ super(name, bytes, type);
+ this.type.setStored(true);
+ }
+
public StoredField(String name, byte[] value) {
super(name, value, TYPE);
}
diff --git a/lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java b/lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java
index a59dd47f188..3fc912ba5cd 100644
--- a/lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/StraightBytesDocValuesField.java
@@ -40,7 +40,7 @@ import org.apache.lucene.util.BytesRef;
* @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();
diff --git a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
index c6281bb723e..6ec7284b594 100644
--- a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
+++ b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java
@@ -31,6 +31,7 @@ import org.apache.lucene.codecs.BlockTreeTermsReader;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.FieldType; // for javadocs
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.DocValues.SortedSource;
import org.apache.lucene.index.DocValues.Source;
import org.apache.lucene.search.DocIdSetIterator;
@@ -1227,7 +1228,7 @@ public class CheckIndex {
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();
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocFieldProcessor.java b/lucene/core/src/java/org/apache/lucene/index/DocFieldProcessor.java
index 09299701ad3..15389c8387d 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocFieldProcessor.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocFieldProcessor.java
@@ -218,7 +218,7 @@ final class DocFieldProcessor extends DocConsumer {
// 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();
// Make sure we have a PerField allocated
@@ -266,17 +266,24 @@ final class DocFieldProcessor extends DocConsumer {
}
fp.addField(field);
+ }
+ for (StorableField field: docState.doc.storableFields()) {
+ final String fieldName = field.name();
- if (field.fieldType().stored()) {
- fieldsWriter.addField(field, fp.fieldInfo);
+ // 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;
}
+
final DocValues.Type dvType = field.fieldType().docValueType();
if (dvType != null) {
DocValuesConsumerHolder docValuesConsumer = docValuesConsumer(dvType,
docState, fp.fieldInfo);
DocValuesConsumer consumer = docValuesConsumer.docValuesConsumer;
if (docValuesConsumer.compatibility == null) {
- consumer.add(docState.docID, field);
+ consumer.add(docState.docID, (StorableField) field);
docValuesConsumer.compatibility = new TypeCompatibility(dvType,
consumer.getValueSize());
} else if (docValuesConsumer.compatibility.isCompatible(dvType,
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocInverterPerField.java b/lucene/core/src/java/org/apache/lucene/index/DocInverterPerField.java
index 0ef2a6f6a2c..667deaae4a3 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocInverterPerField.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocInverterPerField.java
@@ -75,7 +75,7 @@ final class DocInverterPerField extends DocFieldConsumerPerField {
// TODO FI: this should be "genericized" to querying
// consumer if it wants to see this particular field
// tokenized.
- if (fieldType.indexed() && doInvert) {
+ if (doInvert) {
// if the field omits norms, the boost cannot be indexed.
if (fieldType.omitNorms() && field.boost() != 1.0f) {
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
index b66e088a039..4d3754b5a10 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
@@ -322,7 +322,7 @@ final class DocumentsWriter {
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();
@@ -353,7 +353,7 @@ final class DocumentsWriter {
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();
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
index ec393366a22..9a2792742d5 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
@@ -93,7 +93,7 @@ class DocumentsWriterPerThread {
InfoStream infoStream;
Similarity similarity;
int docID;
- Iterable extends IndexableField> doc;
+ IndexDocument doc;
String maxTermPrefix;
DocState(DocumentsWriterPerThread docWriter, InfoStream infoStream) {
@@ -224,7 +224,7 @@ class DocumentsWriterPerThread {
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;
@@ -277,7 +277,7 @@ class DocumentsWriterPerThread {
}
}
- 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;
@@ -289,7 +289,7 @@ class DocumentsWriterPerThread {
}
int docCount = 0;
try {
- for(Iterable extends IndexableField> doc : docs) {
+ for(IndexDocument doc : docs) {
docState.doc = doc;
docState.docID = numDocsInRAM;
docCount++;
diff --git a/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java b/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
index f0ff871b64f..1b9a98d924c 100644
--- a/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
+++ b/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
@@ -260,7 +260,7 @@ public class FieldInfos implements Iterable {
// rather, each component in the chain should update
// what it "owns". EG fieldType.indexOptions() should
// be updated by maybe FreqProxTermsWriterPerField:
- return addOrUpdateInternal(name, -1, fieldType.indexed(), false,
+ return addOrUpdateInternal(name, -1, true, false,
fieldType.omitNorms(), false,
fieldType.indexOptions(), null, null);
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java b/lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java
index 425f158afce..2ca2ed97d76 100644
--- a/lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java
+++ b/lucene/core/src/java/org/apache/lucene/index/FreqProxTermsWriterPerField.java
@@ -103,12 +103,7 @@ final class FreqProxTermsWriterPerField extends TermsHashConsumerPerField implem
@Override
boolean start(IndexableField[] fields, int count) {
- for(int i=0;i indexableFields();
+ public Iterable extends StorableField> storableFields();
+}
diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexReader.java b/lucene/core/src/java/org/apache/lucene/index/IndexReader.java
index 59b6e911929..9c4624a7dbb 100644
--- a/lucene/core/src/java/org/apache/lucene/index/IndexReader.java
+++ b/lucene/core/src/java/org/apache/lucene/index/IndexReader.java
@@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.DocumentStoredFieldVisitor;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.search.SearcherManager; // javadocs
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.util.Bits;
@@ -340,7 +341,7 @@ public abstract class IndexReader implements Closeable {
// 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();
@@ -351,8 +352,10 @@ public abstract class IndexReader implements Closeable {
* 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();
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
index 498c5be24da..5950e1c042b 100644
--- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
@@ -1050,7 +1050,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
* @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);
}
@@ -1069,7 +1069,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
* @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);
}
@@ -1114,7 +1114,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
*
* @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);
}
@@ -1129,7 +1129,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
*
* @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);
}
@@ -1146,7 +1146,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
*
* @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);
}
@@ -1164,7 +1164,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
*
* @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;
@@ -1289,7 +1289,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
* @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());
}
@@ -1312,7 +1312,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
* @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 {
diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexableField.java b/lucene/core/src/java/org/apache/lucene/index/IndexableField.java
index 0408bab4d99..8154fc33303 100644
--- a/lucene/core/src/java/org/apache/lucene/index/IndexableField.java
+++ b/lucene/core/src/java/org/apache/lucene/index/IndexableField.java
@@ -37,25 +37,10 @@ public interface IndexableField {
/** Field name */
public String name();
-
+
/** {@link IndexableFieldType} describing the properties
* of this field. */
public IndexableFieldType fieldType();
-
- /** Field boost (you must pre-multiply in any doc boost). */
- public float boost();
-
- /** 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();
/**
* Creates the TokenStream used for indexing this field. If appropriate,
@@ -67,4 +52,7 @@ public interface IndexableField {
* @throws IOException Can be thrown while creating the TokenStream
*/
public TokenStream tokenStream(Analyzer analyzer) throws IOException;
+
+ /** Field boost (you must pre-multiply in any doc boost). */
+ public float boost();
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexableFieldType.java b/lucene/core/src/java/org/apache/lucene/index/IndexableFieldType.java
index 38b974954a6..98fbd7e9dc3 100644
--- a/lucene/core/src/java/org/apache/lucene/index/IndexableFieldType.java
+++ b/lucene/core/src/java/org/apache/lucene/index/IndexableFieldType.java
@@ -25,12 +25,6 @@ import org.apache.lucene.index.FieldInfo.IndexOptions;
*/
public interface IndexableFieldType {
- /** True if this field should be indexed (inverted) */
- public boolean indexed();
-
- /** True if the field's value should be stored */
- public boolean stored();
-
/** True if this field's value should be analyzed */
public boolean tokenized();
@@ -49,8 +43,4 @@ public interface IndexableFieldType {
/** {@link IndexOptions}, describing what should be
* recorded into the inverted index */
public IndexOptions indexOptions();
-
- /** DocValues type; if non-null then the field's value
- * will be indexed into docValues */
- public DocValues.Type docValueType();
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/Norm.java b/lucene/core/src/java/org/apache/lucene/index/Norm.java
index 4f338c36025..2e668a00eeb 100644
--- a/lucene/core/src/java/org/apache/lucene/index/Norm.java
+++ b/lucene/core/src/java/org/apache/lucene/index/Norm.java
@@ -26,6 +26,7 @@ import org.apache.lucene.document.LongDocValuesField;
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;
@@ -43,13 +44,13 @@ import org.apache.lucene.util.BytesRef;
* @lucene.internal
*/
public final class Norm {
- private Field field;
+ private StoredField field;
private BytesRef spare;
/**
* Returns the {@link IndexableField} representation for this norm
*/
- public IndexableField field() {
+ public StoredField field() {
return field;
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java b/lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java
index 6532330cb1f..47c5f675044 100644
--- a/lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java
+++ b/lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java
@@ -51,10 +51,10 @@ final class NormsConsumerPerField extends InvertedDocEndConsumerPerField impleme
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);
+ consumer.add(docState.docID, (StorableField) field);
}
}
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/PersistentSnapshotDeletionPolicy.java b/lucene/core/src/java/org/apache/lucene/index/PersistentSnapshotDeletionPolicy.java
index ebae93a549b..24cdfd6a76f 100644
--- a/lucene/core/src/java/org/apache/lucene/index/PersistentSnapshotDeletionPolicy.java
+++ b/lucene/core/src/java/org/apache/lucene/index/PersistentSnapshotDeletionPolicy.java
@@ -26,6 +26,8 @@ import java.util.Map.Entry;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.StoredDocument;
+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,12 +69,12 @@ public class PersistentSnapshotDeletionPolicy extends SnapshotDeletionPolicy {
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) {
+ for (StorableField f : doc) {
snapshots.put(f.name(), f.stringValue());
}
} else if (numDocs != 0) {
@@ -184,14 +186,12 @@ public class PersistentSnapshotDeletionPolicy extends SnapshotDeletionPolicy {
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();
diff --git a/lucene/core/src/java/org/apache/lucene/index/StorableField.java b/lucene/core/src/java/org/apache/lucene/index/StorableField.java
new file mode 100644
index 00000000000..767f3c94c94
--- /dev/null
+++ b/lucene/core/src/java/org/apache/lucene/index/StorableField.java
@@ -0,0 +1,44 @@
+package org.apache.lucene.index;
+
+import java.io.Reader;
+
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.util.BytesRef;
+
+/**
+ * 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.
+ */
+
+public interface StorableField {
+
+ /** Field name */
+ public String name();
+
+ /** Field type */
+ public FieldType fieldType();
+
+ /** 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();
+}
diff --git a/lucene/core/src/java/org/apache/lucene/index/StorableFieldType.java b/lucene/core/src/java/org/apache/lucene/index/StorableFieldType.java
new file mode 100644
index 00000000000..38f65ed523f
--- /dev/null
+++ b/lucene/core/src/java/org/apache/lucene/index/StorableFieldType.java
@@ -0,0 +1,25 @@
+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.
+ */
+
+public interface StorableFieldType {
+
+ /** DocValues type; if non-null then the field's value
+ * will be indexed into docValues */
+ public DocValues.Type docValueType();
+}
diff --git a/lucene/core/src/java/org/apache/lucene/index/StoredFieldsConsumer.java b/lucene/core/src/java/org/apache/lucene/index/StoredFieldsConsumer.java
index 3241d38358a..b22c48a7a42 100644
--- a/lucene/core/src/java/org/apache/lucene/index/StoredFieldsConsumer.java
+++ b/lucene/core/src/java/org/apache/lucene/index/StoredFieldsConsumer.java
@@ -44,12 +44,12 @@ final class StoredFieldsConsumer {
}
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 @@ final class StoredFieldsConsumer {
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;
diff --git a/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumerPerField.java b/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumerPerField.java
index e1338402e06..8b263c87411 100644
--- a/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumerPerField.java
+++ b/lucene/core/src/java/org/apache/lucene/index/TermVectorsConsumerPerField.java
@@ -61,7 +61,7 @@ final class TermVectorsConsumerPerField extends TermsHashConsumerPerField {
for(int i=0;i.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 @@ public class IndexSearcher {
}
/** 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);
}
diff --git a/lucene/core/src/java/org/apache/lucene/search/NRTManager.java b/lucene/core/src/java/org/apache/lucene/search/NRTManager.java
index 8f6719c708e..8d3141ce76f 100644
--- a/lucene/core/src/java/org/apache/lucene/search/NRTManager.java
+++ b/lucene/core/src/java/org/apache/lucene/search/NRTManager.java
@@ -27,6 +27,7 @@ import java.util.concurrent.locks.ReentrantLock;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexDocument;
import org.apache.lucene.index.IndexReader; // javadocs
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexableField;
@@ -153,25 +154,25 @@ public class NRTManager extends ReferenceManager {
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();
@@ -207,25 +208,25 @@ public class NRTManager extends ReferenceManager {
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();
diff --git a/lucene/core/src/java/org/apache/lucene/util/FilterIterator.java b/lucene/core/src/java/org/apache/lucene/util/FilterIterator.java
new file mode 100644
index 00000000000..c72956eb910
--- /dev/null
+++ b/lucene/core/src/java/org/apache/lucene/util/FilterIterator.java
@@ -0,0 +1,68 @@
+package org.apache.lucene.util;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * 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.
+ */
+
+public abstract class FilterIterator implements Iterator {
+
+ private Iterator iterator;
+ private T next = null;
+ private boolean nextIsSet = false;
+
+ protected abstract boolean predicateFunction(U field);
+
+ public FilterIterator(Iterator baseIterator) {
+ this.iterator = baseIterator;
+ }
+
+ public boolean hasNext() {
+ if (nextIsSet) {
+ return true;
+ } else {
+ return setNext();
+ }
+ }
+
+ public T next() {
+ if (!nextIsSet) {
+ if (!setNext()) {
+ throw new NoSuchElementException();
+ }
+ }
+ nextIsSet = false;
+ return next;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ private boolean setNext() {
+ while (iterator.hasNext()) {
+ U object = iterator.next();
+ if (predicateFunction(object)) {
+ next = object;
+ nextIsSet = true;
+ return true;
+ }
+ }
+ return false;
+ }
+}
From 00d53046db9a8a41e495b8e95d3ebf7cf16bdd13 Mon Sep 17 00:00:00 2001
From: Uwe Schindler
Date: Mon, 9 Jul 2012 13:06:35 +0000
Subject: [PATCH 03/13] LUCENE-3312: Apply lucene-3312-patch-07.patch
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3312@1359139 13f79535-47bb-0310-9956-ffa450edef68
---
.../org/apache/lucene/document/Document.java | 10 +-
.../document/DocumentStoredFieldVisitor.java | 5 +-
.../apache/lucene/document/DoubleField.java | 1 +
.../org/apache/lucene/document/FieldType.java | 4 +-
.../apache/lucene/document/FloatField.java | 1 +
.../org/apache/lucene/document/IntField.java | 1 +
.../document/PackedLongDocValuesField.java | 1 +
.../lucene/document/StoredDocument.java | 18 ++-
.../apache/lucene/document/StoredField.java | 6 +-
.../lucene/index/DocFieldProcessor.java | 103 +++++++--------
.../org/apache/lucene/index/FieldInfos.java | 2 +-
.../org/apache/lucene/index/GeneralField.java | 44 +++++++
.../apache/lucene/index/IndexableField.java | 9 +-
.../lucene/index/IndexableFieldType.java | 10 ++
.../apache/lucene/index/StorableField.java | 19 +--
.../src/test/org/apache/lucene/TestDemo.java | 3 +-
.../test/org/apache/lucene/TestSearch.java | 2 +-
.../lucene/TestSearchForDuplicates.java | 4 +-
.../codecs/appending/TestAppendingCodec.java | 3 +-
.../codecs/lucene40/values/TestDocValues.java | 16 +--
.../lucene/document/TestBinaryDocument.java | 12 +-
.../apache/lucene/document/TestDocument.java | 13 +-
.../apache/lucene/index/TestAddIndexes.java | 3 +-
.../index/TestBackwardsCompatibility.java | 15 +--
.../apache/lucene/index/TestCustomNorms.java | 3 +-
.../lucene/index/TestDirectoryReader.java | 25 ++--
.../index/TestDirectoryReaderReopen.java | 3 +-
.../apache/lucene/index/TestDocTermOrds.java | 4 +-
.../lucene/index/TestDocumentWriter.java | 5 +-
.../lucene/index/TestDuelingCodecs.java | 15 +--
.../apache/lucene/index/TestFieldInfos.java | 2 +-
.../apache/lucene/index/TestFieldsReader.java | 11 +-
.../apache/lucene/index/TestIndexWriter.java | 13 +-
.../lucene/index/TestIndexWriterMerging.java | 3 +-
.../lucene/index/TestIndexWriterReader.java | 9 +-
.../lucene/index/TestIndexWriterUnicode.java | 3 +-
.../lucene/index/TestIndexableField.java | 118 ++++++++++++++----
.../org/apache/lucene/index/TestNorms.java | 5 +-
.../index/TestParallelAtomicReader.java | 5 +-
.../index/TestParallelCompositeReader.java | 5 +-
.../lucene/index/TestPostingsOffsets.java | 2 +-
.../lucene/index/TestRandomStoredFields.java | 3 +-
.../lucene/index/TestSegmentMerger.java | 5 +-
.../lucene/index/TestSegmentReader.java | 7 +-
.../lucene/index/TestStressIndexing2.java | 17 +--
.../apache/lucene/index/TestStressNRT.java | 5 +-
.../apache/lucene/index/TestTermsEnum.java | 2 +-
.../search/TestBooleanMinShouldMatch.java | 3 +-
.../apache/lucene/search/TestDateSort.java | 3 +-
.../search/TestDisjunctionMaxQuery.java | 3 +-
.../apache/lucene/search/TestNRTManager.java | 11 +-
.../search/TestNumericRangeQuery32.java | 7 +-
.../search/TestNumericRangeQuery64.java | 7 +-
.../org/apache/lucene/search/TestSort.java | 12 +-
.../search/spans/TestSpansAdvanced.java | 3 +-
.../apache/lucene/store/TestRAMDirectory.java | 3 +-
.../org/apache/lucene/demo/SearchFiles.java | 3 +-
.../demo/xmlparser/FormBasedXmlQueryDemo.java | 3 +-
.../lucene/analysis/CollationTestBase.java | 6 +-
.../org/apache/lucene/index/DocHelper.java | 5 +
.../lucene/index/RandomIndexWriter.java | 26 ++--
.../ThreadedIndexingAndSearchingTestCase.java | 13 +-
.../org/apache/lucene/util/_TestUtil.java | 2 +-
63 files changed, 423 insertions(+), 262 deletions(-)
create mode 100644 lucene/core/src/java/org/apache/lucene/index/GeneralField.java
diff --git a/lucene/core/src/java/org/apache/lucene/document/Document.java b/lucene/core/src/java/org/apache/lucene/document/Document.java
index 4f3251ee551..049035deaf4 100644
--- a/lucene/core/src/java/org/apache/lucene/document/Document.java
+++ b/lucene/core/src/java/org/apache/lucene/document/Document.java
@@ -28,8 +28,6 @@ import org.apache.lucene.search.ScoreDoc; // for javadoc
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.FilterIterator;
-import com.google.common.collect.AbstractIterator;
-
/** Documents are the unit of indexing and search.
*
* A Document is a set of fields. Each field has a name and a textual value.
@@ -66,6 +64,14 @@ public final class Document implements IndexDocument{
fields.add(field);
}
+ public final void add(IndexableField field) {
+ fields.add((Field) field);
+ }
+
+ public final void add(StorableField field) {
+ fields.add((Field) field);
+ }
+
/**
*
Removes field with the specified name from the document.
* If multiple fields exist with this name, this method removes the first field that has been added.
diff --git a/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java b/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java
index 9b72651c5fa..c7ecc4e562c 100644
--- a/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java
+++ b/lucene/core/src/java/org/apache/lucene/document/DocumentStoredFieldVisitor.java
@@ -62,15 +62,12 @@ public class DocumentStoredFieldVisitor extends StoredFieldVisitor {
@Override
public void stringField(FieldInfo fieldInfo, String value) throws IOException {
- /*
final FieldType ft = new FieldType(TextField.TYPE_STORED);
ft.setStoreTermVectors(fieldInfo.hasVectors());
ft.setIndexed(fieldInfo.isIndexed());
ft.setOmitNorms(fieldInfo.omitsNorms());
ft.setIndexOptions(fieldInfo.getIndexOptions());
- */
- doc.add(new StoredField(fieldInfo.name, value));
- //doc.add(new Field(fieldInfo.name, value, ft));
+ doc.add(new StoredField(fieldInfo.name, value, ft));
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/document/DoubleField.java b/lucene/core/src/java/org/apache/lucene/document/DoubleField.java
index 17fb53374d5..32a01460d38 100644
--- a/lucene/core/src/java/org/apache/lucene/document/DoubleField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/DoubleField.java
@@ -116,6 +116,7 @@ public final class DoubleField extends Field {
public static final FieldType TYPE_NOT_STORED = new FieldType();
static {
+ TYPE_NOT_STORED.setIndexed(true);
TYPE_NOT_STORED.setTokenized(true);
TYPE_NOT_STORED.setOmitNorms(true);
TYPE_NOT_STORED.setIndexOptions(IndexOptions.DOCS_ONLY);
diff --git a/lucene/core/src/java/org/apache/lucene/document/FieldType.java b/lucene/core/src/java/org/apache/lucene/document/FieldType.java
index facfcc75728..61e2c7347bb 100644
--- a/lucene/core/src/java/org/apache/lucene/document/FieldType.java
+++ b/lucene/core/src/java/org/apache/lucene/document/FieldType.java
@@ -20,14 +20,13 @@ package org.apache.lucene.document;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.FieldInfo.IndexOptions;
import org.apache.lucene.index.IndexableFieldType;
-import org.apache.lucene.index.StorableFieldType;
import org.apache.lucene.search.NumericRangeQuery; // javadocs
import org.apache.lucene.util.NumericUtils;
/**
* Describes the properties of a field.
*/
-public class FieldType implements IndexableFieldType, StorableFieldType {
+public class FieldType implements IndexableFieldType {
/** Data type of the numeric value
* @since 3.2
@@ -240,5 +239,6 @@ public class FieldType implements IndexableFieldType, StorableFieldType {
public void setDocValueType(DocValues.Type type) {
checkIfFrozen();
docValueType = type;
+ this.stored = true;
}
}
diff --git a/lucene/core/src/java/org/apache/lucene/document/FloatField.java b/lucene/core/src/java/org/apache/lucene/document/FloatField.java
index 9ac68f7b91f..dcb5ea76cfc 100644
--- a/lucene/core/src/java/org/apache/lucene/document/FloatField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/FloatField.java
@@ -116,6 +116,7 @@ public final class FloatField extends Field {
public static final FieldType TYPE_NOT_STORED = new FieldType();
static {
+ TYPE_NOT_STORED.setIndexed(true);
TYPE_NOT_STORED.setTokenized(true);
TYPE_NOT_STORED.setOmitNorms(true);
TYPE_NOT_STORED.setIndexOptions(IndexOptions.DOCS_ONLY);
diff --git a/lucene/core/src/java/org/apache/lucene/document/IntField.java b/lucene/core/src/java/org/apache/lucene/document/IntField.java
index 7250d75fc25..648da431b78 100644
--- a/lucene/core/src/java/org/apache/lucene/document/IntField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/IntField.java
@@ -116,6 +116,7 @@ public final class IntField extends Field {
public static final FieldType TYPE_NOT_STORED = new FieldType();
static {
+ TYPE_NOT_STORED.setIndexed(true);
TYPE_NOT_STORED.setTokenized(true);
TYPE_NOT_STORED.setOmitNorms(true);
TYPE_NOT_STORED.setIndexOptions(IndexOptions.DOCS_ONLY);
diff --git a/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java b/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java
index c1e72b3c8eb..401245295c0 100644
--- a/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/PackedLongDocValuesField.java
@@ -44,6 +44,7 @@ public class PackedLongDocValuesField extends StoredField {
public static final FieldType TYPE = new FieldType();
static {
TYPE.setDocValueType(DocValues.Type.VAR_INTS);
+ TYPE.setStored(true);
TYPE.freeze();
}
diff --git a/lucene/core/src/java/org/apache/lucene/document/StoredDocument.java b/lucene/core/src/java/org/apache/lucene/document/StoredDocument.java
index a2eab0b0931..563ea2a8219 100644
--- a/lucene/core/src/java/org/apache/lucene/document/StoredDocument.java
+++ b/lucene/core/src/java/org/apache/lucene/document/StoredDocument.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.StorableField;
import org.apache.lucene.util.BytesRef;
@@ -183,7 +184,7 @@ public class StoredDocument implements Iterable{
Document doc = new Document();
for (StorableField field : fields) {
- Field newField = new Field(field.name(), field.fieldType());
+ Field newField = new Field(field.name(), (FieldType) field.fieldType());
newField.fieldsData = field.stringValue();
if (newField.fieldsData == null)
@@ -198,4 +199,19 @@ public class StoredDocument implements Iterable{
return doc;
}
+
+ /** 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();
+ }
}
diff --git a/lucene/core/src/java/org/apache/lucene/document/StoredField.java b/lucene/core/src/java/org/apache/lucene/document/StoredField.java
index d5e046a87f8..692d48d2152 100644
--- a/lucene/core/src/java/org/apache/lucene/document/StoredField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/StoredField.java
@@ -35,12 +35,10 @@ public class StoredField extends Field {
protected StoredField(String name, FieldType type) {
super(name, type);
- this.type.setStored(true);
}
public StoredField(String name, BytesRef bytes, FieldType type) {
super(name, bytes, type);
- this.type.setStored(true);
}
public StoredField(String name, byte[] value) {
@@ -58,6 +56,10 @@ public class StoredField extends Field {
public StoredField(String name, String value) {
super(name, value, TYPE);
}
+
+ public StoredField(String name, String value, FieldType type) {
+ super(name, value, type);
+ }
public StoredField(String name, int value) {
super(name, TYPE);
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocFieldProcessor.java b/lucene/core/src/java/org/apache/lucene/index/DocFieldProcessor.java
index 15389c8387d..5f7a4acb456 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocFieldProcessor.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocFieldProcessor.java
@@ -28,6 +28,7 @@ import org.apache.lucene.codecs.Codec;
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;
@@ -220,62 +221,18 @@ final class DocFieldProcessor extends DocConsumer {
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;
- }
-
- 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;
- }
+ DocFieldProcessorPerField fp = processField(fieldInfos, thisFieldGen, fieldName, ft);
fp.addField(field);
}
for (StorableField field: docState.doc.storableFields()) {
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);
+ fieldsWriter.addField(field, fp.fieldInfo);
final DocValues.Type dvType = field.fieldType().docValueType();
if (dvType != null) {
@@ -320,6 +277,54 @@ final class DocFieldProcessor extends DocConsumer {
}
}
+ 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);
diff --git a/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java b/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
index 1b9a98d924c..f0ff871b64f 100644
--- a/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
+++ b/lucene/core/src/java/org/apache/lucene/index/FieldInfos.java
@@ -260,7 +260,7 @@ public class FieldInfos implements Iterable {
// rather, each component in the chain should update
// what it "owns". EG fieldType.indexOptions() should
// be updated by maybe FreqProxTermsWriterPerField:
- return addOrUpdateInternal(name, -1, true, false,
+ return addOrUpdateInternal(name, -1, fieldType.indexed(), false,
fieldType.omitNorms(), false,
fieldType.indexOptions(), null, null);
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/GeneralField.java b/lucene/core/src/java/org/apache/lucene/index/GeneralField.java
new file mode 100644
index 00000000000..e1a203d8bc6
--- /dev/null
+++ b/lucene/core/src/java/org/apache/lucene/index/GeneralField.java
@@ -0,0 +1,44 @@
+package org.apache.lucene.index;
+
+import java.io.Reader;
+
+import org.apache.lucene.util.BytesRef;
+
+/*
+ * 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.
+ */
+
+public interface GeneralField {
+
+ /** Field name */
+ public String name();
+
+ /** {@link IndexableFieldType} describing the properties
+ * of this field. */
+ public IndexableFieldType fieldType();
+
+ /** 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();
+}
diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexableField.java b/lucene/core/src/java/org/apache/lucene/index/IndexableField.java
index 8154fc33303..ba8a84cc8a9 100644
--- a/lucene/core/src/java/org/apache/lucene/index/IndexableField.java
+++ b/lucene/core/src/java/org/apache/lucene/index/IndexableField.java
@@ -33,14 +33,7 @@ import org.apache.lucene.util.BytesRef;
*
* @lucene.experimental */
-public interface IndexableField {
-
- /** Field name */
- public String name();
-
- /** {@link IndexableFieldType} describing the properties
- * of this field. */
- public IndexableFieldType fieldType();
+public interface IndexableField extends GeneralField {
/**
* Creates the TokenStream used for indexing this field. If appropriate,
diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexableFieldType.java b/lucene/core/src/java/org/apache/lucene/index/IndexableFieldType.java
index 98fbd7e9dc3..d0e546debea 100644
--- a/lucene/core/src/java/org/apache/lucene/index/IndexableFieldType.java
+++ b/lucene/core/src/java/org/apache/lucene/index/IndexableFieldType.java
@@ -25,6 +25,12 @@ import org.apache.lucene.index.FieldInfo.IndexOptions;
*/
public interface IndexableFieldType {
+ /** True if this field should be indexed (inverted) */
+ public boolean indexed();
+
+ /** True if the field's value should be stored */
+ public boolean stored();
+
/** True if this field's value should be analyzed */
public boolean tokenized();
@@ -43,4 +49,8 @@ public interface IndexableFieldType {
/** {@link IndexOptions}, describing what should be
* recorded into the inverted index */
public IndexOptions indexOptions();
+
+ /** DocValues type; if non-null then the field's value
+ * will be indexed into docValues */
+ public DocValues.Type docValueType();
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/StorableField.java b/lucene/core/src/java/org/apache/lucene/index/StorableField.java
index 767f3c94c94..ed9621eb041 100644
--- a/lucene/core/src/java/org/apache/lucene/index/StorableField.java
+++ b/lucene/core/src/java/org/apache/lucene/index/StorableField.java
@@ -22,23 +22,6 @@ import org.apache.lucene.util.BytesRef;
* limitations under the License.
*/
-public interface StorableField {
-
- /** Field name */
- public String name();
+public interface StorableField extends GeneralField {
- /** Field type */
- public FieldType fieldType();
-
- /** 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();
}
diff --git a/lucene/core/src/test/org/apache/lucene/TestDemo.java b/lucene/core/src/test/org/apache/lucene/TestDemo.java
index 9f36dfebb6a..8d532041754 100644
--- a/lucene/core/src/test/org/apache/lucene/TestDemo.java
+++ b/lucene/core/src/test/org/apache/lucene/TestDemo.java
@@ -23,6 +23,7 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
@@ -64,7 +65,7 @@ public class TestDemo extends LuceneTestCase {
assertEquals(1, hits.totalHits);
// Iterate through the results:
for (int i = 0; i < hits.scoreDocs.length; i++) {
- Document hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
+ StoredDocument hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
assertEquals(text, hitDoc.get("fieldname"));
}
diff --git a/lucene/core/src/test/org/apache/lucene/TestSearch.java b/lucene/core/src/test/org/apache/lucene/TestSearch.java
index 98ee9c9b546..235f45b7ea9 100644
--- a/lucene/core/src/test/org/apache/lucene/TestSearch.java
+++ b/lucene/core/src/test/org/apache/lucene/TestSearch.java
@@ -110,7 +110,7 @@ public class TestSearch extends LuceneTestCase {
out.println(hits.length + " total results");
for (int i = 0 ; i < hits.length && i < 10; i++) {
- Document d = searcher.doc(hits[i].doc);
+ StoredDocument d = searcher.doc(hits[i].doc);
out.println(i + " " + hits[i].score + " " + d.get("contents"));
}
}
diff --git a/lucene/core/src/test/org/apache/lucene/TestSearchForDuplicates.java b/lucene/core/src/test/org/apache/lucene/TestSearchForDuplicates.java
index eecf92a460c..ad1f06ec5db 100644
--- a/lucene/core/src/test/org/apache/lucene/TestSearchForDuplicates.java
+++ b/lucene/core/src/test/org/apache/lucene/TestSearchForDuplicates.java
@@ -127,7 +127,7 @@ public class TestSearchForDuplicates extends LuceneTestCase {
out.println(hits.length + " total results\n");
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);
out.println(i + " " + d.get(ID_FIELD));
}
}
@@ -137,7 +137,7 @@ public class TestSearchForDuplicates extends LuceneTestCase {
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));
}
}
diff --git a/lucene/core/src/test/org/apache/lucene/codecs/appending/TestAppendingCodec.java b/lucene/core/src/test/org/apache/lucene/codecs/appending/TestAppendingCodec.java
index 422d9329d96..a83fea8159a 100644
--- a/lucene/core/src/test/org/apache/lucene/codecs/appending/TestAppendingCodec.java
+++ b/lucene/core/src/test/org/apache/lucene/codecs/appending/TestAppendingCodec.java
@@ -24,6 +24,7 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.codecs.appending.AppendingCodec;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.DocsEnum;
@@ -128,7 +129,7 @@ public class TestAppendingCodec extends LuceneTestCase {
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");
diff --git a/lucene/core/src/test/org/apache/lucene/codecs/lucene40/values/TestDocValues.java b/lucene/core/src/test/org/apache/lucene/codecs/lucene40/values/TestDocValues.java
index c8fcd9eda8c..4aa02a8e46c 100644
--- a/lucene/core/src/test/org/apache/lucene/codecs/lucene40/values/TestDocValues.java
+++ b/lucene/core/src/test/org/apache/lucene/codecs/lucene40/values/TestDocValues.java
@@ -28,12 +28,14 @@ import org.apache.lucene.codecs.DocValuesConsumer;
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,21 +440,11 @@ public class TestDocValues extends LuceneTestCase {
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 @@ public class TestDocValues extends LuceneTestCase {
}
@Override
- public IndexableFieldType fieldType() {
+ public FieldType fieldType() {
return null;
}
}
diff --git a/lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java b/lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java
index 45c72cf0617..cb3092b8e1e 100644
--- a/lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java
+++ b/lucene/core/src/test/org/apache/lucene/document/TestBinaryDocument.java
@@ -37,8 +37,8 @@ public class TestBinaryDocument extends LuceneTestCase {
{
FieldType ft = new FieldType();
ft.setStored(true);
- IndexableField binaryFldStored = new StoredField("binaryStored", binaryValStored.getBytes());
- IndexableField stringFldStored = new Field("stringStored", binaryValStored, ft);
+ StoredField binaryFldStored = new StoredField("binaryStored", binaryValStored.getBytes());
+ Field stringFldStored = new Field("stringStored", binaryValStored, ft);
Document doc = new Document();
@@ -56,7 +56,7 @@ public class TestBinaryDocument extends LuceneTestCase {
/** 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 +75,8 @@ public class TestBinaryDocument extends LuceneTestCase {
}
public void testCompressionTools() throws Exception {
- IndexableField binaryFldCompressed = new StoredField("binaryCompressed", CompressionTools.compress(binaryValCompressed.getBytes()));
- IndexableField stringFldCompressed = new StoredField("stringCompressed", CompressionTools.compressString(binaryValCompressed));
+ StoredField binaryFldCompressed = new StoredField("binaryCompressed", CompressionTools.compress(binaryValCompressed.getBytes()));
+ StoredField stringFldCompressed = new StoredField("stringCompressed", CompressionTools.compressString(binaryValCompressed));
Document doc = new Document();
@@ -90,7 +90,7 @@ public class TestBinaryDocument extends LuceneTestCase {
/** 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 */
diff --git a/lucene/core/src/test/org/apache/lucene/document/TestDocument.java b/lucene/core/src/test/org/apache/lucene/document/TestDocument.java
index d33116bc607..a62a2b39569 100644
--- a/lucene/core/src/test/org/apache/lucene/document/TestDocument.java
+++ b/lucene/core/src/test/org/apache/lucene/document/TestDocument.java
@@ -50,9 +50,9 @@ public class TestDocument extends LuceneTestCase {
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);
@@ -179,7 +179,7 @@ public class TestDocument extends LuceneTestCase {
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,6 +214,9 @@ public class TestDocument extends LuceneTestCase {
return doc;
}
+ private void doAssert(StoredDocument doc) {
+ doAssert(doc.asIndexable(), true);
+ }
private void doAssert(Document doc, boolean fromIndex) {
IndexableField[] keywordFieldValues = doc.getFields("keyword");
IndexableField[] textFieldValues = doc.getFields("text");
@@ -268,7 +271,7 @@ public class TestDocument extends LuceneTestCase {
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;
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java b/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
index 7d394ec96e6..efa608caf53 100755
--- a/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
@@ -45,6 +45,7 @@ import org.apache.lucene.codecs.pulsing.Pulsing40PostingsFormat;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
@@ -1245,7 +1246,7 @@ public class TestAddIndexes extends LuceneTestCase {
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 {
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java b/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
index 1e7bff43972..56c14fdea7a 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
@@ -43,6 +43,7 @@ import org.apache.lucene.document.LongField;
import org.apache.lucene.document.PackedLongDocValuesField;
import org.apache.lucene.document.ShortDocValuesField;
import org.apache.lucene.document.SortedBytesDocValuesField;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.document.StraightBytesDocValuesField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
@@ -328,13 +329,13 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
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");
@@ -405,7 +406,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
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());
@@ -458,7 +459,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
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();
@@ -484,7 +485,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
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();
@@ -752,7 +753,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
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;
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java b/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java
index a9addc86097..1a97c49cb02 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java
@@ -22,6 +22,7 @@ import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DocValues.Source;
import org.apache.lucene.index.DocValues.Type;
@@ -75,7 +76,7 @@ public class TestCustomNorms extends LuceneTestCase {
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);
}
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java b/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java
index f9d3bf3afcf..b806e9690ee 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java
@@ -32,6 +32,7 @@ import org.apache.lucene.codecs.lucene40.Lucene40PostingsFormat;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
@@ -61,10 +62,10 @@ public class TestDirectoryReader extends LuceneTestCase {
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 +387,11 @@ void assertTermDocsCount(String msg,
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 +596,13 @@ public void testFilesOpenClose() throws IOException {
// 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();
@@ -1080,7 +1081,7 @@ public void testFilesOpenClose() throws IOException {
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();
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java b/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java
index 8e6f3ea588e..a76a0a7bbb4 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java
@@ -32,6 +32,7 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.IndexSearcher;
@@ -122,7 +123,7 @@ public class TestDirectoryReaderReopen extends LuceneTestCase {
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);
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java b/lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java
index 7e55009711e..b459100a342 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestDocTermOrds.java
@@ -122,7 +122,7 @@ public class TestDocTermOrds extends LuceneTestCase {
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());
@@ -578,7 +579,7 @@ public class TestDuelingCodecs extends LuceneTestCase {
/**
* 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());
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestFieldInfos.java b/lucene/core/src/test/org/apache/lucene/index/TestFieldInfos.java
index 9850a3dbb8e..312ae6ab94f 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestFieldInfos.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestFieldInfos.java
@@ -47,7 +47,7 @@ public class TestFieldInfos extends LuceneTestCase {
//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();
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java b/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java
index 5bbc43ad547..cc0956bd9dd 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestFieldsReader.java
@@ -31,6 +31,7 @@ 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.document.StoredDocument;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.index.FieldInfo.IndexOptions;
@@ -55,7 +56,7 @@ public class TestFieldsReader extends LuceneTestCase {
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 +80,7 @@ public class TestFieldsReader extends LuceneTestCase {
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 +105,7 @@ public class TestFieldsReader extends LuceneTestCase {
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 +280,7 @@ public class TestFieldsReader extends LuceneTestCase {
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);
@@ -292,7 +293,7 @@ public class TestFieldsReader extends LuceneTestCase {
for(IndexReader sub : r.getSequentialSubReaders()) {
final int[] ids = FieldCache.DEFAULT.getInts((AtomicReader) sub, "id", false);
for(int docID=0;docID 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");
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java
index d07a7756f5f..1ab0190f2c0 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java
@@ -21,6 +21,7 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.util.LuceneTestCase;
@@ -84,7 +85,7 @@ public class TestIndexWriterMerging extends LuceneTestCase
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) + ""))
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java
index 914fccf4195..77f8be60804 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java
@@ -28,6 +28,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.document.TextField;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.IndexSearcher;
@@ -141,10 +142,10 @@ public class TestIndexWriterReader extends LuceneTestCase {
String id10 = r1.document(10).getField("id").stringValue();
- Document newDoc = r1.document(10);
+ StoredDocument newDoc = r1.document(10);
newDoc.removeField("id");
newDoc.add(newStringField("id", Integer.toString(8000), Field.Store.YES));
- writer.updateDocument(new Term("id", id10), newDoc);
+ writer.updateDocument(new Term("id", id10), newDoc.asIndexable());
assertFalse(r1.isCurrent());
DirectoryReader r2 = writer.getReader();
@@ -271,9 +272,9 @@ public class TestIndexWriterReader extends LuceneTestCase {
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();
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterUnicode.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterUnicode.java
index 11a19e880c9..6ff458190f3 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterUnicode.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterUnicode.java
@@ -26,6 +26,7 @@ import java.util.Set;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.CharsRef;
@@ -259,7 +260,7 @@ public class TestIndexWriterUnicode extends LuceneTestCase {
w.close();
IndexReader ir = DirectoryReader.open(dir);
- Document doc2 = ir.document(0);
+ StoredDocument doc2 = ir.document(0);
for(int i=0;i() {
+ IndexDocument d = new IndexDocument() {
@Override
- public Iterator iterator() {
- return new Iterator() {
- int fieldUpto;
-
+ public Iterable extends IndexableField> indexableFields() {
+ return new Iterable() {
@Override
- public boolean hasNext() {
- return fieldUpto < fieldCount;
- }
+ public Iterator iterator() {
+ return new Iterator() {
+ int fieldUpto = 0;
+ private IndexableField next;
- @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));
- }
- }
+ @Override
+ public boolean hasNext() {
+ if (fieldUpto >= fieldCount) return false;
+ next = null;
+ if (fieldUpto > 1)
+ next = new MyField(finalBaseCount + (fieldUpto++-1));
+ else
+ fieldUpto = 2;
+
+ if (next != null && next.fieldType().indexed()) return true;
+ else return this.hasNext();
+ }
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
+ @Override
+ public IndexableField next() {
+ assert fieldUpto <= fieldCount;
+ if (next == null && !hasNext()) {
+ return null;
+ }
+ else {
+ return next;
+ }
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
}
};
}
- });
+
+ @Override
+ public Iterable extends StorableField> storableFields() {
+ return new Iterable() {
+ @Override
+ public Iterator iterator() {
+ return new Iterator() {
+ int fieldUpto = 0;
+ private StorableField next = null;
+
+ @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();
@@ -218,10 +281,11 @@ public class TestIndexableField extends LuceneTestCase {
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;
@@ -240,7 +304,7 @@ public class TestIndexableField extends LuceneTestCase {
// 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);
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestNorms.java b/lucene/core/src/test/org/apache/lucene/index/TestNorms.java
index f7447aa44e4..11c27089918 100755
--- a/lucene/core/src/test/org/apache/lucene/index/TestNorms.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestNorms.java
@@ -23,6 +23,7 @@ import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DocValues.Source;
import org.apache.lucene.index.DocValues.Type;
@@ -105,7 +106,7 @@ public class TestNorms extends LuceneTestCase {
assertEquals(Type.FIXED_INTS_8, normValues.getType());
byte[] norms = (byte[]) source.getArray();
for (int i = 0; i < open.maxDoc(); i++) {
- Document document = open.document(i);
+ StoredDocument document = open.document(i);
int expected = Integer.parseInt(document.get(byteTestField));
assertEquals((byte)expected, norms[i]);
}
@@ -164,7 +165,7 @@ public class TestNorms extends LuceneTestCase {
assertEquals(Type.FIXED_INTS_8, normValues.getType());
byte[] norms = (byte[]) source.getArray();
for (int i = 0; i < mergedReader.maxDoc(); i++) {
- Document document = mergedReader.document(i);
+ StoredDocument document = mergedReader.document(i);
int expected = Integer.parseInt(document.get(byteTestField));
assertEquals((byte) expected, norms[i]);
}
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestParallelAtomicReader.java b/lucene/core/src/test/org/apache/lucene/index/TestParallelAtomicReader.java
index c7760f6317b..58d061b29a9 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestParallelAtomicReader.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestParallelAtomicReader.java
@@ -23,6 +23,7 @@ import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.*;
import org.apache.lucene.store.Directory;
@@ -224,8 +225,8 @@ public class TestParallelAtomicReader extends LuceneTestCase {
assertEquals(parallelHits.length, singleHits.length);
for(int i = 0; i < parallelHits.length; i++) {
assertEquals(parallelHits[i].score, singleHits[i].score, 0.001f);
- Document docParallel = parallel.doc(parallelHits[i].doc);
- Document docSingle = single.doc(singleHits[i].doc);
+ StoredDocument docParallel = parallel.doc(parallelHits[i].doc);
+ StoredDocument docSingle = single.doc(singleHits[i].doc);
assertEquals(docParallel.get("f1"), docSingle.get("f1"));
assertEquals(docParallel.get("f2"), docSingle.get("f2"));
assertEquals(docParallel.get("f3"), docSingle.get("f3"));
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestParallelCompositeReader.java b/lucene/core/src/test/org/apache/lucene/index/TestParallelCompositeReader.java
index 68b417945c2..994fd2a7560 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestParallelCompositeReader.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestParallelCompositeReader.java
@@ -23,6 +23,7 @@ import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.*;
import org.apache.lucene.store.Directory;
@@ -283,8 +284,8 @@ public class TestParallelCompositeReader extends LuceneTestCase {
assertEquals(parallelHits.length, singleHits.length);
for(int i = 0; i < parallelHits.length; i++) {
assertEquals(parallelHits[i].score, singleHits[i].score, 0.001f);
- Document docParallel = parallel.doc(parallelHits[i].doc);
- Document docSingle = single.doc(singleHits[i].doc);
+ StoredDocument docParallel = parallel.doc(parallelHits[i].doc);
+ StoredDocument docSingle = single.doc(singleHits[i].doc);
assertEquals(docParallel.get("f1"), docSingle.get("f1"));
assertEquals(docParallel.get("f2"), docSingle.get("f2"));
assertEquals(docParallel.get("f3"), docSingle.get("f3"));
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java b/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java
index 987594c8862..109aa39cde5 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java
@@ -240,7 +240,7 @@ public class TestPostingsOffsets extends LuceneTestCase {
for(int docCount=0;docCount tokens = new ArrayList();
final int numTokens = atLeast(100);
//final int numTokens = atLeast(20);
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestRandomStoredFields.java b/lucene/core/src/test/org/apache/lucene/index/TestRandomStoredFields.java
index fc74f90b9f7..af3a0f5c36e 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestRandomStoredFields.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestRandomStoredFields.java
@@ -29,6 +29,7 @@ import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.document.TextField;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.TermQuery;
@@ -121,7 +122,7 @@ public class TestRandomStoredFields extends LuceneTestCase {
}
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()));
}
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestStressIndexing2.java b/lucene/core/src/test/org/apache/lucene/index/TestStressIndexing2.java
index e9caa08ea95..c8776d73c78 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestStressIndexing2.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestStressIndexing2.java
@@ -32,6 +32,7 @@ import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.DocIdSetIterator;
@@ -133,8 +134,8 @@ public class TestStressIndexing2 extends LuceneTestCase {
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());
}
};
@@ -287,7 +288,7 @@ public class TestStressIndexing2 extends LuceneTestCase {
Bits liveDocs = ((AtomicReader)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);
@@ -586,8 +587,8 @@ public class TestStressIndexing2 extends LuceneTestCase {
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 @@ public class TestNRTManager extends ThreadedIndexingAndSearchingTestCase {
}
@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 @@ public class TestNRTManager extends ThreadedIndexingAndSearchingTestCase {
}
@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 @@ public class TestNRTManager extends ThreadedIndexingAndSearchingTestCase {
}
@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 class TestNRTManager extends ThreadedIndexingAndSearchingTestCase {
}
public void updateDocument(Term term,
- Iterable extends IndexableField> doc, Analyzer analyzer)
+ IndexDocument doc, Analyzer analyzer)
throws IOException {
super.updateDocument(term, doc, analyzer);
try {
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java b/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
index 456ec914cb3..4fba715e6db 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
@@ -23,6 +23,7 @@ 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.StoredDocument;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
@@ -173,7 +174,7 @@ public class TestNumericRangeQuery32 extends LuceneTestCase {
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());
@@ -227,7 +228,7 @@ public class TestNumericRangeQuery32 extends LuceneTestCase {
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());
@@ -267,7 +268,7 @@ public class TestNumericRangeQuery32 extends LuceneTestCase {
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());
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java b/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
index 82dc587a1cb..b2b2c9b6d8d 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
@@ -23,6 +23,7 @@ import org.apache.lucene.document.DoubleField;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.LongField;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
@@ -182,7 +183,7 @@ public class TestNumericRangeQuery64 extends LuceneTestCase {
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() );
@@ -242,7 +243,7 @@ public class TestNumericRangeQuery64 extends LuceneTestCase {
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() );
@@ -287,7 +288,7 @@ public class TestNumericRangeQuery64 extends LuceneTestCase {
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() );
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestSort.java b/lucene/core/src/test/org/apache/lucene/search/TestSort.java
index cd4d90133ad..32d09edf654 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestSort.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestSort.java
@@ -38,6 +38,7 @@ import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.FloatDocValuesField;
import org.apache.lucene.document.PackedLongDocValuesField;
import org.apache.lucene.document.SortedBytesDocValuesField;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.document.StraightBytesDocValuesField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
@@ -50,6 +51,7 @@ import org.apache.lucene.index.IndexWriterConfig;
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.Term;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.FieldValueHitQueue.Entry;
@@ -522,9 +524,9 @@ public class TestSort extends LuceneTestCase {
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) {
@@ -1229,8 +1231,8 @@ public class TestSort extends LuceneTestCase {
StringBuilder buff = new StringBuilder(10);
int n = result.length;
for (int i=0; i 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 @@ public class RandomIndexWriter implements Closeable {
// (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 @@ public class RandomIndexWriter implements Closeable {
}
@Override
- public Iterable next() {
+ public IndexDocument next() {
if (done) {
throw new IllegalStateException();
}
@@ -273,12 +273,12 @@ public class RandomIndexWriter implements Closeable {
}
}
- 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();
}
@@ -287,16 +287,16 @@ public class RandomIndexWriter implements Closeable {
* Updates a document.
* @see IndexWriter#updateDocument(Term, Iterable)
*/
- 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 @@ public class RandomIndexWriter implements Closeable {
}
@Override
- public Iterable next() {
+ public IndexDocument next() {
if (done) {
throw new IllegalStateException();
}
diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java
index 69f946e7891..d1c51943e11 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/index/ThreadedIndexingAndSearchingTestCase.java
@@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.PhraseQuery;
import org.apache.lucene.search.Query;
@@ -89,19 +90,19 @@ public abstract class ThreadedIndexingAndSearchingTestCase extends LuceneTestCas
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 +465,7 @@ public abstract class ThreadedIndexingAndSearchingTestCase extends LuceneTestCas
final int inc = Math.max(1, maxDoc/50);
for(int docID=0;docID
Date: Sat, 28 Jul 2012 10:56:46 +0000
Subject: [PATCH 04/13] LUCENE-3312: Apply patch 8
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3312@1366638 13f79535-47bb-0310-9956-ffa450edef68
---
.../analysis/uima/UIMABaseAnalyzerTest.java | 5 ++-
.../benchmark/byTask/feeds/DocMaker.java | 1 +
.../byTask/tasks/BenchmarkHighlighter.java | 3 +-
.../benchmark/byTask/tasks/ReadTask.java | 16 ++++----
.../tasks/SearchTravRetHighlightTask.java | 5 ++-
.../SearchTravRetLoadFieldSelectorTask.java | 3 +-
.../SearchTravRetVectorHighlightTask.java | 5 ++-
.../tasks/CountingHighlighterTestTask.java | 7 ++--
.../org/apache/lucene/document/Document.java | 20 +++++-----
.../lucene/index/DocFieldProcessor.java | 2 +-
.../lucene/index/NormsConsumerPerField.java | 2 +-
.../apache/lucene/util/FilterIterator.java | 10 ++---
.../lucene/index/TestIndexableField.java | 9 +++--
.../lucene/search/highlight/TokenSources.java | 13 ++++---
.../search/highlight/HighlighterTest.java | 5 ++-
.../lucene/search/join/TestBlockJoin.java | 38 +++++++++----------
.../apache/lucene/document/LazyDocument.java | 24 +++---------
.../index/TestMultiPassIndexSplitter.java | 5 ++-
.../lucene/queries/mlt/MoreLikeThis.java | 8 ++--
.../complexPhrase/TestComplexPhraseQuery.java | 3 +-
.../lucene/queryparser/xml/TestParser.java | 3 +-
.../sandbox/queries/DuplicateFilterTest.java | 11 +++---
.../queries/FuzzyLikeThisQueryTest.java | 7 ++--
.../lucene/spatial/SpatialTestCase.java | 7 ++--
.../apache/solr/schema/ICUCollationField.java | 3 +-
.../solr/handler/MoreLikeThisHandler.java | 3 +-
.../handler/admin/LukeRequestHandler.java | 13 ++++---
.../component/RealTimeGetComponent.java | 18 +++++----
.../highlight/DefaultSolrHighlighter.java | 18 +++++----
.../solr/response/BinaryResponseWriter.java | 12 +++---
.../solr/response/TextResponseWriter.java | 16 ++++----
.../org/apache/solr/schema/BCDIntField.java | 8 ++--
.../org/apache/solr/schema/BCDLongField.java | 4 +-
.../org/apache/solr/schema/BCDStrField.java | 4 +-
.../org/apache/solr/schema/BinaryField.java | 7 ++--
.../org/apache/solr/schema/BoolField.java | 8 ++--
.../org/apache/solr/schema/ByteField.java | 5 ++-
.../apache/solr/schema/CollationField.java | 3 +-
.../org/apache/solr/schema/CurrencyField.java | 3 +-
.../org/apache/solr/schema/DateField.java | 11 ++++--
.../org/apache/solr/schema/DoubleField.java | 5 ++-
.../apache/solr/schema/ExternalFileField.java | 3 +-
.../org/apache/solr/schema/FieldType.java | 10 +++--
.../org/apache/solr/schema/FloatField.java | 5 ++-
.../org/apache/solr/schema/GeoHashField.java | 5 ++-
.../org/apache/solr/schema/IndexSchema.java | 6 ++-
.../java/org/apache/solr/schema/IntField.java | 5 ++-
.../org/apache/solr/schema/LatLonType.java | 3 +-
.../org/apache/solr/schema/LongField.java | 5 ++-
.../org/apache/solr/schema/PointType.java | 3 +-
.../apache/solr/schema/PreAnalyzedField.java | 3 +-
.../apache/solr/schema/RandomSortField.java | 3 +-
.../org/apache/solr/schema/ShortField.java | 5 ++-
.../solr/schema/SortableDoubleField.java | 7 ++--
.../solr/schema/SortableFloatField.java | 7 ++--
.../apache/solr/schema/SortableIntField.java | 7 ++--
.../apache/solr/schema/SortableLongField.java | 7 ++--
.../java/org/apache/solr/schema/StrField.java | 3 +-
.../org/apache/solr/schema/TextField.java | 3 +-
.../org/apache/solr/schema/TrieDateField.java | 9 +++--
.../org/apache/solr/schema/TrieField.java | 11 +++---
.../org/apache/solr/schema/UUIDField.java | 5 ++-
.../apache/solr/search/SolrIndexSearcher.java | 19 +++++-----
.../TopGroupsResultTransformer.java | 7 ++--
.../org/apache/solr/util/SolrPluginUtils.java | 8 ++--
.../apache/solr/BasicFunctionalityTest.java | 5 ++-
.../apache/solr/search/TestStressLucene.java | 3 +-
67 files changed, 284 insertions(+), 226 deletions(-)
diff --git a/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java b/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java
index ffff5f93d0e..d31dc267822 100644
--- a/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java
+++ b/lucene/analysis/uima/src/test/org/apache/lucene/analysis/uima/UIMABaseAnalyzerTest.java
@@ -21,6 +21,7 @@ import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriter;
@@ -80,7 +81,7 @@ public class UIMABaseAnalyzerTest extends BaseTokenStreamTestCase {
IndexSearcher indexSearcher = new IndexSearcher(directoryReader);
TopDocs result = indexSearcher.search(new MatchAllDocsQuery(), 10);
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());
@@ -100,7 +101,7 @@ public class UIMABaseAnalyzerTest extends BaseTokenStreamTestCase {
directoryReader = DirectoryReader.open(dir);
indexSearcher = new IndexSearcher(directoryReader);
result = indexSearcher.search(new MatchAllDocsQuery(), 10);
- 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());
diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/DocMaker.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/DocMaker.java
index af434cc8dab..f593d7afaed 100644
--- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/DocMaker.java
+++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/DocMaker.java
@@ -231,6 +231,7 @@ public class DocMaker implements Closeable {
// Set ID_FIELD
FieldType ft = new FieldType(valType);
ft.setIndexed(true);
+ ft.setStored(true);
Field idField = ds.getField(ID_FIELD, ft);
int id;
diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/BenchmarkHighlighter.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/BenchmarkHighlighter.java
index fd229d08964..91d59cddf38 100644
--- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/BenchmarkHighlighter.java
+++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/BenchmarkHighlighter.java
@@ -19,6 +19,7 @@ package org.apache.lucene.benchmark.byTask.tasks;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.IndexReader;
/**
@@ -26,5 +27,5 @@ import org.apache.lucene.index.IndexReader;
*/
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 ;
}
diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java
index f1cce8a8a37..075934f7c2a 100644
--- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java
+++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java
@@ -28,10 +28,12 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.benchmark.byTask.PerfRunData;
import org.apache.lucene.benchmark.byTask.feeds.QueryMaker;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.DirectoryReader;
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.search.Collector;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.MultiTermQuery;
@@ -96,7 +98,7 @@ public abstract class ReadTask extends PerfTask {
// 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 @@ public abstract class ReadTask extends PerfTask {
System.out.println("numDocs() = " + reader.numDocs());
for(int i=0;i 0 && m < numHighlight) {
Collection fieldsToHighlight = getFieldsToHighlight(document);
@@ -193,7 +195,7 @@ public abstract class ReadTask extends PerfTask {
}
- 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 @@ public abstract class ReadTask extends PerfTask {
* @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;
diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetHighlightTask.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetHighlightTask.java
index 8af944b4f83..7cf3ac58dd9 100644
--- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetHighlightTask.java
+++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetHighlightTask.java
@@ -21,6 +21,7 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.benchmark.byTask.PerfRunData;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.highlight.Highlighter;
@@ -101,7 +102,7 @@ public class SearchTravRetHighlightTask extends SearchTravTask {
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 @@ public class SearchTravRetHighlightTask extends SearchTravTask {
}
@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) {
diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetLoadFieldSelectorTask.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetLoadFieldSelectorTask.java
index a7858ab5dcd..8962b1e1a8c 100644
--- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetLoadFieldSelectorTask.java
+++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetLoadFieldSelectorTask.java
@@ -24,6 +24,7 @@ import java.util.StringTokenizer;
import org.apache.lucene.benchmark.byTask.PerfRunData;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.DocumentStoredFieldVisitor;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.IndexReader;
/**
@@ -54,7 +55,7 @@ public class SearchTravRetLoadFieldSelectorTask extends SearchTravTask {
@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 {
diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetVectorHighlightTask.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetVectorHighlightTask.java
index 2a897ec5e37..17d1413c81f 100644
--- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetVectorHighlightTask.java
+++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchTravRetVectorHighlightTask.java
@@ -20,6 +20,7 @@ package org.apache.lucene.benchmark.byTask.tasks;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.benchmark.byTask.PerfRunData;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.vectorhighlight.FastVectorHighlighter;
@@ -99,7 +100,7 @@ public class SearchTravRetVectorHighlightTask extends SearchTravTask {
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 @@ public class SearchTravRetVectorHighlightTask extends SearchTravTask {
}
@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) {
diff --git a/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CountingHighlighterTestTask.java b/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CountingHighlighterTestTask.java
index a6e029398a6..63b6118c93b 100644
--- a/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CountingHighlighterTestTask.java
+++ b/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/tasks/CountingHighlighterTestTask.java
@@ -27,6 +27,7 @@ import org.apache.lucene.search.highlight.QueryScorer;
import org.apache.lucene.search.highlight.TokenSources;
import org.apache.lucene.search.Query;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.IndexReader;
import java.io.IOException;
@@ -44,8 +45,8 @@ public class CountingHighlighterTestTask extends SearchTravRetHighlightTask {
}
@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 @@ public class CountingHighlighterTestTask extends SearchTravRetHighlightTask {
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;
diff --git a/lucene/core/src/java/org/apache/lucene/document/Document.java b/lucene/core/src/java/org/apache/lucene/document/Document.java
index 049035deaf4..fc42ddf7b9d 100644
--- a/lucene/core/src/java/org/apache/lucene/document/Document.java
+++ b/lucene/core/src/java/org/apache/lucene/document/Document.java
@@ -124,7 +124,7 @@ public final class Document implements IndexDocument{
*/
public final BytesRef[] getBinaryValues(String name) {
final List result = new ArrayList();
- Iterator it = storedFieldsIterator();
+ Iterator it = storedFieldsIterator();
while (it.hasNext()) {
StorableField field = it.next();
@@ -149,7 +149,7 @@ public final class Document implements IndexDocument{
* @return a byte[] containing the binary field value or null
*/
public final BytesRef getBinaryValue(String name) {
- Iterator it = storedFieldsIterator();
+ Iterator it = storedFieldsIterator();
while (it.hasNext()) {
StorableField field = it.next();
@@ -224,7 +224,7 @@ public final class Document implements IndexDocument{
*/
public final String[] getValues(String name) {
List result = new ArrayList();
- Iterator it = storedFieldsIterator();
+ Iterator it = storedFieldsIterator();
while (it.hasNext()) {
StorableField field = it.next();
@@ -249,7 +249,7 @@ public final class Document implements IndexDocument{
* the actual numeric field instance back, use {@link #getField}.
*/
public final String get(String name) {
- Iterator it = storedFieldsIterator();
+ Iterator it = storedFieldsIterator();
while (it.hasNext()) {
StorableField field = it.next();
@@ -277,7 +277,7 @@ public final class Document implements IndexDocument{
@Override
public Iterable extends IndexableField> indexableFields() {
- Iterator it = indexedFieldsIterator();
+ Iterator it = indexedFieldsIterator();
List result = new ArrayList();
while(it.hasNext()) {
@@ -289,7 +289,7 @@ public final class Document implements IndexDocument{
@Override
public Iterable extends StorableField> storableFields() {
- Iterator it = storedFieldsIterator();
+ Iterator it = storedFieldsIterator();
List result = new ArrayList();
while(it.hasNext()) {
@@ -299,8 +299,8 @@ public final class Document implements IndexDocument{
return result;
}
- public Iterator storedFieldsIterator() {
- return new FilterIterator(fields.iterator()) {
+ public Iterator storedFieldsIterator() {
+ return new FilterIterator(fields.iterator()) {
@Override
protected boolean predicateFunction(Field field) {
return field.type.stored();
@@ -308,8 +308,8 @@ public final class Document implements IndexDocument{
};
}
- public Iterator indexedFieldsIterator() {
- return new FilterIterator(fields.iterator()) {
+ public Iterator indexedFieldsIterator() {
+ return new FilterIterator(fields.iterator()) {
@Override
protected boolean predicateFunction(Field field) {
return field.type.indexed();
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocFieldProcessor.java b/lucene/core/src/java/org/apache/lucene/index/DocFieldProcessor.java
index 5f7a4acb456..0853ed3b5eb 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocFieldProcessor.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocFieldProcessor.java
@@ -240,7 +240,7 @@ final class DocFieldProcessor extends DocConsumer {
docState, fp.fieldInfo);
DocValuesConsumer consumer = docValuesConsumer.docValuesConsumer;
if (docValuesConsumer.compatibility == null) {
- consumer.add(docState.docID, (StorableField) field);
+ consumer.add(docState.docID, field);
docValuesConsumer.compatibility = new TypeCompatibility(dvType,
consumer.getValueSize());
} else if (docValuesConsumer.compatibility.isCompatible(dvType,
diff --git a/lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java b/lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java
index 47c5f675044..a936c3722b5 100644
--- a/lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java
+++ b/lucene/core/src/java/org/apache/lucene/index/NormsConsumerPerField.java
@@ -54,7 +54,7 @@ final class NormsConsumerPerField extends InvertedDocEndConsumerPerField impleme
StorableField field = norm.field();
// some similarity might not compute any norms
DocValuesConsumer consumer = getConsumer(norm.type());
- consumer.add(docState.docID, (StorableField) field);
+ consumer.add(docState.docID, field);
}
}
}
diff --git a/lucene/core/src/java/org/apache/lucene/util/FilterIterator.java b/lucene/core/src/java/org/apache/lucene/util/FilterIterator.java
index c72956eb910..8e9b5a9b232 100644
--- a/lucene/core/src/java/org/apache/lucene/util/FilterIterator.java
+++ b/lucene/core/src/java/org/apache/lucene/util/FilterIterator.java
@@ -20,15 +20,15 @@ import java.util.NoSuchElementException;
* the License.
*/
-public abstract class FilterIterator implements Iterator {
+public abstract class FilterIterator implements Iterator {
- private Iterator iterator;
+ private Iterator iterator;
private T next = null;
private boolean nextIsSet = false;
- protected abstract boolean predicateFunction(U field);
+ protected abstract boolean predicateFunction(T field);
- public FilterIterator(Iterator baseIterator) {
+ public FilterIterator(Iterator baseIterator) {
this.iterator = baseIterator;
}
@@ -56,7 +56,7 @@ public abstract class FilterIterator implements Iterator {
private boolean setNext() {
while (iterator.hasNext()) {
- U object = iterator.next();
+ T object = iterator.next();
if (predicateFunction(object)) {
next = object;
nextIsSet = true;
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexableField.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexableField.java
index 918a8f576cb..bdcda97dbdc 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexableField.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexableField.java
@@ -192,11 +192,14 @@ public class TestIndexableField extends LuceneTestCase {
@Override
public boolean hasNext() {
if (fieldUpto >= fieldCount) return false;
+
next = null;
- if (fieldUpto > 1)
+ if (fieldUpto == 0) {
+ fieldUpto = 1;
+ next = newStringField("id", ""+finalDocCount, Field.Store.YES);
+ } else {
next = new MyField(finalBaseCount + (fieldUpto++-1));
- else
- fieldUpto = 2;
+ }
if (next != null && next.fieldType().indexed()) return true;
else return this.hasNext();
diff --git a/lucene/highlighter/src/java/org/apache/lucene/search/highlight/TokenSources.java b/lucene/highlighter/src/java/org/apache/lucene/search/highlight/TokenSources.java
index 1824741b9c7..3bb1bbf24ef 100644
--- a/lucene/highlighter/src/java/org/apache/lucene/search/highlight/TokenSources.java
+++ b/lucene/highlighter/src/java/org/apache/lucene/search/highlight/TokenSources.java
@@ -32,6 +32,7 @@ import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.DocsAndPositionsEnum;
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.IndexReader;
@@ -57,7 +58,7 @@ public class TokenSources {
* 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
@@ -67,7 +68,7 @@ public class TokenSources {
*/
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);
@@ -80,7 +81,7 @@ public class TokenSources {
// 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;
}
@@ -298,11 +299,11 @@ public class TokenSources {
// 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) {
diff --git a/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java b/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
index 67ea75f940c..78057db2a55 100644
--- a/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
+++ b/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
@@ -37,6 +37,7 @@ import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.IntField;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
@@ -97,7 +98,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
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);
diff --git a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
index 44555003b12..851f2f716a4 100644
--- a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
+++ b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
@@ -119,11 +119,11 @@ public class TestBlockJoin extends LuceneTestCase {
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 @@ public class TestBlockJoin extends LuceneTestCase {
}
}
- 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.getTopReaderContext().leaves();
final int subIndex = ReaderUtil.subIndex(childDocID, leaves);
final AtomicReaderContext leaf = leaves.get(subIndex);
@@ -563,7 +563,7 @@ public class TestBlockJoin extends LuceneTestCase {
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 @@ public class TestBlockJoin extends LuceneTestCase {
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"));
diff --git a/lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java b/lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java
index 06563cdf3e3..b3a16af2b06 100644
--- a/lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java
+++ b/lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java
@@ -25,8 +25,8 @@ import org.apache.lucene.analysis.Analyzer;
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.util.BytesRef;
/** Defers actually loading a field's value until you ask
@@ -38,7 +38,7 @@ public class LazyDocument {
private final int docID;
// null until first field is loaded
- private Document doc;
+ private StoredDocument doc;
private Map fields = new HashMap();
@@ -47,7 +47,7 @@ public class LazyDocument {
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 +59,7 @@ public class LazyDocument {
return new LazyField(fieldInfo.name, num);
}
- private synchronized Document getDocument() {
+ private synchronized StoredDocument getDocument() {
if (doc == null) {
try {
doc = reader.document(docID);
@@ -71,7 +71,7 @@ public class LazyDocument {
return doc;
}
- private class LazyField implements IndexableField {
+ private class LazyField implements StorableField {
private String name;
private int num;
@@ -85,11 +85,6 @@ public class LazyDocument {
return name;
}
- @Override
- public float boost() {
- return 1.0f;
- }
-
@Override
public BytesRef binaryValue() {
if (num == 0) {
@@ -134,14 +129,5 @@ public class LazyDocument {
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);
- }
- }
}
}
diff --git a/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java b/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java
index 7f1535779bb..1f808e3c0a2 100644
--- a/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java
+++ b/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java
@@ -19,6 +19,7 @@ package org.apache.lucene.index;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
@@ -68,7 +69,7 @@ public class TestMultiPassIndexSplitter extends LuceneTestCase {
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 +114,7 @@ public class TestMultiPassIndexSplitter extends LuceneTestCase {
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();
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java b/lucene/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java
index d8b97762782..06787dbdd7b 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java
@@ -22,10 +22,12 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.Fields;
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.Term;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
@@ -715,9 +717,9 @@ public final class MoreLikeThis {
// 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);
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
index 23ec531a4f3..a86976f4bd9 100644
--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
@@ -23,6 +23,7 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
@@ -100,7 +101,7 @@ public class TestComplexPhraseQuery extends LuceneTestCase {
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));
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java
index e087f644a54..03f46408f41 100644
--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java
+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java
@@ -24,6 +24,7 @@ import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.IntField;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
@@ -232,7 +233,7 @@ public class TestParser extends LuceneTestCase {
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();
diff --git a/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java b/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java
index 9b13f995b6b..a665ad28a53 100644
--- a/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java
+++ b/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java
@@ -23,6 +23,7 @@ import java.util.HashSet;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.*;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.IndexSearcher;
@@ -87,7 +88,7 @@ public class DuplicateFilterTest extends LuceneTestCase {
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 +102,7 @@ public class DuplicateFilterTest extends LuceneTestCase {
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 +119,7 @@ public class DuplicateFilterTest extends LuceneTestCase {
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 +133,7 @@ public class DuplicateFilterTest extends LuceneTestCase {
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 +157,7 @@ public class DuplicateFilterTest extends LuceneTestCase {
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,
diff --git a/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java b/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java
index dfedd8adecb..ce9bdbe28a4 100644
--- a/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java
+++ b/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/FuzzyLikeThisQueryTest.java
@@ -21,6 +21,7 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
@@ -88,7 +89,7 @@ public class FuzzyLikeThisQueryTest extends LuceneTestCase {
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 @@ public class FuzzyLikeThisQueryTest extends LuceneTestCase {
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 @@ public class FuzzyLikeThisQueryTest extends LuceneTestCase {
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"));
}
diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java b/lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java
index 8d1741dcc90..e78b4d01673 100644
--- a/lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java
+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java
@@ -18,6 +18,7 @@
package org.apache.lucene.spatial;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.search.IndexSearcher;
@@ -130,11 +131,11 @@ public abstract class SpatialTestCase extends LuceneTestCase {
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
diff --git a/solr/contrib/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.java b/solr/contrib/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.java
index 88e1ce5c675..6a7b6fc564c 100644
--- a/solr/contrib/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.java
+++ b/solr/contrib/analysis-extras/src/java/org/apache/solr/schema/ICUCollationField.java
@@ -27,6 +27,7 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
import org.apache.lucene.collation.ICUCollationKeyAnalyzer;
+import org.apache.lucene.index.GeneralField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.SortField;
@@ -210,7 +211,7 @@ public class ICUCollationField extends FieldType {
}
@Override
- public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
+ public void write(TextResponseWriter writer, String name, GeneralField f) throws IOException {
writer.writeStr(name, f.stringValue(), true);
}
diff --git a/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java b/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
index 7a5a0fadb20..59f8d3c106c 100644
--- a/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
@@ -30,6 +30,7 @@ import java.util.Map;
import java.util.regex.Pattern;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.queryparser.classic.ParseException;
@@ -342,7 +343,7 @@ public class MoreLikeThisHandler extends RequestHandlerBase
public DocListAndSet getMoreLikeThis( int id, int start, int rows, List filters, List terms, int flags ) throws IOException
{
- Document doc = reader.document(id);
+ StoredDocument doc = reader.document(id);
rawMLTQuery = mlt.like(id);
boostedMLTQuery = getBoostedQuery( rawMLTQuery );
if( terms != null ) {
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
index 16eb4cb140d..3f4c37a5f8e 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
@@ -28,6 +28,7 @@ import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.analysis.util.TokenizerFactory;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StoredDocument;
import org.apache.lucene.index.*;
import org.apache.lucene.index.FieldInfo.IndexOptions;
import org.apache.lucene.search.DocIdSetIterator;
@@ -132,7 +133,7 @@ public class LukeRequestHandler extends RequestHandlerBase
if( style != null && style != ShowStyle.DOC ) {
throw new SolrException(ErrorCode.BAD_REQUEST, "missing doc param for doc style");
}
- Document doc = null;
+ StoredDocument doc = null;
try {
doc = reader.document( docId );
}
@@ -169,7 +170,7 @@ public class LukeRequestHandler extends RequestHandlerBase
/**
* @return a string representing a IndexableField's flags.
*/
- private static String getFieldFlags( IndexableField f )
+ private static String getFieldFlags( StorableField f )
{
IndexOptions opts = (f == null) ? null : f.fieldType().indexOptions();
@@ -238,7 +239,7 @@ public class LukeRequestHandler extends RequestHandlerBase
return key;
}
- private static SimpleOrderedMap