Gandiva 表达式编译器#

TreeExprBuilder 类#

class TreeExprBuilder#

用于嵌套表达式的树构建器。

公共静态函数

static NodePtr MakeLiteral(bool value)#

基于字面量创建节点。

static NodePtr MakeNull(DataTypePtr data_type)#

基于空字面量创建节点。

如果 data_type 为空或不支持该数据类型,则返回 null。

static NodePtr MakeField(FieldPtr field)#

基于 Arrow 字段创建节点。

如果输入为空,则返回 null。

static NodePtr MakeFunction(const std::string &name, const NodeVector &params, DataTypePtr return_type)#

使用函数创建节点。

如果 return_type 为 null,则返回 null。

static NodePtr MakeIf(NodePtr condition, NodePtr then_node, NodePtr else_node, DataTypePtr result_type)#

使用 if-else 表达式创建节点。

如果任何输入为 null,则返回 null。

static NodePtr MakeAnd(const NodeVector &children)#

使用布尔 AND 表达式创建节点。

static NodePtr MakeOr(const NodeVector &children)#

使用布尔 OR 表达式创建节点。

static ExpressionPtr MakeExpression(NodePtr root_node, FieldPtr result_field)#

创建具有指定根节点的表达式,并将结果写入 result_field。

如果 result_field 为 null,则返回 null。

static ExpressionPtr MakeExpression(const std::string &function, const FieldVector &in_fields, FieldPtr out_field)#

用于简单函数表达式的便捷函数。

如果 out_field 为 null,则返回 null。

static ConditionPtr MakeCondition(NodePtr root_node)#

使用指定的根节点创建条件。

static ConditionPtr MakeCondition(const std::string &function, const FieldVector &in_fields)#

用于简单函数条件的便捷函数。

static NodePtr MakeInExpressionInt32(NodePtr node, const std::unordered_set<int32_t> &constants)#

创建 IN 表达式。

static NodePtr MakeInExpressionFloat(NodePtr node, const std::unordered_set<float> &constants)#

为 float 创建 IN 表达式。

static NodePtr MakeInExpressionDouble(NodePtr node, const std::unordered_set<double> &constants)#

为 double 创建 IN 表达式。

static NodePtr MakeInExpressionDate32(NodePtr node, const std::unordered_set<int32_t> &constants)#

日期作为自纪元以来的秒数/毫秒数。

static NodePtr MakeInExpressionDate64(NodePtr node, const std::unordered_set<int64_t> &constants)#

日期作为自纪元以来的毫秒数/微秒数/纳秒数。

static NodePtr MakeInExpressionTime32(NodePtr node, const std::unordered_set<int32_t> &constants)#

时间作为每日的秒数/毫秒数。

static NodePtr MakeInExpressionTime64(NodePtr node, const std::unordered_set<int64_t> &constants)#

时间作为每日的毫秒数/微秒数/纳秒数。

static NodePtr MakeInExpressionTimeStamp(NodePtr node, const std::unordered_set<int64_t> &constants)#

时间戳作为自纪元以来的毫秒数。

class Node#

表示表达式树中的一个节点。

有效性和值处于结合状态。

子类:gandiva::BooleanNode, gandiva::FieldNode, gandiva::FunctionNode, gandiva::IfNode, gandiva::InExpressionNode< Type >, gandiva::InExpressionNode< gandiva::DecimalScalar128 >, gandiva::LiteralNode

公共函数

virtual Status Accept(NodeVisitor &visitor) const = 0#

派生类只需调用访问者的 Visit API。

class Expression#

具有根节点和结果字段的表达式树。

子类:gandiva::Condition

class Condition : public gandiva::Expression#

条件表达式。

函数注册表#

class FunctionSignature#

函数签名:包含基名称、输入参数类型和输出类型。

公共函数

std::size_t Hash() const#

基于名称、参数数据类型 ID 和返回类型数据类型 ID 计算。

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

获取所有函数签名的列表。

配置#

class Configuration#

Gandiva 的运行时配置

它包含用于在运行时自定义 Gandiva 执行的元素。

class ConfigurationBuilder#

Gandiva 的配置构建器

提供默认配置和覆盖特定值并构建自定义实例的便捷方法

投影器 (Projector)#

class Projector#

使用表达式进行投影。

投影器是为特定的 Schema 和表达式向量构建的。一旦构建完成,它可以用于评估多个行批次。

公共函数

Status Evaluate(const arrow::RecordBatch &batch, arrow::MemoryPool *pool, arrow::ArrayVector *output) const#

评估指定的记录批次,并返回分配和填充的输出数组。

输出数组将从内存池 'pool' 中分配,并添加到向量 'output' 中。

参数:
  • batch[输入] 记录批次。Schema 应与 'Make' 中使用的 Schema 相同。

  • pool[输入] 用于分配输出数组的内存池(如有必要)。

  • output[输出] 分配/填充的数组向量。

Status Evaluate(const arrow::RecordBatch &batch, const ArrayDataVector &output) const#

评估指定的记录批次,并填充输出数组。

输出数组必须由调用者预先分配足够的容量。

参数:
  • batch[输入] 记录批次。Schema 应与 'Make' 中使用的 Schema 相同。

  • output[输入输出] 数组向量,数组由调用者分配并由 Evaluate 填充。

Status Evaluate(const arrow::RecordBatch &batch, const SelectionVector *selection_vector, arrow::MemoryPool *pool, arrow::ArrayVector *output) const#

评估指定的记录批次,并返回分配和填充的输出数组。

输出数组将从内存池 'pool' 中分配,并添加到向量 'output' 中。

参数:
  • batch[输入] 记录批次。Schema 应与 'Make' 中使用的 Schema 相同。

  • selection_vector[输入] 包含过滤后行位置的选择向量。

  • pool[输入] 用于分配输出数组的内存池(如有必要)。

  • output[输出] 分配/填充的数组向量。

Status Evaluate(const arrow::RecordBatch &batch, const SelectionVector *selection_vector, const ArrayDataVector &output) const#

评估指定的记录批次,并在过滤后的位置填充输出数组。

输出数组必须由调用者预先分配足够的容量。

参数:
  • batch[输入] 记录批次。Schema 应与 'Make' 中使用的 Schema 相同。

  • selection_vector[输入] 包含过滤后行位置的选择向量。

  • output[输入输出] 数组向量,数组由调用者分配并由 Evaluate 填充。

公共静态函数

static Status Make(SchemaPtr schema, const ExpressionVector &exprs, std::shared_ptr<Projector> *projector)#

为给定的 Schema 构建一个默认投影器,以评估表达式向量。

参数:
  • schema[输入] 记录批次和表达式的 Schema。

  • exprs[输入] 表达式向量。

  • projector[输出] 返回的投影器对象。

static Status Make(SchemaPtr schema, const ExpressionVector &exprs, std::shared_ptr<Configuration> configuration, std::shared_ptr<Projector> *projector)#

为给定的 Schema 构建投影器,以评估表达式向量。

使用运行时配置自定义投影器。

参数:
  • schema[输入] 记录批次和表达式的 Schema。

  • exprs[输入] 表达式向量。

  • configuration[输入] 运行时配置。

  • projector[输出] 返回的投影器对象。

static Status Make(SchemaPtr schema, const ExpressionVector &exprs, SelectionVector::Mode selection_vector_mode, std::shared_ptr<Configuration> configuration, std::shared_ptr<Projector> *projector)#

为给定的 Schema 构建投影器,以评估表达式向量。

使用运行时配置自定义投影器。

参数:
  • schema[输入] 记录批次和表达式的 Schema。

  • exprs[输入] 表达式向量。

  • selection_vector_mode[输入] 选择向量的模式。

  • configuration[输入] 运行时配置。

  • projector[输出] 返回的投影器对象。

过滤器 (Filter)#

class Filter#

基于条件过滤记录。

过滤器是为特定的 Schema 和条件构建的。一旦构建完成,它可以用于评估多个行批次。

公共函数

Status Evaluate(const arrow::RecordBatch &batch, std::shared_ptr<SelectionVector> out_selection)#

评估指定的记录批次,并填充输出选择向量。

参数:
  • batch[输入] 记录批次。Schema 应与 'Make' 中使用的 Schema 相同。

  • out_selection[输入输出] 包含符合条件的行索引的选择数组。

公共静态函数

static inline Status Make(SchemaPtr schema, ConditionPtr condition, std::shared_ptr<Filter> *filter)#

使用默认配置为给定的 Schema 和条件构建过滤器。

参数:
  • schema[输入] 记录批次和条件的 Schema。

  • condition[输入] 过滤条件。

  • filter[输出] 返回的过滤器对象。

static Status Make(SchemaPtr schema, ConditionPtr condition, std::shared_ptr<Configuration> config, std::shared_ptr<Filter> *filter)#

为给定的 Schema 和条件构建过滤器。

使用运行时配置自定义过滤器。

参数:
  • schema[输入] 记录批次和条件的 Schema。

  • condition[输入] 过滤条件。

  • config[输入] 运行时配置。

  • filter[输出] 返回的过滤器对象。

