工具#

十进制数#

class BasicDecimal128 : public arrow::GenericBasicDecimal<BasicDecimal128, 128>#

表示一个补码形式的带符号 128 位整数。

该类也可编译为 LLVM IR,因此不应包含像 streams 和 boost 这样的 C++ 引用。

派生类 arrow::Decimal128

公共函数

inline constexpr BasicDecimal128(int64_t high, uint64_t low) noexcept#

根据补码表示形式创建一个 BasicDecimal128

BasicDecimal128 &Negate()#

对当前值取反(原地操作)

BasicDecimal128 &Abs()#

取绝对值(原地操作)

BasicDecimal128 &operator+=(const BasicDecimal128 &right)#

将一个数字加到当前数字上。结果被截断为 128 位。

BasicDecimal128 &operator-=(const BasicDecimal128 &right)#

从当前数字中减去一个数字。结果被截断为 128 位。

BasicDecimal128 &operator*=(const BasicDecimal128 &right)#

将当前数字乘以另一个数字。结果被截断为 128 位。

DecimalStatus Divide(const BasicDecimal128 &divisor, BasicDecimal128 *result, BasicDecimal128 *remainder) const#

将当前数字除以右侧数字并返回结果。

此操作不会销毁原数据。结果向零舍入。符号运算规则如下:21 / 5 -> 4, 1; -21 / 5 -> -4, -1; 21 / -5 -> -4, 1; -21 / -5 -> 4, -1

参数:
  • divisor[输入] 除数

  • result[输出]

  • remainder[输出] 除法后的余数

BasicDecimal128 &operator/=(const BasicDecimal128 &right)#

原地除法。

BasicDecimal128 &operator|=(const BasicDecimal128 &right)#

两个 BasicDecimal128 之间的按位“或”运算。

BasicDecimal128 &operator&=(const BasicDecimal128 &right)#

两个 BasicDecimal128 之间的按位“与”运算。

BasicDecimal128 &operator<<=(uint32_t bits)#

向左移动指定的位数。

BasicDecimal128 &operator>>=(uint32_t bits)#

向右移动指定的位数。

负值将进行符号扩展。

inline constexpr int64_t high_bits() const#

获取数字补码表示中的高位部分。

inline constexpr uint64_t low_bits() const#

获取数字补码表示中的低位部分。

void GetWholeAndFraction(int32_t scale, BasicDecimal128 *whole, BasicDecimal128 *fraction) const#

根据给定的比例(scale)分离整数部分和小数部分。

DecimalStatus Rescale(int32_t original_scale, int32_t new_scale, BasicDecimal128 *out) const#

BasicDecimal128 从一个比例转换为另一个比例。

BasicDecimal128 IncreaseScaleBy(int32_t increase_by) const#

增加比例。

BasicDecimal128 ReduceScaleBy(int32_t reduce_by, bool round = true) const#

降低比例。

  • 如果 ‘round’ 为 true,则舍弃最右侧的数字,并根据被舍弃数字的值(>= 10^reduce_by / 2)对结果进行四舍五入(正数+1,负数-1)。

  • 如果 ‘round’ 为 false,则直接丢弃最右侧的数字。

bool FitsInPrecision(int32_t precision) const#

此数字是否在给定的精度范围内。

如果有效位数小于或等于 precision,则返回 true。

int32_t CountLeadingBinaryZeros() const#

计算前导二进制零的个数。

inline constexpr GenericBasicDecimal() noexcept#

空构造函数创建一个值为 0 的十进制数。

inline explicit constexpr GenericBasicDecimal(const WordArray &array) noexcept#

根据补码表示创建一个十进制数。

假设输入数组采用本机字节序。

inline GenericBasicDecimal(LittleEndianArrayTag, const WordArray &array) noexcept#

根据补码表示创建一个十进制数。

假设输入数组采用小端字节序,且元素为本机字节序。

template<typename T, typename = typename std::enable_if<std::is_integral<T>::value && (sizeof(T) <= sizeof(uint64_t)), T>::type>
inline constexpr GenericBasicDecimal(T value) noexcept#

从不超过 64 位的任何整数创建一个十进制数。

inline explicit GenericBasicDecimal(const uint8_t *bytes)#

从字节数组创建一个十进制数。

假设字节采用本机字节序。

公共静态函数

static BasicDecimal128 Abs(const BasicDecimal128 &left)#

绝对值。

static const BasicDecimal128 &GetScaleMultiplier(int32_t scale)#

给定比例值的比例乘数。

static const BasicDecimal128 &GetHalfScaleMultiplier(int32_t scale)#

给定比例值的半比例乘数。

static const BasicDecimal128 &GetMaxValue()#

获取最大有效未缩放十进制值。

static BasicDecimal128 GetMaxValue(int32_t precision)#

获取给定精度下的最大有效未缩放十进制值。

static inline constexpr BasicDecimal128 GetMaxSentinel()#

获取最大十进制哨兵值(不是有效值)。

static inline constexpr BasicDecimal128 GetMinSentinel()#

获取最小十进制哨兵值(不是有效值)。

class Decimal128 : public arrow::BasicDecimal128#

表示一个补码形式的带符号 128 位整数。

计算采用环绕处理,溢出会被忽略。可安全表示的最大十进制精度为 38 位有效数字。

有关算法的讨论,请参阅 Knuth 的《计算机程序设计艺术》第 2 卷第 4.3.1 节“半数值算法”。

改编自 Apache ORC C++ 实现

实现分为两部分:

  1. BasicDecimal128

    • 可以安全地编译为 IR,无需引用 libstdc++。

  2. Decimal128

    • BasicDecimal128 之上添加了处理字符串和流的附加功能。

公共函数

inline constexpr Decimal128(const BasicDecimal128 &value) noexcept#

构造函数通过 BasicDecimal128 创建一个 Decimal128

explicit Decimal128(const std::string &value)#

从十进制字符串表示形式中解析数字。

inline constexpr Decimal128() noexcept#

空构造函数创建一个值为 0 的 Decimal128

inline Result<std::pair<Decimal128, Decimal128>> Divide(const Decimal128 &divisor) const#

将当前数字除以右侧数字并返回结果。

此操作不会销毁原数据。结果向零舍入。符号运算规则如下:21 / 5 -> 4, 1; -21 / 5 -> -4, -1; 21 / -5 -> -4, 1; -21 / -5 -> 4, -1

参数:

divisor[输入] 除数

返回:

包含商和余数的对。

std::string ToString(int32_t scale) const#

Decimal128 值转换为具有给定比例的十进制字符串。

std::string ToIntegerString() const#

将值转换为整数字符串。

explicit operator int64_t() const#

将此值强制转换为 int64_t。

inline Result<Decimal128> Rescale(int32_t original_scale, int32_t new_scale) const#

Decimal128 从一个比例转换为另一个比例。

template<typename T, typename = internal::EnableIfIsOneOf<T, int32_t, int64_t>>
inline Result<T> ToInteger() const#

转换为带符号整数。

template<typename T, typename = internal::EnableIfIsOneOf<T, int32_t, int64_t>>
inline Status ToInteger(T *out) const#

转换为带符号整数。

float ToFloat(int32_t scale) const#

转换为浮点数(带缩放)

double ToDouble(int32_t scale) const#

转换为浮点数(带缩放)

template<typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>>
inline T ToReal(int32_t scale) const#

转换为浮点数(带缩放)

公共静态函数

static Status FromString(std::string_view s, Decimal128 *out, int32_t *precision, int32_t *scale = NULLPTR)#

将十进制字符串转换为 Decimal128 值,若传入了 precision 和 scale 指针且不为空,则解析并填充它们。

