Gandiva Expression Compiler#

TreeExprBuilder Class#

classTreeExprBuilder#

Tree Builder for a nested expression.

Public Static Functions

staticNodePtrMakeLiteral(boolvalue)#

create a node on a literal.

staticNodePtrMakeNull(DataTypePtrdata_type)#

create a node on a null literal.

returns null if data_type is null or if it’s not a supported datatype.

staticNodePtrMakeField(FieldPtrfield)#

create a node on arrow field.

returns null if input is null.

staticNodePtrMakeFunction(conststd::string&name,constNodeVector&params,DataTypePtrreturn_type)#

create a node with a function.

returns null if return_type is null

staticNodePtrMakeIf(NodePtrcondition,NodePtrthen_node,NodePtrelse_node,DataTypePtrresult_type)#

create a node with an if-else expression.

returns null if any of the inputs is null.

staticNodePtrMakeAnd(constNodeVector&children)#

create a node with a boolean AND expression.

staticNodePtrMakeOr(constNodeVector&children)#

create a node with a boolean OR expression.

staticExpressionPtrMakeExpression(NodePtrroot_node,FieldPtrresult_field)#

create an expression with the specified root_node, and the result written to result_field.

returns null if the result_field is null.

staticExpressionPtrMakeExpression(conststd::string&function,constFieldVector&in_fields,FieldPtrout_field)#

convenience function for simple function expressions.

returns null if the out_field is null.

staticConditionPtrMakeCondition(NodePtrroot_node)#

create a condition with the specified root_node

staticConditionPtrMakeCondition(conststd::string&function,constFieldVector&in_fields)#

convenience function for simple function conditions.

staticNodePtrMakeInExpressionInt32(NodePtrnode,conststd::unordered_set<int32_t>&constants)#

creates an in expression

staticNodePtrMakeInExpressionFloat(NodePtrnode,conststd::unordered_set<float>&constants)#

creates an in expression for float

staticNodePtrMakeInExpressionDouble(NodePtrnode,conststd::unordered_set<double>&constants)#

creates an in expression for double

staticNodePtrMakeInExpressionDate32(NodePtrnode,conststd::unordered_set<int32_t>&constants)#

Date as s/millis since epoch.

staticNodePtrMakeInExpressionDate64(NodePtrnode,conststd::unordered_set<int64_t>&constants)#

Date as millis/us/ns since epoch.

staticNodePtrMakeInExpressionTime32(NodePtrnode,conststd::unordered_set<int32_t>&constants)#

Time as s/millis of day.

staticNodePtrMakeInExpressionTime64(NodePtrnode,conststd::unordered_set<int64_t>&constants)#

Time as millis/us/ns of day.

staticNodePtrMakeInExpressionTimeStamp(NodePtrnode,conststd::unordered_set<int64_t>&constants)#

Timestamp as millis since epoch.

classNode#

Represents a node in the expression tree.

Validity and value are in a joined state.

Subclassed by gandiva::BooleanNode, gandiva::FieldNode, gandiva::FunctionNode, gandiva::IfNode, gandiva::InExpressionNode< Type >, gandiva::InExpressionNode< gandiva::DecimalScalar128 >, gandiva::LiteralNode

Public Functions

virtualStatusAccept(NodeVisitor&visitor)const=0#

Derived classes should simply invoke the Visit api of the visitor.

classExpression#

An expression tree with a root node, and a result field.

Subclassed bygandiva::Condition

classCondition:publicgandiva::Expression#

A condition expression.

Function registry#

classFunctionSignature#

Signature for a function : includes the base name, input param types and output types.

Public Functions

std::size_tHash()const#

calculated based on name, datatype id of parameters and datatype id of return type.

std::vector<std::shared_ptr<FunctionSignature>>gandiva::GetRegisteredFunctionSignatures()#

Get the list of all function signatures.

Configuration#

classConfiguration#

runtime config for gandiva

It contains elements to customize gandiva execution at run time.

classConfigurationBuilder#

configuration builder for gandiva

Provides a default configuration and convenience methods to override specific values and build a custom instance

Projector#

classProjector#

projection using expressions.

A projector is built for a specific schema and vector of expressions. Once the projector is built, it can be used to evaluate many row batches.

Public Functions

StatusEvaluate(constarrow::RecordBatch&batch,arrow::MemoryPool*pool,arrow::ArrayVector*output)const#

