Class IndexTermType
AbstractType as an indexable type. It is responsible for determining the
capabilities of the type and provides helper methods for handling term values associated with the type.-
Method Summary
Modifier and TypeMethodDescriptionasComparableBytes(ByteBuffer value, ByteComparable.Version version) asIndexBytes(ByteBuffer value) Translates the external value of specific types into a format used by the index.asString(ByteBuffer value) Allows overriding the default getString method forCompositeType.intcompare(ByteBuffer b1, ByteBuffer b2) Compare two terms based on their type.intcomparePostFilter(Expression.Value requestedValue, Expression.Value columnValue) This is used for value comparison in post-filtering -Expression.isSatisfiedBy(ByteBuffer).static IndexTermTypecreate(ColumnMetadata columnMetadata, List<ColumnMetadata> partitionColumns, IndexTarget.Type indexTargetType) float[]decomposeVector(ByteBuffer byteBuffer) booleandependsOn(ColumnMetadata columnMetadata) static ByteBufferencodeBigInteger(ByteBuffer value) Encode aBigIntegerinto a fixed width 20 byte encoded value.static ByteBufferencodeDecimal(ByteBuffer value) booleanintReturns the value length for the givenAbstractType, selecting 16 for types that officially use VARIABLE_LENGTH but are, in fact, of a fixed length.fromString(String value) The inverse of the above method.inthashCode()AbstractType<?>booleanReturnstrueif the index type is a composite type, e.g.static booleanisEqOnlyType(AbstractType<?> type) booleanisFrozen()Returnstrueif the index type is frozen, e.g.booleanReturnstrueif the index type is a frozen collection.booleanReturnstrueif the index type is a literal type and will use a literal index.booleanisMultiExpression(RowFilter.Expression expression) Returnstrueif theRowFilter.Expressionpassed is backed by a non-frozen collection and theOperatoris one that cannot be merged together.booleanReturnstrueif the index type is a non-frozen collectionbooleanReturnstrueif the index type is reversed.booleanisString()Returnstrueif the index type is a string type.booleanisValid(ByteBuffer term) Returnstrueif given buffer would pass theAbstractType.validate(ByteBuffer)check.booleanisVector()Returnstrueif the index type is a vector type.max(ByteBuffer a, ByteBuffer b) Returns the greater of twoByteBuffervalues, based on the result ofcompare(ByteBuffer, ByteBuffer)comparision.min(ByteBuffer a, ByteBuffer b) Returns the smaller of twoByteBuffervalues, based on the result ofcompare(ByteBuffer, ByteBuffer)comparision.booleansubTypes()booleanbooleanIndicates if the type encoding supports rounding of the raw value.voidtoComparableBytes(ByteBuffer value, byte[] bytes) Fills a byte array with the comparable bytes for a type.toString()valueOf(DecoratedKey key, Row row, long nowInSecs) Returns the cell value from theDecoratedKeyorRowfor theIndexTermTypebased on the kind of column thisIndexTermTypeis based on.Returns a value iterator for collection typeIndexTermTypes.intAbstractType<?>
-
Method Details
-
create
public static IndexTermType create(ColumnMetadata columnMetadata, List<ColumnMetadata> partitionColumns, IndexTarget.Type indexTargetType) - Parameters:
columnMetadata- theColumnMetadatafor the column being indexedpartitionColumns- the partition columns for the table this column belongs to. This is used for identifying if thecolumnMetadatais a partition column and if it belongs to a composite partitionindexTargetType- theIndexTarget.Typefor the index- Returns:
- the
IndexTermType
-
isLiteral
public boolean isLiteral()Returnstrueif the index type is a literal type and will use a literal index. This applies to string types, frozen types, composite types and boolean type. -
isString
public boolean isString()Returnstrueif the index type is a string type. This is used to determine if the type supports analysis. -
isVector
public boolean isVector()Returnstrueif the index type is a vector type. Note: being a vector type does not mean that the type is valid for indexing in that we don't check the element type and dimension constraints here. -
isReversed
public boolean isReversed()Returnstrueif the index type is reversed. This is only the case (currently) for clustering keys with descending ordering. -
isFrozen
public boolean isFrozen()Returnstrueif the index type is frozen, e.g. the type is wrapped withfrozen<type>. -
isNonFrozenCollection
public boolean isNonFrozenCollection()Returnstrueif the index type is a non-frozen collection -
isFrozenCollection
public boolean isFrozenCollection()Returnstrueif the index type is a frozen collection. This is the inverse of a non-frozen collection but this method is here for clarity. -
isComposite
public boolean isComposite()Returnstrueif the index type is a composite type, e.g. it has the formComposite<typea, typeb> -
isMultiExpression
Returnstrueif theRowFilter.Expressionpassed is backed by a non-frozen collection and theOperatoris one that cannot be merged together. -
isValid
Returnstrueif given buffer would pass theAbstractType.validate(ByteBuffer)check. False otherwise. -
skipsEmptyValue
public boolean skipsEmptyValue()- Returns:
trueif the empty values of the given type should be excluded from indexing
-
indexType
-
subTypes
-
asCQL3Type
-
columnMetadata
-
columnName
-
vectorElementType
-
vectorDimension
public int vectorDimension() -
dependsOn
-
isEqOnlyType
-
supportsRounding
public boolean supportsRounding()Indicates if the type encoding supports rounding of the raw value.This is significant in range searches where we have to make all range queries inclusive when searching the indexes in order to avoid excluding rounded values. Excluded values are removed by post-filtering.
-
fixedSizeOf
public int fixedSizeOf()Returns the value length for the givenAbstractType, selecting 16 for types that officially use VARIABLE_LENGTH but are, in fact, of a fixed length. -
asString
Allows overriding the default getString method forCompositeType. It is a requirement of theConcurrentRadixTreethat the keys are strings but the getString method ofCompositeTypedoes not return a string that compares in the same order as the underlyingByteBuffer. To get round this we convert theCompositeTypebytes to a hex string. -
fromString
The inverse of the above method. Overrides the fromString method onCompositeTypein order to convert the hex string to bytes. -
valueOf
Returns the cell value from theDecoratedKeyorRowfor theIndexTermTypebased on the kind of column thisIndexTermTypeis based on.- Parameters:
key- theDecoratedKeyof the rowrow- theRowcontaining the non-partition column datanowInSecs- the time that the index write operation started- Returns:
- a
ByteBuffercontaining the cell value
-
valuesOf
Returns a value iterator for collection typeIndexTermTypes. -
comparator
-
compare
Compare two terms based on their type. This is used in place ofAbstractType.compare(ByteBuffer, ByteBuffer)so that the default comparison can be overridden for specific types.Note: This should be used for all term comparison
-
min
Returns the smaller of twoByteBuffervalues, based on the result ofcompare(ByteBuffer, ByteBuffer)comparision. -
max
Returns the greater of twoByteBuffervalues, based on the result ofcompare(ByteBuffer, ByteBuffer)comparision. -
comparePostFilter
This is used for value comparison in post-filtering -Expression.isSatisfiedBy(ByteBuffer).This allows types to decide whether they should be compared based on their encoded value or their raw value. At present only
InetAddressTypevalues are compared by their encoded values to allow for ipv4 -> ipv6 equivalency in searches. -
toComparableBytes
Fills a byte array with the comparable bytes for a type.This method expects a
valueparameter generated by callingasIndexBytes(ByteBuffer). It is not generally safe to pass the output of other serialization methods to this method. For instance, it is not generally safe to pass the output ofAbstractType.decompose(Object)as thevalueparameter (there are certain types for which this is technically OK, but that doesn't hold for all types).- Parameters:
value- a value buffer returned byasIndexBytes(ByteBuffer)bytes- this method's output
-
asComparableBytes
-
asIndexBytes
Translates the external value of specific types into a format used by the index. -
decomposeVector
-
supports
-
toString
-
equals
-
hashCode
public int hashCode() -
encodeBigInteger
Encode aBigIntegerinto a fixed width 20 byte encoded value. The encoded value is byte comparable and prefix compressible.The format of the encoding is:
The first 4 bytes contain the integer length of the
BigIntegerbyte array with the top bit flipped for positive values.The remaining 16 bytes contain the 16 most significant bytes of the
BigIntegerbyte array.For
BigIntegervalues whose underlying byte array is less than 16 bytes, the encoded value is sign extended. -
encodeDecimal
-