static Result<Decimal128> FromBigEndian(const uint8_t *data, int32_t length)#

从大端字节表示形式转换而来。

长度必须在 1 到 16 之间。

返回:

如果长度为无效值,则返回错误状态。

class BasicDecimal256 : public arrow::GenericBasicDecimal<BasicDecimal256, 256>#

派生类 arrow::Decimal256

公共函数

BasicDecimal256 &Negate()#

对当前值取反(原地操作)

BasicDecimal256 &Abs()#

取绝对值(原地操作)

BasicDecimal256 &operator+=(const BasicDecimal256 &right)#

将一个数字加到当前数字上。结果被截断为 256 位。

BasicDecimal256 &operator-=(const BasicDecimal256 &right)#

从当前数字中减去一个数字。结果被截断为 256 位。

inline uint64_t low_bits() const#

获取数字补码表示中的最低位部分。

void GetWholeAndFraction(int32_t scale, BasicDecimal256 *whole, BasicDecimal256 *fraction) const#

根据给定的比例(scale)分离整数部分和小数部分。

DecimalStatus Rescale(int32_t original_scale, int32_t new_scale, BasicDecimal256 *out) const#

BasicDecimal256 从一个比例转换为另一个比例。

BasicDecimal256 IncreaseScaleBy(int32_t increase_by) const#

增加比例。

BasicDecimal256 ReduceScaleBy(int32_t reduce_by, bool round = true) const#

降低比例。

  • 如果 ‘round’ 为 true,则舍弃最右侧的数字,并根据被舍弃数字的值(>= 10^reduce_by / 2)对结果进行四舍五入(正数+1,负数-1)。

  • 如果 ‘round’ 为 false,则直接丢弃最右侧的数字。

bool FitsInPrecision(int32_t precision) const#

此数字是否在给定的精度范围内。

如果有效位数小于或等于 precision,则返回 true。

BasicDecimal256 &operator*=(const BasicDecimal256 &right)#

将当前数字乘以另一个数字。结果被截断为 256 位。

DecimalStatus Divide(const BasicDecimal256 &divisor, BasicDecimal256 *result, BasicDecimal256 *remainder) const#

将当前数字除以右侧数字并返回结果。

此操作不会销毁原数据。结果向零舍入。符号运算规则如下:21 / 5 -> 4, 1; -21 / 5 -> -4, -1; 21 / -5 -> -4, 1; -21 / -5 -> 4, -1

参数:
  • divisor[输入] 除数

  • result[输出]

  • remainder[输出] 除法后的余数

BasicDecimal256 &operator<<=(uint32_t bits)#

向左移动指定的位数。

BasicDecimal256 &operator>>=(uint32_t bits)#

向右移动指定的位数。

负值将进行符号扩展。

BasicDecimal256 &operator/=(const BasicDecimal256 &right)#

原地除法。

inline constexpr GenericBasicDecimal() noexcept#

空构造函数创建一个值为 0 的十进制数。

inline explicit constexpr GenericBasicDecimal(const WordArray &array) noexcept#

根据补码表示创建一个十进制数。

假设输入数组采用本机字节序。

inline GenericBasicDecimal(LittleEndianArrayTag, const WordArray &array) noexcept#

根据补码表示创建一个十进制数。

假设输入数组采用小端字节序,且元素为本机字节序。

template<typename T, typename = typename std::enable_if<std::is_integral<T>::value && (sizeof(T) <= sizeof(uint64_t)), T>::type>
inline constexpr GenericBasicDecimal(T value) noexcept#

从不超过 64 位的任何整数创建一个十进制数。

inline explicit GenericBasicDecimal(const uint8_t *bytes)#

从字节数组创建一个十进制数。

假设字节采用本机字节序。

公共静态函数

static BasicDecimal256 Abs(const BasicDecimal256 &left)#

绝对值。

static const BasicDecimal256 &GetScaleMultiplier(int32_t scale)#

给定比例值的比例乘数。

static const BasicDecimal256 &GetHalfScaleMultiplier(int32_t scale)#

给定比例值的半比例乘数。

static BasicDecimal256 GetMaxValue(int32_t precision)#

获取给定精度下的最大有效未缩放十进制值。

static inline constexpr BasicDecimal256 GetMaxSentinel()#

获取最大十进制哨兵值(不是有效值)。

static inline constexpr BasicDecimal256 GetMinSentinel()#

获取最小十进制哨兵值(不是有效值)。

class Decimal256 : public arrow::BasicDecimal256#

表示一个二进制补码形式的有符号 256 位整数。

可安全表示的最大十进制精度为 76 位有效数字。

实现分为两部分:

  1. BasicDecimal256

    • 可以安全地编译为 IR,无需引用 libstdc++。

  2. 十进制数256

    • (TODO)在 BasicDecimal256 之上提供了额外的功能,用于处理字符串和流。

公共函数

inline constexpr Decimal256(const BasicDecimal256 &value) noexcept#

构造函数根据 BasicDecimal256 创建一个 Decimal256

explicit Decimal256(const std::string &value)#

从十进制字符串表示形式中解析数字。

inline constexpr Decimal256() noexcept#

空构造函数创建一个值为 0 的 Decimal256

std::string ToString(int32_t scale) const#

Decimal256 值转换为具有给定小数位数的 10 进制字符串。

std::string ToIntegerString() const#

将值转换为整数字符串。

inline Result<Decimal256> Rescale(int32_t original_scale, int32_t new_scale) const#

Decimal256 从一种小数位数转换为另一种。

inline Result<std::pair<Decimal256, Decimal256>> Divide(const Decimal256 &divisor) const#

将当前数字除以右侧数字并返回结果。

此操作不会销毁原数据。结果向零舍入。符号运算规则如下:21 / 5 -> 4, 1; -21 / 5 -> -4, -1; 21 / -5 -> -4, 1; -21 / -5 -> 4, -1

参数:

divisor[输入] 除数

返回:

包含商和余数的对。

float ToFloat(int32_t scale) const#

转换为浮点数(应用小数位数)。

在溢出的情况下可能会返回无穷大。

double ToDouble(int32_t scale) const#

转换为浮点数(带缩放)

template<typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>>
inline T ToReal(int32_t scale) const#

转换为浮点数(带缩放)

公共静态函数

static Status FromString(std::string_view s, Decimal256 *out, int32_t *precision, int32_t *scale = NULLPTR)#

将十进制字符串转换为 Decimal256 值,如果传入了精度和小数位数(且不为空),则将其包含在内。

static Result<Decimal256> FromBigEndian(const uint8_t *data, int32_t length)#

从大端字节表示形式转换而来。

长度必须在 1 到 32 之间。

返回:

如果长度为无效值,则返回错误状态。

迭代器#

template<typename T>
class Iterator : public arrow::util::EqualityComparable<Iterator<T>>#

一个可以返回错误的通用 Iterator

公共函数

template<typename Wrapped>
inline explicit Iterator(Wrapped has_next)#

Iterator 可以由任何具有签名为 Result<T> Next() 成员函数的类型构造;迭代结束由返回 IteratorTraits<T>::End(); 表示。

该参数被移动或复制到堆中并保存在 unique_ptr<void> 中。构造后仅引用其析构函数和 Next 方法(存储在函数指针中)。

这种方法用于避免在使用抽象模板基类时出现的 MSVC 链接问题(ARROW-6244, ARROW-6558):基类的虚析构函数将作为导出符号,而不是像普通模板函数那样被内联,从而在链接到实例化该基类的任何其他编译单元时导致多重定义错误。

inline Result<T> Next()#

返回序列的下一个元素,当迭代完成时返回 IterationTraits<T>::End()。

template<typename Visitor>
inline Status Visit(Visitor &&visitor)#

将序列中的每个元素传递给访问者。

将返回访问者返回的任何错误状态,从而终止迭代。

inline bool Equals(const Iterator &other) const#

迭代器仅在两者皆为空时才被视为相等。

等价性比较是制作迭代器的迭代器(用于检查结束条件)所必需的。

inline Result<std::vector<T>> ToVector()#

将此迭代器的每个元素移动到向量中。

class RangeIterator#
template<typename T>
class VectorIterator#

生成 std::vector 元素的简单迭代器。

比较#

class EqualOptions#

用于相等性比较的选项容器。

公共函数

inline bool nans_equal() const#

NaNs 是否被视为相等。

inline EqualOptions nans_equal(bool v) const#

返回一个修改了“nans_equal”属性的新 EqualOptions 对象。

inline bool signed_zeros_equal() const#

符号不同的零是否被视为相等。

inline EqualOptions signed_zeros_equal(bool v) const#

返回一个修改了“signed_zeros_equal”属性的新 EqualOptions 对象。

inline bool use_atol() const#

比较中是否使用“atol”属性。

此选项仅影响 Equals 方法,对 ApproxEquals 方法没有影响。

inline EqualOptions use_atol(bool v) const#

返回一个修改了“use_atol”属性的新 EqualOptions 对象。

inline double atol() const#

浮点值近似比较的绝对容差。

请注意,如果将“use_atol”设置为 false,则忽略此选项。

inline EqualOptions atol(double v) const#

返回一个修改了“atol”属性的新 EqualOptions 对象。

inline bool use_schema() const#

比较中是否使用 arrow::Schema 属性。

此选项仅影响 Equals 方法,对 ApproxEquals 方法没有影响。

inline EqualOptions use_schema(bool v) const#

返回一个修改了“use_schema_”属性的新 EqualOptions 对象。

将此选项设置为 false 会导致 EqualOptions::use_metadata 的值被忽略。

inline bool use_metadata() const#

比较中是否使用 arrow::Schema 中的“元数据(metadata)”。

此选项仅影响 Equals 方法,对 ApproxEquals 方法没有影响。

注意:仅当 arrow::EqualOptions::use_schema 设置为 true 时,才会考虑此选项。

inline EqualOptions use_metadata(bool v) const#

返回一个修改了“use_metadata”属性的新 EqualOptions 对象。

inline std::ostream *diff_sink() const#

当数组不一致时,差异(diff)将格式化输出到的 ostream。

如果此项为 null(默认值),则不会格式化差异。

inline EqualOptions diff_sink(std::ostream *diff_sink) const#

返回一个修改了“diff_sink”属性的新 EqualOptions 对象。

如果不支持所比较数组类型的差异格式化,此选项将被忽略。

压缩#

enum arrow::Compression::type#

压缩算法。

enumerator UNCOMPRESSED#
enumerator SNAPPY#
enumerator GZIP#
enumerator BROTLI#
enumerator ZSTD#
enumerator LZ4#
enumerator LZ4_FRAME#
enumerator LZO#
enumerator BZ2#
enumerator LZ4_HADOOP#
class Codec#

压缩编解码器。

公共函数

virtual int minimum_compression_level() const = 0#

返回支持的最小压缩级别。

virtual int maximum_compression_level() const = 0#

返回支持的最大压缩级别。

virtual int default_compression_level() const = 0#

返回默认压缩级别。

virtual Result<int64_t> Decompress(int64_t input_len, const uint8_t *input, int64_t output_buffer_len, uint8_t *output_buffer) = 0#

一次性解压缩函数。

output_buffer_len 必须正确,因此需提前获取。返回实际解压后的长度。

注意

一次性解压缩并不总是与流式压缩兼容。根据编解码器(例如 LZ4),可能会使用不同的格式。

virtual Result<int64_t> Compress(int64_t input_len, const uint8_t *input, int64_t output_buffer_len, uint8_t *output_buffer) = 0#

一次性压缩函数。

output_buffer_len 必须先使用 MaxCompressedLen() 计算得出。返回实际压缩后的长度。

注意

一次性压缩并不总是与流式解压缩兼容。根据编解码器(例如 LZ4),可能会使用不同的格式。

virtual Result<std::shared_ptr<Compressor>> MakeCompressor() = 0#

创建一个流式压缩器实例。

virtual Result<std::shared_ptr<Decompressor>> MakeDecompressor() = 0#

创建一个流式压缩器实例。

virtual Compression::type compression_type() const = 0#

Codec 的压缩类型。

inline const std::string &name() const#

Codec 的压缩类型名称。

inline virtual int compression_level() const#

Codec 的压缩级别(如果适用)。

公共静态函数

static int UseDefaultCompressionLevel()#

返回一个特殊值,表示编解码器实现应使用其默认压缩级别。

static const std::string &GetCodecAsString(Compression::type t)#

返回压缩类型的字符串名称。

static Result<Compression::type> GetCompressionType(const std::string &name)#

根据名称返回压缩类型(全小写)

static Result<std::unique_ptr<Codec>> Create(Compression::type codec, const CodecOptions &codec_options = CodecOptions{})#

使用 CodecOptions 为给定的压缩算法创建一个编解码器。

static Result<std::unique_ptr<Codec>> Create(Compression::type codec, int compression_level)#

为给定的压缩算法创建一个编解码器。

static bool IsAvailable(Compression::type codec)#

如果已启用对指定编解码器的支持,则返回 true。

static bool SupportsCompressionLevel(Compression::type codec)#

如果指定的编解码器支持设置压缩级别,则返回 true。

static Result<int> MinimumCompressionLevel(Compression::type codec)#

返回该编解码器支持的最小压缩级别。注意:此函数会创建一个临时的 Codec 实例。

static Result<int> MaximumCompressionLevel(Compression::type codec)#

返回该编解码器支持的最大压缩级别。注意:此函数会创建一个临时的 Codec 实例。

static Result<int> DefaultCompressionLevel(Compression::type codec)#

返回默认压缩级别。注意:此函数会创建一个临时的 Codec 实例。

class Compressor#

流式压缩器接口。

公共函数

virtual Result<CompressResult> Compress(int64_t input_len, const uint8_t *input, int64_t output_len, uint8_t *output) = 0#

压缩部分输入数据。

如果返回时 bytes_read 为 0,则应提供更大的输出缓冲区。

virtual Result<FlushResult> Flush(int64_t output_len, uint8_t *output) = 0#

刷新部分压缩后的输出。

如果返回时 should_retry 为 true,则应使用更大的缓冲区再次调用 Flush()

virtual Result<EndResult> End(int64_t output_len, uint8_t *output) = 0#

结束压缩,执行结束流所需的任何必要操作。

如果返回时 should_retry 为 true,则应使用更大的缓冲区再次调用 End()。否则,不应再使用该 Compressor

End() 隐含了 Flush()

struct CompressResult#
struct EndResult#
struct FlushResult#
class Decompressor#

流式解压缩器接口。

公共函数

virtual Result<DecompressResult> Decompress(int64_t input_len, const uint8_t *input, int64_t output_len, uint8_t *output) = 0#

解压缩部分输入数据。

如果返回时 need_more_output 为 true,则需要提供更大的输出缓冲区。

virtual bool IsFinished() = 0#

返回压缩流是否已完成。

这是一个启发式判断。如果返回 true,则保证流已完成。如果返回 false,则可能只是底层库无法提供相关信息。

virtual Status Reset() = 0#

重新初始化解压缩器,使其准备好处理新的压缩流。

struct DecompressResult#

访问者 (Visitors)#

template<typename VISITOR, typename ...ARGS>
inline Status arrow::VisitTypeInline(const DataType &type, VISITOR *visitor, ARGS&&... args)#

使用相应的具体类型类调用 visitor

访问者 (visitor) 是一种为每种 Arrow 类型实现专用逻辑的类型。示例用法

class ExampleVisitor {
  arrow::Status Visit(const arrow::Int32Type& type) { ... }
  arrow::Status Visit(const arrow::Int64Type& type) { ... }
  ...
}
ExampleVisitor visitor;
VisitTypeInline(some_type, &visitor);
模板参数:
  • VISITOR – 为所有 Arrow 类型实现 Visit() 的访问者类型。

  • ARGS – 其他参数(如果有),将在 type 参数之后传递给 Visit 函数。

返回:

Status(状态)

template<typename VISITOR, typename ...ARGS>
inline Status arrow::VisitTypeIdInline(Type::type id, VISITOR *visitor, ARGS&&... args)#

使用相应具体类型类的 nullptr 调用 visitor

模板参数:
  • VISITOR – 为所有 Arrow 类型实现 Visit() 的访问者类型。

  • ARGS – 其他参数(如果有),将在 type 参数之后传递给 Visit 函数。

返回:

Status(状态)

template<typename VISITOR, typename ...ARGS>
inline Status arrow::VisitScalarInline(const Scalar &scalar, VISITOR *visitor, ARGS&&... args)#

应用专门针对标量类型的访问者 Visit() 方法。

访问者 (visitor) 是一种为每种 Arrow 类型实现专用逻辑的类型。示例用法

class ExampleVisitor {
  arrow::Status Visit(arrow::Int32Scalar scalar) { ... }
  arrow::Status Visit(arrow::Int64Scalar scalar) { ... }
  ...
}
ExampleVisitor visitor;
VisitScalarInline(some_scalar, &visitor);
模板参数:
  • VISITOR – 为所有标量类型实现 Visit() 的访问者类型。

  • ARGS – 其他参数(如果有),将在 scalar 参数之后传递给 Visit 函数。

返回:

Status(状态)

template<typename VISITOR, typename ...ARGS>
inline Status arrow::VisitArrayInline(const Array &array, VISITOR *visitor, ARGS&&... args)#

应用专门针对数组类型的访问者 Visit() 方法。

访问者 (visitor) 是一种为每种 Arrow 类型实现专用逻辑的类型。示例用法

class ExampleVisitor {
  arrow::Status Visit(arrow::NumericArray<Int32Type> arr) { ... }
  arrow::Status Visit(arrow::NumericArray<Int64Type> arr) { ... }
  ...
}
ExampleVisitor visitor;
VisitArrayInline(some_array, &visitor);
模板参数:
  • VISITOR – 为所有数组类型实现 Visit() 的访问者类型。

  • ARGS – 其他参数(如果有),将在 arr 参数之后传递给 Visit 函数。

返回:

Status(状态)

类型特征 (Type Traits)#

这些类型在编译时提供 Arrow 类型之间的关系。TypeTraits 将 Arrow 数据类型映射到其他类型,而 CTypeTraits 将 C 类型映射到 Arrow 类型。

TypeTraits#

每个专用类型定义以下相关类型:

type TypeTraits::ArrayType#

相应的 Arrow 数组类型

type TypeTraits::BuilderType#

相应的 数组构建器类型

type TypeTraits::ScalarType#

相应的 Arrow 标量类型

bool TypeTraits::is_parameter_free#

类型是否具有任何类型参数,例如嵌套类型中的字段类型,或十进制类型中的精度和标度。

此外,许多(但不是全部)类型还定义了以下内容:

type TypeTraits::CType#

相应的 C 类型。例如,Int64Array 对应 int64_t

type TypeTraits::TensorType#

相应的 Arrow 张量类型

static inline constexpr int64_t bytes_required(int64_t elements)#

返回给定元素数量所需的字节数。为固定大小的类型定义。

static inline std::shared_ptr<DataType> TypeTraits::type_singleton()#

对于 is_parameter_free 为 true 的类型,返回该数据类型的一个实例。

template<>
struct TypeTraits<NullType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = NullArray#
using BuilderType = NullBuilder#
using ScalarType = NullScalar#

公共静态函数

static inline constexpr int64_t bytes_required(int64_t)#
static inline std::shared_ptr<DataType> type_singleton()#

公共静态属性

static constexpr bool is_parameter_free = true#
template<>
struct TypeTraits<BooleanType>#
#include <arrow/type_traits.h>

由 arrow::CTypeTraits< bool > 子类化

公共类型

using ArrayType = BooleanArray#
using BuilderType = BooleanBuilder#
using ScalarType = BooleanScalar#
using CType = bool#

公共静态函数

static inline constexpr int64_t bytes_required(int64_t elements)#
static inline std::shared_ptr<DataType> type_singleton()#

公共静态属性

static constexpr bool is_parameter_free = true#
template<>
struct TypeTraits<Date64Type>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = Date64Array#
using BuilderType = Date64Builder#
using ScalarType = Date64Scalar#
using CType = Date64Type::c_type#

公共静态函数

static inline constexpr int64_t bytes_required(int64_t elements)#
static inline std::shared_ptr<DataType> type_singleton()#

公共静态属性

static constexpr bool is_parameter_free = true#
template<>
struct TypeTraits<Date32Type>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = Date32Array#
using BuilderType = Date32Builder#
using ScalarType = Date32Scalar#
using CType = Date32Type::c_type#

公共静态函数

static inline constexpr int64_t bytes_required(int64_t elements)#
static inline std::shared_ptr<DataType> type_singleton()#

公共静态属性

static constexpr bool is_parameter_free = true#
template<>
struct TypeTraits<TimestampType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = TimestampArray#
using BuilderType = TimestampBuilder#
using ScalarType = TimestampScalar#
using CType = TimestampType::c_type#

公共静态函数

static inline constexpr int64_t bytes_required(int64_t elements)#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<DurationType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = DurationArray#
using BuilderType = DurationBuilder#
using ScalarType = DurationScalar#
using CType = DurationType::c_type#

公共静态函数

static inline constexpr int64_t bytes_required(int64_t elements)#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<DayTimeIntervalType>#
#include <arrow/type_traits.h>

arrow::CTypeTraits< DayTimeIntervalType::DayMilliseconds > 子类化

公共类型

using ArrayType = DayTimeIntervalArray#
using BuilderType = DayTimeIntervalBuilder#
using ScalarType = DayTimeIntervalScalar#
using CType = DayTimeIntervalType::c_type#

公共静态函数

static inline constexpr int64_t bytes_required(int64_t elements)#
static inline std::shared_ptr<DataType> type_singleton()#

公共静态属性

static constexpr bool is_parameter_free = true#
template<>
struct TypeTraits<MonthDayNanoIntervalType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = MonthDayNanoIntervalArray#
using BuilderType = MonthDayNanoIntervalBuilder#
using ScalarType = MonthDayNanoIntervalScalar#
using CType = MonthDayNanoIntervalType::c_type#

公共静态函数

static inline constexpr int64_t bytes_required(int64_t elements)#
static inline std::shared_ptr<DataType> type_singleton()#

公共静态属性

static constexpr bool is_parameter_free = true#
template<>
struct TypeTraits<MonthIntervalType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = MonthIntervalArray#
using BuilderType = MonthIntervalBuilder#
using ScalarType = MonthIntervalScalar#
using CType = MonthIntervalType::c_type#

