Awkward Array: include/awkward/builder/Builder.h Source File

Loading...
Searching...
No Matches
Builder.h
Go to the documentation of this file.
1// BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE
2
3#ifndef AWKWARD_FILLABLE_H_
4#define AWKWARD_FILLABLE_H_
5
6#include <complex>
7#include <string>
8#include <vector>
9
10#include "awkward/common.h"
11
12namespace awkward {
13 class Builder;
14 using BuilderPtr = std::shared_ptr<Builder>;
15
20 class BuffersContainer {
21 public:
26 virtual void
27 copy_buffer(const std::string& name, const void* source, int64_t num_bytes) = 0;
28
30 virtual void
31 full_buffer(const std::string& name, int64_t length, int64_t value, const std::string& dtype) = 0;
32
33 virtual void*
34 empty_buffer(const std::string& name, int64_t num_bytes) = 0;
35 };
36
41 class LIBAWKWARD_EXPORT_SYMBOL Builder: public std::enable_shared_from_this<Builder> {
42 public:
46 virtual ~Builder();
47
49 virtual const std::string
50 classname() const = 0;
51
54 virtual const std::string
55 to_buffers(BuffersContainer& container, int64_t& form_key_id) const = 0;
56
58 virtual int64_t
59 length() const = 0;
60
63 virtual void
64 clear() = 0;
65
68 virtual bool
69 active() const = 0;
70
72 virtual const BuilderPtr
73 null() = 0;
74
76 virtual const BuilderPtr
77 boolean(bool x) = 0;
78
80 virtual const BuilderPtr
81 integer(int64_t x) = 0;
82
84 virtual const BuilderPtr
85 real(double x) = 0;
86
88 virtual const BuilderPtr
89 complex(std::complex<double> x) = 0;
90
92 virtual const BuilderPtr
93 datetime(int64_t x, const std::string& unit) = 0;
94
96 virtual const BuilderPtr
97 timedelta(int64_t x, const std::string& unit) = 0;
98
108 virtual const BuilderPtr
109 string(const char* x, int64_t length, const char* encoding) = 0;
110
112 virtual const BuilderPtr
113 beginlist() = 0;
114
116 virtual const BuilderPtr
117 endlist() = 0;
118
120 virtual const BuilderPtr
121 begintuple(int64_t numfields) = 0;
122
125 virtual const BuilderPtr
126 index(int64_t index) = 0;
127
129 virtual const BuilderPtr
130 endtuple() = 0;
131
143 virtual const BuilderPtr
144 beginrecord(const char* name, bool check) = 0;
145
157 virtual void
158 field(const char* key, bool check) = 0;
159
161 virtual const BuilderPtr
162 endrecord() = 0;
163 };
164}
165
166#endif // AWKWARD_FILLABLE_H_
awkward::BuffersContainer
Abstract class to represent the output of ak.to_buffers. In Python, this would be a dict of NumPy arr...
Definition: Builder.h:20
awkward::BuffersContainer::full_buffer
virtual void full_buffer(const std::string &name, int64_t length, int64_t value, const std::string &dtype)=0
Create an array initialized to a given fill value.
awkward::BuffersContainer::empty_buffer
virtual void * empty_buffer(const std::string &name, int64_t num_bytes)=0
awkward::BuffersContainer::copy_buffer
virtual void copy_buffer(const std::string &name, const void *source, int64_t num_bytes)=0
Copy data at source with num_bytes into the BuffersContainer with name.
awkward::Builder
Abstract base class for nodes within an ArrayBuilder that cumulatively discover an array's type and f...
Definition: Builder.h:41
awkward::Builder::integer
virtual const BuilderPtr integer(int64_t x)=0
Adds an integer value x to the accumulated data.
awkward::Builder::~Builder
virtual ~Builder()
Virtual destructor acts as a first non-inline virtual function that determines a specific translation...
awkward::Builder::to_buffers
virtual const std::string to_buffers(BuffersContainer &container, int64_t &form_key_id) const =0
Copy the current snapshot into the BuffersContainer and return a Form as a std::string (JSON).
awkward::Builder::field
virtual void field(const char *key, bool check)=0
Sets the pointer to a given record field key; the next command will fill that slot.
awkward::Builder::datetime
virtual const BuilderPtr datetime(int64_t x, const std::string &unit)=0
Adds a datetime value x to the accumulated data.
awkward::Builder::endlist
virtual const BuilderPtr endlist()=0
Ends a nested list.
awkward::Builder::clear
virtual void clear()=0
Removes all accumulated data without resetting the type knowledge.
awkward::Builder::active
virtual bool active() const =0
If true, this node has started but has not finished a multi-step command (e.g. beginX ....
awkward::Builder::beginlist
virtual const BuilderPtr beginlist()=0
Begins building a nested list.
awkward::Builder::string
virtual const BuilderPtr string(const char *x, int64_t length, const char *encoding)=0
Adds a string value x with a given length and encoding to the accumulated data.
awkward::Builder::null
virtual const BuilderPtr null()=0
Adds a null value to the accumulated data.
awkward::Builder::endtuple
virtual const BuilderPtr endtuple()=0
Ends a tuple.
awkward::Builder::classname
virtual const std::string classname() const =0
User-friendly name of this class.
awkward::Builder::timedelta
virtual const BuilderPtr timedelta(int64_t x, const std::string &unit)=0
Adds a timedelta value x to the accumulated data.
awkward::Builder::complex
virtual const BuilderPtr complex(std::complex< double > x)=0
Adds a complex value x to the accumulated data.
awkward::Builder::index
virtual const BuilderPtr index(int64_t index)=0
Sets the pointer to a given tuple field index; the next command will fill that slot.
awkward::Builder::beginrecord
virtual const BuilderPtr beginrecord(const char *name, bool check)=0
Begins building a record with an optional name.
awkward::Builder::begintuple
virtual const BuilderPtr begintuple(int64_t numfields)=0
Begins building a tuple with a fixed number of fields.
awkward::Builder::boolean
virtual const BuilderPtr boolean(bool x)=0
Adds a boolean value x to the accumulated data.
awkward::Builder::endrecord
virtual const BuilderPtr endrecord()=0
Ends a record.
awkward::Builder::length
virtual int64_t length() const =0
Current length of the accumulated array.
awkward::Builder::real
virtual const BuilderPtr real(double x)=0
Adds a real value x to the accumulated data.
common.h
LIBAWKWARD_EXPORT_SYMBOL
#define LIBAWKWARD_EXPORT_SYMBOL
Definition: common.h:45
awkward
Definition: BitMaskedArray.h:15
awkward::BuilderPtr
std::shared_ptr< Builder > BuilderPtr
Definition: ArrayBuilder.h:16