mirror of https://github.com/apache/lucene.git
switch packed ints impl from IndexInput/Output to DataInput/Output
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1175984 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4287d1bb52
commit
1e554bd943
|
@ -17,7 +17,7 @@ package org.apache.lucene.util.packed;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.lucene.store.IndexInput;
|
||||
import org.apache.lucene.store.DataInput;
|
||||
import org.apache.lucene.util.RamUsageEstimator;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -38,7 +38,7 @@ public class Direct16 extends PackedInts.ReaderImpl
|
|||
values = new short[valueCount];
|
||||
}
|
||||
|
||||
public Direct16(IndexInput in, int valueCount) throws IOException {
|
||||
public Direct16(DataInput in, int valueCount) throws IOException {
|
||||
super(valueCount, BITS_PER_VALUE);
|
||||
short[] values = new short[valueCount];
|
||||
for(int i=0;i<valueCount;i++) {
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.lucene.util.packed;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.lucene.store.IndexInput;
|
||||
import org.apache.lucene.store.DataInput;
|
||||
import org.apache.lucene.util.RamUsageEstimator;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -38,7 +38,7 @@ public class Direct32 extends PackedInts.ReaderImpl
|
|||
values = new int[valueCount];
|
||||
}
|
||||
|
||||
public Direct32(IndexInput in, int valueCount) throws IOException {
|
||||
public Direct32(DataInput in, int valueCount) throws IOException {
|
||||
super(valueCount, BITS_PER_VALUE);
|
||||
int[] values = new int[valueCount];
|
||||
for(int i=0;i<valueCount;i++) {
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.lucene.util.packed;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.lucene.store.IndexInput;
|
||||
import org.apache.lucene.store.DataInput;
|
||||
import org.apache.lucene.util.RamUsageEstimator;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -38,7 +38,7 @@ public class Direct64 extends PackedInts.ReaderImpl
|
|||
values = new long[valueCount];
|
||||
}
|
||||
|
||||
public Direct64(IndexInput in, int valueCount) throws IOException {
|
||||
public Direct64(DataInput in, int valueCount) throws IOException {
|
||||
super(valueCount, BITS_PER_VALUE);
|
||||
long[] values = new long[valueCount];
|
||||
for(int i=0;i<valueCount;i++) {
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.lucene.util.packed;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.lucene.store.IndexInput;
|
||||
import org.apache.lucene.store.DataInput;
|
||||
import org.apache.lucene.util.RamUsageEstimator;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -38,7 +38,7 @@ public class Direct8 extends PackedInts.ReaderImpl
|
|||
values = new byte[valueCount];
|
||||
}
|
||||
|
||||
public Direct8(IndexInput in, int valueCount)
|
||||
public Direct8(DataInput in, int valueCount)
|
||||
throws IOException {
|
||||
super(valueCount, BITS_PER_VALUE);
|
||||
byte[] values = new byte[valueCount];
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.lucene.util.packed;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.lucene.store.IndexInput;
|
||||
import org.apache.lucene.store.DataInput;
|
||||
import org.apache.lucene.util.RamUsageEstimator;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -122,14 +122,14 @@ class Packed32 extends PackedInts.ReaderImpl implements PackedInts.Mutable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates an array with content retrieved from the given IndexInput.
|
||||
* @param in an IndexInput, positioned at the start of Packed64-content.
|
||||
* Creates an array with content retrieved from the given DataInput.
|
||||
* @param in a DataInput, positioned at the start of Packed64-content.
|
||||
* @param valueCount the number of elements.
|
||||
* @param bitsPerValue the number of bits available for any given value.
|
||||
* @throws java.io.IOException if the values for the backing array could not
|
||||
* be retrieved.
|
||||
*/
|
||||
public Packed32(IndexInput in, int valueCount, int bitsPerValue)
|
||||
public Packed32(DataInput in, int valueCount, int bitsPerValue)
|
||||
throws IOException {
|
||||
super(valueCount, bitsPerValue);
|
||||
int size = size(bitsPerValue, valueCount);
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.lucene.util.packed;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.lucene.store.IndexInput;
|
||||
import org.apache.lucene.store.DataInput;
|
||||
import org.apache.lucene.util.RamUsageEstimator;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -141,14 +141,14 @@ class Packed64 extends PackedInts.ReaderImpl implements PackedInts.Mutable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates an array with content retrieved from the given IndexInput.
|
||||
* @param in an IndexInput, positioned at the start of Packed64-content.
|
||||
* Creates an array with content retrieved from the given DataInput.
|
||||
* @param in a DataInput, positioned at the start of Packed64-content.
|
||||
* @param valueCount the number of elements.
|
||||
* @param bitsPerValue the number of bits available for any given value.
|
||||
* @throws java.io.IOException if the values for the backing array could not
|
||||
* be retrieved.
|
||||
*/
|
||||
public Packed64(IndexInput in, int valueCount, int bitsPerValue)
|
||||
public Packed64(DataInput in, int valueCount, int bitsPerValue)
|
||||
throws IOException {
|
||||
super(valueCount, bitsPerValue);
|
||||
int size = size(valueCount, bitsPerValue);
|
||||
|
|
|
@ -19,7 +19,8 @@ package org.apache.lucene.util.packed;
|
|||
|
||||
import java.io.Closeable;
|
||||
|
||||
import org.apache.lucene.store.IndexOutput;
|
||||
import org.apache.lucene.store.DataInput;
|
||||
import org.apache.lucene.store.DataOutput;
|
||||
import org.apache.lucene.store.IndexInput;
|
||||
import org.apache.lucene.util.CodecUtil;
|
||||
import org.apache.lucene.util.Constants;
|
||||
|
@ -134,11 +135,11 @@ public class PackedInts {
|
|||
* @lucene.internal
|
||||
*/
|
||||
public static abstract class Writer {
|
||||
protected final IndexOutput out;
|
||||
protected final DataOutput out;
|
||||
protected final int bitsPerValue;
|
||||
protected final int valueCount;
|
||||
|
||||
protected Writer(IndexOutput out, int valueCount, int bitsPerValue)
|
||||
protected Writer(DataOutput out, int valueCount, int bitsPerValue)
|
||||
throws IOException {
|
||||
assert bitsPerValue <= 64;
|
||||
|
||||
|
@ -155,14 +156,14 @@ public class PackedInts {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieve PackedInt data from the IndexInput and return a packed int
|
||||
* Retrieve PackedInt data from the DataInput and return a packed int
|
||||
* structure based on it.
|
||||
* @param in positioned at the beginning of a stored packed int structure.
|
||||
* @return a read only random access capable array of positive integers.
|
||||
* @throws IOException if the structure could not be retrieved.
|
||||
* @lucene.internal
|
||||
*/
|
||||
public static Reader getReader(IndexInput in) throws IOException {
|
||||
public static Reader getReader(DataInput in) throws IOException {
|
||||
CodecUtil.checkHeader(in, CODEC_NAME, VERSION_START, VERSION_START);
|
||||
final int bitsPerValue = in.readVInt();
|
||||
assert bitsPerValue > 0 && bitsPerValue <= 64: "bitsPerValue=" + bitsPerValue;
|
||||
|
@ -244,7 +245,7 @@ public class PackedInts {
|
|||
* @throws IOException if bits could not be written to out.
|
||||
* @lucene.internal
|
||||
*/
|
||||
public static Writer getWriter(IndexOutput out, int valueCount, int bitsPerValue)
|
||||
public static Writer getWriter(DataOutput out, int valueCount, int bitsPerValue)
|
||||
throws IOException {
|
||||
return new PackedWriter(out, valueCount, bitsPerValue);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.lucene.util.packed;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.lucene.store.IndexOutput;
|
||||
import org.apache.lucene.store.DataOutput;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -38,7 +38,7 @@ class PackedWriter extends PackedInts.Writer {
|
|||
private final long[] masks;
|
||||
private int written = 0;
|
||||
|
||||
public PackedWriter(IndexOutput out, int valueCount, int bitsPerValue)
|
||||
public PackedWriter(DataOutput out, int valueCount, int bitsPerValue)
|
||||
throws IOException {
|
||||
super(out, valueCount, bitsPerValue);
|
||||
|
||||
|
|
Loading…
Reference in New Issue