Apache Arrow (C++)
A columnar in-memory analytics layer designed to accelerate big data.
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
arrow::ArrayBuilder Class Referenceabstract

Base class for all data array builders. More...

#include <arrow/builder.h>

Inheritance diagram for arrow::ArrayBuilder:
arrow::BinaryBuilder arrow::BooleanBuilder arrow::DictionaryBuilder< T > arrow::DictionaryBuilder< NullType > arrow::FixedSizeBinaryBuilder arrow::ListBuilder arrow::NullBuilder arrow::PrimitiveBuilder< Type > arrow::StructBuilder arrow::DictionaryBuilder< BinaryType > arrow::DictionaryBuilder< StringType > arrow::PrimitiveBuilder< T >

Public Member Functions

 ArrayBuilder (const std::shared_ptr< DataType > &type, MemoryPool *pool)
 
virtual ~ArrayBuilder ()=default
 
ArrayBuilderchild (int i)
 For nested types. More...
 
int num_children () const
 
int64_t length () const
 
int64_t null_count () const
 
int64_t capacity () const
 
Status AppendToBitmap (bool is_valid)
 Append to null bitmap. More...
 
Status AppendToBitmap (const uint8_t *valid_bytes, int64_t length)
 Vector append. More...
 
Status SetNotNull (int64_t length)
 Set the next length bits to not null (i.e. valid). More...
 
virtual Status Resize (int64_t capacity)
 Ensure that enough memory has been allocated to fit the indicated number of total elements in the builder, including any that have already been appended. More...
 
Status Reserve (int64_t additional_capacity)
 Ensure that there is enough space allocated to add the indicated number of elements without any further calls to Resize. More...
 
virtual void Reset ()
 Reset the builder. More...
 
Status Advance (int64_t elements)
 For cases where raw data was memcpy'd into the internal buffers, allows us to advance the length of the builder. More...
 
virtual Status FinishInternal (std::shared_ptr< ArrayData > *out)=0
 Return result of builder as an internal generic ArrayData object. More...
 
Status Finish (std::shared_ptr< Array > *out)
 Return result of builder as an Array object. More...
 
std::shared_ptr< DataTypetype () const
 
void UnsafeAppendToBitmap (bool is_valid)
 
template<typename IterType >
void UnsafeAppendToBitmap (const IterType &begin, const IterType &end)
 

Protected Member Functions

 ArrayBuilder ()
 
void UnsafeAppendToBitmap (const uint8_t *valid_bytes, int64_t length)
 
void UnsafeAppendToBitmap (const std::vector< bool > &is_valid)
 
void UnsafeSetNotNull (int64_t length)
 

Protected Attributes

std::shared_ptr< DataTypetype_
 
MemoryPoolpool_
 
std::shared_ptr< ResizableBuffernull_bitmap_
 
int64_t null_count_
 
uint8_t * null_bitmap_data_
 
int64_t length_
 
int64_t capacity_
 
std::vector< std::unique_ptr< ArrayBuilder > > children_
 

Detailed Description

Base class for all data array builders.

This class provides a facilities for incrementally building the null bitmap (see Append methods) and as a side effect the current number of slots and the null count.

Constructor & Destructor Documentation

◆ ArrayBuilder() [1/2]

arrow::ArrayBuilder::ArrayBuilder ( const std::shared_ptr< DataType > &  type,
MemoryPool pool 
)
inlineexplicit

◆ ~ArrayBuilder()

virtual arrow::ArrayBuilder::~ArrayBuilder ( )
virtualdefault

◆ ArrayBuilder() [2/2]

arrow::ArrayBuilder::ArrayBuilder ( )
inlineprotected

Member Function Documentation

◆ Advance()

Status arrow::ArrayBuilder::Advance ( int64_t  elements)

For cases where raw data was memcpy'd into the internal buffers, allows us to advance the length of the builder.

It is your responsibility to use this function responsibly.

◆ AppendToBitmap() [1/2]

Status arrow::ArrayBuilder::AppendToBitmap ( bool  is_valid)

Append to null bitmap.

◆ AppendToBitmap() [2/2]

Status arrow::ArrayBuilder::AppendToBitmap ( const uint8_t *  valid_bytes,
int64_t  length 
)

Vector append.

Treat each zero byte as a null. If valid_bytes is null assume all of length bits are valid.

