mirror of https://github.com/apache/lucene.git
LUCENE-8470: Remove legacy doc values APIs from lucene/core.
This commit is contained in:
parent
57334721f0
commit
3302ed2ac6
|
@ -23,7 +23,6 @@ import java.util.Iterator;
|
|||
import org.apache.lucene.codecs.CodecUtil;
|
||||
import org.apache.lucene.codecs.DocValuesConsumer;
|
||||
import org.apache.lucene.codecs.DocValuesProducer;
|
||||
import org.apache.lucene.codecs.LegacyDocValuesIterables;
|
||||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.IndexFileNames;
|
||||
import org.apache.lucene.index.SegmentWriteState;
|
||||
|
|
|
@ -14,9 +14,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.lucene.index;
|
||||
package org.apache.lucene.codecs.memory;
|
||||
|
||||
|
||||
import org.apache.lucene.index.BinaryDocValues;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
/**
|
||||
|
@ -25,7 +26,7 @@ import org.apache.lucene.util.BytesRef;
|
|||
* @deprecated Use {@link BinaryDocValues} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class LegacyBinaryDocValues {
|
||||
abstract class LegacyBinaryDocValues {
|
||||
|
||||
/** Sole constructor. (For invocation by subclass
|
||||
* constructors, typically implicit.) */
|
|
@ -15,10 +15,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.lucene.index;
|
||||
package org.apache.lucene.codecs.memory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.index.BinaryDocValues;
|
||||
import org.apache.lucene.util.Bits;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
|
@ -28,7 +29,7 @@ import org.apache.lucene.util.BytesRef;
|
|||
* @deprecated Implement {@link BinaryDocValues} directly.
|
||||
*/
|
||||
@Deprecated
|
||||
public final class LegacyBinaryDocValuesWrapper extends BinaryDocValues {
|
||||
final class LegacyBinaryDocValuesWrapper extends BinaryDocValues {
|
||||
private final Bits docsWithField;
|
||||
private final LegacyBinaryDocValues values;
|
||||
private final int maxDoc;
|
|
@ -15,11 +15,16 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.lucene.codecs;
|
||||
package org.apache.lucene.codecs.memory;
|
||||
|
||||
import static org.apache.lucene.index.SortedSetDocValues.NO_MORE_ORDS;
|
||||
import static org.apache.lucene.search.DocIdSetIterator.NO_MORE_DOCS;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.lucene.codecs.DocValuesProducer;
|
||||
import org.apache.lucene.codecs.NormsProducer;
|
||||
import org.apache.lucene.index.BinaryDocValues;
|
||||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.NumericDocValues;
|
||||
|
@ -28,12 +33,9 @@ import org.apache.lucene.index.SortedNumericDocValues;
|
|||
import org.apache.lucene.index.SortedSetDocValues;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
import static org.apache.lucene.index.SortedSetDocValues.NO_MORE_ORDS;
|
||||
import static org.apache.lucene.search.DocIdSetIterator.NO_MORE_DOCS;
|
||||
|
||||
/** Bridge helper methods for legacy codecs to map sorted doc values to iterables. */
|
||||
|
||||
public class LegacyDocValuesIterables {
|
||||
class LegacyDocValuesIterables {
|
||||
|
||||
private LegacyDocValuesIterables() {
|
||||
// no
|
|
@ -14,8 +14,9 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.lucene.index;
|
||||
package org.apache.lucene.codecs.memory;
|
||||
|
||||
import org.apache.lucene.index.NumericDocValues;
|
||||
|
||||
/**
|
||||
* A per-document numeric value.
|
||||
|
@ -23,7 +24,7 @@ package org.apache.lucene.index;
|
|||
* @deprecated Use {@link NumericDocValues} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class LegacyNumericDocValues {
|
||||
abstract class LegacyNumericDocValues {
|
||||
|
||||
/** Sole constructor. (For invocation by subclass
|
||||
* constructors, typically implicit.) */
|
|
@ -15,10 +15,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.lucene.index;
|
||||
package org.apache.lucene.codecs.memory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.index.NumericDocValues;
|
||||
import org.apache.lucene.util.Bits;
|
||||
|
||||
/**
|
||||
|
@ -27,7 +28,7 @@ import org.apache.lucene.util.Bits;
|
|||
* @deprecated Implement {@link NumericDocValues} directly.
|
||||
*/
|
||||
@Deprecated
|
||||
public final class LegacyNumericDocValuesWrapper extends NumericDocValues {
|
||||
final class LegacyNumericDocValuesWrapper extends NumericDocValues {
|
||||
private final Bits docsWithField;
|
||||
private final LegacyNumericDocValues values;
|
||||
private final int maxDoc;
|
|
@ -14,9 +14,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.lucene.index;
|
||||
package org.apache.lucene.codecs.memory;
|
||||
|
||||
|
||||
import org.apache.lucene.index.SortedDocValues;
|
||||
import org.apache.lucene.index.TermsEnum;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
/**
|
||||
|
@ -30,7 +32,7 @@ import org.apache.lucene.util.BytesRef;
|
|||
* @deprecated Use {@link SortedDocValues} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class LegacySortedDocValues extends LegacyBinaryDocValues {
|
||||
abstract class LegacySortedDocValues extends LegacyBinaryDocValues {
|
||||
|
||||
/** Sole constructor. (For invocation by subclass
|
||||
* constructors, typically implicit.) */
|
|
@ -15,10 +15,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.lucene.index;
|
||||
package org.apache.lucene.codecs.memory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.index.SortedDocValues;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
/**
|
||||
|
@ -27,7 +28,7 @@ import org.apache.lucene.util.BytesRef;
|
|||
* @deprecated Implement {@link SortedDocValues} directly.
|
||||
*/
|
||||
@Deprecated
|
||||
public final class LegacySortedDocValuesWrapper extends SortedDocValues {
|
||||
final class LegacySortedDocValuesWrapper extends SortedDocValues {
|
||||
private final LegacySortedDocValues values;
|
||||
private final int maxDoc;
|
||||
private int docID = -1;
|
|
@ -14,8 +14,9 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.lucene.index;
|
||||
package org.apache.lucene.codecs.memory;
|
||||
|
||||
import org.apache.lucene.index.SortedNumericDocValues;
|
||||
|
||||
/**
|
||||
* A list of per-document numeric values, sorted
|
||||
|
@ -24,7 +25,7 @@ package org.apache.lucene.index;
|
|||
* @deprecated Use {@link SortedNumericDocValues} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class LegacySortedNumericDocValues {
|
||||
abstract class LegacySortedNumericDocValues {
|
||||
|
||||
/** Sole constructor. (For invocation by subclass
|
||||
* constructors, typically implicit.) */
|
|
@ -15,17 +15,19 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.lucene.index;
|
||||
package org.apache.lucene.codecs.memory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.index.SortedNumericDocValues;
|
||||
|
||||
/**
|
||||
* Wraps a {@link LegacySortedNumericDocValues} into a {@link SortedNumericDocValues}.
|
||||
*
|
||||
* @deprecated Implement {@link SortedNumericDocValues} directly.
|
||||
*/
|
||||
@Deprecated
|
||||
public final class LegacySortedNumericDocValuesWrapper extends SortedNumericDocValues {
|
||||
final class LegacySortedNumericDocValuesWrapper extends SortedNumericDocValues {
|
||||
private final LegacySortedNumericDocValues values;
|
||||
private final int maxDoc;
|
||||
private int docID = -1;
|
|
@ -14,11 +14,13 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.lucene.index;
|
||||
package org.apache.lucene.codecs.memory;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.index.SortedSetDocValues;
|
||||
import org.apache.lucene.index.TermsEnum;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
/**
|
||||
|
@ -32,7 +34,7 @@ import org.apache.lucene.util.BytesRef;
|
|||
* @deprecated Use {@link SortedSetDocValues} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class LegacySortedSetDocValues {
|
||||
abstract class LegacySortedSetDocValues {
|
||||
|
||||
/** Sole constructor. (For invocation by subclass
|
||||
* constructors, typically implicit.) */
|
|
@ -15,10 +15,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.lucene.index;
|
||||
package org.apache.lucene.codecs.memory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.index.SortedSetDocValues;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
||||
/**
|
||||
|
@ -27,7 +28,7 @@ import org.apache.lucene.util.BytesRef;
|
|||
* @deprecated Implement {@link SortedSetDocValues} directly.
|
||||
*/
|
||||
@Deprecated
|
||||
public final class LegacySortedSetDocValuesWrapper extends SortedSetDocValues {
|
||||
final class LegacySortedSetDocValuesWrapper extends SortedSetDocValues {
|
||||
private final LegacySortedSetDocValues values;
|
||||
private final int maxDoc;
|
||||
private int docID = -1;
|
|
@ -112,29 +112,6 @@ public final class DocValues {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* An empty SortedDocValues which returns {@link BytesRef#EMPTY_BYTES} for every document
|
||||
*/
|
||||
public static final LegacySortedDocValues emptyLegacySorted() {
|
||||
final BytesRef empty = new BytesRef();
|
||||
return new LegacySortedDocValues() {
|
||||
@Override
|
||||
public int getOrd(int docID) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BytesRef lookupOrd(int ord) {
|
||||
return empty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValueCount() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* An empty SortedDocValues which returns {@link BytesRef#EMPTY_BYTES} for every document
|
||||
*/
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.io.IOException;
|
|||
import java.util.Arrays;
|
||||
|
||||
import org.apache.lucene.codecs.CodecUtil;
|
||||
import org.apache.lucene.index.LegacyNumericDocValues;
|
||||
import org.apache.lucene.store.DataInput;
|
||||
import org.apache.lucene.store.DataOutput;
|
||||
import org.apache.lucene.store.IndexInput;
|
||||
|
@ -449,7 +448,10 @@ public class PackedInts {
|
|||
* A read-only random access array of positive integers.
|
||||
* @lucene.internal
|
||||
*/
|
||||
public static abstract class Reader extends LegacyNumericDocValues implements Accountable {
|
||||
public static abstract class Reader implements Accountable {
|
||||
|
||||
/** Get the long at the given index. Behavior is undefined for out-of-range indices. */
|
||||
public abstract long get(int index);
|
||||
|
||||
/**
|
||||
* Bulk get: read at least one and at most <code>len</code> longs starting
|
||||
|
|
|
@ -28,8 +28,6 @@ import org.apache.lucene.index.DocValuesType;
|
|||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.ImpactsEnum;
|
||||
import org.apache.lucene.index.LeafReader;
|
||||
import org.apache.lucene.index.LegacySortedSetDocValues;
|
||||
import org.apache.lucene.index.LegacySortedSetDocValuesWrapper;
|
||||
import org.apache.lucene.index.PostingsEnum;
|
||||
import org.apache.lucene.index.SortedSetDocValues;
|
||||
import org.apache.lucene.index.Terms;
|
||||
|
@ -756,24 +754,27 @@ public class DocTermOrds implements Accountable {
|
|||
if (isEmpty()) {
|
||||
return DocValues.emptySortedSet();
|
||||
} else {
|
||||
return new LegacySortedSetDocValuesWrapper(new Iterator(reader), reader.maxDoc());
|
||||
return new Iterator(reader);
|
||||
}
|
||||
}
|
||||
|
||||
private class Iterator extends LegacySortedSetDocValues {
|
||||
private class Iterator extends SortedSetDocValues {
|
||||
final LeafReader reader;
|
||||
final TermsEnum te; // used internally for lookupOrd() and lookupTerm()
|
||||
final int maxDoc;
|
||||
// currently we read 5 at a time (using the logic of the old iterator)
|
||||
final int buffer[] = new int[5];
|
||||
int bufferUpto;
|
||||
int bufferLength;
|
||||
|
||||
private int doc = -1;
|
||||
private int tnum;
|
||||
private int upto;
|
||||
private byte[] arr;
|
||||
|
||||
Iterator(LeafReader reader) throws IOException {
|
||||
this.reader = reader;
|
||||
this.maxDoc = reader.maxDoc();
|
||||
this.te = termsEnum();
|
||||
}
|
||||
|
||||
|
@ -835,8 +836,8 @@ public class DocTermOrds implements Accountable {
|
|||
return bufferUpto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDocument(int docID) {
|
||||
private void setDocument(int docID) {
|
||||
this.doc = docID;
|
||||
tnum = 0;
|
||||
final int code = index[docID];
|
||||
if ((code & 0x80000000) != 0) {
|
||||
|
@ -854,6 +855,37 @@ public class DocTermOrds implements Accountable {
|
|||
bufferLength = read(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advanceExact(int target) throws IOException {
|
||||
setDocument(target);
|
||||
return bufferLength > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int docID() {
|
||||
return doc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextDoc() throws IOException {
|
||||
return advance(docID() + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int advance(int target) throws IOException {
|
||||
for (int d = target; d < maxDoc; ++d) {
|
||||
if (advanceExact(d)) {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
return doc = NO_MORE_DOCS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long cost() {
|
||||
return maxDoc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BytesRef lookupOrd(long ord) {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue