Documentation Index
Fetch the complete documentation index at: https://private-7c7dfe99-page-updates.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
NumericIndexedVector
NumericIndexedVector is an abstract data structure that encapsulates a vector and implements vector aggregating and pointwise operations. Bit-Sliced Index is its storage method. For theoretical basis and usage scenarios, refer to the paper Large-Scale Metric Computation in Online Controlled Experiment Platform.BSI
In the BSI (Bit-Sliced Index) storage method, the data is stored in Bit-Sliced Index and then compressed using Roaring Bitmap. Aggregating operations and pointwise operations are directly on the compressed data, which can significantly improve the efficiency of storage and query. A vector contains indices and their corresponding values. The following are some characteristics and constraints of this data structure in BSI storage mode:- The index type can be one of
UInt8,UInt16, orUInt32. Note: Considering the performance of 64-bit implementation of Roaring Bitmap, BSI format does not supportUInt64/Int64. - The value type can be one of
Int8,Int16,Int32,Int64,UInt8,UInt16,UInt32,UInt64,Float32, orFloat64. Note: The value type does not automatically expand. For example, if you useUInt8as the value type, any sum that exceeds the capacity ofUInt8will result in an overflow rather than being promoted to a higher type; similarly, operations on integers will yield integer results (e.g., division will not automatically convert to a floating-point result). Therefore, it is important to plan and design the value type ahead of time. In real-world scenarios, floating-point types (Float32/Float64) are commonly used. - Only two vectors with the same index type and value type can perform operations.
- The underlying storage uses Bit-Sliced Index, with bitmap storing indexes. Roaring Bitmap is used as the specific implementation of bitmap. A best practice is to concentrate the index in several Roaring Bitmap containers as much as possible to maximize compression and query performance.
- The Bit-Sliced Index mechanism converts value into binary. For floating-point types, the conversion uses fixed-point representation, which may lead to precision loss. The precision can be adjusted by customizing the number of bits used for the fractional part, default is 24 bits, which is sufficient for most scenarios. You can customize the number of integer bits and fractional bits when constructing NumericIndexedVector using aggregate function groupNumericIndexedVector with
-State. - There are three cases for indices: non-zero value, zero value and non-existent. In NumericIndexedVector, only non-zero value and zero value will be stored. In addition, in pointwise operations between two NumericIndexedVectors, the value of non-existent index will be treated as 0. In the division scenario, the result is zero when the divisor is zero.
Create a numericIndexedVector object
There are two ways to create this structure: one is to use the aggregate functiongroupNumericIndexedVector with -State.
You can add suffix -if to accept an additional condition.
The aggregate function will only process the rows that trigger the condition.
The other is to build it from a map using numericIndexedVectorBuild.
The groupNumericIndexedVectorState function allows customization of the number of integer and fractional bits through parameters, while numericIndexedVectorBuild does not.
groupNumericIndexedVector
Constructs a NumericIndexedVector from two data columns and returns the sum of all values as aFloat64 type. If the suffix State is added, it returns a NumericIndexedVector object.
Syntax
type: String, optional. Specifies the storage format. Currently, only'BSI'is supported.integer_bit_num:UInt32, optional. Effective under the'BSI'storage format, this parameter indicates the number of bits used for the integer part. When the index type is an integer type, the default value corresponds to the number of bits used to store the index. For example, if the index type is UInt16, the defaultinteger_bit_numis 16. For Float32 and Float64 index types, the default value of integer_bit_num is 40, so the integer part of the data that can be represented is in the range[-2^39, 2^39 - 1]. The legal range is[0, 64].fraction_bit_num:UInt32, optional. Effective under the'BSI'storage format, this parameter indicates the number of bits used for the fractional part. When the value type is an integer, the default value is 0; when the value type is Float32 or Float64 types, the default value is 24. The valid range is[0, 24].- There is also a constraint that the valid range of integer_bit_num + fraction_bit_num is [0, 64].
col1: The index column. Supported types:UInt8/UInt16/UInt32/Int8/Int16/Int32.col2: The value column. Supported types:Int8/Int16/Int32/Int64/UInt8/UInt16/UInt32/UInt64/Float32/Float64.
Float64 value representing the sum of all values.
Example
Test data:
The documentation below is generated from the
system.functions system table.numericIndexedVectorAllValueSum
Introduced in: v25.7.0 Returns the sum of all values in the numericIndexedVector. SyntaxFloat64
Examples
Usage example
Query
Response
numericIndexedVectorBuild
Introduced in: v25.7.0 Creates a NumericIndexedVector from a map. The map’s keys represent the vector’s index and map’s value represents the vector’s value. Syntaxmap— A mapping from index to value.Map
AggregateFunction
Examples
Usage example
Query
Response
numericIndexedVectorCardinality
Introduced in: v25.7.0 Returns the cardinality (number of unique indexes) of the numericIndexedVector. SyntaxUInt64
Examples
Usage example
Query
Response
numericIndexedVectorGetValue
Introduced in: v25.7.0 Retrieves the value corresponding to a specified index from a numericIndexedVector. Syntaxv—numericIndexedVectori— The index for which the value is to be retrieved.(U)Int*
(U)Int* or Float*
Examples
Usage example
Query
Response
numericIndexedVectorPointwiseAdd
Introduced in: v25.7.0 Performs pointwise addition between a numericIndexedVector and either another numericIndexedVector or a numeric constant. Syntaxv1—numericIndexedVectorv2— A numeric constant or numericIndexedVector object.(U)Int*orFloat*ornumericIndexedVector
numericIndexedVector
Examples
Usage example
Query
Response
numericIndexedVectorPointwiseDivide
Introduced in: v25.7.0 Performs pointwise division between a numericIndexedVector and either another numericIndexedVector or a numeric constant. Syntaxv1—numericIndexedVectorv2— A numeric constant or numericIndexedVector object.(U)Int*orFloat*ornumericIndexedVector
numericIndexedVector
Examples
Usage example
Query
Response
numericIndexedVectorPointwiseEqual
Introduced in: v25.7.0 Performs pointwise comparison between a numericIndexedVector and either another numericIndexedVector or a numeric constant. The result is a numericIndexedVector containing the indices where the values are equal, with all corresponding values set to 1. Syntaxv1—numericIndexedVectorv2— A numeric constant or numericIndexedVector object.(U)Int*orFloat*ornumericIndexedVector
numericIndexedVector
Examples
Query
Response
numericIndexedVectorPointwiseGreater
Introduced in: v25.7.0 Performs pointwise comparison between a numericIndexedVector and either another numericIndexedVector or a numeric constant. The result is a numericIndexedVector containing the indices where the first vector’s value is greater than the second vector’s value, with all corresponding values set to 1. Syntaxv1—numericIndexedVectorv2— A numeric constant or numericIndexedVector object.(U)Int*orFloat*ornumericIndexedVector
numericIndexedVector
Examples
Usage example
Query
Response
numericIndexedVectorPointwiseGreaterEqual
Introduced in: v25.7.0 Performs pointwise comparison between a numericIndexedVector and either another numericIndexedVector or a numeric constant. The result is a numericIndexedVector containing the indices where the first vector’s value is greater than or equal to the second vector’s value, with all corresponding values set to 1. Syntaxv1—numericIndexedVectorv2— A numeric constant or numericIndexedVector object.(U)Int*orFloat*ornumericIndexedVector
numericIndexedVector
Examples
Usage example
Query
Response
numericIndexedVectorPointwiseLess
Introduced in: v25.7.0 Performs pointwise comparison between a numericIndexedVector and either another numericIndexedVector or a numeric constant. The result is a numericIndexedVector containing the indices where the first vector’s value is less than the second vector’s value, with all corresponding values set to 1. Syntaxv1—numericIndexedVectorv2— A numeric constant or numericIndexedVector object.(U)Int*orFloat*ornumericIndexedVector
numericIndexedVector
Examples
Usage example
Query
Response
numericIndexedVectorPointwiseLessEqual
Introduced in: v25.7.0 Performs pointwise comparison between a numericIndexedVector and either another numericIndexedVector or a numeric constant. The result is a numericIndexedVector containing the indices where the first vector’s value is less than or equal to the second vector’s value, with all corresponding values set to 1. Syntaxv1—numericIndexedVectorv2— A numeric constant or numericIndexedVector object(U)Int*orFloat*ornumericIndexedVector
numericIndexedVector
Examples
Usage example
Query
Response
numericIndexedVectorPointwiseMultiply
Introduced in: v25.7.0 Performs pointwise multiplication between a numericIndexedVector and either another numericIndexedVector or a numeric constant. Syntaxv1—numericIndexedVectorv2— A numeric constant or numericIndexedVector object.(U)Int*orFloat*ornumericIndexedVector
numericIndexedVector
Examples
Query
Response
numericIndexedVectorPointwiseNotEqual
Introduced in: v25.7.0 Performs pointwise comparison between a numericIndexedVector and either another numericIndexedVector or a numeric constant. The result is a numericIndexedVector containing the indices where the values are not equal, with all corresponding values set to 1. Syntaxv1—numericIndexedVectorv2— A numeric constant or numericIndexedVector object.(U)Int*orFloat*ornumericIndexedVector
numericIndexedVector
Examples
Usage example
Query
Response
numericIndexedVectorPointwiseSubtract
Introduced in: v25.7.0 Performs pointwise subtraction between a numericIndexedVector and either another numericIndexedVector or a numeric constant. Syntaxv1—numericIndexedVectorv2— A numeric constant or numericIndexedVector object.(U)Int*orFloat*ornumericIndexedVector
numericIndexedVector
Examples
Usage example
Query
Response
numericIndexedVectorShortDebugString
Introduced in: v25.7.0 Returns internal information of the numericIndexedVector in JSON format. This function is primarily used for debugging purposes. SyntaxString
Examples
Usage example
Query
Response
numericIndexedVectorToMap
Introduced in: v25.7.0 Converts a numericIndexedVector to a map. SyntaxMap
Examples
Usage example
Query
Response