Scalars

struct arrow::Scalar : public arrow::util::EqualityComparable<Scalar>

Base class for scalar values.

A Scalar represents a single value with a specific DataType. Scalars are useful for passing single value inputs to compute functions, or for representing individual array elements (with a non-trivial wrapping cost, though).

Subclassed by arrow::BaseListScalar, arrow::ExtensionScalar, arrow::internal::PrimitiveScalarBase, arrow::NullScalar, arrow::StructScalar, arrow::UnionScalar

Public Functions

Status Validate() const

Perform cheap validation checks.

This is O(k) where k is the number of descendents.

Returns

Status

Status ValidateFull() const

Perform extensive data validation checks.

This is potentially O(k*n) where k is the number of descendents and n is the length of descendents (if list scalars are involved).

Returns

Status

Public Members

std::shared_ptr<DataType> type

The type of the scalar value.

bool is_valid = false

Whether the value is valid (not null) or not.

struct Hash

Factory functions

std::shared_ptr<Scalar> MakeNullScalar(std::shared_ptr<DataType> type)

Scalar factory for null scalars.

template<typename Value>
Result<std::shared_ptr<Scalar>> MakeScalar(std::shared_ptr<DataType> type, Value &&value)

Scalar factory for non-null scalars.

template<typename Value, typename Traits = CTypeTraits<typename std::decay<Value>::type>, typename ScalarType = typename Traits::ScalarType, typename Enable = decltype(ScalarType(std::declval<Value>(), Traits::type_singleton()))>
std::shared_ptr<Scalar> MakeScalar(Value value)

Type-inferring scalar factory for non-null scalars.

Construct a Scalar instance with a DataType determined by the input C++ type. (for example Int8Scalar for a int8_t input). Only non-parametric primitive types and String are supported.

inline std::shared_ptr<Scalar> MakeScalar(std::string value)

Concrete scalar subclasses

struct arrow::NullScalar : public arrow::Scalar
#include <arrow/scalar.h>

A scalar value for NullType. Never valid.

Public Types

using TypeClass = NullType

Public Functions

inline NullScalar()
struct arrow::BooleanScalar : public arrow::internal::PrimitiveScalar<BooleanType, bool>
#include <arrow/scalar.h>

Public Types

using Base = internal::PrimitiveScalar<BooleanType, bool>

Public Functions

inline explicit BooleanScalar(bool value)
inline BooleanScalar()
template<typename T>
struct arrow::NumericScalar : public arrow::internal::PrimitiveScalar<T>
#include <arrow/scalar.h>

Public Types

using Base = typename internal::PrimitiveScalar<T>
using TypeClass = typename Base::TypeClass
using ValueType = typename Base::ValueType

Public Functions

inline explicit NumericScalar(ValueType value)
inline NumericScalar()
struct Int8Scalar : public arrow::NumericScalar<Int8Type>
#include <arrow/scalar.h>
struct Int16Scalar : public arrow::NumericScalar<Int16Type>
#include <arrow/scalar.h>
struct Int32Scalar : public arrow::NumericScalar<Int32Type>
#include <arrow/scalar.h>
struct Int64Scalar : public arrow::NumericScalar<Int64Type>
#include <arrow/scalar.h>
struct UInt8Scalar : public arrow::NumericScalar<UInt8Type>
#include <arrow/scalar.h>
struct UInt16Scalar : public arrow::NumericScalar<UInt16Type>
#include <arrow/scalar.h>
struct UInt32Scalar : public arrow::NumericScalar<UInt32Type>
#include <arrow/scalar.h>
struct UInt64Scalar : public arrow::NumericScalar<UInt64Type>
#include <arrow/scalar.h>
struct HalfFloatScalar : public arrow::NumericScalar<HalfFloatType>
#include <arrow/scalar.h>
struct FloatScalar : public arrow::NumericScalar<FloatType>
#include <arrow/scalar.h>
struct DoubleScalar : public arrow::NumericScalar<DoubleType>
#include <arrow/scalar.h>
struct arrow::BaseBinaryScalar : public arrow::internal::PrimitiveScalarBase
#include <arrow/scalar.h>

