mirror of https://github.com/apache/lucene.git
LUCENE-2380: expose method of getting native arrays
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@956286 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b910ea232f
commit
0f5172a44e
|
@ -24,6 +24,7 @@ import org.apache.lucene.util.RamUsageEstimator;
|
|||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.document.NumericField; // for javadocs
|
||||
import org.apache.lucene.analysis.NumericTokenStream; // for javadocs
|
||||
import org.apache.lucene.util.packed.PackedInts;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
@ -534,6 +535,9 @@ public interface FieldCache {
|
|||
|
||||
/** Returns a TermsEnum that can iterate over the values in this index entry */
|
||||
public abstract TermsEnum getTermsEnum();
|
||||
|
||||
/** @lucene.internal */
|
||||
public abstract PackedInts.Reader getDocToOrd();
|
||||
}
|
||||
|
||||
/** Checks the internal cache for an appropriate entry, and if none
|
||||
|
|
|
@ -634,7 +634,7 @@ class FieldCacheImpl implements FieldCache {
|
|||
}
|
||||
}
|
||||
|
||||
private static class DocTermsIndexImpl extends DocTermsIndex {
|
||||
public static class DocTermsIndexImpl extends DocTermsIndex {
|
||||
private final PagedBytes.Reader bytes;
|
||||
private final PackedInts.Reader termOrdToBytesOffset;
|
||||
private final PackedInts.Reader docToTermOrd;
|
||||
|
@ -647,6 +647,11 @@ class FieldCacheImpl implements FieldCache {
|
|||
this.numOrd = numOrd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackedInts.Reader getDocToOrd() {
|
||||
return docToTermOrd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int numOrd() {
|
||||
return numOrd;
|
||||
|
|
|
@ -25,9 +25,10 @@ import java.util.Arrays;
|
|||
|
||||
/**
|
||||
* Direct wrapping of 16 bit values to a backing array of shorts.
|
||||
* @lucene.internal
|
||||
*/
|
||||
|
||||
class Direct16 extends PackedInts.ReaderImpl
|
||||
public class Direct16 extends PackedInts.ReaderImpl
|
||||
implements PackedInts.Mutable {
|
||||
private short[] values;
|
||||
private static final int BITS_PER_VALUE = 16;
|
||||
|
@ -67,6 +68,10 @@ class Direct16 extends PackedInts.ReaderImpl
|
|||
this.values = values;
|
||||
}
|
||||
|
||||
public short[] getArray() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public long get(final int index) {
|
||||
return 0xFFFFL & values[index];
|
||||
}
|
||||
|
|
|
@ -25,9 +25,10 @@ import java.util.Arrays;
|
|||
|
||||
/**
|
||||
* Direct wrapping of 32 bit values to a backing array of ints.
|
||||
* @lucene.internal
|
||||
*/
|
||||
|
||||
class Direct32 extends PackedInts.ReaderImpl
|
||||
public class Direct32 extends PackedInts.ReaderImpl
|
||||
implements PackedInts.Mutable {
|
||||
private int[] values;
|
||||
private static final int BITS_PER_VALUE = 32;
|
||||
|
@ -63,6 +64,10 @@ class Direct32 extends PackedInts.ReaderImpl
|
|||
this.values = values;
|
||||
}
|
||||
|
||||
public int[] getArray() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public long get(final int index) {
|
||||
return 0xFFFFFFFFL & values[index];
|
||||
}
|
||||
|
|
|
@ -25,9 +25,10 @@ import java.util.Arrays;
|
|||
|
||||
/**
|
||||
* Direct wrapping of 32 bit values to a backing array of ints.
|
||||
* @lucene.internal
|
||||
*/
|
||||
|
||||
class Direct64 extends PackedInts.ReaderImpl
|
||||
public class Direct64 extends PackedInts.ReaderImpl
|
||||
implements PackedInts.Mutable {
|
||||
private long[] values;
|
||||
private static final int BITS_PER_VALUE = 64;
|
||||
|
@ -47,6 +48,9 @@ class Direct64 extends PackedInts.ReaderImpl
|
|||
this.values = values;
|
||||
}
|
||||
|
||||
public long[] getArray() {
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array backed by the given values.
|
||||
|
|
|
@ -25,9 +25,10 @@ import java.util.Arrays;
|
|||
|
||||
/**
|
||||
* Direct wrapping of 8 bit values to a backing array of bytes.
|
||||
* @lucene.internal
|
||||
*/
|
||||
|
||||
class Direct8 extends PackedInts.ReaderImpl
|
||||
public class Direct8 extends PackedInts.ReaderImpl
|
||||
implements PackedInts.Mutable {
|
||||
private byte[] values;
|
||||
private static final int BITS_PER_VALUE = 8;
|
||||
|
@ -68,6 +69,10 @@ class Direct8 extends PackedInts.ReaderImpl
|
|||
this.values = values;
|
||||
}
|
||||
|
||||
public byte[] getArray() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public long get(final int index) {
|
||||
return 0xFFL & values[index];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue