mirror of https://github.com/apache/lucene.git
pull from DV under FC.getXXX if possible
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1410878 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6735e95b1f
commit
f9bfb920c6
|
@ -414,7 +414,7 @@ public class SimpleTextSimpleDocValuesFormat extends SimpleDocValuesFormat {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NumericDocValues getDirectNumeric(FieldInfo fieldInfo) throws IOException {
|
public NumericDocValues getNumeric(FieldInfo fieldInfo) throws IOException {
|
||||||
final OneField field = fields.get(fieldInfo.name);
|
final OneField field = fields.get(fieldInfo.name);
|
||||||
|
|
||||||
// SegmentCoreReaders already verifies this field is
|
// SegmentCoreReaders already verifies this field is
|
||||||
|
@ -454,7 +454,7 @@ public class SimpleTextSimpleDocValuesFormat extends SimpleDocValuesFormat {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BinaryDocValues getDirectBinary(FieldInfo fieldInfo) throws IOException {
|
public BinaryDocValues getBinary(FieldInfo fieldInfo) throws IOException {
|
||||||
final OneField field = fields.get(fieldInfo.name);
|
final OneField field = fields.get(fieldInfo.name);
|
||||||
|
|
||||||
// SegmentCoreReaders already verifies this field is
|
// SegmentCoreReaders already verifies this field is
|
||||||
|
@ -497,7 +497,7 @@ public class SimpleTextSimpleDocValuesFormat extends SimpleDocValuesFormat {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortedDocValues getDirectSorted(FieldInfo fieldInfo) throws IOException {
|
public SortedDocValues getSorted(FieldInfo fieldInfo) throws IOException {
|
||||||
final OneField field = fields.get(fieldInfo.name);
|
final OneField field = fields.get(fieldInfo.name);
|
||||||
|
|
||||||
// SegmentCoreReaders already verifies this field is
|
// SegmentCoreReaders already verifies this field is
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.lucene.codecs;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.lucene.index.AtomicReader;
|
import org.apache.lucene.index.AtomicReader;
|
||||||
|
import org.apache.lucene.index.BinaryDocValues;
|
||||||
import org.apache.lucene.index.DocValues.Source;
|
import org.apache.lucene.index.DocValues.Source;
|
||||||
import org.apache.lucene.index.FieldInfos;
|
import org.apache.lucene.index.FieldInfos;
|
||||||
import org.apache.lucene.index.MergeState;
|
import org.apache.lucene.index.MergeState;
|
||||||
|
@ -36,10 +37,14 @@ public abstract class BinaryDocValuesConsumer {
|
||||||
for (AtomicReader reader : mergeState.readers) {
|
for (AtomicReader reader : mergeState.readers) {
|
||||||
final int maxDoc = reader.maxDoc();
|
final int maxDoc = reader.maxDoc();
|
||||||
final Bits liveDocs = reader.getLiveDocs();
|
final Bits liveDocs = reader.getLiveDocs();
|
||||||
final Source source = reader.docValues(mergeState.fieldInfo.name).getDirectSource();
|
|
||||||
|
// nocommit what if this is null...? need default source?
|
||||||
|
final BinaryDocValues source = reader.getBinaryDocValues(mergeState.fieldInfo.name);
|
||||||
|
|
||||||
for (int i = 0; i < maxDoc; i++) {
|
for (int i = 0; i < maxDoc; i++) {
|
||||||
if (liveDocs == null || liveDocs.get(i)) {
|
if (liveDocs == null || liveDocs.get(i)) {
|
||||||
add(source.getBytes(i, bytes));
|
source.get(i, bytes);
|
||||||
|
add(bytes);
|
||||||
}
|
}
|
||||||
docCount++;
|
docCount++;
|
||||||
mergeState.checkAbort.work(300);
|
mergeState.checkAbort.work(300);
|
||||||
|
|
|
@ -20,10 +20,11 @@ package org.apache.lucene.codecs;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.lucene.index.AtomicReader;
|
import org.apache.lucene.index.AtomicReader;
|
||||||
|
import org.apache.lucene.index.DocValues.Source;
|
||||||
import org.apache.lucene.index.FieldInfo;
|
import org.apache.lucene.index.FieldInfo;
|
||||||
import org.apache.lucene.index.FieldInfos;
|
import org.apache.lucene.index.FieldInfos;
|
||||||
import org.apache.lucene.index.MergeState;
|
import org.apache.lucene.index.MergeState;
|
||||||
import org.apache.lucene.index.DocValues.Source;
|
import org.apache.lucene.index.NumericDocValues;
|
||||||
import org.apache.lucene.util.Bits;
|
import org.apache.lucene.util.Bits;
|
||||||
|
|
||||||
public abstract class NumericDocValuesConsumer {
|
public abstract class NumericDocValuesConsumer {
|
||||||
|
@ -35,10 +36,11 @@ public abstract class NumericDocValuesConsumer {
|
||||||
for (AtomicReader reader : mergeState.readers) {
|
for (AtomicReader reader : mergeState.readers) {
|
||||||
final int maxDoc = reader.maxDoc();
|
final int maxDoc = reader.maxDoc();
|
||||||
final Bits liveDocs = reader.getLiveDocs();
|
final Bits liveDocs = reader.getLiveDocs();
|
||||||
final Source source = reader.docValues(mergeState.fieldInfo.name).getDirectSource();
|
// nocommit what if this is null...? need default source?
|
||||||
|
final NumericDocValues source = reader.getNumericDocValues(mergeState.fieldInfo.name);
|
||||||
for (int i = 0; i < maxDoc; i++) {
|
for (int i = 0; i < maxDoc; i++) {
|
||||||
if (liveDocs == null || liveDocs.get(i)) {
|
if (liveDocs == null || liveDocs.get(i)) {
|
||||||
add(source.getInt(i));
|
add(source.get(i));
|
||||||
}
|
}
|
||||||
docCount++;
|
docCount++;
|
||||||
mergeState.checkAbort.work(300);
|
mergeState.checkAbort.work(300);
|
||||||
|
|
|
@ -35,86 +35,9 @@ public abstract class SimpleDVProducer implements Closeable {
|
||||||
this.maxDoc = maxDoc;
|
this.maxDoc = maxDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract NumericDocValues getDirectNumeric(FieldInfo field) throws IOException;
|
public abstract NumericDocValues getNumeric(FieldInfo field) throws IOException;
|
||||||
|
|
||||||
/** Loads all values into RAM. */
|
public abstract BinaryDocValues getBinary(FieldInfo field) throws IOException;
|
||||||
public NumericDocValues getNumeric(FieldInfo field) throws IOException {
|
|
||||||
NumericDocValues source = getDirectNumeric(field);
|
|
||||||
// nocommit more ram efficient?
|
|
||||||
final long[] values = new long[maxDoc];
|
|
||||||
for(int docID=0;docID<maxDoc;docID++) {
|
|
||||||
values[docID] = source.get(docID);
|
|
||||||
}
|
|
||||||
return new NumericDocValues() {
|
|
||||||
@Override
|
|
||||||
public long get(int docID) {
|
|
||||||
return values[docID];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract BinaryDocValues getDirectBinary(FieldInfo field) throws IOException;
|
public abstract SortedDocValues getSorted(FieldInfo field) throws IOException;
|
||||||
|
|
||||||
/** Loads all values into RAM. */
|
|
||||||
public BinaryDocValues getBinary(FieldInfo field) throws IOException {
|
|
||||||
|
|
||||||
BinaryDocValues source = getDirectBinary(field);
|
|
||||||
|
|
||||||
// nocommit more ram efficient
|
|
||||||
final byte[][] values = new byte[maxDoc][];
|
|
||||||
BytesRef scratch = new BytesRef();
|
|
||||||
for(int docID=0;docID<maxDoc;docID++) {
|
|
||||||
source.get(docID, scratch);
|
|
||||||
values[docID] = new byte[scratch.length];
|
|
||||||
System.arraycopy(scratch.bytes, scratch.offset, values[docID], 0, scratch.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new BinaryDocValues() {
|
|
||||||
@Override
|
|
||||||
public void get(int docID, BytesRef result) {
|
|
||||||
result.bytes = values[docID];
|
|
||||||
result.offset = 0;
|
|
||||||
result.length = result.bytes.length;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract SortedDocValues getDirectSorted(FieldInfo field) throws IOException;
|
|
||||||
|
|
||||||
/** Loads all values into RAM. */
|
|
||||||
public SortedDocValues getSorted(FieldInfo field) throws IOException {
|
|
||||||
SortedDocValues source = getDirectSorted(field);
|
|
||||||
final int valueCount = source.getValueCount();
|
|
||||||
final byte[][] values = new byte[valueCount][];
|
|
||||||
BytesRef scratch = new BytesRef();
|
|
||||||
for(int ord=0;ord<valueCount;ord++) {
|
|
||||||
source.lookupOrd(ord, scratch);
|
|
||||||
values[ord] = new byte[scratch.length];
|
|
||||||
System.arraycopy(scratch.bytes, scratch.offset, values[ord], 0, scratch.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
final int[] ords = new int[maxDoc];
|
|
||||||
for(int docID=0;docID<maxDoc;docID++) {
|
|
||||||
ords[docID] = source.getOrd(docID);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new SortedDocValues() {
|
|
||||||
@Override
|
|
||||||
public int getOrd(int docID) {
|
|
||||||
return ords[docID];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void lookupOrd(int ord, BytesRef result) {
|
|
||||||
result.bytes = values[ord];
|
|
||||||
result.offset = 0;
|
|
||||||
result.length = result.bytes.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getValueCount() {
|
|
||||||
return valueCount;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.lucene.index.AtomicReader;
|
||||||
import org.apache.lucene.index.DocValues.SortedSource;
|
import org.apache.lucene.index.DocValues.SortedSource;
|
||||||
import org.apache.lucene.index.DocValues;
|
import org.apache.lucene.index.DocValues;
|
||||||
import org.apache.lucene.index.MergeState;
|
import org.apache.lucene.index.MergeState;
|
||||||
|
import org.apache.lucene.index.SortedDocValues;
|
||||||
import org.apache.lucene.util.Bits;
|
import org.apache.lucene.util.Bits;
|
||||||
import org.apache.lucene.util.BytesRef;
|
import org.apache.lucene.util.BytesRef;
|
||||||
import org.apache.lucene.util.FixedBitSet;
|
import org.apache.lucene.util.FixedBitSet;
|
||||||
|
@ -57,7 +58,7 @@ public abstract class SortedDocValuesConsumer {
|
||||||
AtomicReader reader;
|
AtomicReader reader;
|
||||||
FixedBitSet liveTerms;
|
FixedBitSet liveTerms;
|
||||||
int ord = -1;
|
int ord = -1;
|
||||||
SortedSource source;
|
SortedDocValues values;
|
||||||
BytesRef scratch = new BytesRef();
|
BytesRef scratch = new BytesRef();
|
||||||
|
|
||||||
// nocommit can we factor out the compressed fields
|
// nocommit can we factor out the compressed fields
|
||||||
|
@ -67,10 +68,10 @@ public abstract class SortedDocValuesConsumer {
|
||||||
int[] segOrdToMergedOrd;
|
int[] segOrdToMergedOrd;
|
||||||
|
|
||||||
public BytesRef nextTerm() {
|
public BytesRef nextTerm() {
|
||||||
while (ord < source.getValueCount()-1) {
|
while (ord < values.getValueCount()-1) {
|
||||||
ord++;
|
ord++;
|
||||||
if (liveTerms == null || liveTerms.get(ord)) {
|
if (liveTerms == null || liveTerms.get(ord)) {
|
||||||
source.getByOrd(ord, scratch);
|
values.lookupOrd(ord, scratch);
|
||||||
return scratch;
|
return scratch;
|
||||||
} else {
|
} else {
|
||||||
// Skip "deleted" terms (ie, terms that were not
|
// Skip "deleted" terms (ie, terms that were not
|
||||||
|
@ -98,26 +99,20 @@ public abstract class SortedDocValuesConsumer {
|
||||||
|
|
||||||
// First pass: mark "live" terms
|
// First pass: mark "live" terms
|
||||||
for (AtomicReader reader : mergeState.readers) {
|
for (AtomicReader reader : mergeState.readers) {
|
||||||
DocValues docvalues = reader.docValues(mergeState.fieldInfo.name);
|
// nocommit what if this is null...? need default source?
|
||||||
final SortedSource source;
|
|
||||||
int maxDoc = reader.maxDoc();
|
int maxDoc = reader.maxDoc();
|
||||||
if (docvalues == null) {
|
|
||||||
source = DocValues.getDefaultSortedSource(mergeState.fieldInfo.getDocValuesType(), maxDoc);
|
|
||||||
} else {
|
|
||||||
source = (SortedSource) docvalues.getDirectSource();
|
|
||||||
}
|
|
||||||
|
|
||||||
SegmentState state = new SegmentState();
|
SegmentState state = new SegmentState();
|
||||||
state.reader = reader;
|
state.reader = reader;
|
||||||
state.source = source;
|
state.values = reader.getSortedDocValues(mergeState.fieldInfo.name);
|
||||||
segStates.add(state);
|
segStates.add(state);
|
||||||
assert source.getValueCount() < Integer.MAX_VALUE;
|
assert state.values.getValueCount() < Integer.MAX_VALUE;
|
||||||
if (reader.hasDeletions()) {
|
if (reader.hasDeletions()) {
|
||||||
state.liveTerms = new FixedBitSet(source.getValueCount());
|
state.liveTerms = new FixedBitSet(state.values.getValueCount());
|
||||||
Bits liveDocs = reader.getLiveDocs();
|
Bits liveDocs = reader.getLiveDocs();
|
||||||
for(int docID=0;docID<maxDoc;docID++) {
|
for(int docID=0;docID<maxDoc;docID++) {
|
||||||
if (liveDocs.get(docID)) {
|
if (liveDocs.get(docID)) {
|
||||||
state.liveTerms.set(source.ord(docID));
|
state.liveTerms.set(state.values.getOrd(docID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +130,7 @@ public abstract class SortedDocValuesConsumer {
|
||||||
// nocommit we could defer this to 3rd pass (and
|
// nocommit we could defer this to 3rd pass (and
|
||||||
// reduce transient RAM spike) but then
|
// reduce transient RAM spike) but then
|
||||||
// we'd spend more effort computing the mapping...:
|
// we'd spend more effort computing the mapping...:
|
||||||
segState.segOrdToMergedOrd = new int[segState.source.getValueCount()];
|
segState.segOrdToMergedOrd = new int[segState.values.getValueCount()];
|
||||||
q.add(segState);
|
q.add(segState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,7 +179,7 @@ public abstract class SortedDocValuesConsumer {
|
||||||
int maxDoc = segState.reader.maxDoc();
|
int maxDoc = segState.reader.maxDoc();
|
||||||
for(int docID=0;docID<maxDoc;docID++) {
|
for(int docID=0;docID<maxDoc;docID++) {
|
||||||
if (liveDocs == null || liveDocs.get(docID)) {
|
if (liveDocs == null || liveDocs.get(docID)) {
|
||||||
int segOrd = segState.source.ord(docID);
|
int segOrd = segState.values.getOrd(docID);
|
||||||
int mergedOrd = segState.segOrdToMergedOrd[segOrd];
|
int mergedOrd = segState.segOrdToMergedOrd[segOrd];
|
||||||
consumer.addDoc(mergedOrd);
|
consumer.addDoc(mergedOrd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,9 @@ public class DoubleDocValuesField extends StoredField {
|
||||||
*/
|
*/
|
||||||
public static final FieldType TYPE = new FieldType();
|
public static final FieldType TYPE = new FieldType();
|
||||||
static {
|
static {
|
||||||
TYPE.setDocValueType(DocValues.Type.FLOAT_64);
|
// nocommit kinda messy ... if user calls .numericValue
|
||||||
|
// they get back strange int ... hmmm
|
||||||
|
TYPE.setDocValueType(DocValues.Type.FIXED_INTS_64);
|
||||||
TYPE.freeze();
|
TYPE.freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +56,8 @@ public class DoubleDocValuesField extends StoredField {
|
||||||
*/
|
*/
|
||||||
public DoubleDocValuesField(String name, double value) {
|
public DoubleDocValuesField(String name, double value) {
|
||||||
super(name, TYPE);
|
super(name, TYPE);
|
||||||
fieldsData = Double.valueOf(value);
|
// nocommit kinda messy ... if user calls .numericValue
|
||||||
|
// they get back strange int ... hmmm
|
||||||
|
fieldsData = Double.doubleToRawLongBits(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,9 @@ public class FloatDocValuesField extends StoredField {
|
||||||
*/
|
*/
|
||||||
public static final FieldType TYPE = new FieldType();
|
public static final FieldType TYPE = new FieldType();
|
||||||
static {
|
static {
|
||||||
TYPE.setDocValueType(DocValues.Type.FLOAT_32);
|
// nocommit kinda messy ... if user calls .numericValue
|
||||||
|
// they get back strange int ... hmmm
|
||||||
|
TYPE.setDocValueType(DocValues.Type.FIXED_INTS_32);
|
||||||
TYPE.freeze();
|
TYPE.freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +55,8 @@ public class FloatDocValuesField extends StoredField {
|
||||||
*/
|
*/
|
||||||
public FloatDocValuesField(String name, float value) {
|
public FloatDocValuesField(String name, float value) {
|
||||||
super(name, TYPE);
|
super(name, TYPE);
|
||||||
fieldsData = Float.valueOf(value);
|
// nocommit kinda messy ... if user calls .numericValue
|
||||||
|
// they get back strange int ... hmmm
|
||||||
|
fieldsData = Float.floatToRawIntBits(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,13 +164,13 @@ public abstract class AtomicReader extends IndexReader {
|
||||||
public abstract DocValues docValues(String field) throws IOException;
|
public abstract DocValues docValues(String field) throws IOException;
|
||||||
|
|
||||||
// nocommit javadocs
|
// nocommit javadocs
|
||||||
public abstract NumericDocValues getNumericDocValues(String field, boolean direct) throws IOException;
|
public abstract NumericDocValues getNumericDocValues(String field) throws IOException;
|
||||||
|
|
||||||
// nocommit javadocs
|
// nocommit javadocs
|
||||||
public abstract BinaryDocValues getBinaryDocValues(String field, boolean direct) throws IOException;
|
public abstract BinaryDocValues getBinaryDocValues(String field) throws IOException;
|
||||||
|
|
||||||
// nocommit javadocs
|
// nocommit javadocs
|
||||||
public abstract SortedDocValues getSortedDocValues(String field, boolean direct) throws IOException;
|
public abstract SortedDocValues getSortedDocValues(String field) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@link DocValues} for this field's normalization values.
|
* Returns {@link DocValues} for this field's normalization values.
|
||||||
|
|
|
@ -412,21 +412,21 @@ public class FilterAtomicReader extends AtomicReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NumericDocValues getNumericDocValues(String field, boolean direct) throws IOException {
|
public NumericDocValues getNumericDocValues(String field) throws IOException {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
return in.getNumericDocValues(field, direct);
|
return in.getNumericDocValues(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BinaryDocValues getBinaryDocValues(String field, boolean direct) throws IOException {
|
public BinaryDocValues getBinaryDocValues(String field) throws IOException {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
return in.getBinaryDocValues(field, direct);
|
return in.getBinaryDocValues(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortedDocValues getSortedDocValues(String field, boolean direct) throws IOException {
|
public SortedDocValues getSortedDocValues(String field) throws IOException {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
return in.getSortedDocValues(field, direct);
|
return in.getSortedDocValues(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -271,24 +271,24 @@ public final class ParallelAtomicReader extends AtomicReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NumericDocValues getNumericDocValues(String field, boolean direct) throws IOException {
|
public NumericDocValues getNumericDocValues(String field) throws IOException {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
AtomicReader reader = fieldToReader.get(field);
|
AtomicReader reader = fieldToReader.get(field);
|
||||||
return reader == null ? null : reader.getNumericDocValues(field, direct);
|
return reader == null ? null : reader.getNumericDocValues(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BinaryDocValues getBinaryDocValues(String field, boolean direct) throws IOException {
|
public BinaryDocValues getBinaryDocValues(String field) throws IOException {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
AtomicReader reader = fieldToReader.get(field);
|
AtomicReader reader = fieldToReader.get(field);
|
||||||
return reader == null ? null : reader.getBinaryDocValues(field, direct);
|
return reader == null ? null : reader.getBinaryDocValues(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortedDocValues getSortedDocValues(String field, boolean direct) throws IOException {
|
public SortedDocValues getSortedDocValues(String field) throws IOException {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
AtomicReader reader = fieldToReader.get(field);
|
AtomicReader reader = fieldToReader.get(field);
|
||||||
return reader == null ? null : reader.getSortedDocValues(field, direct);
|
return reader == null ? null : reader.getSortedDocValues(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -66,8 +66,6 @@ final class SegmentCoreReaders {
|
||||||
final TermVectorsReader termVectorsReaderOrig;
|
final TermVectorsReader termVectorsReaderOrig;
|
||||||
final CompoundFileDirectory cfsReader;
|
final CompoundFileDirectory cfsReader;
|
||||||
|
|
||||||
private final Map<FieldInfo,Object> docValuesCache = new HashMap<FieldInfo,Object>();
|
|
||||||
|
|
||||||
final CloseableThreadLocal<StoredFieldsReader> fieldsReaderLocal = new CloseableThreadLocal<StoredFieldsReader>() {
|
final CloseableThreadLocal<StoredFieldsReader> fieldsReaderLocal = new CloseableThreadLocal<StoredFieldsReader>() {
|
||||||
@Override
|
@Override
|
||||||
protected StoredFieldsReader initialValue() {
|
protected StoredFieldsReader initialValue() {
|
||||||
|
@ -155,72 +153,60 @@ final class SegmentCoreReaders {
|
||||||
}
|
}
|
||||||
|
|
||||||
// nocommit shrink the sync'd part to a cache miss
|
// nocommit shrink the sync'd part to a cache miss
|
||||||
synchronized NumericDocValues getNumericDocValues(String field, boolean direct) throws IOException {
|
synchronized NumericDocValues getNumericDocValues(String field) throws IOException {
|
||||||
FieldInfo fi = fieldInfos.fieldInfo(field);
|
FieldInfo fi = fieldInfos.fieldInfo(field);
|
||||||
if (fi == null) {
|
if (fi == null) {
|
||||||
|
// Field does not exist
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (fi.getDocValuesType() == null) {
|
||||||
|
// Field was not indexed with doc values
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!DocValues.isNumber(fi.getDocValuesType())) {
|
if (!DocValues.isNumber(fi.getDocValuesType())) {
|
||||||
throw new IllegalArgumentException("field \"" + field + "\" was not indexed as a numeric doc values field");
|
// DocValues were not numeric
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direct) {
|
return simpleDVProducer.getNumeric(fi);
|
||||||
return simpleDVProducer.getDirectNumeric(fi);
|
|
||||||
} else {
|
|
||||||
if (!docValuesCache.containsKey(fi)) {
|
|
||||||
NumericDocValues dv = simpleDVProducer.getNumeric(fi);
|
|
||||||
if (dv != null) {
|
|
||||||
docValuesCache.put(fi, dv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (NumericDocValues) docValuesCache.get(fi);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// nocommit shrink the sync'd part to a cache miss
|
// nocommit shrink the sync'd part to a cache miss
|
||||||
synchronized BinaryDocValues getBinaryDocValues(String field, boolean direct) throws IOException {
|
synchronized BinaryDocValues getBinaryDocValues(String field) throws IOException {
|
||||||
FieldInfo fi = fieldInfos.fieldInfo(field);
|
FieldInfo fi = fieldInfos.fieldInfo(field);
|
||||||
if (fi == null) {
|
if (fi == null) {
|
||||||
|
// Field does not exist
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (fi.getDocValuesType() == null) {
|
||||||
|
// Field was not indexed with doc values
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!DocValues.isBytes(fi.getDocValuesType())) {
|
if (!DocValues.isBytes(fi.getDocValuesType())) {
|
||||||
throw new IllegalArgumentException("field \"" + field + "\" was not indexed as a binary doc values field");
|
// DocValues were not binary
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direct) {
|
return simpleDVProducer.getBinary(fi);
|
||||||
return simpleDVProducer.getDirectBinary(fi);
|
|
||||||
} else {
|
|
||||||
if (!docValuesCache.containsKey(fi)) {
|
|
||||||
BinaryDocValues dv = simpleDVProducer.getBinary(fi);
|
|
||||||
if (dv != null) {
|
|
||||||
docValuesCache.put(fi, dv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (BinaryDocValues) docValuesCache.get(fi);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// nocommit shrink the sync'd part to a cache miss
|
// nocommit shrink the sync'd part to a cache miss
|
||||||
synchronized SortedDocValues getSortedDocValues(String field, boolean direct) throws IOException {
|
synchronized SortedDocValues getSortedDocValues(String field) throws IOException {
|
||||||
FieldInfo fi = fieldInfos.fieldInfo(field);
|
FieldInfo fi = fieldInfos.fieldInfo(field);
|
||||||
if (fi == null) {
|
if (fi == null) {
|
||||||
|
// Field does not exist
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (fi.getDocValuesType() == null) {
|
||||||
|
// Field was not indexed with doc values
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!DocValues.isSortedBytes(fi.getDocValuesType())) {
|
if (!DocValues.isSortedBytes(fi.getDocValuesType())) {
|
||||||
throw new IllegalArgumentException("field \"" + field + "\" was not indexed as a sorted doc values field");
|
// DocValues were not sorted
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direct) {
|
return simpleDVProducer.getSorted(fi);
|
||||||
return simpleDVProducer.getDirectSorted(fi);
|
|
||||||
} else {
|
|
||||||
if (!docValuesCache.containsKey(fi)) {
|
|
||||||
SortedDocValues dv = simpleDVProducer.getSorted(fi);
|
|
||||||
if (dv != null) {
|
|
||||||
docValuesCache.put(fi, dv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (SortedDocValues) docValuesCache.get(fi);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// nocommit binary, sorted too
|
// nocommit binary, sorted too
|
||||||
|
|
|
@ -226,18 +226,18 @@ public final class SegmentReader extends AtomicReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NumericDocValues getNumericDocValues(String field, boolean direct) throws IOException {
|
public NumericDocValues getNumericDocValues(String field) throws IOException {
|
||||||
return core.getNumericDocValues(field, direct);
|
return core.getNumericDocValues(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BinaryDocValues getBinaryDocValues(String field, boolean direct) throws IOException {
|
public BinaryDocValues getBinaryDocValues(String field) throws IOException {
|
||||||
return core.getBinaryDocValues(field, direct);
|
return core.getBinaryDocValues(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortedDocValues getSortedDocValues(String field, boolean direct) throws IOException {
|
public SortedDocValues getSortedDocValues(String field) throws IOException {
|
||||||
return core.getSortedDocValues(field, direct);
|
return core.getSortedDocValues(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -89,19 +89,19 @@ public final class SlowCompositeReaderWrapper extends AtomicReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NumericDocValues getNumericDocValues(String field, boolean direct) throws IOException {
|
public NumericDocValues getNumericDocValues(String field) throws IOException {
|
||||||
// nocommit todo
|
// nocommit todo
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BinaryDocValues getBinaryDocValues(String field, boolean direct) throws IOException {
|
public BinaryDocValues getBinaryDocValues(String field) throws IOException {
|
||||||
// nocommit todo
|
// nocommit todo
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortedDocValues getSortedDocValues(String field, boolean direct) throws IOException {
|
public SortedDocValues getSortedDocValues(String field) throws IOException {
|
||||||
// nocommit todo
|
// nocommit todo
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -87,6 +87,7 @@ import org.apache.lucene.util.packed.PackedInts;
|
||||||
* @lucene.experimental
|
* @lucene.experimental
|
||||||
*/
|
*/
|
||||||
public abstract class FieldComparator<T> {
|
public abstract class FieldComparator<T> {
|
||||||
|
// nocommit remove the doc values comparators
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare hit at slot1 with hit at slot2.
|
* Compare hit at slot1 with hit at slot2.
|
||||||
|
|
|
@ -49,7 +49,7 @@ import org.apache.lucene.util.LuceneTestCase;
|
||||||
* to this class.
|
* to this class.
|
||||||
*/
|
*/
|
||||||
// nocommit don't suppress any:
|
// nocommit don't suppress any:
|
||||||
@SuppressCodecs({"Direct", "Memory", "Lucene41", "MockRandom", "Lucene40", "Compressing"})
|
@SuppressCodecs({"Asserting", "Direct", "Memory", "Lucene41", "MockRandom", "Lucene40", "Compressing"})
|
||||||
public class TestDemoDocValue extends LuceneTestCase {
|
public class TestDemoDocValue extends LuceneTestCase {
|
||||||
|
|
||||||
public void testDemoNumber() throws IOException {
|
public void testDemoNumber() throws IOException {
|
||||||
|
@ -82,7 +82,7 @@ public class TestDemoDocValue extends LuceneTestCase {
|
||||||
StoredDocument hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
|
StoredDocument hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
|
||||||
assertEquals(text, hitDoc.get("fieldname"));
|
assertEquals(text, hitDoc.get("fieldname"));
|
||||||
assert ireader.leaves().size() == 1;
|
assert ireader.leaves().size() == 1;
|
||||||
NumericDocValues dv = ireader.leaves().get(0).reader().getNumericDocValues("dv", random().nextBoolean());
|
NumericDocValues dv = ireader.leaves().get(0).reader().getNumericDocValues("dv");
|
||||||
assertEquals(5, dv.get(hits.scoreDocs[i].doc));
|
assertEquals(5, dv.get(hits.scoreDocs[i].doc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public class TestDemoDocValue extends LuceneTestCase {
|
||||||
// Now search the index:
|
// Now search the index:
|
||||||
IndexReader ireader = DirectoryReader.open(directory); // read-only=true
|
IndexReader ireader = DirectoryReader.open(directory); // read-only=true
|
||||||
assert ireader.leaves().size() == 1;
|
assert ireader.leaves().size() == 1;
|
||||||
NumericDocValues dv = ireader.leaves().get(0).reader().getNumericDocValues("dv", random().nextBoolean());
|
NumericDocValues dv = ireader.leaves().get(0).reader().getNumericDocValues("dv");
|
||||||
assertEquals(1, dv.get(0));
|
assertEquals(1, dv.get(0));
|
||||||
assertEquals(2, dv.get(1));
|
assertEquals(2, dv.get(1));
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ public class TestDemoDocValue extends LuceneTestCase {
|
||||||
// Now search the index:
|
// Now search the index:
|
||||||
IndexReader ireader = DirectoryReader.open(directory); // read-only=true
|
IndexReader ireader = DirectoryReader.open(directory); // read-only=true
|
||||||
assert ireader.leaves().size() == 1;
|
assert ireader.leaves().size() == 1;
|
||||||
NumericDocValues dv = ireader.leaves().get(0).reader().getNumericDocValues("dv", random().nextBoolean());
|
NumericDocValues dv = ireader.leaves().get(0).reader().getNumericDocValues("dv");
|
||||||
for(int i=0;i<2;i++) {
|
for(int i=0;i<2;i++) {
|
||||||
StoredDocument doc2 = ireader.leaves().get(0).reader().document(i);
|
StoredDocument doc2 = ireader.leaves().get(0).reader().document(i);
|
||||||
long expected;
|
long expected;
|
||||||
|
@ -186,7 +186,7 @@ public class TestDemoDocValue extends LuceneTestCase {
|
||||||
// Now search the index:
|
// Now search the index:
|
||||||
IndexReader ireader = DirectoryReader.open(directory); // read-only=true
|
IndexReader ireader = DirectoryReader.open(directory); // read-only=true
|
||||||
assert ireader.leaves().size() == 1;
|
assert ireader.leaves().size() == 1;
|
||||||
NumericDocValues dv = ireader.leaves().get(0).reader().getNumericDocValues("dv", random().nextBoolean());
|
NumericDocValues dv = ireader.leaves().get(0).reader().getNumericDocValues("dv");
|
||||||
assertEquals(Long.MIN_VALUE, dv.get(0));
|
assertEquals(Long.MIN_VALUE, dv.get(0));
|
||||||
assertEquals(Long.MAX_VALUE, dv.get(1));
|
assertEquals(Long.MAX_VALUE, dv.get(1));
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ public class TestDemoDocValue extends LuceneTestCase {
|
||||||
StoredDocument hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
|
StoredDocument hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
|
||||||
assertEquals(text, hitDoc.get("fieldname"));
|
assertEquals(text, hitDoc.get("fieldname"));
|
||||||
assert ireader.leaves().size() == 1;
|
assert ireader.leaves().size() == 1;
|
||||||
BinaryDocValues dv = ireader.leaves().get(0).reader().getBinaryDocValues("dv", random().nextBoolean());
|
BinaryDocValues dv = ireader.leaves().get(0).reader().getBinaryDocValues("dv");
|
||||||
dv.get(hits.scoreDocs[i].doc, scratch);
|
dv.get(hits.scoreDocs[i].doc, scratch);
|
||||||
assertEquals(new BytesRef("hello world"), scratch);
|
assertEquals(new BytesRef("hello world"), scratch);
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ public class TestDemoDocValue extends LuceneTestCase {
|
||||||
// Now search the index:
|
// Now search the index:
|
||||||
IndexReader ireader = DirectoryReader.open(directory); // read-only=true
|
IndexReader ireader = DirectoryReader.open(directory); // read-only=true
|
||||||
assert ireader.leaves().size() == 1;
|
assert ireader.leaves().size() == 1;
|
||||||
BinaryDocValues dv = ireader.leaves().get(0).reader().getBinaryDocValues("dv", random().nextBoolean());
|
BinaryDocValues dv = ireader.leaves().get(0).reader().getBinaryDocValues("dv");
|
||||||
BytesRef scratch = new BytesRef();
|
BytesRef scratch = new BytesRef();
|
||||||
for(int i=0;i<2;i++) {
|
for(int i=0;i<2;i++) {
|
||||||
StoredDocument doc2 = ireader.leaves().get(0).reader().document(i);
|
StoredDocument doc2 = ireader.leaves().get(0).reader().document(i);
|
||||||
|
@ -311,7 +311,7 @@ public class TestDemoDocValue extends LuceneTestCase {
|
||||||
StoredDocument hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
|
StoredDocument hitDoc = isearcher.doc(hits.scoreDocs[i].doc);
|
||||||
assertEquals(text, hitDoc.get("fieldname"));
|
assertEquals(text, hitDoc.get("fieldname"));
|
||||||
assert ireader.leaves().size() == 1;
|
assert ireader.leaves().size() == 1;
|
||||||
SortedDocValues dv = ireader.leaves().get(0).reader().getSortedDocValues("dv", random().nextBoolean());
|
SortedDocValues dv = ireader.leaves().get(0).reader().getSortedDocValues("dv");
|
||||||
dv.lookupOrd(dv.getOrd(hits.scoreDocs[i].doc), scratch);
|
dv.lookupOrd(dv.getOrd(hits.scoreDocs[i].doc), scratch);
|
||||||
assertEquals(new BytesRef("hello world"), scratch);
|
assertEquals(new BytesRef("hello world"), scratch);
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ public class TestDemoDocValue extends LuceneTestCase {
|
||||||
// Now search the index:
|
// Now search the index:
|
||||||
IndexReader ireader = DirectoryReader.open(directory); // read-only=true
|
IndexReader ireader = DirectoryReader.open(directory); // read-only=true
|
||||||
assert ireader.leaves().size() == 1;
|
assert ireader.leaves().size() == 1;
|
||||||
SortedDocValues dv = ireader.leaves().get(0).reader().getSortedDocValues("dv", random().nextBoolean());
|
SortedDocValues dv = ireader.leaves().get(0).reader().getSortedDocValues("dv");
|
||||||
BytesRef scratch = new BytesRef();
|
BytesRef scratch = new BytesRef();
|
||||||
dv.lookupOrd(dv.getOrd(0), scratch);
|
dv.lookupOrd(dv.getOrd(0), scratch);
|
||||||
assertEquals("hello world 1", scratch.utf8ToString());
|
assertEquals("hello world 1", scratch.utf8ToString());
|
||||||
|
@ -380,7 +380,7 @@ public class TestDemoDocValue extends LuceneTestCase {
|
||||||
// Now search the index:
|
// Now search the index:
|
||||||
IndexReader ireader = DirectoryReader.open(directory); // read-only=true
|
IndexReader ireader = DirectoryReader.open(directory); // read-only=true
|
||||||
assert ireader.leaves().size() == 1;
|
assert ireader.leaves().size() == 1;
|
||||||
SortedDocValues dv = ireader.leaves().get(0).reader().getSortedDocValues("dv", random().nextBoolean());
|
SortedDocValues dv = ireader.leaves().get(0).reader().getSortedDocValues("dv");
|
||||||
BytesRef scratch = new BytesRef();
|
BytesRef scratch = new BytesRef();
|
||||||
for(int i=0;i<2;i++) {
|
for(int i=0;i<2;i++) {
|
||||||
StoredDocument doc2 = ireader.leaves().get(0).reader().document(i);
|
StoredDocument doc2 = ireader.leaves().get(0).reader().document(i);
|
||||||
|
|
|
@ -740,17 +740,17 @@ public class MemoryIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
// nocommit todo
|
// nocommit todo
|
||||||
public NumericDocValues getNumericDocValues(String field, boolean direct) {
|
public NumericDocValues getNumericDocValues(String field) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// nocommit todo
|
// nocommit todo
|
||||||
public BinaryDocValues getBinaryDocValues(String field, boolean direct) {
|
public BinaryDocValues getBinaryDocValues(String field) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// nocommit todo
|
// nocommit todo
|
||||||
public SortedDocValues getSortedDocValues(String field, boolean direct) {
|
public SortedDocValues getSortedDocValues(String field) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -399,17 +399,17 @@ public class TestDocSet extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NumericDocValues getNumericDocValues(String field, boolean direct) {
|
public NumericDocValues getNumericDocValues(String field) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BinaryDocValues getBinaryDocValues(String field, boolean direct) {
|
public BinaryDocValues getBinaryDocValues(String field) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortedDocValues getSortedDocValues(String field, boolean direct) {
|
public SortedDocValues getSortedDocValues(String field) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue