@Override protected boolean match( int doc ) { return liveDocs.get( doc ); } };
@Override protected AcceptStatus accept( BytesRef term ) { return StringHelper.startsWith( term, prefix ) ? AcceptStatus.YES : AcceptStatus.END; } }
/** Return the {@see DocIdSet} which contains all the recorded docs. */ public DocIdSet getDocIdSet() { return bits.build(); } }
@Override public PayloadAttributeImpl clone() { PayloadAttributeImpl clone = (PayloadAttributeImpl) super.clone(); if (payload != null) { clone.payload = BytesRef.deepCopyOf(payload); } return clone; }
@Override public int[] init() { final int[] ord = super.init(); boost = new float[ArrayUtil.oversize(ord.length, Float.BYTES)]; termState = new TermContext[ArrayUtil.oversize(ord.length, RamUsageEstimator.NUM_BYTES_OBJECT_REF)]; assert termState.length >= ord.length && boost.length >= ord.length; return ord; }
/** * Augments an existing accountable with the provided description. * <p> * The resource description is constructed in this format: * {@code description [toString()]} * <p> * This is a point-in-time type safe view: consumers * will not be able to cast or manipulate the resource in any way. */ public static Accountable namedAccountable(String description, Accountable in) { return namedAccountable(description + " [" + in + "]", in.getChildResources(), in.ramBytesUsed()); }
/** * Creates a new {@link BytesRefArray} with a counter to track allocated bytes */ public BytesRefArray(Counter bytesUsed) { this.pool = new ByteBlockPool(new ByteBlockPool.DirectTrackingAllocator( bytesUsed)); pool.nextBuffer(); bytesUsed.addAndGet(RamUsageEstimator.NUM_BYTES_ARRAY_HEADER * Integer.BYTES); this.bytesUsed = bytesUsed; }
/** * Creates a new CharsRef that points to a copy of the chars from * <code>other</code> * <p> * The returned CharsRef will have a length of other.length * and an offset of zero. */ public static CharsRef deepCopyOf(CharsRef other) { return new CharsRef(ArrayUtil.copyOfSubArray(other.chars, other.offset, other.offset + other.length), 0, other.length); }
@Override public CharSequence subSequence(int start, int end) { // NOTE: must do a real check here to meet the specs of CharSequence FutureObjects.checkFromToIndex(start, end, length); return new CharsRef(chars, offset + start, end - start); }
Docs( int maxDoc ) { bits = new DocIdSetBuilder( maxDoc ); }
/** * Creates a new LongsRef that points to a copy of the longs from * <code>other</code> * <p> * The returned IntsRef will have a length of other.length * and an offset of zero. */ public static LongsRef deepCopyOf(LongsRef other) { return new LongsRef(ArrayUtil.copyOfSubArray(other.longs, other.offset, other.offset + other.length), 0, other.length); }
/** * Copy the given UTF-8 bytes into this builder. Works as if the bytes were * first converted from UTF-8 to UTF-32 and then copied into this builder. */ public void copyUTF8Bytes(BytesRef bytes) { grow(bytes.length); ref.length = UnicodeUtil.UTF8toUTF32(bytes, ref.ints); }
@Override public final void sort(int from, int to) { checkRange(from, to); quicksort(from, to, 2 * MathUtil.log(to - from, 2)); }
/** Record the given document. */ public void addDoc( int docId ) { bits.add( docId ); }
void grow(int newBlockCount) { ramBytesUsed -= RamUsageEstimator.shallowSizeOf(values); values = ArrayUtil.growExact(values, newBlockCount); ramBytesUsed += RamUsageEstimator.shallowSizeOf(values); }
/** * Resets all Attributes in this AttributeSource by calling * {@link AttributeImpl#clear()} on each Attribute implementation. */ public final void clearAttributes() { for (State state = getCurrentState(); state != null; state = state.next) { state.attribute.clear(); } }
/** * Captures the state of all Attributes. The return value can be passed to * {@link #restoreState} to restore the state of this or another AttributeSource. */ public final State captureState() { final State state = this.getCurrentState(); return (state == null) ? null : state.clone(); }
/** Build an instance. */ public RoaringDocIdSet build() { flush(); return new RoaringDocIdSet(sets, cardinality); }