Subclassed by arrow::BinaryScalar, arrow::LargeBinaryScalar

Public Types

using ValueType = std::shared_ptr<Buffer>

Public Functions

inline void *mutable_data() override
inline util::string_view view() const override

Public Members

std::shared_ptr<Buffer> value
struct arrow::BinaryScalar : public arrow::BaseBinaryScalar
#include <arrow/scalar.h>

Subclassed by arrow::FixedSizeBinaryScalar, arrow::StringScalar

Public Types

using TypeClass = BinaryType

Public Functions

inline BinaryScalar(std::shared_ptr<Buffer> value, std::shared_ptr<DataType> type)
inline explicit BinaryScalar(std::shared_ptr<Buffer> value)
inline BinaryScalar()
inline BaseBinaryScalar(std::shared_ptr<Buffer> value, std::shared_ptr<DataType> type)
struct arrow::StringScalar : public arrow::BinaryScalar
#include <arrow/scalar.h>

Public Types

using TypeClass = StringType

Public Functions

inline explicit StringScalar(std::shared_ptr<Buffer> value)
explicit StringScalar(std::string s)
inline StringScalar()
inline BinaryScalar(std::shared_ptr<Buffer> value, std::shared_ptr<DataType> type)
inline explicit BinaryScalar(std::shared_ptr<Buffer> value)
inline BinaryScalar()
struct arrow::LargeBinaryScalar : public arrow::BaseBinaryScalar
#include <arrow/scalar.h>

Subclassed by arrow::LargeStringScalar

Public Types

using TypeClass = LargeBinaryType

Public Functions

inline LargeBinaryScalar(std::shared_ptr<Buffer> value, std::shared_ptr<DataType> type)
inline explicit LargeBinaryScalar(std::shared_ptr<Buffer> value)
inline LargeBinaryScalar()
inline BaseBinaryScalar(std::shared_ptr<Buffer> value, std::shared_ptr<DataType> type)
struct arrow::LargeStringScalar : public arrow::LargeBinaryScalar
#include <arrow/scalar.h>

Public Types

using TypeClass = LargeStringType

Public Functions

inline explicit LargeStringScalar(std::shared_ptr<Buffer> value)
explicit LargeStringScalar(std::string s)
inline LargeStringScalar()
inline LargeBinaryScalar(std::shared_ptr<Buffer> value, std::shared_ptr<DataType> type)
inline explicit LargeBinaryScalar(std::shared_ptr<Buffer> value)
inline LargeBinaryScalar()
struct arrow::FixedSizeBinaryScalar : public arrow::BinaryScalar
#include <arrow/scalar.h>

Public Types

using TypeClass = FixedSizeBinaryType

Public Functions

FixedSizeBinaryScalar(std::shared_ptr<Buffer> value, std::shared_ptr<DataType> type)
inline explicit FixedSizeBinaryScalar(std::shared_ptr<DataType> type)
template<typename T>
struct arrow::TemporalScalar : public arrow::internal::PrimitiveScalar<T>
#include <arrow/scalar.h>

Subclassed by arrow::DateScalar< T >, arrow::IntervalScalar< T >, arrow::TimeScalar< T >

Public Types

using ValueType = typename TemporalScalar<T>::ValueType

Public Functions

inline explicit TemporalScalar(ValueType value, std::shared_ptr<DataType> type)
template<typename T>
struct arrow::DateScalar : public arrow::TemporalScalar<T>
#include <arrow/scalar.h>

Public Types

using ValueType = typename TemporalScalar<T>::ValueType

Public Functions

