Pyvelox Legacy Api¶
- class pyvelox.legacy.VeloxType¶
Bases:
pybind11_object
- __eq__(self: pyvelox.legacy.VeloxType, arg0: pyvelox.legacy.VeloxType) bool ¶
- __hash__ = None¶
- __init__(*args, **kwargs)¶
- __str__(self: pyvelox.legacy.VeloxType) str ¶
- cpp_size_in_bytes(self: pyvelox.legacy.VeloxType) int ¶
Return the C++ size in bytes
- is_fixed_width(self: pyvelox.legacy.VeloxType) bool ¶
Check if the type is fixed width
- is_primitive_type(self: pyvelox.legacy.VeloxType) bool ¶
Check if the type is a primitive type
- kind(self: pyvelox.legacy.VeloxType) pyvelox.legacy.TypeKind ¶
Returns the kind of the type
- serialize(self: pyvelox.legacy.VeloxType) str ¶
Serializes the type as JSON
- class pyvelox.legacy.BaseVector¶
- __init__(*args, **kwargs)¶
- __len__(self: pyvelox.legacy.BaseVector) int ¶
Returns an int representing the number of elements in the vector.
- Returns:
An int
- Examples:
>>> import pyvelox.legacy as pv >>> flat_vec = pv.from_list([1, 2, 3]) >>> len(flat_vec) 3
- __str__(self: pyvelox.legacy.BaseVector) str ¶
Returns str object which represents the content in the vector.
- Returns:
Representation of vector as a string.
- Examples:
>>> import pyvelox.legacy as pv >>> flat_vec = pv.from_list([1, 2, 3]) >>> print(flat_vec) [FLAT BIGINT: 3 elements, no nulls] 0: 1 1: 2 2: 3 >>> const_vec = pv.constant_vector(10, 3) >>> print(const_vec) [CONSTANT BIGINT: 3 elements, 10] 0: 10 1: 10 2: 10 >>> dict_vec = pv.dictionary_vector(pv.from_list([1, 2, 3]), [0, 0, 1, 0, 2]) >>> print(dict_vec) [DICTIONARY BIGINT: 5 elements, no nulls] 0: [0->0] 1 1: [1->0] 1 2: [2->1] 2 3: [3->0] 1 4: [4->2] 3
- append(self: pyvelox.legacy.BaseVector, arg0: pyvelox.legacy.BaseVector) None ¶
Appends a vector to the current vector.
:params vector : Union[FlatVector, ConstantVector, DictionaryVector] Appending vector.
- Returns:
pyvelox.pyvelox.BaseVector Returns extended types from the pyvelox.pyvelox.BaseVector
- Examples:
>>> import pyvelox.legacy as pv >>> flat_vec = pv.from_list([1, 2, 3]) >>> const_vec = pv.constant_vector(2, 4) >>> dict_vec = pv.dictionary_vector(pv.from_list([10, 20, 30]), [0, 1, 2, 1]) >>> flat_vec.append(const_vec) >>> print(flat_vec) [FLAT BIGINT: 7 elements, no nulls] 0: 1 1: 2 2: 3 3: 2 4: 2 5: 2 6: 2 >>> flat_vec.append(dict_vec) >>> print(flat_vec) [FLAT BIGINT: 11 elements, no nulls] 0: 1 1: 2 2: 3 3: 2 4: 2 5: 2 6: 2 7: 10 8: 20 9: 30 10: 20
- dtype(self: pyvelox.legacy.BaseVector) pyvelox.legacy.VeloxType ¶
Returns the data type.
- Returns:
pyvelox.pyvelox.VeloxType
- Examples:
>>> import pyvelox.legacy as pv >>> flat_vec = pv.from_list([1, 2, 3]) >>> flat_vec_dtype = flat_vec.dtype() >>> flat_vec_dtype.kind() <TypeKind.BIGINT: 4> >>> const_vec = pv.constant_vector(10.5, 3) >>> const_vec_dtype = const_vec.dtype() >>> const_vec_dtype.kind() <TypeKind.DOUBLE: 6> >>> dict_vec = pv.dictionary_vector(pv.from_list([1, 2, 3]), [0, 0, 1, 0, 2]) >>> dict_vec_dtype = dict_vec.dtype() >>> dict_vec_dtype.kind() <TypeKind.BIGINT: 4>
- encoding(self: pyvelox.legacy.BaseVector) pyvelox.legacy.VectorEncodingSimple ¶
Encoding of the vector.
- Returns:
Returns an integer
- Examples:
>>> import pyvelox.legacy as pv >>> flat_vec = pv.from_list([1, 2, 3]) >>> flat_vec.encoding() <VectorEncodingSimple.FLAT: 3> >>> const_vec = pv.constant_vector(1, 3) >>> const_vec.encoding() <VectorEncodingSimple.CONSTANT: 1> >>> dict_vec = pv.dictionary_vector(pv.from_list([1, 2, 3]), [0, 0, 2, 1]) >>> dict_vec.encoding() <VectorEncodingSimple.DICTIONARY: 2>
- hashValueAt(self: pyvelox.legacy.BaseVector, arg0: int) int ¶
Generates the hash value at the given index.
- Parameters:
index – Index for which hash value is generated.
- Returns:
Generated hash value
- Examples:
>>> import pyvelox.legacy as pv >>> flat_vec = pv.from_list([1, 2, 3]) >>> flat_vec.hashValueAt(0) 6614235796240398542 >>> const_vec = pv.constant_vector(1, 3) >>> const_vec.hashValueAt(0) 6614235796240398542 >>> dict_vec = pv.dictionary_vector(pv.from_list([1, 2, 3]), [0, 0, 2, 1]) >>> dict_vec.hashValueAt(0) 6614235796240398542
- isLazy(self: pyvelox.legacy.BaseVector) bool ¶
When the encoding of the vector is VectorEncoding::Simple::LAZY, the method returns True, otherwise returns False.
- Returns:
bool
- Examples:
>>> import pyvelox.legacy as pv >>> flat_vec = pv.from_list([3, 4, 3, None]) >>> flat_vec.isLazy() False >>> const_vec = pv.constant_vector(None, 3, pv.BigintType()) >>> const_vec.isLazy() False >>> dict_vec = pv.dictionary_vector(pv.from_list([None, 2, 3]), [0, 0, 1, 0, 2]) >>> dict_vec.isLazy() False
- isNullAt(self: pyvelox.legacy.BaseVector, arg0: int) bool ¶
Check if null values are in the given index.
- Parameters:
index – Index at which null value is checked.
- Returns:
Returns True, if the value at the given index is null, else False.
- Examples:
>>> import pyvelox.legacy as pv >>> flat_vec = pv.from_list([3, 4, 3, None]) >>> flat_vec.isNullAt(0) False >>> flat_vec.isNullAt(3) True >>> const_vec = pv.constant_vector(None, 3, pv.BigintType()) >>> const_vec.isNullAt(1) True >>> dict_vec = pv.dictionary_vector(pv.from_list([None, 2, 3]), [0, 0, 1, 0, 2]) >>> dict_vec.isNullAt(0) True >>> dict_vec.isNullAt(2) False
- mayHaveNulls(self: pyvelox.legacy.BaseVector) bool ¶
Check whether the vector contains null values. Returns True if null values are present else returns False.
- Returns:
bool
- Examples:
>>> import pyvelox.legacy as pv >>> flat_vec = pv.from_list([3, 4, 3, None]) >>> flat_vec.mayHaveNulls() True >>> const_vec = pv.constant_vector(None, 3, pv.BigintType()) >>> const_vec.mayHaveNulls() True >>> dict_vec = pv.dictionary_vector(pv.from_list([None, 2, 3]), [0, 0, 1, 0, 2]) >>> dict_vec.mayHaveNulls() True
- resize(self: pyvelox.legacy.BaseVector, arg0: int, arg1: bool) None ¶
Resize the vector.
- Parameters:
new_size – New size of the vector.
set_not_null – bool Indicates if nulls in range [old_size, new_size]
- Examples:
>>> import pyvelox.legacy as pv >>> vec = pv.from_list([1, 2, 3]) >>> len(vec) 3 >>> vec.resize(4, False) >>> len(vec) 4
- size(self: pyvelox.legacy.BaseVector) int ¶
Returns an int representing the number of elements in the vector. Similar function as __len__.
- Returns:
int
- Examples:
>>> import pyvelox.legacy as pv >>> flat_vec = pv.from_list([1, 2, 3]) >>> flat_vec.size() 3 >>> const_vec = pv.constant_vector(10, 4) >>> const_vec.size() 4 >>> dict_vec = pv.dictionary_vector(pv.from_list([1, 2, 3]), [0, 0, 1, 0, 2]) >>> dict_vec.size() 5
- slice(self: pyvelox.legacy.BaseVector, start: int, stop: int, step: int = 1) pyvelox.legacy.BaseVector ¶
Slicing vector.
- Parameters:
start – Start index.
stop – Stop index
step – Step at which index is incremented.
- Examples:
>>> import pyvelox.legacy as pv >>> vec = pv.from_list([1, 2, 3, 4, 5]) >>> vec[1:3] [FLAT BIGINT: 2 elements, no nulls] 0: 2 1: 3
- typeKind(self: pyvelox.legacy.BaseVector) pyvelox.legacy.TypeKind ¶
Returns the data type kind.
- Returns:
pyvelox.pyvelox.TypeKind
- Examples:
>>> import pyvelox.legacy as pv >>> flat_vec = pv.from_list([1, 2, 3]) >>> flat_vec.typeKind() <TypeKind.BIGINT: 4> >>> const_vec = pv.constant_vector(10.5, 3) >>> const_vec.typeKind() <TypeKind.DOUBLE: 6> >>> dict_vec = pv.dictionary_vector(pv.from_list([1, 2, 3]), [0, 0, 1, 0, 2]) >>> dict_vec.typeKind() <TypeKind.BIGINT: 4>