ArrayBuilder Class Reference

User interface to the Builder system: the ArrayBuilder is a fixed reference while the Builder subclass instances change in response to accumulating data. More...

#include <ArrayBuilder.h>

Public Member Functions

 ArrayBuilder (const ArrayBuilderOptions &options)
 Creates an ArrayBuilder from a full set of parameters. More...
 
const std::string to_buffers (BuffersContainer &container, int64_t &form_key_id) const
 Copy the current snapshot into the BuffersContainer and return a Form as a std::string (JSON). More...
 
int64_t length () const
 Current length of the accumulated array. More...
 
void clear ()
 Removes all accumulated data without resetting the type knowledge. More...
 
void null ()
 Adds a null value to the accumulated data. More...
 
void boolean (bool x)
 Adds a boolean value x to the accumulated data. More...
 
void integer (int64_t x)
 Adds an integer value x to the accumulated data. More...
 
void real (double x)
 Adds a real value x to the accumulated data. More...
 
void complex (std::complex< double > x)
 Adds a complex value x to the accumulated data. More...
 
void datetime (int64_t x, const std::string &unit)
 Adds a datetime value x to the accumulated data. More...
 
void timedelta (int64_t x, const std::string &unit)
 Adds a timedelta value x to the accumulated data. More...
 
void bytestring (const char *x)
 Adds an unencoded, null-terminated bytestring value x to the accumulated data. More...
 
void bytestring (const char *x, int64_t length)
 Adds an unencoded bytestring value x with a given length to the accumulated data. More...
 
void bytestring (const std::string &x)
 Adds an unencoded bytestring x in STL format to the accumulated data. More...
 
void string (const char *x)
 Adds a UTF-8 encoded, null-terminated bytestring value x to the accumulated data. More...
 
void string (const char *x, int64_t length)
 Adds a UTF-8 encoded bytestring value x with a given length to the accumulated data. More...
 
void string (const std::string &x)
 Adds a UTF-8 encoded bytestring x in STL format to the accumulated data. More...
 
void beginlist ()
 Begins building a nested list. More...
 
void endlist ()
 Ends a nested list. More...
 
void begintuple (int64_t numfields)
 Begins building a tuple with a fixed number of fields. More...
 
void index (int64_t index)
 Sets the pointer to a given tuple field index; the next command will fill that slot. More...
 
void endtuple ()
 Ends a tuple. More...
 
void beginrecord ()
 Begins building a record without a name. More...
 
void beginrecord_fast (const char *name)
 Begins building a record with a name. More...
 
void beginrecord_check (const char *name)
 Begins building a record with a name. More...
 
void beginrecord_check (const std::string &name)
 Begins building a record with a name. More...
 
void field_fast (const char *key)
 Sets the pointer to a given record field key; the next command will fill that slot. More...
 
void field_check (const char *key)
 Sets the pointer to a given record field key; the next command will fill that slot. More...
 
void field_check (const std::string &key)
 Sets the pointer to a given record field key; the next command will fill that slot. More...
 
void endrecord ()
 Ends a record. More...
 
const BuilderPtr builder () const
 
void builder_update (BuilderPtr builder)
 
void maybeupdate (const BuilderPtr builder)
 Internal function to replace the root node of the ArrayBuilder's Builder tree with a new root. More...
 

Detailed Description

User interface to the Builder system: the ArrayBuilder is a fixed reference while the Builder subclass instances change in response to accumulating data.

Constructor & Destructor Documentation

◆ ArrayBuilder()

ArrayBuilder ( const ArrayBuilderOptions options)

Creates an ArrayBuilder from a full set of parameters.

Parameters
optionsConfiguration options for building an array; these are passed to every Builder's constructor.

Member Function Documentation

◆ beginlist()

void beginlist ( )

Begins building a nested list.

◆ beginrecord()

void beginrecord ( )

Begins building a record without a name.

See beginrecord_fast and beginrecord_check.

◆ beginrecord_check() [1/2]

void beginrecord_check ( const char *  name)

Begins building a record with a name.

Parameters
nameThis name is used to distinguish records of different types in heterogeneous data (to build a union of record arrays, rather than a record array with union fields and optional values) and it also sets the "__record__" parameter to later add custom behaviors in Python.

In the _check version of this method, a string comparison is performed every time it is called to verify that the name matches a stored name.

See beginrecord and beginrecord_fast.

◆ beginrecord_check() [2/2]

void beginrecord_check ( const std::string &  name)

Begins building a record with a name.

Parameters
nameThis name is used to distinguish records of different types in heterogeneous data (to build a union of record arrays, rather than a record array with union fields and optional values) and it also sets the "__record__" parameter to later add custom behaviors in Python.

In the _check version of this method, a string comparison is performed every time it is called to verify that the name matches a stored name.

See beginrecord and beginrecord_fast.

◆ beginrecord_fast()

void beginrecord_fast ( const char *  name)

Begins building a record with a name.

Parameters
nameThis name is used to distinguish records of different types in heterogeneous data (to build a union of record arrays, rather than a record array with union fields and optional values) and it also sets the "__record__" parameter to later add custom behaviors in Python.

In the _fast version of this method, a string comparison is not performed: the same pointer is assumed to have the same value each time (safe for string literals).

See beginrecord and beginrecord_check.

◆ begintuple()

void begintuple ( int64_t  numfields)

Begins building a tuple with a fixed number of fields.

◆ boolean()

void boolean ( bool  x)

Adds a boolean value x to the accumulated data.

◆ builder()

const BuilderPtr builder ( ) const
inline

◆ builder_update()

void builder_update ( BuilderPtr  builder)
inline

◆ bytestring() [1/3]

void bytestring ( const char *  x)

Adds an unencoded, null-terminated bytestring value x to the accumulated data.

◆ bytestring() [2/3]

void bytestring ( const char *  x,
int64_t  length 
)

Adds an unencoded bytestring value x with a given length to the accumulated data.

The string does not need to be null-terminated.

◆ bytestring() [3/3]

void bytestring ( const std::string &  x)

Adds an unencoded bytestring x in STL format to the accumulated data.

◆ clear()

void clear ( )

Removes all accumulated data without resetting the type knowledge.

◆ complex()

void complex ( std::complex< double >  x)

Adds a complex value x to the accumulated data.

◆ datetime()

void datetime ( int64_t  x,
const std::string &  unit 
)

Adds a datetime value x to the accumulated data.

◆ endlist()

void endlist ( )

Ends a nested list.

◆ endrecord()

void endrecord ( )

Ends a record.

◆ endtuple()

void endtuple ( )

Ends a tuple.

◆ field_check() [1/2]

void field_check ( const char *  key)

Sets the pointer to a given record field key; the next command will fill that slot.

In the _check version of this method, a string comparison is performed every time it is called to verify that the key matches a stored key. See field_fast.

Record keys are checked in round-robin order. The best performance will be achieved by filling them in the same order for each record. Lookup time for random order scales with the number of fields.

◆ field_check() [2/2]

void field_check ( const std::string &  key)

Sets the pointer to a given record field key; the next command will fill that slot.

In the _check version of this method, a string comparison is performed every time it is called to verify that the key matches a stored key. See field_fast.

Record keys are checked in round-robin order. The best performance will be achieved by filling them in the same order for each record. Lookup time for random order scales with the number of fields.

◆ field_fast()

void field_fast ( const char *  key)

Sets the pointer to a given record field key; the next command will fill that slot.

In the _fast version of this method, a string comparison is not performed: the same pointer is assumed to have the same value each time (safe for string literals). See field_check.

Record keys are checked in round-robin order. The best performance will be achieved by filling them in the same order for each record. Lookup time for random order scales with the number of fields.

◆ index()

void index ( int64_t  index)

Sets the pointer to a given tuple field index; the next command will fill that slot.

◆ integer()

void integer ( int64_t  x)

Adds an integer value x to the accumulated data.

◆ length()

int64_t length ( ) const

Current length of the accumulated array.

◆ maybeupdate()

void maybeupdate ( const BuilderPtr  builder)

Internal function to replace the root node of the ArrayBuilder's Builder tree with a new root.

◆ null()

void null ( )

Adds a null value to the accumulated data.

◆ real()

void real ( double  x)

Adds a real value x to the accumulated data.

◆ string() [1/3]

void string ( const char *  x)

Adds a UTF-8 encoded, null-terminated bytestring value x to the accumulated data.

◆ string() [2/3]

void string ( const char *  x,
int64_t  length 
)

Adds a UTF-8 encoded bytestring value x with a given length to the accumulated data.

The string does not need to be null-terminated.

◆ string() [3/3]

void string ( const std::string &  x)

Adds a UTF-8 encoded bytestring x in STL format to the accumulated data.

◆ timedelta()

void timedelta ( int64_t  x,
const std::string &  unit 
)

Adds a timedelta value x to the accumulated data.

◆ to_buffers()

const std::string to_buffers ( BuffersContainer container,
int64_t &  form_key_id 
) const

Copy the current snapshot into the BuffersContainer and return a Form as a std::string (JSON).


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