reader.setPosition(numBytes-1);
@Override public BytesRef lookupOrd(long ord) { try { in.setPosition(0); fst.getFirstArc(firstArc); IntsRef output = Util.getByOutput(fst, ord, in, firstArc, scratchArc, scratchInts); return Util.toBytesRef(output, term); } catch (IOException bogus) { throw new RuntimeException(bogus); } }
@Override public BytesRef lookupOrd(int ord) { try { in.setPosition(0); fst.getFirstArc(firstArc); IntsRef output = Util.getByOutput(fst, ord, in, firstArc, scratchArc, scratchInts); return Util.toBytesRef(output, term); } catch (IOException bogus) { throw new RuntimeException(bogus); } }
/** * Checks if <code>arc</code>'s target state is in expanded (or vector) format. * * @return Returns <code>true</code> if <code>arc</code> points to a state in an * expanded array format. */ boolean isExpandedTarget(Arc<T> follow, BytesReader in) throws IOException { if (!targetHasArcs(follow)) { return false; } else { in.setPosition(getNodeAddress(follow.target)); return in.readByte() == ARCS_AS_FIXED_ARRAY; } }
/** * Checks if <code>arc</code>'s target state is in expanded (or vector) format. * * @return Returns <code>true</code> if <code>arc</code> points to a state in an * expanded array format. */ boolean isExpandedTarget(Arc<T> follow, BytesReader in) throws IOException { if (!targetHasArcs(follow)) { return false; } else { in.setPosition(follow.target); return in.readByte() == ARCS_AS_FIXED_ARRAY; } }
@Override public void seekExact(long ord) throws IOException { // TODO: would be better to make this simpler and faster. // but we dont want to introduce a bug that corrupts our enum state! bytesReader.setPosition(0); fst.getFirstArc(firstArc); IntsRef output = Util.getByOutput(fst, ord, bytesReader, firstArc, scratchArc, scratchInts); BytesRefBuilder scratchBytes = new BytesRefBuilder(); scratchBytes.clear(); Util.toBytesRef(output, scratchBytes); // TODO: we could do this lazily, better to try to push into FSTEnum though? in.seekExact(scratchBytes.get()); }
@Override public BytesRef lookupOrd(int ord) { try { in.setPosition(0); fst.getFirstArc(firstArc); IntsRef output = Util.getByOutput(fst, ord, in, firstArc, scratchArc, scratchInts); term.grow(output.length); term.clear(); return Util.toBytesRef(output, term); } catch (IOException bogus) { throw new RuntimeException(bogus); } }
/** * Checks if <code>arc</code>'s target state is in expanded (or vector) format. * * @return Returns <code>true</code> if <code>arc</code> points to a state in an * expanded array format. */ boolean isExpandedTarget(Arc<T> follow, BytesReader in) throws IOException { if (!targetHasArcs(follow)) { return false; } else { in.setPosition(getNodeAddress(follow.target)); return in.readByte() == ARCS_AS_FIXED_ARRAY; } }
@Override public BytesRef lookupOrd(long ord) { try { in.setPosition(0); fst.getFirstArc(firstArc); IntsRef output = Util.getByOutput(fst, ord, in, firstArc, scratchArc, scratchInts); term.grow(output.length); term.clear(); return Util.toBytesRef(output, term); } catch (IOException bogus) { throw new RuntimeException(bogus); } }
@Override public void seekExact(long ord) throws IOException { // TODO: would be better to make this simpler and faster. // but we dont want to introduce a bug that corrupts our enum state! bytesReader.setPosition(0); fst.getFirstArc(firstArc); IntsRef output = Util.getByOutput(fst, ord, bytesReader, firstArc, scratchArc, scratchInts); // TODO: we could do this lazily, better to try to push into FSTEnum though? in.seekExact(Util.toBytesRef(output, new BytesRefBuilder())); }
while (low <= high) { mid = (low + high) >>> 1; in.setPosition(arc.posArcsStart); in.skipBytes(arc.bytesPerArc*mid+1); final int midLabel = fst.readLabel(in);
while (low <= high) { mid = (low + high) >>> 1; in.setPosition(arc.posArcsStart); in.skipBytes(arc.bytesPerArc*mid+1); final int midLabel = fst.readLabel(in);
while (low <= high) { mid = (low + high) >>> 1; in.setPosition(arc.posArcsStart); in.skipBytes(arc.bytesPerArc*mid); final byte flags = in.readByte();
in.setPosition(arc.posArcsStart); in.skipBytes(arc.bytesPerArc * mid + 1); final int midLabel = fst.readLabel(in);
in.setPosition(follow.target); in.setPosition(arc.posArcsStart); in.skipBytes(arc.bytesPerArc*mid + 1); int midLabel = readLabel(in);
return arc; } else { in.setPosition(follow.target); final byte b = in.readByte(); if (b == ARCS_AS_FIXED_ARRAY) {
in.setPosition(arc.posArcsStart); in.skipBytes(arc.arcIdx*arc.bytesPerArc); } else { in.setPosition(arc.nextArc); in.setPosition(arc.posArcsStart); in.skipBytes(arc.bytesPerArc * arc.numArcs);
in.setPosition(pos); in.setPosition(pos); in.setPosition(arc.posArcsStart); in.skipBytes((1+arc.arcIdx)*arc.bytesPerArc); } else { in.setPosition(arc.nextArc);
public Arc<T> readFirstRealTargetArc(long node, Arc<T> arc, final BytesReader in) throws IOException { final long address = node; in.setPosition(address); //System.out.println(" readFirstRealTargtArc address=" //+ address); //System.out.println(" flags=" + arc.flags); if (in.readByte() == ARCS_AS_FIXED_ARRAY) { //System.out.println(" fixedArray"); // this is first arc in a fixed-array arc.numArcs = in.readVInt(); if (version >= VERSION_VINT_TARGET) { arc.bytesPerArc = in.readVInt(); } else { arc.bytesPerArc = in.readInt(); } arc.arcIdx = -1; arc.nextArc = arc.posArcsStart = in.getPosition(); //System.out.println(" bytesPer=" + arc.bytesPerArc + " numArcs=" + arc.numArcs + " arcsStart=" + pos); } else { //arc.flags = b; arc.nextArc = address; arc.bytesPerArc = 0; } return readNextRealArc(arc, in); }
/** * Checks if <code>arc</code>'s target state is in expanded (or vector) format. * * @return Returns <code>true</code> if <code>arc</code> points to a state in an * expanded array format. */ boolean isExpandedTarget(Arc<T> follow, BytesReader in) throws IOException { if (!targetHasArcs(follow)) { return false; } else { in.setPosition(follow.target); return in.readByte() == ARCS_AS_FIXED_ARRAY; } }