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

Status Accept(ScalarVisitor *visitor) const#

Apply the ScalarVisitor::Visit() method specialized to the scalar type.

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)#
explicit BinaryScalar(std::string s)#
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)#
explicit BinaryScalar(std::string s)#
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)#
explicit LargeBinaryScalar(std::string s)#
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)#
explicit LargeBinaryScalar(std::string s)#
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)#
explicit FixedSizeBinaryScalar(const std::shared_ptr<Buffer> &value)#
explicit FixedSizeBinaryScalar(std::string s)#
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 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 arrow::TimeScalar : public arrow::TemporalScalar<T>#
#include <arrow/scalar.h>

Public Functions

inline TimeScalar(typename TemporalScalar<T>::ValueType value, TimeUnit::type unit)#
struct Time32Scalar : public arrow::TimeScalar<Time32Type>#
#include <arrow/scalar.h>
struct Time64Scalar : public arrow::TimeScalar<Time64Type>#
#include <arrow/scalar.h>
struct arrow::TimestampScalar : public arrow::TemporalScalar<TimestampType>#
#include <arrow/scalar.h>

Public Functions

inline TimestampScalar(typename TemporalScalar<TimestampType>::ValueType value, TimeUnit::type unit, std::string tz = "")#
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 arrow::DurationScalar : public arrow::TemporalScalar<DurationType>#
#include <arrow/scalar.h>

Public Functions

inline DurationScalar(typename TemporalScalar<DurationType>::ValueType value, TimeUnit::type unit)#
template<typename TYPE_CLASS, typename VALUE_TYPE>
struct arrow::DecimalScalar : public arrow::internal::PrimitiveScalarBase#
#include <arrow/scalar.h>

Public Types

using TypeClass = TYPE_CLASS#
using ValueType = VALUE_TYPE#

Public Functions

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

Public Members

ValueType value#
struct arrow::Decimal128Scalar : public arrow::DecimalScalar<Decimal128Type, Decimal128>#
#include <arrow/scalar.h>

Public Functions

inline DecimalScalar(ValueType value, std::shared_ptr<DataType> type)#
struct arrow::Decimal256Scalar : public arrow::DecimalScalar<Decimal256Type, Decimal256>#
#include <arrow/scalar.h>

Public Functions

inline DecimalScalar(ValueType value, std::shared_ptr<DataType> type)#
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)#
template<typename Storage, typename = enable_if_t<std::is_base_of<Scalar, Storage>::value>>
inline ExtensionScalar(Storage &&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#

Utilities#

class arrow::ScalarVisitor#

Abstract scalar visitor class.

Subclass this to create a visitor that can be used with the Scalar::Accept() method.

Public Functions

virtual ~ScalarVisitor() = default#
virtual Status Visit(const NullScalar &scalar)#
virtual Status Visit(const BooleanScalar &scalar)#
virtual Status Visit(const Int8Scalar &scalar)#
virtual Status Visit(const Int16Scalar &scalar)#
virtual Status Visit(const Int32Scalar &scalar)#
virtual Status Visit(const Int64Scalar &scalar)#
virtual Status Visit(const UInt8Scalar &scalar)#
virtual Status Visit(const UInt16Scalar &scalar)#
virtual Status Visit(const UInt32Scalar &scalar)#
virtual Status Visit(const UInt64Scalar &scalar)#
virtual Status Visit(const HalfFloatScalar &scalar)#
virtual Status Visit(const FloatScalar &scalar)#
virtual Status Visit(const DoubleScalar &scalar)#
virtual Status Visit(const StringScalar &scalar)#
virtual Status Visit(const BinaryScalar &scalar)#
virtual Status Visit(const LargeStringScalar &scalar)#
virtual Status Visit(const LargeBinaryScalar &scalar)#
virtual Status Visit(const FixedSizeBinaryScalar &scalar)#
virtual Status Visit(const Date64Scalar &scalar)#
virtual Status Visit(const Date32Scalar &scalar)#
virtual Status Visit(const Time32Scalar &scalar)#
virtual Status Visit(const Time64Scalar &scalar)#
virtual Status Visit(const TimestampScalar &scalar)#
virtual Status Visit(const DayTimeIntervalScalar &scalar)#
virtual Status Visit(const MonthDayNanoIntervalScalar &type)#
virtual Status Visit(const MonthIntervalScalar &scalar)#
virtual Status Visit(const DurationScalar &scalar)#
virtual Status Visit(const Decimal128Scalar &scalar)#
virtual Status Visit(const Decimal256Scalar &scalar)#
virtual Status Visit(const ListScalar &scalar)#
virtual Status Visit(const LargeListScalar &scalar)#
virtual Status Visit(const MapScalar &scalar)#
virtual Status Visit(const FixedSizeListScalar &scalar)#
virtual Status Visit(const StructScalar &scalar)#
virtual Status Visit(const DictionaryScalar &scalar)#
virtual Status Visit(const SparseUnionScalar &scalar)#
virtual Status Visit(const DenseUnionScalar &scalar)#
virtual Status Visit(const ExtensionScalar &scalar)#