class SelectionVector#

选择向量:行批次中用于选择的索引向量,由 Arrow 数组支持。

子类:gandiva::SelectionVectorImpl< C_TYPE, A_TYPE, mode >

公共函数

virtual uint64_t GetIndex(int64_t index) const = 0#

获取给定索引处的值。

virtual void SetIndex(int64_t index, uint64_t value) = 0#

设置给定索引处的值。

virtual int64_t GetMaxSlots() const = 0#

选择向量的最大槽位(容量)。

virtual int64_t GetNumSlots() const = 0#

选择向量的槽位数量(大小)。

virtual void SetNumSlots(int64_t num_slots) = 0#

设置选择向量中的槽位数量。

virtual ArrayPtr ToArray() const = 0#

转换为 Arrow 数组。

virtual arrow::Buffer &GetBuffer() const = 0#

获取底层的 Arrow 缓冲区。

virtual Mode GetMode() const = 0#

SelectionVector 的模式。

Status PopulateFromBitMap(const uint8_t *bitmap, int64_t bitmap_size, int64_t max_bitmap_index)#

根据位图中的所有已设置位填充选择向量。

参数:
  • bitmap[输入] 位图。

  • bitmap_size[输入] 以字节为单位的位图大小。

  • max_bitmap_index[输入] 位图中的最大有效索引(由于对齐/填充,可能小于位图中的容量)。

公共静态函数

static Status MakeInt16(int64_t max_slots, std::shared_ptr<arrow::Buffer> buffer, std::shared_ptr<SelectionVector> *selection_vector)#

使用 int16 类型记录创建选择向量。

参数:
  • max_slots[输入] 最大槽位数量。

  • buffer[输入] 大小足以容纳 max_slots 的缓冲区。

  • selection_vector[输出] 由 'buffer' 支持的选择向量。

static Status MakeInt16(int64_t max_slots, arrow::MemoryPool *pool, std::shared_ptr<SelectionVector> *selection_vector)#
参数:
  • max_slots[输入] 最大槽位数量。

  • pool[输入] 用于分配缓冲区的内存池。

  • selection_vector[输出] 由从池中分配的缓冲区支持的选择向量。

static Status MakeImmutableInt16(int64_t num_slots, std::shared_ptr<arrow::Buffer> buffer, std::shared_ptr<SelectionVector> *selection_vector)#

创建具有预填充缓冲区的选择向量。

参数:
  • num_slots[输入] 选择向量的大小。

  • buffer[输入] 预填充的缓冲区。

  • selection_vector[输出] 由 'buffer' 支持的选择向量。

static Status MakeInt32(int64_t max_slots, std::shared_ptr<arrow::Buffer> buffer, std::shared_ptr<SelectionVector> *selection_vector)#

使用 int32 类型记录创建选择向量。

参数:
  • max_slots[输入] 最大槽位数量。

  • buffer[输入] 大小足以容纳 max_slots 的缓冲区。

  • selection_vector[输出] 由 'buffer' 支持的选择向量。

static Status MakeInt32(int64_t max_slots, arrow::MemoryPool *pool, std::shared_ptr<SelectionVector> *selection_vector)#

使用 int32 类型记录创建选择向量。

参数:
  • max_slots[输入] 最大槽位数量。

  • pool[输入] 用于分配缓冲区的内存池。

  • selection_vector[输出] 由从池中分配的缓冲区支持的选择向量。

static Status MakeImmutableInt32(int64_t num_slots, std::shared_ptr<arrow::Buffer> buffer, std::shared_ptr<SelectionVector> *selection_vector)#

创建具有预填充缓冲区的选择向量。

参数:
  • num_slots[输入] 选择向量的大小。

  • buffer[输入] 预填充的缓冲区。

  • selection_vector[输出] 由 'buffer' 支持的选择向量。

static Status MakeInt64(int64_t max_slots, std::shared_ptr<arrow::Buffer> buffer, std::shared_ptr<SelectionVector> *selection_vector)#

使用 int64 类型记录创建选择向量。

参数:
  • max_slots[输入] 最大槽位数量。

  • buffer[输入] 大小足以容纳 max_slots 的缓冲区。

  • selection_vector[输出] 由 'buffer' 支持的选择向量。

static Status MakeInt64(int64_t max_slots, arrow::MemoryPool *pool, std::shared_ptr<SelectionVector> *selection_vector)#

使用 int64 类型记录创建选择向量。

参数:
  • max_slots[输入] 最大槽位数量。

  • pool[输入] 用于分配缓冲区的内存池。

  • selection_vector[输出] 由从池中分配的缓冲区支持的选择向量。