inline explicit DateScalar(ValueType value)
inline DateScalar()
struct Date32Scalar : public arrow::DateScalar<Date32Type>
#include <arrow/scalar.h>
struct Date64Scalar : public arrow::DateScalar<Date64Type>
#include <arrow/scalar.h>
template<typename T>
struct TimeScalar : public arrow::TemporalScalar<T>
#include <arrow/scalar.h>
struct Time32Scalar : public arrow::TimeScalar<Time32Type>
#include <arrow/scalar.h>
struct Time64Scalar : public arrow::TimeScalar<Time64Type>
#include <arrow/scalar.h>
struct TimestampScalar : public arrow::TemporalScalar<TimestampType>
#include <arrow/scalar.h>
template<typename T>
struct arrow::IntervalScalar : public arrow::TemporalScalar<T>
#include <arrow/scalar.h>

Public Types

using ValueType = typename TemporalScalar<T>::ValueType

Public Functions

inline explicit IntervalScalar(ValueType value)
inline IntervalScalar()
struct MonthIntervalScalar : public arrow::IntervalScalar<MonthIntervalType>
#include <arrow/scalar.h>
struct DayTimeIntervalScalar : public arrow::IntervalScalar<DayTimeIntervalType>
#include <arrow/scalar.h>
struct MonthDayNanoIntervalScalar : public arrow::IntervalScalar<MonthDayNanoIntervalType>
#include <arrow/scalar.h>
struct DurationScalar : public arrow::TemporalScalar<DurationType>
#include <arrow/scalar.h>
struct arrow::Decimal128Scalar : public arrow::internal::PrimitiveScalarBase
#include <arrow/scalar.h>

Public Types

using TypeClass = Decimal128Type
using ValueType = Decimal128

Public Functions

inline Decimal128Scalar(Decimal128 value, std::shared_ptr<DataType> type)
inline void *mutable_data() override
inline util::string_view view() const override

Public Members

Decimal128 value
struct arrow::Decimal256Scalar : public arrow::internal::PrimitiveScalarBase
#include <arrow/scalar.h>

Public Types

using TypeClass = Decimal256Type
using ValueType = Decimal256

Public Functions

inline Decimal256Scalar(Decimal256 value, std::shared_ptr<DataType> type)
inline void *mutable_data() override
inline util::string_view view() const override

Public Members

Decimal256 value
struct arrow::BaseListScalar : public arrow::Scalar
#include <arrow/scalar.h>

Subclassed by arrow::FixedSizeListScalar, arrow::LargeListScalar, arrow::ListScalar, arrow::MapScalar

Public Types

using ValueType = std::shared_ptr<Array>

Public Functions

BaseListScalar(std::shared_ptr<Array> value, std::shared_ptr<DataType> type)
inline explicit Scalar(std::shared_ptr<DataType> type)
inline Scalar(std::shared_ptr<DataType> type, bool is_valid)

Public Members

std::shared_ptr<Array> value
struct arrow::ListScalar : public arrow::BaseListScalar
#include <arrow/scalar.h>

Public Types

using TypeClass = ListType

Public Functions

explicit ListScalar(std::shared_ptr<Array> value)
BaseListScalar(std::shared_ptr<Array> value, std::shared_ptr<DataType> type)
struct arrow::LargeListScalar : public arrow::BaseListScalar
#include <arrow/scalar.h>

Public Types

using TypeClass = LargeListType

Public Functions

explicit LargeListScalar(std::shared_ptr<Array> value)
BaseListScalar(std::shared_ptr<Array> value, std::shared_ptr<DataType> type)
struct arrow::MapScalar : public arrow::BaseListScalar
#include <arrow/scalar.h>

Public Types

using TypeClass = MapType

Public Functions

explicit MapScalar(std::shared_ptr<Array> value)
BaseListScalar(std::shared_ptr<Array> value, std::shared_ptr<DataType> type)
struct arrow::FixedSizeListScalar : public arrow::BaseListScalar
#include <arrow/scalar.h>

Public Types