Evaluate the specified record batch, and return the allocated and populated output arrays.

The output arrays will be allocated from the memory pool ‘pool’, and added to the vector ‘output’.

Parameters:
  • batch[in] the record batch. schema should be the same as the one in ‘Make’

  • pool[in] memory pool used to allocate output arrays (if required).

  • output[out] the vector of allocated/populated arrays.

StatusEvaluate(constarrow::RecordBatch&batch,constArrayDataVector&output)const#

Evaluate the specified record batch, and populate the output arrays.

The output arrays of sufficient capacity must be allocated by the caller.

Parameters:
  • batch[in] the record batch. schema should be the same as the one in ‘Make’

  • output[inout] vector of arrays, the arrays are allocated by the caller and populated by Evaluate.

StatusEvaluate(constarrow::RecordBatch&batch,constSelectionVector*selection_vector,arrow::MemoryPool*pool,arrow::ArrayVector*output)const#

Evaluate the specified record batch, and return the allocated and populated output arrays.

The output arrays will be allocated from the memory pool ‘pool’, and added to the vector ‘output’.

Parameters:
  • batch[in] the record batch. schema should be the same as the one in ‘Make’

  • selection_vector[in] selection vector which has filtered row positions.

  • pool[in] memory pool used to allocate output arrays (if required).

  • output[out] the vector of allocated/populated arrays.

StatusEvaluate(constarrow::RecordBatch&batch,constSelectionVector*selection_vector,constArrayDataVector&output)const#

Evaluate the specified record batch, and populate the output arrays at the filtered positions.

The output arrays of sufficient capacity must be allocated by the caller.

Parameters:
  • batch[in] the record batch. schema should be the same as the one in ‘Make’

  • selection_vector[in] selection vector which has the filtered row positions

  • output[inout] vector of arrays, the arrays are allocated by the caller and populated by Evaluate.

Public Static Functions

staticStatusMake(SchemaPtrschema,constExpressionVector&exprs,std::shared_ptr<Projector>*projector)#

Build a default projector for the given schema to evaluate the vector of expressions.

Parameters:
  • schema[in] schema for the record batches, and the expressions.

  • exprs[in] vector of expressions.

  • projector[out] the returned projector object

staticStatusMake(SchemaPtrschema,constExpressionVector&exprs,std::shared_ptr<Configuration>configuration,std::shared_ptr<Projector>*projector)#

Build a projector for the given schema to evaluate the vector of expressions.

Customize the projector with runtime configuration.

Parameters:
  • schema[in] schema for the record batches, and the expressions.

  • exprs[in] vector of expressions.

  • configuration[in] run time configuration.

  • projector[out] the returned projector object

staticStatusMake(SchemaPtrschema,constExpressionVector&exprs,SelectionVector::Modeselection_vector_mode,std::shared_ptr<Configuration>configuration,std::shared_ptr<Projector>*projector)#

Build a projector for the given schema to evaluate the vector of expressions.

Customize the projector with runtime configuration.

Parameters:
  • schema[in] schema for the record batches, and the expressions.

  • exprs[in] vector of expressions.

  • selection_vector_mode[in] mode of selection vector

  • configuration[in] run time configuration.

  • projector[out] the returned projector object

Filter#

classFilter#

filter records based on a condition.

A filter is built for a specific schema and condition. Once the filter is built, it can be used to evaluate many row batches.

Public Functions

StatusEvaluate(constarrow::RecordBatch&batch,std::shared_ptr<SelectionVector>out_selection)#

Evaluate the specified record batch, and populate output selection vector.

Parameters:
  • batch[in] the record batch. schema should be the same as the one in ‘Make’

  • out_selection[inout] the selection array with indices of rows that match the condition.

Public Static Functions

staticinlineStatusMake(SchemaPtrschema,ConditionPtrcondition,std::shared_ptr<Filter>*filter)#

Build a filter for the given schema and condition, with the default configuration.

Parameters:
  • schema[in] schema for the record batches, and the condition.

  • condition[in] filter condition.

  • filter[out] the returned filter object

staticStatusMake(SchemaPtrschema,ConditionPtrcondition,std::shared_ptr<Configuration>config,std::shared_ptr<Filter>*filter)#

Build a filter for the given schema and condition.

Customize the filter with runtime configuration.

Parameters:
  • schema[in] schema for the record batches, and the condition.

  • condition[in] filter conditions.

  • config[in] run time configuration.

  • filter[out] the returned filter object