◆ capacity()

int64_t arrow::ArrayBuilder::capacity ( ) const
inline

◆ child()

ArrayBuilder* arrow::ArrayBuilder::child ( int  i)
inline

For nested types.

Since the objects are owned by this class instance, we skip shared pointers and just return a raw pointer

◆ Finish()

Status arrow::ArrayBuilder::Finish ( std::shared_ptr< Array > *  out)

Return result of builder as an Array object.

Resets the builder except for DictionaryBuilder

Parameters
[out]outthe finalized Array object
Returns
Status

◆ FinishInternal()

virtual Status arrow::ArrayBuilder::FinishInternal ( std::shared_ptr< ArrayData > *  out)
pure virtual

◆ length()

int64_t arrow::ArrayBuilder::length ( ) const
inline

◆ null_count()

int64_t arrow::ArrayBuilder::null_count ( ) const
inline

◆ num_children()

int arrow::ArrayBuilder::num_children ( ) const
inline

◆ Reserve()

Status arrow::ArrayBuilder::Reserve ( int64_t  additional_capacity)

Ensure that there is enough space allocated to add the indicated number of elements without any further calls to Resize.

The memory allocated is rounded up to the next highest power of 2 similar to memory allocations in STL containers like std::vector

Parameters
[in]additional_capacitythe number of additional array values
Returns
Status

◆ Reset()

virtual void arrow::ArrayBuilder::Reset ( )
virtual

◆ Resize()

virtual Status arrow::ArrayBuilder::Resize ( int64_t  capacity)
virtual

Ensure that enough memory has been allocated to fit the indicated number of total elements in the builder, including any that have already been appended.

Does not account for reallocations that may be due to variable size data, like binary values. To make space for incremental appends, use Reserve instead.

Parameters
[in]capacitythe minimum number of additional array values
Returns
Status

Reimplemented in arrow::DictionaryBuilder< NullType >, arrow::DictionaryBuilder< T >, arrow::DictionaryBuilder< StringType >, arrow::DictionaryBuilder< BinaryType >, arrow::FixedSizeBinaryBuilder, arrow::BinaryBuilder, arrow::ListBuilder, arrow::BooleanBuilder, arrow::PrimitiveBuilder< Type >, and arrow::PrimitiveBuilder< T >.

◆ SetNotNull()

Status arrow::ArrayBuilder::SetNotNull ( int64_t  length)

Set the next length bits to not null (i.e. valid).

◆ type()

std::shared_ptr<DataType> arrow::ArrayBuilder::type ( ) const
inline

◆ UnsafeAppendToBitmap() [1/4]

void arrow::ArrayBuilder::UnsafeAppendToBitmap ( bool  is_valid)
inline

◆ UnsafeAppendToBitmap() [2/4]

template<typename IterType >
void arrow::ArrayBuilder::UnsafeAppendToBitmap ( const IterType &  begin,
const IterType &  end 
)
inline

◆ UnsafeAppendToBitmap() [3/4]

void arrow::ArrayBuilder::UnsafeAppendToBitmap ( const uint8_t *  valid_bytes,
int64_t  length 
)
protected

◆ UnsafeAppendToBitmap() [4/4]

void arrow::ArrayBuilder::UnsafeAppendToBitmap ( const std::vector< bool > &  is_valid)
protected

◆ UnsafeSetNotNull()

void arrow::ArrayBuilder::UnsafeSetNotNull ( int64_t  length)
protected

Member Data Documentation

◆ capacity_

int64_t arrow::ArrayBuilder::capacity_
protected

◆ children_

std::vector<std::unique_ptr<ArrayBuilder> > arrow::ArrayBuilder::children_
protected

◆ length_

int64_t arrow::ArrayBuilder::length_
protected

◆ null_bitmap_

std::shared_ptr<ResizableBuffer> arrow::ArrayBuilder::null_bitmap_
protected

◆ null_bitmap_data_

uint8_t* arrow::ArrayBuilder::null_bitmap_data_
protected

◆ null_count_

int64_t arrow::ArrayBuilder::null_count_
protected

◆ pool_

MemoryPool* arrow::ArrayBuilder::pool_
protected

◆ type_

std::shared_ptr<DataType> arrow::ArrayBuilder::type_
protected

The documentation for this class was generated from the following file: