mirror of https://github.com/apache/lucene.git
LUCENE-5969: add merge api
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5969@1628073 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
24005cdcc5
commit
5229a9a4ee
|
@ -24,7 +24,6 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.apache.lucene.index.LeafReader;
|
||||
import org.apache.lucene.index.BinaryDocValues;
|
||||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.FilteredTermsEnum;
|
||||
|
@ -150,7 +149,6 @@ public abstract class DocValuesConsumer implements Closeable {
|
|||
if (docValuesProducer != null) {
|
||||
FieldInfo fieldInfo = mergeState.fieldInfos[i].fieldInfo(mergeFieldInfo.name);
|
||||
if (fieldInfo != null && fieldInfo.getDocValuesType() == DocValuesType.NUMERIC) {
|
||||
// TODO: use dedicated merge API, so impl can do merge-specific checksumming, and won't cache values in RAM
|
||||
values = docValuesProducer.getNumeric(fieldInfo);
|
||||
bits = docValuesProducer.getDocsWithField(fieldInfo);
|
||||
}
|
||||
|
@ -173,7 +171,6 @@ public abstract class DocValuesConsumer implements Closeable {
|
|||
if (docValuesProducer != null) {
|
||||
FieldInfo fieldInfo = mergeState.fieldInfos[i].fieldInfo(mergeFieldInfo.name);
|
||||
if (fieldInfo != null && fieldInfo.getDocValuesType() == DocValuesType.BINARY) {
|
||||
// TODO: use dedicated merge API, so impl can do merge-specific checksumming, and won't cache values in RAM
|
||||
values = docValuesProducer.getBinary(fieldInfo);
|
||||
bits = docValuesProducer.getDocsWithField(fieldInfo);
|
||||
}
|
||||
|
@ -194,7 +191,6 @@ public abstract class DocValuesConsumer implements Closeable {
|
|||
if (docValuesProducer != null) {
|
||||
FieldInfo fieldInfo = mergeState.fieldInfos[i].fieldInfo(mergeFieldInfo.name);
|
||||
if (fieldInfo != null && fieldInfo.getDocValuesType() == DocValuesType.SORTED) {
|
||||
// TODO: use dedicated merge API, so impl can do merge-specific checksumming, and won't cache values in RAM
|
||||
values = docValuesProducer.getSorted(fieldInfo);
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +208,6 @@ public abstract class DocValuesConsumer implements Closeable {
|
|||
if (docValuesProducer != null) {
|
||||
FieldInfo fieldInfo = mergeState.fieldInfos[i].fieldInfo(mergeFieldInfo.name);
|
||||
if (fieldInfo != null && fieldInfo.getDocValuesType() == DocValuesType.SORTED_SET) {
|
||||
// TODO: use dedicated merge API, so impl can do merge-specific checksumming, and won't cache values in RAM
|
||||
values = docValuesProducer.getSortedSet(fieldInfo);
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +225,6 @@ public abstract class DocValuesConsumer implements Closeable {
|
|||
if (docValuesProducer != null) {
|
||||
FieldInfo fieldInfo = mergeState.fieldInfos[i].fieldInfo(mergeFieldInfo.name);
|
||||
if (fieldInfo != null && fieldInfo.getDocValuesType() == DocValuesType.SORTED_NUMERIC) {
|
||||
// TODO: use dedicated merge API, so impl can do merge-specific checksumming, and won't cache values in RAM
|
||||
values = docValuesProducer.getSortedNumeric(fieldInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,4 +79,12 @@ public abstract class DocValuesProducer implements Closeable, Accountable {
|
|||
* @lucene.internal
|
||||
*/
|
||||
public abstract void checkIntegrity() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns an instance optimized for merging.
|
||||
* <p>
|
||||
* The default implementation returns {@code this} */
|
||||
public DocValuesProducer getMergeInstance() throws IOException {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.lucene.index.LeafReader;
|
||||
import org.apache.lucene.index.Fields;
|
||||
import org.apache.lucene.index.MappedMultiFields;
|
||||
import org.apache.lucene.index.MergeState;
|
||||
|
|
|
@ -46,4 +46,12 @@ public abstract class FieldsProducer extends Fields implements Closeable, Accoun
|
|||
* @lucene.internal
|
||||
*/
|
||||
public abstract void checkIntegrity() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns an instance optimized for merging.
|
||||
* <p>
|
||||
* The default implementation returns {@code this} */
|
||||
public FieldsProducer getMergeInstance() throws IOException {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@ import java.util.NoSuchElementException;
|
|||
|
||||
import org.apache.lucene.index.DocValues;
|
||||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.FieldInfos;
|
||||
import org.apache.lucene.index.LeafReader;
|
||||
import org.apache.lucene.index.MergeState;
|
||||
import org.apache.lucene.index.NumericDocValues;
|
||||
import org.apache.lucene.index.SegmentWriteState;
|
||||
|
@ -87,7 +85,6 @@ public abstract class NormsConsumer implements Closeable {
|
|||
if (normsProducer != null) {
|
||||
FieldInfo fieldInfo = mergeState.fieldInfos[i].fieldInfo(mergeFieldInfo.name);
|
||||
if (fieldInfo != null && fieldInfo.hasNorms()) {
|
||||
// TODO: use dedicated merge API, so impl can do merge-specific checksumming, and won't cache values in RAM
|
||||
norms = normsProducer.getNorms(fieldInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,4 +47,12 @@ public abstract class NormsProducer implements Closeable, Accountable {
|
|||
* @lucene.internal
|
||||
*/
|
||||
public abstract void checkIntegrity() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns an instance optimized for merging.
|
||||
* <p>
|
||||
* The default implementation returns {@code this} */
|
||||
public NormsProducer getMergeInstance() throws IOException {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,4 +50,12 @@ public abstract class StoredFieldsReader implements Cloneable, Closeable, Accoun
|
|||
* @lucene.internal
|
||||
*/
|
||||
public abstract void checkIntegrity() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns an instance optimized for merging.
|
||||
* <p>
|
||||
* The default implementation returns {@code this} */
|
||||
public StoredFieldsReader getMergeInstance() throws IOException {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,6 @@ import java.io.IOException;
|
|||
import org.apache.lucene.document.DocumentStoredFieldVisitor;
|
||||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.FieldInfos;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.LeafReader;
|
||||
import org.apache.lucene.index.MergeState;
|
||||
import org.apache.lucene.index.StorableField;
|
||||
import org.apache.lucene.index.StoredDocument;
|
||||
|
|
|
@ -56,4 +56,12 @@ public abstract class TermVectorsReader implements Cloneable, Closeable, Account
|
|||
* read term vectors. */
|
||||
@Override
|
||||
public abstract TermVectorsReader clone();
|
||||
|
||||
/**
|
||||
* Returns an instance optimized for merging.
|
||||
* <p>
|
||||
* The default implementation returns {@code this} */
|
||||
public TermVectorsReader getMergeInstance() throws IOException {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,6 @@ import org.apache.lucene.index.DocsAndPositionsEnum;
|
|||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.FieldInfos;
|
||||
import org.apache.lucene.index.Fields;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.LeafReader;
|
||||
import org.apache.lucene.index.MergeState;
|
||||
import org.apache.lucene.index.Terms;
|
||||
import org.apache.lucene.index.TermsEnum;
|
||||
|
|
|
@ -116,10 +116,25 @@ public class MergeState {
|
|||
if (reader instanceof SegmentReader) {
|
||||
SegmentReader segmentReader = (SegmentReader) reader;
|
||||
normsProducer = segmentReader.getNormsReader();
|
||||
if (normsProducer != null) {
|
||||
normsProducer = normsProducer.getMergeInstance();
|
||||
}
|
||||
docValuesProducer = segmentReader.getDocValuesReader();
|
||||
if (docValuesProducer != null) {
|
||||
docValuesProducer = docValuesProducer.getMergeInstance();
|
||||
}
|
||||
storedFieldsReader = segmentReader.getFieldsReader();
|
||||
if (storedFieldsReader != null) {
|
||||
storedFieldsReader = storedFieldsReader.getMergeInstance();
|
||||
}
|
||||
termVectorsReader = segmentReader.getTermVectorsReader();
|
||||
if (termVectorsReader != null) {
|
||||
termVectorsReader = termVectorsReader.getMergeInstance();
|
||||
}
|
||||
fieldsProducer = segmentReader.fields();
|
||||
if (fieldsProducer != null) {
|
||||
fieldsProducer = fieldsProducer.getMergeInstance();
|
||||
}
|
||||
} else {
|
||||
// A "foreign" reader
|
||||
normsProducer = readerToNormsProducer(reader);
|
||||
|
|
Loading…
Reference in New Issue