using TypeClass = FixedSizeListType

Public Functions

FixedSizeListScalar(std::shared_ptr<Array> value, std::shared_ptr<DataType> type)
explicit FixedSizeListScalar(std::shared_ptr<Array> value)
BaseListScalar(std::shared_ptr<Array> value, std::shared_ptr<DataType> type)
struct arrow::StructScalar : public arrow::Scalar
#include <arrow/scalar.h>

Public Types

using TypeClass = StructType
using ValueType = std::vector<std::shared_ptr<Scalar>>

Public Functions

Result<std::shared_ptr<Scalar>> field(FieldRef ref) const
inline StructScalar(ValueType value, std::shared_ptr<DataType> type)
inline explicit StructScalar(std::shared_ptr<DataType> type)

Public Members

ScalarVector value

Public Static Functions

static Result<std::shared_ptr<StructScalar>> Make(ValueType value, std::vector<std::string> field_names)
struct arrow::UnionScalar : public arrow::Scalar
#include <arrow/scalar.h>

Subclassed by arrow::DenseUnionScalar, arrow::SparseUnionScalar

Public Types

using ValueType = std::shared_ptr<Scalar>

Public Functions

inline UnionScalar(int8_t type_code, std::shared_ptr<DataType> type)
inline UnionScalar(ValueType value, int8_t type_code, std::shared_ptr<DataType> type)
inline explicit Scalar(std::shared_ptr<DataType> type)
inline Scalar(std::shared_ptr<DataType> type, bool is_valid)

Public Members

ValueType value
int8_t type_code
struct arrow::SparseUnionScalar : public arrow::UnionScalar
#include <arrow/scalar.h>

Public Types

using TypeClass = SparseUnionType

Public Functions

inline UnionScalar(int8_t type_code, std::shared_ptr<DataType> type)
inline UnionScalar(ValueType value, int8_t type_code, std::shared_ptr<DataType> type)
struct arrow::DenseUnionScalar : public arrow::UnionScalar
#include <arrow/scalar.h>

Public Types

using TypeClass = DenseUnionType

Public Functions

inline UnionScalar(int8_t type_code, std::shared_ptr<DataType> type)
inline UnionScalar(ValueType value, int8_t type_code, std::shared_ptr<DataType> type)
struct arrow::DictionaryScalar : public arrow::internal::PrimitiveScalarBase
#include <arrow/scalar.h>

A Scalar value for DictionaryType.

is_valid denotes the validity of the index, regardless of the corresponding value in the dictionary.

Public Types

using TypeClass = DictionaryType

Public Functions

explicit DictionaryScalar(std::shared_ptr<DataType> type)
inline DictionaryScalar(ValueType value, std::shared_ptr<DataType> type, bool is_valid = true)
Result<std::shared_ptr<Scalar>> GetEncodedValue() const
inline void *mutable_data() override
inline util::string_view view() const override

Public Members

struct arrow::DictionaryScalar::ValueType value

Public Static Functions

static std::shared_ptr<DictionaryScalar> Make(std::shared_ptr<Scalar> index, std::shared_ptr<Array> dict)
struct ValueType
#include <arrow/scalar.h>

Public Members

std::shared_ptr<Scalar> index
std::shared_ptr<Array> dictionary
struct arrow::ExtensionScalar : public arrow::Scalar
#include <arrow/scalar.h>

A Scalar value for ExtensionType.

The value is the underlying storage scalar. is_valid must only be true if value is non-null and value->is_valid is true

Public Types

using TypeClass = ExtensionType
using ValueType = std::shared_ptr<Scalar>

Public Functions

inline ExtensionScalar(std::shared_ptr<Scalar> storage, std::shared_ptr<DataType> type)
inline explicit Scalar(std::shared_ptr<DataType> type)
inline Scalar(std::shared_ptr<DataType> type, bool is_valid)

Public Members

std::shared_ptr<Scalar> value