公共静态函数

static inline constexpr int64_t bytes_required(int64_t elements)#
static inline std::shared_ptr<DataType> type_singleton()#

公共静态属性

static constexpr bool is_parameter_free = true#
template<>
struct TypeTraits<Time32Type>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = Time32Array#
using BuilderType = Time32Builder#
using ScalarType = Time32Scalar#
using CType = Time32Type::c_type#

公共静态函数

static inline constexpr int64_t bytes_required(int64_t elements)#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<Time64Type>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = Time64Array#
using BuilderType = Time64Builder#
using ScalarType = Time64Scalar#
using CType = Time64Type::c_type#

公共静态函数

static inline constexpr int64_t bytes_required(int64_t elements)#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<HalfFloatType>#
#include <arrow/type_traits.h>

由以下类继承:arrow::CTypeTraits< util::Float16 >

公共类型

using ArrayType = HalfFloatArray#
using BuilderType = HalfFloatBuilder#
using ScalarType = HalfFloatScalar#
using TensorType = HalfFloatTensor#
using CType = uint16_t#

公共静态函数

static inline constexpr int64_t bytes_required(int64_t elements)#
static inline std::shared_ptr<DataType> type_singleton()#

公共静态属性

static constexpr bool is_parameter_free = true#
template<>
struct CTypeTraits<util::Float16> : public arrow::TypeTraits<HalfFloatType>#
#include <arrow/type_traits.h>

公共类型

using ArrowType = HalfFloatType#
template<>
struct TypeTraits<Decimal32Type>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = Decimal32Array#
using BuilderType = Decimal32Builder#
using ScalarType = Decimal32Scalar#
using CType = Decimal32#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<Decimal64Type>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = Decimal64Array#
using BuilderType = Decimal64Builder#
using ScalarType = Decimal64Scalar#
using CType = Decimal64#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<Decimal128Type>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = Decimal128Array#
using BuilderType = Decimal128Builder#
using ScalarType = Decimal128Scalar#
using CType = Decimal128#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<Decimal256Type>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = Decimal256Array#
using BuilderType = Decimal256Builder#
using ScalarType = Decimal256Scalar#
using CType = Decimal256#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<BinaryType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = BinaryArray#
using BuilderType = BinaryBuilder#
using ScalarType = BinaryScalar#
using OffsetType = Int32Type#

公共静态函数

static inline std::shared_ptr<DataType> type_singleton()#

公共静态属性

static constexpr bool is_parameter_free = true#
template<>
struct TypeTraits<BinaryViewType>#
#include <arrow/type_traits.h>

由以下类继承:arrow::CTypeTraits< BinaryViewType::c_type >

公共类型

using ArrayType = BinaryViewArray#
using BuilderType = BinaryViewBuilder#
using ScalarType = BinaryViewScalar#
using CType = BinaryViewType::c_type#

公共静态函数

static inline std::shared_ptr<DataType> type_singleton()#

公共静态属性

static constexpr bool is_parameter_free = true#
template<>
struct TypeTraits<LargeBinaryType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = LargeBinaryArray#
using BuilderType = LargeBinaryBuilder#
using ScalarType = LargeBinaryScalar#
using OffsetType = Int64Type#

公共静态函数

static inline std::shared_ptr<DataType> type_singleton()#

公共静态属性

static constexpr bool is_parameter_free = true#
template<>
struct TypeTraits<FixedSizeBinaryType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = FixedSizeBinaryArray#
using BuilderType = FixedSizeBinaryBuilder#
using ScalarType = FixedSizeBinaryScalar#
using OffsetType = Int32Type#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<StringType>#
#include <arrow/type_traits.h>

由以下类继承:arrow::CTypeTraits< std::string >

公共类型

using ArrayType = StringArray#
using BuilderType = StringBuilder#
using ScalarType = StringScalar#
using OffsetType = Int32Type#

公共静态函数

static inline std::shared_ptr<DataType> type_singleton()#

公共静态属性

static constexpr bool is_parameter_free = true#
template<>
struct TypeTraits<StringViewType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = StringViewArray#
using BuilderType = StringViewBuilder#
using ScalarType = StringViewScalar#
using CType = BinaryViewType::c_type#

公共静态函数

static inline std::shared_ptr<DataType> type_singleton()#

公共静态属性

static constexpr bool is_parameter_free = true#
template<>
struct TypeTraits<LargeStringType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = LargeStringArray#
using BuilderType = LargeStringBuilder#
using ScalarType = LargeStringScalar#
using OffsetType = Int64Type#

公共静态函数

static inline std::shared_ptr<DataType> type_singleton()#

公共静态属性

static constexpr bool is_parameter_free = true#
template<>
struct TypeTraits<RunEndEncodedType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = RunEndEncodedArray#
using BuilderType = RunEndEncodedBuilder#
using ScalarType = RunEndEncodedScalar#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<ListType>#
#include <arrow/type_traits.h>

由 arrow::CTypeTraits< std::vector< CType > > 子类化

公共类型

using ArrayType = ListArray#
using BuilderType = ListBuilder#
using ScalarType = ListScalar#
using OffsetType = Int32Type#
using OffsetArrayType = Int32Array#
using OffsetBuilderType = Int32Builder#
using OffsetScalarType = Int32Scalar#
using LargeType = LargeListType#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<LargeListType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = LargeListArray#
using BuilderType = LargeListBuilder#
using ScalarType = LargeListScalar#
using OffsetType = Int64Type#
using OffsetArrayType = Int64Array#
using OffsetBuilderType = Int64Builder#
using OffsetScalarType = Int64Scalar#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<ListViewType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = ListViewArray#
using BuilderType = ListViewBuilder#
using ScalarType = ListViewScalar#
using OffsetType = Int32Type#
using OffsetArrayType = Int32Array#
using OffsetBuilderType = Int32Builder#
using OffsetScalarType = Int32Scalar#
using LargeType = LargeListViewType#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<LargeListViewType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = LargeListViewArray#
using BuilderType = LargeListViewBuilder#
using ScalarType = LargeListViewScalar#
using OffsetType = Int64Type#
using OffsetArrayType = Int64Array#
using OffsetBuilderType = Int64Builder#
using OffsetScalarType = Int64Scalar#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<MapType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = MapArray#
using BuilderType = MapBuilder#
using ScalarType = MapScalar#
using OffsetType = Int32Type#
using OffsetArrayType = Int32Array#
using OffsetBuilderType = Int32Builder#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<FixedSizeListType>#
#include <arrow/type_traits.h>

由 arrow::CTypeTraits< std::array< CType, N > > 子类化

公共类型

using ArrayType = FixedSizeListArray#
using BuilderType = FixedSizeListBuilder#
using ScalarType = FixedSizeListScalar#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<StructType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = StructArray#
using BuilderType = StructBuilder#
using ScalarType = StructScalar#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<SparseUnionType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = SparseUnionArray#
using BuilderType = SparseUnionBuilder#
using ScalarType = SparseUnionScalar#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<DenseUnionType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = DenseUnionArray#
using BuilderType = DenseUnionBuilder#
using ScalarType = DenseUnionScalar#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<DictionaryType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = DictionaryArray#
using ScalarType = DictionaryScalar#

公共静态属性

static constexpr bool is_parameter_free = false#
template<>
struct TypeTraits<ExtensionType>#
#include <arrow/type_traits.h>

公共类型

using ArrayType = ExtensionArray#
using ScalarType = ExtensionScalar#

公共静态属性

static constexpr bool is_parameter_free = false#

CTypeTraits#

每个专用类型定义以下相关类型:

