@Override public void intersect(IntersectVisitor visitor) throws IOException { final BytesRef scratch = new BytesRef(); final byte[] packedValue = new byte[packedBytesLength]; for(int i=0;i<numPoints;i++) { getValue(i, scratch); assert scratch.length == packedValue.length; System.arraycopy(scratch.bytes, scratch.offset, packedValue, 0, packedBytesLength); visitor.visit(getDocID(i), packedValue); } }
visitor.visit(docIDs[i]);
@Override public void intersect(IntersectVisitor visitor) throws IOException { final BytesRef scratch = new BytesRef(); final byte[] packedValue = new byte[packedBytesLength]; for(int i=0;i<numPoints;i++) { getValue(i, scratch); assert scratch.length == packedValue.length; System.arraycopy(scratch.bytes, scratch.offset, packedValue, 0, packedBytesLength); visitor.visit(getDocID(i), packedValue); } }
@Override public void visit(int docID, byte[] packedValue) throws IOException { visitor.visit(docMap.oldToNew(docID), packedValue); }
private void visitRawDocValues(int[] commonPrefixLengths, byte[] scratchPackedValue, IndexInput in, int[] docIDs, int count, IntersectVisitor visitor) throws IOException { for (int i = 0; i < count; ++i) { for(int dim=0;dim<numDataDims;dim++) { int prefix = commonPrefixLengths[dim]; in.readBytes(scratchPackedValue, dim*bytesPerDim + prefix, bytesPerDim - prefix); } visitor.visit(docIDs[i], scratchPackedValue); } }
@Override public void visit(int docID) throws IOException { visitor.visit(docMap.oldToNew(docID)); }
@Override public void visit(int docID) throws IOException { visitor.visit(docMap.oldToNew(docID)); }
static void readInts32(IndexInput in, int count, IntersectVisitor visitor) throws IOException { for (int i = 0; i < count; i++) { visitor.visit(in.readInt()); } }
private static void readDeltaVInts(IndexInput in, int count, IntersectVisitor visitor) throws IOException { int doc = 0; for (int i = 0; i < count; i++) { doc += in.readVInt(); visitor.visit(doc); } }
void visitDocIDs(IndexInput in, long blockFP, IntersectVisitor visitor) throws IOException { BytesRefBuilder scratch = new BytesRefBuilder(); in.seek(blockFP); readLine(in, scratch); int count = parseInt(scratch, BLOCK_COUNT); visitor.grow(count); for(int i=0;i<count;i++) { readLine(in, scratch); visitor.visit(parseInt(scratch, BLOCK_DOC_ID)); } }
@Override public void intersect(IntersectVisitor visitor) throws IOException { BytesRef[] values = info.pointValues; visitor.grow(info.pointValuesCount); for (int i = 0; i < info.pointValuesCount; i++) { visitor.visit(0, values[i].bytes); } }
private void visitCompressedDocValues(int[] commonPrefixLengths, byte[] scratchPackedValue, IndexInput in, int[] docIDs, int count, IntersectVisitor visitor, int compressedDim) throws IOException { // the byte at `compressedByteOffset` is compressed using run-length compression, // other suffix bytes are stored verbatim final int compressedByteOffset = compressedDim * bytesPerDim + commonPrefixLengths[compressedDim]; commonPrefixLengths[compressedDim]++; int i; for (i = 0; i < count; ) { scratchPackedValue[compressedByteOffset] = in.readByte(); final int runLen = Byte.toUnsignedInt(in.readByte()); for (int j = 0; j < runLen; ++j) { for(int dim=0;dim<numDataDims;dim++) { int prefix = commonPrefixLengths[dim]; in.readBytes(scratchPackedValue, dim*bytesPerDim + prefix, bytesPerDim - prefix); } visitor.visit(docIDs[i+j], scratchPackedValue); } i += runLen; } if (i != count) { throw new CorruptIndexException("Sub blocks do not add up to the expected count: " + count + " != " + i, in); } }
private static void readInts24(IndexInput in, int count, IntersectVisitor visitor) throws IOException { int i; for (i = 0; i < count - 7; i += 8) { long l1 = in.readLong(); long l2 = in.readLong(); long l3 = in.readLong(); visitor.visit((int) (l1 >>> 40)); visitor.visit((int) (l1 >>> 16) & 0xffffff); visitor.visit((int) (((l1 & 0xffff) << 8) | (l2 >>> 56))); visitor.visit((int) (l2 >>> 32) & 0xffffff); visitor.visit((int) (l2 >>> 8) & 0xffffff); visitor.visit((int) (((l2 & 0xff) << 16) | (l3 >>> 48))); visitor.visit((int) (l3 >>> 24) & 0xffffff); visitor.visit((int) l3 & 0xffffff); } for (; i < count; ++i) { visitor.visit((Short.toUnsignedInt(in.readShort()) << 8) | Byte.toUnsignedInt(in.readByte())); } } }
@Override public void visit(int docID, byte[] packedValue) throws IOException { visitor.visit(docMap.oldToNew(docID), packedValue); }
@Override public void visit(int docID) throws IOException { visitor.visit(docMap.oldToNew(docID)); }
@Override public void visit(int docID) throws IOException { visitor.visit(docMap.oldToNew(docID)); }
@Override public void visit(int docID, byte[] packedValue) throws IOException { visitor.visit(docMap.oldToNew(docID), packedValue); }
static void readInts32(IndexInput in, int count, IntersectVisitor visitor) throws IOException { for (int i = 0; i < count; i++) { visitor.visit(in.readInt()); } }
private void visitRawDocValues(int[] commonPrefixLengths, byte[] scratchPackedValue, IndexInput in, int[] docIDs, int count, IntersectVisitor visitor) throws IOException { for (int i = 0; i < count; ++i) { for(int dim=0;dim<numDataDims;dim++) { int prefix = commonPrefixLengths[dim]; in.readBytes(scratchPackedValue, dim*bytesPerDim + prefix, bytesPerDim - prefix); } visitor.visit(docIDs[i], scratchPackedValue); } }
private static void readDeltaVInts(IndexInput in, int count, IntersectVisitor visitor) throws IOException { int doc = 0; for (int i = 0; i < count; i++) { doc += in.readVInt(); visitor.visit(doc); } }