@Override public final short readShort() throws IOException { if (2 <= (bufferLength-bufferPosition)) { return (short) (((buffer[bufferPosition++] & 0xFF) << 8) | (buffer[bufferPosition++] & 0xFF)); } else { return super.readShort(); } }
@Override public short readShort(long pos) throws IOException { slice.seek(pos); return slice.readShort(); }
@Override boolean advanceWithinBlock(IndexedDISI disi, int target) throws IOException { final int targetInBlock = target & 0xFFFF; // TODO: binary search for (; disi.index < disi.nextBlockIndex;) { int doc = Short.toUnsignedInt(disi.slice.readShort()); disi.index++; if (doc >= targetInBlock) { disi.doc = disi.block | doc; disi.exists = true; return true; } } return false; } @Override
@Override public final short readShort() throws IOException { try { return guard.getShort(curBuf); } catch (BufferUnderflowException e) { return super.readShort(); } catch (NullPointerException npe) { throw new AlreadyClosedException("Already closed: " + this); } }
private void readBlockHeader() throws IOException { block = Short.toUnsignedInt(slice.readShort()) << 16; assert block >= 0; final int numValues = 1 + Short.toUnsignedInt(slice.readShort()); index = nextBlockIndex; nextBlockIndex = index + numValues; if (numValues <= MAX_ARRAY_LENGTH) { method = Method.SPARSE; blockEnd = slice.getFilePointer() + (numValues << 1); } else if (numValues == 65536) { method = Method.ALL; blockEnd = slice.getFilePointer(); gap = block - index - 1; } else { method = Method.DENSE; blockEnd = slice.getFilePointer() + (1 << 13); wordIndex = -1; numberOfOnes = index + 1; } }
@Override boolean advanceExactWithinBlock(IndexedDISI disi, int target) throws IOException { final int targetInBlock = target & 0xFFFF; // TODO: binary search if (target == disi.doc) { return disi.exists; } for (; disi.index < disi.nextBlockIndex;) { int doc = Short.toUnsignedInt(disi.slice.readShort()); disi.index++; if (doc >= targetInBlock) { if (doc != targetInBlock) { disi.index--; disi.slice.seek(disi.slice.getFilePointer() - Short.BYTES); break; } disi.exists = true; return true; } } disi.exists = false; return false; } },
break; case 2: rawValue = in.readShort(); break; case 3: rawValue = ((long)in.readShort() << 8) | (in.readByte() & 0xFFL); break; case 4: break; case 6: rawValue = ((long)in.readInt() << 16) | (in.readShort() & 0xFFFFL); break; case 7: rawValue = ((long)in.readInt() << 24) | ((in.readShort() & 0xFFFFL) << 8) | (in.readByte() & 0xFFL); break; case 8:
private static void readInts24(IndexInput in, int count, int[] docIDs) throws IOException { int i; for (i = 0; i < count - 7; i += 8) { long l1 = in.readLong(); long l2 = in.readLong(); long l3 = in.readLong(); docIDs[i] = (int) (l1 >>> 40); docIDs[i+1] = (int) (l1 >>> 16) & 0xffffff; docIDs[i+2] = (int) (((l1 & 0xffff) << 8) | (l2 >>> 56)); docIDs[i+3] = (int) (l2 >>> 32) & 0xffffff; docIDs[i+4] = (int) (l2 >>> 8) & 0xffffff; docIDs[i+5] = (int) (((l2 & 0xff) << 16) | (l3 >>> 48)); docIDs[i+6] = (int) (l3 >>> 24) & 0xffffff; docIDs[i+7] = (int) l3 & 0xffffff; } for (; i < count; ++i) { docIDs[i] = (Short.toUnsignedInt(in.readShort()) << 8) | Byte.toUnsignedInt(in.readByte()); } }
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 final short readShort() throws IOException { if (2 <= (bufferLength-bufferPosition)) { return (short) (((buffer[bufferPosition++] & 0xFF) << 8) | (buffer[bufferPosition++] & 0xFF)); } else { return super.readShort(); } }
@Override public final short readShort() throws IOException { if (2 <= (bufferLength-bufferPosition)) { return (short) (((buffer[bufferPosition++] & 0xFF) << 8) | (buffer[bufferPosition++] & 0xFF)); } else { return super.readShort(); } }
@Override public final short readShort() throws IOException { if (2 <= (bufferLength-bufferPosition)) { return (short) (((buffer[bufferPosition++] & 0xFF) << 8) | (buffer[bufferPosition++] & 0xFF)); } else { return super.readShort(); } }
@Override public final short readShort() throws IOException { try { return curBuf.getShort(); } catch (BufferUnderflowException e) { return super.readShort(); } catch (NullPointerException npe) { throw new AlreadyClosedException("Already closed: " + this); } }
@Override public short readShort(long pos) throws IOException { slice.seek(pos); return slice.readShort(); }
@Override public short readShort() throws IOException { return delegate.readShort(); }
@Override public short readShort(long pos) throws IOException { slice.seek(pos); return slice.readShort(); }
@Override public short readShort(long pos) throws IOException { slice.seek(pos); return slice.readShort(); }
@Override public final short readShort() throws IOException { try { return curBuf.getShort(); } catch (BufferUnderflowException e) { return super.readShort(); } catch (NullPointerException npe) { throw new AlreadyClosedException("Already closed: " + this); } }
@Override boolean advanceWithinBlock(IndexedDISI disi, int target) throws IOException { final int targetInBlock = target & 0xFFFF; // TODO: binary search for (; disi.index < disi.nextBlockIndex;) { int doc = Short.toUnsignedInt(disi.slice.readShort()); disi.index++; if (doc >= targetInBlock) { disi.doc = disi.block | doc; disi.exists = true; return true; } } return false; } @Override
@Override public final short readShort() throws IOException { try { return guard.getShort(curBuf); } catch (BufferUnderflowException e) { return super.readShort(); } catch (NullPointerException npe) { throw new AlreadyClosedException("Already closed: " + this); } }