type CTypeTraits::ArrowType#

对应的 Arrow 类型

template<>
struct CTypeTraits<std::string> : public arrow::TypeTraits<StringType>#
#include <arrow/type_traits.h>

arrow::CTypeTraits< const char * >, arrow::CTypeTraits< const char(&)[N]>, arrow::stl::ConversionTraits< std::string > 子类化

公共类型

using ArrowType = StringType#
template<>
struct CTypeTraits<BinaryViewType::c_type> : public arrow::TypeTraits<BinaryViewType>#
#include <arrow/type_traits.h>

公共类型

using ArrowType = BinaryViewType#
template<>
struct CTypeTraits<const char*> : public arrow::CTypeTraits<std::string>#
#include <arrow/type_traits.h>
template<size_t N>
struct CTypeTraits<const char (&)[N]> : public arrow::CTypeTraits<std::string>#
#include <arrow/type_traits.h>
template<>
struct CTypeTraits<DayTimeIntervalType::DayMilliseconds> : public arrow::TypeTraits<DayTimeIntervalType>#
#include <arrow/type_traits.h>

公共类型

using ArrowType = DayTimeIntervalType#

类型谓词 (Type Predicates)#

可与模板一起使用的类型谓词。形如 is_XXX 的谓词解析为常量布尔值,而形如 enable_if_XXX 的谓词,如果第一个参数 T 通过测试,则解析为第二个类型参数 R

示例用法

template<typename TypeClass>
arrow::enable_if_number<TypeClass, RETURN_TYPE> MyFunction(const TypeClass& type) {
  ..
}

