@Override public BytesRef getPayload() { if (hasPayload) { return payload.get(); } else { return null; } } }
@Override public BytesRef binaryValue() { return value.get(); } }
@Override public BytesRef term() { assert !eof; return term.get(); }
@Override public BytesRef term() throws IOException { return scratch.get(); }
@Override public BytesRef term() throws IOException { return scratch.get(); }
/** * Append the provided bytes to this builder. */ public void append(BytesRefBuilder builder) { append(builder.get()); }
@Override public BytesRef getBytesRef() { builder.copyChars(termBuffer, 0, termLength); return builder.get(); }
@Override public Iterator iterator() { ensureFinished(); return new Iterator(size, offsets, lengths, docs, values.get(), delGen); }
@Override public int hashCode() { assert exists || 0 == value.length(); return value.get().hashCode(); } }
@Override public Object toObject() { assert exists || 0 == value.length(); return exists ? value.get().utf8ToString() : null; }
@Override public CharTermAttributeImpl clone() { CharTermAttributeImpl t = (CharTermAttributeImpl)super.clone(); // Do a deep clone t.termBuffer = new char[this.termLength]; System.arraycopy(this.termBuffer, 0, t.termBuffer, 0, this.termLength); t.builder = new BytesRefBuilder(); t.builder.copyBytes(builder.get()); return t; }
@Override public BytesRef next() throws IOException { currentOrd++; if (currentOrd >= values.getValueCount()) { return null; } scratch.copyBytes(values.lookupOrd(currentOrd)); return scratch.get(); }
@Override public BytesRef next() throws IOException { currentOrd++; if (currentOrd >= values.getValueCount()) { return null; } scratch.copyBytes(values.lookupOrd(currentOrd)); return scratch.get(); }
@Override public void copy(int slot, int doc) throws IOException { final BytesRef comparableBytes = getValueForDoc(doc); if (comparableBytes == null) { values[slot] = null; } else { if (tempBRs[slot] == null) { tempBRs[slot] = new BytesRefBuilder(); } tempBRs[slot].copyBytes(comparableBytes); values[slot] = tempBRs[slot].get(); } }
/** Just converts IntsRef to BytesRef; you must ensure the * int values fit into a byte. */ public static BytesRef toBytesRef(IntsRef input, BytesRefBuilder scratch) { scratch.grow(input.length); for(int i=0;i<input.length;i++) { int value = input.ints[i+input.offset]; // NOTE: we allow -128 to 255 assert value >= Byte.MIN_VALUE && value <= 255: "value " + value + " doesn't fit into byte"; scratch.setByteAt(i, (byte) value); } scratch.setLength(input.length); return scratch.get(); }
private boolean compareToLastTerm(BytesRef t) { if (lastTerm == null && t != null) { lastTerm = new BytesRefBuilder(); lastTerm.append(t); } else if (t == null) { lastTerm = null; } else { assert lastTerm.get().compareTo(t) < 0: "lastTerm=" + lastTerm + " t=" + t; lastTerm.copyBytes(t); } return true; }