classSelectionVector#

Selection Vector : vector of indices in a row-batch for a selection, backed by an arrow-array.

Subclassed by gandiva::SelectionVectorImpl< C_TYPE, A_TYPE, mode >

Public Functions

virtualuint64_tGetIndex(int64_tindex)const=0#

Get the value at a given index.

virtualvoidSetIndex(int64_tindex,uint64_tvalue)=0#

Set the value at a given index.

virtualint64_tGetMaxSlots()const=0#

The maximum slots (capacity) of the selection vector.

virtualint64_tGetNumSlots()const=0#

The number of slots (size) of the selection vector.

virtualvoidSetNumSlots(int64_tnum_slots)=0#

Set the number of slots in the selection vector.

virtualArrayPtrToArray()const=0#

Convert to arrow-array.

virtualarrow::Buffer&GetBuffer()const=0#

Get the underlying arrow buffer.

virtualModeGetMode()const=0#

Mode ofSelectionVector.

StatusPopulateFromBitMap(constuint8_t*bitmap,int64_tbitmap_size,int64_tmax_bitmap_index)#

populate selection vector for all the set bits in the bitmap.

Parameters:
  • bitmap[in] the bitmap

  • bitmap_size[in] size of the bitmap in bytes

  • max_bitmap_index[in] max valid index in bitmap (can be lesser than capacity in the bitmap, due to alignment/padding).

Public Static Functions

staticStatusMakeInt16(int64_tmax_slots,std::shared_ptr<arrow::Buffer>buffer,std::shared_ptr<SelectionVector>*selection_vector)#

make selection vector with int16 type records.

Parameters:
  • max_slots[in] max number of slots

  • buffer[in] buffer sized to accommodate max_slots

  • selection_vector[out] selection vector backed by ‘buffer’

staticStatusMakeInt16(int64_tmax_slots,arrow::MemoryPool*pool,std::shared_ptr<SelectionVector>*selection_vector)#
Parameters:
  • max_slots[in] max number of slots

  • pool[in] memory pool to allocate buffer

  • selection_vector[out] selection vector backed by a buffer allocated from the pool.

staticStatusMakeImmutableInt16(int64_tnum_slots,std::shared_ptr<arrow::Buffer>buffer,std::shared_ptr<SelectionVector>*selection_vector)#

creates a selection vector with pre populated buffer.

Parameters:
  • num_slots[in] size of the selection vector

  • buffer[in] pre-populated buffer

  • selection_vector[out] selection vector backed by ‘buffer’

staticStatusMakeInt32(int64_tmax_slots,std::shared_ptr<arrow::Buffer>buffer,std::shared_ptr<SelectionVector>*selection_vector)#

make selection vector with int32 type records.

Parameters:
  • max_slots[in] max number of slots

  • buffer[in] buffer sized to accommodate max_slots

  • selection_vector[out] selection vector backed by ‘buffer’

staticStatusMakeInt32(int64_tmax_slots,arrow::MemoryPool*pool,std::shared_ptr<SelectionVector>*selection_vector)#

make selection vector with int32 type records.

Parameters:
  • max_slots[in] max number of slots

  • pool[in] memory pool to allocate buffer

  • selection_vector[out] selection vector backed by a buffer allocated from the pool.

staticStatusMakeImmutableInt32(int64_tnum_slots,std::shared_ptr<arrow::Buffer>buffer,std::shared_ptr<SelectionVector>*selection_vector)#

creates a selection vector with pre populated buffer.

Parameters:
  • num_slots[in] size of the selection vector

  • buffer[in] pre-populated buffer

  • selection_vector[out] selection vector backed by ‘buffer’

staticStatusMakeInt64(int64_tmax_slots,std::shared_ptr<arrow::Buffer>buffer,std::shared_ptr<SelectionVector>*selection_vector)#

make selection vector with int64 type records.

Parameters:
  • max_slots[in] max number of slots

  • buffer[in] buffer sized to accommodate max_slots

  • selection_vector[out] selection vector backed by ‘buffer’

staticStatusMakeInt64(int64_tmax_slots,arrow::MemoryPool*pool,std::shared_ptr<SelectionVector>*selection_vector)#

make selection vector with int64 type records.

Parameters:
  • max_slots[in] max number of slots

  • pool[in] memory pool to allocate buffer

  • selection_vector[out] selection vector backed by a buffer allocated from the pool.

On this page