template<typename ArrayType, typename TypeClass=ArrayType::TypeClass>
arrow::enable_if_number<TypeClass, RETURN_TYPE> MyFunction(const ArrayType& array) {
  ..
}
template<bool B, typename T = void>
using enable_if_t = typename std::enable_if<B, T>::type#
template<typename T>
using is_null_type = std::is_same<NullType, T>#
template<typename T, typename R = void>
using enable_if_null = enable_if_t<is_null_type<T>::value, R>#
template<typename T>
using is_boolean_type = std::is_same<BooleanType, T>#
template<typename T, typename R = void>
using enable_if_boolean = enable_if_t<is_boolean_type<T>::value, R>#
template<typename T>
using is_number_type = std::is_base_of<NumberType, T>#
template<typename T, typename R = void>
using enable_if_number = enable_if_t<is_number_type<T>::value, R>#
template<typename T>
using is_integer_type = std::is_base_of<IntegerType, T>#
template<typename T, typename R = void>
using enable_if_integer = enable_if_t<is_integer_type<T>::value, R>#
template<typename T>
using is_signed_integer_type = std::integral_constant<bool, is_integer_type<T>::value && std::is_signed<typename T::c_type>::value>#
template<typename T, typename R = void>
using enable_if_signed_integer = enable_if_t<is_signed_integer_type<T>::value, R>#
template<typename T>
using is_unsigned_integer_type = std::integral_constant<bool, is_integer_type<T>::value && std::is_unsigned<typename T::c_type>::value>#
template<typename T, typename R = void>
using enable_if_unsigned_integer = enable_if_t<is_unsigned_integer_type<T>::value, R>#
template<typename T>
using is_floating_type = std::is_base_of<FloatingPointType, T>#
template<typename T, typename R = void>
using enable_if_floating_point = enable_if_t<is_floating_type<T>::value, R>#
template<typename T>
using is_half_float_type = std::is_same<HalfFloatType, T>#
template<typename T, typename R = void>
using enable_if_half_float = enable_if_t<is_half_float_type<T>::value, R>#
template<typename T>
using is_base_binary_type = std::is_base_of<BaseBinaryType, T>#
template<typename T, typename R = void>
using enable_if_base_binary = enable_if_t<is_base_binary_type<T>::value, R>#
template<typename T>
using is_binary_type = std::integral_constant<bool, std::is_same<BinaryType, T>::value || std::is_same<LargeBinaryType, T>::value>#
template<typename T, typename R = void>
using enable_if_binary = enable_if_t<is_binary_type<T>::value, R>#
template<typename T>
using is_string_type = std::integral_constant<bool, std::is_same<StringType, T>::value || std::is_same<LargeStringType, T>::value>#
template<typename T, typename R = void>
using enable_if_string = enable_if_t<is_string_type<T>::value, R>#
template<typename T>
using is_binary_view_like_type = std::is_base_of<BinaryViewType, T>#
template<typename T>
using is_binary_view_type = std::is_same<BinaryViewType, T>#
template<typename T>
using is_string_view_type = std::is_same<StringViewType, T>#
template<typename T, typename R = void>
using enable_if_binary_view_like = enable_if_t<is_binary_view_like_type<T>::value, R>#
template<typename T, typename R = void>
using enable_if_binary_view = enable_if_t<is_binary_view_type<T>::value, R>#
template<typename T, typename R = void>
using enable_if_string_view = enable_if_t<is_string_view_type<T>::value, R>#
template<typename T>
using is_string_like_type = std::integral_constant<bool, is_base_binary_type<T>::value && T::is_utf8>#
template<typename T, typename R = void>
using enable_if_string_like = enable_if_t<is_string_like_type<T>::value, R>#
template<typename T, typename U, typename R = void>
using enable_if_same = enable_if_t<std::is_same<T, U>::value, R>#
template<typename T>
using is_fixed_size_binary_type = std::is_base_of<FixedSizeBinaryType, T>#
template<typename T, typename R = void>
using enable_if_fixed_size_binary = enable_if_t<is_fixed_size_binary_type<T>::value, R>#
template<typename T>
using is_fixed_width_type = std::is_base_of<FixedWidthType, T>#
template<typename T, typename R = void>
using enable_if_fixed_width_type = enable_if_t<is_fixed_width_type<T>::value, R>#
template<typename T>
using is_binary_like_type = std::integral_constant<bool, (is_base_binary_type<T>::value && !is_string_like_type<T>::value) || is_fixed_size_binary_type<T>::value>#
template<typename T, typename R = void>
using enable_if_binary_like = enable_if_t<is_binary_like_type<T>::value, R>#
template<typename T>
using is_decimal_type = std::is_base_of<DecimalType, T>#
template<typename T, typename R = void>
using enable_if_decimal = enable_if_t<is_decimal_type<T>::value, R>#
template<typename T>
using is_decimal32_type = std::is_base_of<Decimal32Type, T>#
template<typename T, typename R = void>
using enable_if_decimal32 = enable_if_t<is_decimal32_type<T>::value, R>#
template<typename T>
using is_decimal64_type = std::is_base_of<Decimal64Type, T>#
template<typename T, typename R = void>
using enable_if_decimal64 = enable_if_t<is_decimal64_type<T>::value, R>#
template<typename T>
using is_decimal128_type = std::is_base_of<Decimal128Type, T>#
template<typename T, typename R = void>
using enable_if_decimal128 = enable_if_t<is_decimal128_type<T>::value, R>#
template<typename T>
using is_decimal256_type = std::is_base_of<Decimal256Type, T>#
template<typename T, typename R = void>
using enable_if_decimal256 = enable_if_t<is_decimal256_type<T>::value, R>#
template<typename T>
using is_nested_type = std::is_base_of<NestedType, T>#
template<typename T, typename R = void>
using enable_if_nested = enable_if_t<is_nested_type<T>::value, R>#
template<typename T, typename R = void>
using enable_if_not_nested = enable_if_t<!is_nested_type<T>::value, R>#
template<typename T>
using is_var_length_list_type = std::integral_constant<bool, std::is_base_of<LargeListType, T>::value || std::is_base_of<ListType, T>::value>#
template<typename T, typename R = void>
using enable_if_var_size_list = enable_if_t<is_var_length_list_type<T>::value, R>#
template<typename T>
using is_base_list_type = is_var_length_list_type<T>#
template<typename T, typename R = void>
using enable_if_base_list = enable_if_var_size_list<T, R>#
template<typename T>
using is_fixed_size_list_type = std::is_same<FixedSizeListType, T>#
template<typename T, typename R = void>
using enable_if_fixed_size_list = enable_if_t<is_fixed_size_list_type<T>::value, R>#
template<typename T>
using is_list_type = std::integral_constant<bool, std::is_same<T, ListType>::value || std::is_same<T, LargeListType>::value || std::is_same<T, FixedSizeListType>::value>#
template<typename T, typename R = void>
using enable_if_list_type = enable_if_t<is_list_type<T>::value, R>#
template<typename T>
using is_list_view_type = std::disjunction<std::is_same<T, ListViewType>, std::is_same<T, LargeListViewType>>#
template<typename T, typename R = void>
using enable_if_list_view = enable_if_t<is_list_view_type<T>::value, R>#
template<typename T>
using is_list_like_type = std::integral_constant<bool, is_var_length_list_type<T>::value || is_fixed_size_list_type<T>::value>#
template<typename T, typename R = void>
using enable_if_list_like = enable_if_t<is_list_like_type<T>::value, R>#
template<typename T>
using is_var_length_list_like_type = std::disjunction<is_var_length_list_type<T>, is_list_view_type<T>>#
template<typename T, typename R = void>
using enable_if_var_length_list_like = enable_if_t<is_var_length_list_like_type<T>::value, R>#
template<typename T>
using is_struct_type = std::is_base_of<StructType, T>#
template<typename T, typename R = void>
using enable_if_struct = enable_if_t<is_struct_type<T>::value, R>#
template<typename T>
using is_union_type = std::is_base_of<UnionType, T>#
template<typename T, typename R = void>
using enable_if_union = enable_if_t<is_union_type<T>::value, R>#
template<typename T>
using is_temporal_type = std::is_base_of<TemporalType, T>#
template<typename T, typename R = void>
using enable_if_temporal = enable_if_t<is_temporal_type<T>::value, R>#
template<typename T>
using is_date_type = std::is_base_of<DateType, T>#
template<typename T, typename R = void>
using enable_if_date = enable_if_t<is_date_type<T>::value, R>#
template<typename T>
using is_time_type = std::is_base_of<TimeType, T>#
template<typename T, typename R = void>
using enable_if_time = enable_if_t<is_time_type<T>::value, R>#
template<typename T>
using is_timestamp_type = std::is_base_of<TimestampType, T>#
template<typename T, typename R = void>
using enable_if_timestamp = enable_if_t<is_timestamp_type<T>::value, R>#
template<typename T>
using is_duration_type = std::is_base_of<DurationType, T>#
template<typename T, typename R = void>
using enable_if_duration = enable_if_t<is_duration_type<T>::value, R>#
template<typename T>
using is_interval_type = std::is_base_of<IntervalType, T>#
template<typename T, typename R = void>
using enable_if_interval = enable_if_t<is_interval_type<T>::value, R>#
template<typename T>
using is_run_end_encoded_type = std::is_base_of<RunEndEncodedType, T>#
template<typename T, typename R = void>
using enable_if_run_end_encoded = enable_if_t<is_run_end_encoded_type<T>::value, R>#
template<typename T>
using is_dictionary_type = std::is_base_of<DictionaryType, T>#
template<typename T, typename R = void>
using enable_if_dictionary = enable_if_t<is_dictionary_type<T>::value, R>#
template<typename T>
using is_extension_type = std::is_base_of<ExtensionType, T>#
template<typename T, typename R = void>
using enable_if_extension = enable_if_t<is_extension_type<T>::value, R>#
template<typename T>
using is_primitive_ctype = std::is_base_of<PrimitiveCType, T>#
template<typename T, typename R = void>
using enable_if_primitive_ctype = enable_if_t<is_primitive_ctype<T>::value, R>#
template<typename T>
using has_c_type = std::integral_constant<bool, is_primitive_ctype<T>::value || is_temporal_type<T>::value>#
template<typename T, typename R = void>
using enable_if_has_c_type = enable_if_t<has_c_type<T>::value, R>#
template<typename T>
using has_string_view = std::integral_constant<bool, std::is_same<BinaryType, T>::value || std::is_same<BinaryViewType, T>::value || std::is_same<LargeBinaryType, T>::value || std::is_same<StringType, T>::value || std::is_same<StringViewType, T>::value || std::is_same<LargeStringType, T>::value || std::is_same<FixedSizeBinaryType, T>::value>#
template<typename T, typename R = void>
using enable_if_has_string_view = enable_if_t<has_string_view<T>::value, R>#
template<typename T>
using is_8bit_int = std::integral_constant<bool, std::is_same<UInt8Type, T>::value || std::is_same<Int8Type, T>::value>#
template<typename T, typename R = void>
using enable_if_8bit_int = enable_if_t<is_8bit_int<T>::value, R>#
template<typename T>
using is_parameter_free_type = std::integral_constant<bool, TypeTraits<T>::is_parameter_free>#
template<typename T, typename R = void>
using enable_if_parameter_free = enable_if_t<is_parameter_free_type<T>::value, R>#
template<typename T>
using is_physical_signed_integer_type = std::integral_constant<bool, is_signed_integer_type<T>::value || (is_temporal_type<T>::value && has_c_type<T>::value && std::is_integral<typename T::c_type>::value)>#
template<typename T, typename R = void>
using enable_if_physical_signed_integer = enable_if_t<is_physical_signed_integer_type<T>::value, R>#
template<typename T>
using is_physical_unsigned_integer_type = std::integral_constant<bool, is_unsigned_integer_type<T>::value || is_half_float_type<T>::value>#
template<typename T, typename R = void>
using enable_if_physical_unsigned_integer = enable_if_t<is_physical_unsigned_integer_type<T>::value, R>#
template<typename T>
using is_physical_integer_type = std::integral_constant<bool, is_physical_unsigned_integer_type<T>::value || is_physical_signed_integer_type<T>::value>#
template<typename T, typename R = void>
using enable_if_physical_integer = enable_if_t<is_physical_integer_type<T>::value, R>#
template<typename T>
using is_physical_floating_type = std::integral_constant<bool, is_floating_type<T>::value && !is_half_float_type<T>::value>#
template<typename T, typename R = void>
using enable_if_physical_floating_point = enable_if_t<is_physical_floating_type<T>::value, R>#

运行时类型谓词#

可在运行时应用的类型谓词。

constexpr bool is_integer(Type::type type_id)#

检查是否为整数类型(有符号或无符号)

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为整数类型

constexpr bool is_signed_integer(Type::type type_id)#

检查是否为有符号整数类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为有符号整数类型

constexpr bool is_unsigned_integer(Type::type type_id)#

检查是否为无符号整数类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为无符号整数类型

constexpr bool is_floating(Type::type type_id)#

检查是否为浮点类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为浮点类型

constexpr bool is_physical_floating(Type::type type_id)#

检查是否为物理浮点类型。

此谓词匹配浮点类型,但不包括半精度浮点(half-float)。

constexpr bool is_numeric(Type::type type_id)#

检查是否为数值类型。

此谓词不匹配小数(请参阅 is_decimal)。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为数值类型

constexpr bool is_decimal(Type::type type_id)#

