lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1533781 - in /lucene/dev/branches/lucene4956/lucene/core/src/java/org/apache/lucene/util/packed: BlockPackedReader.java MonotonicBlockPackedReader.java
Date Sat, 19 Oct 2013 16:14:30 GMT
Author: rmuir
Date: Sat Oct 19 16:14:29 2013
New Revision: 1533781

URL: http://svn.apache.org/r1533781
Log:
LUCENE-4956: allow use of these with datainput

Modified:
    lucene/dev/branches/lucene4956/lucene/core/src/java/org/apache/lucene/util/packed/BlockPackedReader.java
    lucene/dev/branches/lucene4956/lucene/core/src/java/org/apache/lucene/util/packed/MonotonicBlockPackedReader.java

Modified: lucene/dev/branches/lucene4956/lucene/core/src/java/org/apache/lucene/util/packed/BlockPackedReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/lucene/core/src/java/org/apache/lucene/util/packed/BlockPackedReader.java?rev=1533781&r1=1533780&r2=1533781&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/lucene/core/src/java/org/apache/lucene/util/packed/BlockPackedReader.java
(original)
+++ lucene/dev/branches/lucene4956/lucene/core/src/java/org/apache/lucene/util/packed/BlockPackedReader.java
Sat Oct 19 16:14:29 2013
@@ -28,6 +28,7 @@ import static org.apache.lucene.util.pac
 
 import java.io.IOException;
 
+import org.apache.lucene.store.DataInput;
 import org.apache.lucene.store.IndexInput;
 
 /**
@@ -41,8 +42,11 @@ public final class BlockPackedReader {
   private final long[] minValues;
   private final PackedInts.Reader[] subReaders;
 
-  /** Sole constructor. */
-  public BlockPackedReader(IndexInput in, int packedIntsVersion, int blockSize, long valueCount,
boolean direct) throws IOException {
+  /** 
+   * Sole constructor. 
+   * @throws ClassCastException if you try to use {@code direct} without an IndexInput
+   */
+  public BlockPackedReader(DataInput in, int packedIntsVersion, int blockSize, long valueCount,
boolean direct) throws IOException {
     this.valueCount = valueCount;
     blockShift = checkBlockSize(blockSize, MIN_BLOCK_SIZE, MAX_BLOCK_SIZE);
     blockMask = blockSize - 1;
@@ -66,9 +70,10 @@ public final class BlockPackedReader {
       } else {
         final int size = (int) Math.min(blockSize, valueCount - (long) i * blockSize);
         if (direct) {
-          final long pointer = in.getFilePointer();
-          subReaders[i] = PackedInts.getDirectReaderNoHeader(in, PackedInts.Format.PACKED,
packedIntsVersion, size, bitsPerValue);
-          in.seek(pointer + PackedInts.Format.PACKED.byteCount(packedIntsVersion, size, bitsPerValue));
+          IndexInput ii = (IndexInput)in;
+          final long pointer = ii.getFilePointer();
+          subReaders[i] = PackedInts.getDirectReaderNoHeader(ii, PackedInts.Format.PACKED,
packedIntsVersion, size, bitsPerValue);
+          ii.seek(pointer + PackedInts.Format.PACKED.byteCount(packedIntsVersion, size, bitsPerValue));
         } else {
           subReaders[i] = PackedInts.getReaderNoHeader(in, PackedInts.Format.PACKED, packedIntsVersion,
size, bitsPerValue);
         }

Modified: lucene/dev/branches/lucene4956/lucene/core/src/java/org/apache/lucene/util/packed/MonotonicBlockPackedReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/lucene/core/src/java/org/apache/lucene/util/packed/MonotonicBlockPackedReader.java?rev=1533781&r1=1533780&r2=1533781&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/lucene/core/src/java/org/apache/lucene/util/packed/MonotonicBlockPackedReader.java
(original)
+++ lucene/dev/branches/lucene4956/lucene/core/src/java/org/apache/lucene/util/packed/MonotonicBlockPackedReader.java
Sat Oct 19 16:14:29 2013
@@ -25,6 +25,7 @@ import static org.apache.lucene.util.pac
 
 import java.io.IOException;
 
+import org.apache.lucene.store.DataInput;
 import org.apache.lucene.store.IndexInput;
 
 /**
@@ -40,8 +41,11 @@ public final class MonotonicBlockPackedR
   private final float[] averages;
   private final PackedInts.Reader[] subReaders;
 
-  /** Sole constructor. */
-  public MonotonicBlockPackedReader(IndexInput in, int packedIntsVersion, int blockSize,
long valueCount, boolean direct) throws IOException {
+  /** 
+   * Sole constructor. 
+   * @throws ClassCastException if you try to use {@code direct} without an IndexInput
+   */
+  public MonotonicBlockPackedReader(DataInput in, int packedIntsVersion, int blockSize, long
valueCount, boolean direct) throws IOException {
     this.valueCount = valueCount;
     blockShift = checkBlockSize(blockSize, MIN_BLOCK_SIZE, MAX_BLOCK_SIZE);
     blockMask = blockSize - 1;
@@ -61,9 +65,10 @@ public final class MonotonicBlockPackedR
       } else {
         final int size = (int) Math.min(blockSize, valueCount - (long) i * blockSize);
         if (direct) {
-          final long pointer = in.getFilePointer();
-          subReaders[i] = PackedInts.getDirectReaderNoHeader(in, PackedInts.Format.PACKED,
packedIntsVersion, size, bitsPerValue);
-          in.seek(pointer + PackedInts.Format.PACKED.byteCount(packedIntsVersion, size, bitsPerValue));
+          IndexInput ii = (IndexInput) in;
+          final long pointer = ii.getFilePointer();
+          subReaders[i] = PackedInts.getDirectReaderNoHeader(ii, PackedInts.Format.PACKED,
packedIntsVersion, size, bitsPerValue);
+          ii.seek(pointer + PackedInts.Format.PACKED.byteCount(packedIntsVersion, size, bitsPerValue));
         } else {
           subReaders[i] = PackedInts.getReaderNoHeader(in, PackedInts.Format.PACKED, packedIntsVersion,
size, bitsPerValue);
         }



Mime
View raw message