@Override public Long read(DataInput in) throws IOException { long v = in.readVLong(); if (v == 0) { return NO_OUTPUT; } else { return v; } }
/** * Read a {@link BitUtil#zigZagDecode(long) zig-zag}-encoded * {@link #readVLong() variable-length} integer. Reads between one and ten * bytes. * @see DataOutput#writeZLong(long) */ public long readZLong() throws IOException { return BitUtil.zigZagDecode(readVLong(true)); }
/** * Reads a long in a variable-length format. Reads between one andCorePropLo * nine bytes. Small values typically take fewer bytes. */ static long readTLong(DataInput in) throws IOException { int header = in.readByte() & 0xFF; long bits = header & 0x1F; if ((header & 0x20) != 0) { // continuation bit bits |= in.readVLong() << 5; } long l = BitUtil.zigZagDecode(bits); switch (header & DAY_ENCODING) { case SECOND_ENCODING: l *= SECOND; break; case HOUR_ENCODING: l *= HOUR; break; case DAY_ENCODING: l *= DAY; break; case 0: // uncompressed break; default: throw new AssertionError(); } return l; }
@Override public void visitDocument(int docID, StoredFieldVisitor visitor) throws IOException { final SerializedDocument doc = document(docID); for (int fieldIDX = 0; fieldIDX < doc.numStoredFields; fieldIDX++) { final long infoAndBits = doc.in.readVLong(); final int fieldNumber = (int) (infoAndBits >>> TYPE_BITS); final FieldInfo fieldInfo = fieldInfos.fieldInfo(fieldNumber); final int bits = (int) (infoAndBits & TYPE_MASK); assert bits <= NUMERIC_DOUBLE: "bits=" + Integer.toHexString(bits); switch(visitor.needsField(fieldInfo)) { case YES: readField(doc.in, visitor, fieldInfo, bits); break; case NO: if (fieldIDX == doc.numStoredFields - 1) {// don't skipField on last field value; treat like STOP return; } skipField(doc.in, bits); break; case STOP: return; } } }
private long readVLong(boolean allowNegative) throws IOException { /* This is the original code of this method, * but a Hotspot bug (see LUCENE-2975) corrupts the for-loop if * readByte() is inlined. So the loop was unwinded! byte b = readByte(); long i = b & 0x7F; for (int shift = 7; (b & 0x80) != 0; shift += 7) { b = readByte(); i |= (b & 0x7FL) << shift; } return i; */ byte b = readByte(); if (b >= 0) return b; long i = b & 0x7FL; b = readByte(); i |= (b & 0x7FL) << 7; if (b >= 0) return i; b = readByte(); i |= (b & 0x7FL) << 14; if (b >= 0) return i; b = readByte(); i |= (b & 0x7FL) << 21; if (b >= 0) return i; b = readByte(); i |= (b & 0x7FL) << 28; if (b >= 0) return i; b = readByte(); i |= (b & 0x7FL) << 35; if (b >= 0) return i;
@Override public boolean load(DataInput input) throws IOException { count = input.readVLong(); this.fst = new FST<>(input, new PairOutputs<>(PositiveIntOutputs.getSingleton(), ByteSequenceOutputs.getSingleton())); maxAnalyzedPathsForOneInput = input.readVInt(); hasPayloads = input.readByte() == 1; return true; }
@Override public Long read(DataInput in) throws IOException { long v = in.readVLong(); if (v == 0) { return NO_OUTPUT; } else { return v; } }
@Override public Long read(DataInput in) throws IOException { long v = in.readVLong(); if (v == 0) { return NO_OUTPUT; } else { return v; } }
/** * Read a {@link BitUtil#zigZagDecode(long) zig-zag}-encoded * {@link #readVLong() variable-length} integer. Reads between one and ten * bytes. * @see DataOutput#writeZLong(long) */ public long readZLong() throws IOException { return BitUtil.zigZagDecode(readVLong(true)); }
/** * Read a {@link BitUtil#zigZagDecode(long) zig-zag}-encoded * {@link #readVLong() variable-length} integer. Reads between one and ten * bytes. * @see DataOutput#writeZLong(long) */ public long readZLong() throws IOException { return BitUtil.zigZagDecode(readVLong(true)); }
/** * Read a {@link BitUtil#zigZagDecode(long) zig-zag}-encoded * {@link #readVLong() variable-length} integer. Reads between one and ten * bytes. * @see DataOutput#writeZLong(long) */ public long readZLong() throws IOException { return BitUtil.zigZagDecode(readVLong(true)); }
@Override public void decodeTerm(long[] longs, DataInput in, FieldInfo fieldInfo, BlockTermState _termState, boolean absolute) throws IOException { final IDVersionTermState termState = (IDVersionTermState) _termState; termState.docID = in.readVInt(); if (absolute) { termState.idVersion = in.readVLong(); } else { termState.idVersion += in.readZLong(); } }
@Override public boolean load(DataInput input) throws IOException { count = input.readVLong(); this.fst = new FST<>(input, PositiveIntOutputs.getSingleton()); return true; }
@Override public void decodeTerm(long[] longs, DataInput in, FieldInfo fieldInfo, BlockTermState _termState, boolean absolute) throws IOException { final IDVersionTermState termState = (IDVersionTermState) _termState; termState.docID = in.readVInt(); if (absolute) { termState.idVersion = in.readVLong(); } else { termState.idVersion += in.readZLong(); } }
@Override public boolean load(DataInput input) throws IOException { count = input.readVLong(); TSTNode root = trie.new TSTNode('\0', null); readRecursively(input, root); trie.setRoot(root); return true; }
@Override public boolean load(DataInput input) throws IOException { count = input.readVLong(); this.fst = new FST<>(input, new PairOutputs<>(PositiveIntOutputs.getSingleton(), ByteSequenceOutputs.getSingleton())); maxAnalyzedPathsForOneInput = input.readVInt(); hasPayloads = input.readByte() == 1; return true; }