检查是否为小数类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为小数类型

constexpr bool is_run_end_type(Type::type type_id)#

检查类型是否可用作游程编码(Run-End Encoded)数组的游程结束(run-end)。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否可表示游程结束值

constexpr bool is_primitive(Type::type type_id)#

检查是否为原始类型。

此谓词不匹配 null、小数和类二进制类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为原始类型

constexpr bool is_base_binary_like(Type::type type_id)#

检查是否为基二进制类(base-binary-like)类型。

此谓词不匹配固定大小二进制类型,但会匹配所有其他二进制和字符串类类型,无论偏移宽度如何。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为基二进制类类型

constexpr bool is_binary_like(Type::type type_id)#

检查是否为二进制类类型(即

使用 32 位偏移量)

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为二进制类类型

constexpr bool is_large_binary_like(Type::type type_id)#

检查是否为大型二进制类类型(即

使用 64 位偏移量)

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为大型二进制类类型

constexpr bool is_binary(Type::type type_id)#

检查是否为二进制(非字符串)类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为二进制类型

constexpr bool is_binary_or_binary_view(Type::type type_id)#

检查是否为二进制或二进制视图(非字符串)类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为二进制类型

constexpr bool is_string(Type::type type_id)#

检查是否为字符串类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为字符串类型

constexpr bool is_string_or_string_view(Type::type type_id)#

检查是否为字符串或字符串视图类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为字符串类型

constexpr bool is_binary_view_like(Type::type type_id)#

检查是否为类二进制视图类型(即

字符串视图和二进制视图)

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为类二进制视图类型

constexpr bool is_temporal(Type::type type_id)#

检查是否为时间类(temporal)类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为时间类类型

constexpr bool is_time(Type::type type_id)#

检查是否为时间(time)类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为原始类型

constexpr bool is_date(Type::type type_id)#

检查是否为日期(date)类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为原始类型

constexpr bool is_interval(Type::type type_id)#

检查是否为间隔(interval)类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为间隔类型

constexpr bool is_dictionary(Type::type type_id)#

检查是否为字典(dictionary)类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为字典类型

constexpr bool is_fixed_size_binary(Type::type type_id)#

检查是否为固定大小二进制类型。

此谓词也匹配小数。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为固定大小二进制类型

constexpr bool is_fixed_width(Type::type type_id)#

检查是否为固定宽度类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为固定宽度类型

constexpr bool is_var_length_list(Type::type type_id)#

检查是否为变长列表类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为变长列表类型

constexpr bool is_list(Type::type type_id)#

检查是否为列表类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为列表类型

constexpr bool is_list_like(Type::type type_id)#

检查是否为类列表类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为类列表类型

constexpr bool is_var_length_list_like(Type::type type_id)#

检查是否为变长列表或列表视图类类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为变长列表或列表视图类类型

constexpr bool is_list_view(Type::type type_id)#

检查是否为列表视图类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为列表视图类型

constexpr bool is_nested(Type::type type_id)#

检查是否为嵌套类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为嵌套类型

constexpr bool is_union(Type::type type_id)#

检查是否为联合(union)类型。

参数:

type_id[输入] 要检查的类型 ID

返回:

type-id 是否为联合类型

constexpr int bit_width(Type::type type_id)#

返回类型值的位宽。

对于 Type::FIXED_SIZE_BINARY,您需要检查具体的 DataType 以获取此信息。

参数:

type_id[输入] 要检查的类型 ID

返回:

值的位宽,如果该类型没有固定宽度值,则返回 0

constexpr int offset_bit_width(Type::type type_id)#

返回类型偏移量的位宽。

参数:

type_id[输入] 要检查的类型 ID

返回:

偏移量的位宽,如果该类型没有偏移量,则返回 0

int RequiredValueAlignmentForBuffer(Type::type type_id, int buffer_index)#

获取缓冲区被视为“值对齐(value aligned)”所需的对齐方式。

某些缓冲区经常被类型强转(type-punned)。例如,在 int32 数组中,值缓冲区经常被转换为 int32_t*。

这种强转在技术上只有在指针与适当的宽度(例如 int32 的情况下为 4 字节)对齐时才有效。然而,如果处理不当,大多数现代编译器会比较宽容。请注意,这种对齐方式是由 malloc 保证的(例如 new int32_t[] 会返回 4 字节对齐的缓冲区)或由通用库(例如 numpy)保证,但目前在 Flight 中并不保证(GH-32276)。

我们将此称为“值对齐”,此方法将计算所需的对齐方式。

参数:
  • type_id – 包含缓冲区的数组类型。注意:对于字典数组,这应该是索引类型,因为字典数组的缓冲区是索引;对于扩展数组,它应该是存储类型。

  • buffer_index – 要检查的缓冲区的索引,例如 0 通常会给出有效性(validity)缓冲区所需的对齐方式。

返回:

所需的字节对齐方式(如果不需要对齐,则为 1)

constexpr bool is_integer(const DataType &type)#

检查是否为整数类型(有符号或无符号)

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为整数类型

constexpr bool is_signed_integer(const DataType &type)#

检查是否为有符号整数类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为有符号整数类型

constexpr bool is_unsigned_integer(const DataType &type)#

检查是否为无符号整数类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为无符号整数类型

constexpr bool is_floating(const DataType &type)#

检查是否为浮点类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为浮点类型

constexpr bool is_numeric(const DataType &type)#

检查是否为数值类型(数字,不包括布尔类型)

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为数值类型

constexpr bool is_decimal(const DataType &type)#

检查是否为小数类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为小数类型

constexpr bool is_primitive(const DataType &type)#

检查是否为原始类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为原始类型

constexpr bool is_base_binary_like(const DataType &type)#

检查是否为二进制或类字符串类型(不包括固定大小二进制)

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为二进制或类字符串类型

constexpr bool is_binary_like(const DataType &type)#

检查是否为二进制类类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为二进制类类型

constexpr bool is_large_binary_like(const DataType &type)#

检查是否为大型二进制类类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为大型二进制类类型

constexpr bool is_binary(const DataType &type)#

检查是否为二进制类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为二进制类型

constexpr bool is_string(const DataType &type)#

检查是否为字符串类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为字符串类型

constexpr bool is_binary_view_like(const DataType &type)#

检查是否为类二进制视图类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为类二进制视图类型

constexpr bool is_temporal(const DataType &type)#

检查是否为时间类类型,包括每种单位的时间和时间戳。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为时间类类型

constexpr bool is_interval(const DataType &type)#

检查是否为间隔(interval)类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为间隔类型

constexpr bool is_dictionary(const DataType &type)#

检查是否为字典(dictionary)类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为字典类型

constexpr bool is_fixed_size_binary(const DataType &type)#

检查是否为固定大小二进制类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为固定大小二进制类型

constexpr bool is_fixed_width(const DataType &type)#

检查是否为固定宽度类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为固定宽度类型

constexpr bool is_var_length_list(const DataType &type)#

检查是否为变长列表类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为变长列表类型

constexpr bool is_list_like(const DataType &type)#

检查是否为类列表类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为类列表类型

constexpr bool is_var_length_list_like(const DataType &type)#

检查是否为变长列表或列表视图类类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为变长列表或列表视图类类型

constexpr bool is_list_view(const DataType &type)#

检查是否为列表视图类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为列表视图类型

constexpr bool is_nested(const DataType &type)#

检查是否为嵌套类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为嵌套类型

constexpr bool is_union(const DataType &type)#

检查是否为联合(union)类型。

使用类型 ID 进行检查的便利函数

参数:

type[输入] 要检查的类型

返回:

type 是否为联合类型