- All Superinterfaces:
org.apache.lucene.util.Accountable,AutoCloseable,Closeable,RefCounted,Releasable,Vector
- All Known Implementing Classes:
BytesRefArrayVector,BytesRefArrowBufVector,ConstantBytesRefVector,ConstantNullVector,DirectBytesRefVector,OrdinalBytesRefVector
X-Vector.java.st instead.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA builder that grows as needed. -
Field Summary
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLEFields inherited from interface org.elasticsearch.core.RefCounted
ALWAYS_REFERENCEDFields inherited from interface org.elasticsearch.compute.data.Vector
SERIALIZE_VECTOR_ARRAY, SERIALIZE_VECTOR_BIG_ARRAY, SERIALIZE_VECTOR_CONSTANT, SERIALIZE_VECTOR_ORDINAL, SERIALIZE_VECTOR_VALUES -
Method Summary
Modifier and TypeMethodDescriptionasBlock()Returns a new Block containing this vector.Returns an ordinal BytesRef vector if this vector is backed by a dictionary and ordinals; otherwise, returns null.default BytesRefVectordeepCopy(BlockFactory blockFactory) Make a deep copy of thisVectorusing the providedBlockFactory, likely copying all data.booleanCompares the given object with this vector for equality.static booleanequals(BytesRefVector vector1, BytesRefVector vector2) Returnstrueif the given vectors are equal to each other, otherwisefalse.default BytesRefVectorfilter(boolean mayContainDuplicates, int... positions) Creates a new vector that only exposes the positions provided.filter(boolean mayContainDuplicates, int[] positions, int offset, int length) Creates a new vector that only exposes the positions provided.get(int position, PagedBytesCursor scratch) Retrieves the bytes value stored at the given value index using aPagedBytesCursorfor zero-copy access to the underlying paged byte storage.org.apache.lucene.util.BytesRefgetBytesRef(int position, org.apache.lucene.util.BytesRef dest) Build a contiguous array of bytes for the value stored at the given position.static inthash(BytesRefVector vector) Generates the hash code for the given vector.inthashCode()Returns the hash code of this vector, as defined byhash(BytesRefVector).keepMask(BooleanVector mask) ReleasableIterator<? extends BytesRefBlock> lookup(IntBlock positions, ByteSizeValue targetBlockSize) Builds an Iterator of newBlocks with the sameVector.elementType()as thisVectorwhose values are copied from positions in this Vector.static BytesRefVectorreadFrom(BlockFactory blockFactory, StreamInput in) Deserializes a Vector from the given stream input.slice(int beginInclusive, int endExclusive) Return a subset of this vector frombeginInclusivetoendExclusive.intThe maximum size in bytes of any single value stored in this vector, or0if there are no values.default voidwriteTo(StreamOutput out) Serializes this Vector to the given stream output.Methods inherited from interface org.apache.lucene.util.Accountable
getChildResources, ramBytesUsedMethods inherited from interface org.elasticsearch.core.RefCounted
decRef, hasReferences, incRef, mustIncRef, tryIncRefMethods inherited from interface org.elasticsearch.core.Releasable
closeMethods inherited from interface org.elasticsearch.compute.data.Vector
allowPassingToDifferentDriver, attachReleasable, blockFactory, elementType, getPositionCount, isConstant, isReleased
-
Method Details
-
getBytesRef
org.apache.lucene.util.BytesRef getBytesRef(int position, org.apache.lucene.util.BytesRef dest) Build a contiguous array of bytes for the value stored at the given position. The underlying data is generally stored in pages that look likebyte[][]with some data spanning more than one of the innerbyte[]arrays. In that case, this builds abyte[]in theBytesRef, copies the bytes, and returns it. Otherwise, this returns a zero-copy snapshot of the underlying data. Except arrow. Arrow always copies.If possible, use
get(int, org.elasticsearch.common.bytes.PagedBytesCursor)because it only needs to copy in the arrow implementation.- Parameters:
position- the position indexdest- the destination- Returns:
- the data value (as a BytesRef)
-
get
Retrieves the bytes value stored at the given value index using aPagedBytesCursorfor zero-copy access to the underlying paged byte storage. Except arrow. Arrow always copies.- Parameters:
position- the position indexscratch- the cursor to initialize and return- Returns:
- the initialized cursor pointing to the value's bytes
-
asBlock
BytesRefBlock asBlock()Description copied from interface:VectorReturns a new Block containing this vector. -
asOrdinals
OrdinalBytesRefVector asOrdinals()Returns an ordinal BytesRef vector if this vector is backed by a dictionary and ordinals; otherwise, returns null. Callers must not release the returned vector as no extra reference is retained by this method. -
filter
Description copied from interface:VectorCreates a new vector that only exposes the positions provided. Materialization of the selected positions is avoided. -
filter
Description copied from interface:VectorCreates a new vector that only exposes the positions provided. Materialization of the selected positions is avoided. -
keepMask
Description copied from interface:Vector -
deepCopy
Make a deep copy of thisVectorusing the providedBlockFactory, likely copying all data. -
lookup
ReleasableIterator<? extends BytesRefBlock> lookup(IntBlock positions, ByteSizeValue targetBlockSize) Description copied from interface:VectorBuilds an Iterator of newBlocks with the sameVector.elementType()as thisVectorwhose values are copied from positions in this Vector. It has the same number ofpositionsas thepositionsparameter.For example, if this vector contained
[a, b, c]and were called with the block[0, 1, 1, [1, 2]]then the result would be[a, b, b, [b, c]].This process produces
count(positions)values per positions which could be quite large. Instead of returning a single Block, this returns an Iterator of Blocks containing all of the promised values.The returned
ReleasableIteratormay retain a reference to thepositionsparameter. Close it to release those references.This block is built using the same
BlockFactoryas was used to build thepositionsparameter. -
slice
Return a subset of this vector frombeginInclusivetoendExclusive. This may return the same instance if the range covers all positions, but if it does it willRefCounted.incRef()it. -
valueMaxByteSize
int valueMaxByteSize()The maximum size in bytes of any single value stored in this vector, or0if there are no values. Scans all positions to find the maximum.- Specified by:
valueMaxByteSizein interfaceVector- Returns:
- the maximum byte size of any single value in this vector
-
equals
Compares the given object with this vector for equality. Returnstrueif and only if the given object is a BytesRefVector, and both vectors areequal. -
hashCode
int hashCode()Returns the hash code of this vector, as defined byhash(BytesRefVector). -
equals
Returnstrueif the given vectors are equal to each other, otherwisefalse. Two vectors are considered equal if they have the same position count, and contain the same values in the same order. This definition ensures that the equals method works properly across different implementations of the BytesRefVector interface. -
hash
Generates the hash code for the given vector. The hash code is computed from the vector's values. This ensures thatvector1.equals(vector2)implies thatvector1.hashCode()==vector2.hashCode()for any two vectors,vector1andvector2, as required by the general contract ofObject.hashCode(). -
readFrom
Deserializes a Vector from the given stream input.- Throws:
IOException
-
writeTo
Serializes this Vector to the given stream output.- Throws:
IOException
-