Apache Lucene open-source search software
switch packed ints impl from IndexInput/Output to DataInput/Output
Michael McCandless1e554bd9430c
diff --git a/lucene/src/java/org/apache/lucene/util/packed/Direct16.java b/lucene/src/java/org/apache/lucene/util/packed/Direct16.javaindex 962e224cb3c..c698bd6ab1f 100644--- a/lucene/src/java/org/apache/lucene/util/packed/Direct16.java+++ b/lucene/src/java/org/apache/lucene/util/packed/Direct16.java@@ -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.ReaderImplvalues = 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++) {diff --git a/lucene/src/java/org/apache/lucene/util/packed/Direct32.java b/lucene/src/java/org/apache/lucene/util/packed/Direct32.javaindex 8d3486ae6bf..c48d5b07d4c 100644--- a/lucene/src/java/org/apache/lucene/util/packed/Direct32.java+++ b/lucene/src/java/org/apache/lucene/util/packed/Direct32.java@@ -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.ReaderImplvalues = 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++) {diff --git a/lucene/src/java/org/apache/lucene/util/packed/Direct64.java b/lucene/src/java/org/apache/lucene/util/packed/Direct64.javaindex c72abfb6bd8..591483d02b4 100644--- a/lucene/src/java/org/apache/lucene/util/packed/Direct64.java+++ b/lucene/src/java/org/apache/lucene/util/packed/Direct64.java@@ -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.ReaderImplvalues = 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++) {diff --git a/lucene/src/java/org/apache/lucene/util/packed/Direct8.java b/lucene/src/java/org/apache/lucene/util/packed/Direct8.javaindex 233dfe0c310..ab4000418ac 100644--- a/lucene/src/java/org/apache/lucene/util/packed/Direct8.java+++ b/lucene/src/java/org/apache/lucene/util/packed/Direct8.java@@ -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.ReaderImplvalues = 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];diff --git a/lucene/src/java/org/apache/lucene/util/packed/Packed32.java b/lucene/src/java/org/apache/lucene/util/packed/Packed32.javaindex ff22ad7ef48..ed7b8fd8b10 100644--- a/lucene/src/java/org/apache/lucene/util/packed/Packed32.java+++ b/lucene/src/java/org/apache/lucene/util/packed/Packed32.java@@ -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);diff --git a/lucene/src/java/org/apache/lucene/util/packed/Packed64.java b/lucene/src/java/org/apache/lucene/util/packed/Packed64.javaindex 8428c9e36f2..db407519a2a 100644--- a/lucene/src/java/org/apache/lucene/util/packed/Packed64.java+++ b/lucene/src/java/org/apache/lucene/util/packed/Packed64.java@@ -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);diff --git a/lucene/src/java/org/apache/lucene/util/packed/PackedInts.java b/lucene/src/java/org/apache/lucene/util/packed/PackedInts.javaindex c7f670c6eaa..589c8bcfe76 100644--- a/lucene/src/java/org/apache/lucene/util/packed/PackedInts.java+++ b/lucene/src/java/org/apache/lucene/util/packed/PackedInts.java@@ -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);}diff --git a/lucene/src/java/org/apache/lucene/util/packed/PackedWriter.java b/lucene/src/java/org/apache/lucene/util/packed/PackedWriter.javaindex b2c86dd799f..92e361561da 100644--- a/lucene/src/java/org/apache/lucene/util/packed/PackedWriter.java+++ b/lucene/src/java/org/apache/lucene/util/packed/PackedWriter.java@@ -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);