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

Loading...
Searching...
No Matches
RecordBuilder.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_RECORDBUILDER_H_
4#define AWKWARD_RECORDBUILDER_H_
5
6#include <vector>
7
8#include "awkward/common.h"
9#include "awkward/BuilderOptions.h"
10#include "awkward/GrowableBuffer.h"
11#include "awkward/builder/Builder.h"
12
13namespace awkward {
14
18 class LIBAWKWARD_EXPORT_SYMBOL RecordBuilder: public Builder {
19 public:
23 static const BuilderPtr
24 fromempty(const BuilderOptions& options);
25
40 RecordBuilder(const BuilderOptions& options,
41 const std::vector<BuilderPtr>& contents,
42 const std::vector<std::string>& keys,
43 const std::vector<const char*>& pointers,
44 const std::string& name,
45 const char* nameptr,
46 int64_t length,
47 bool begun,
48 int64_t nextindex,
49 int64_t nexttotry);
50
52 const std::string
53 name() const;
54
56 const char*
57 nameptr() const;
58
60 const std::string
61 classname() const override;
62
63 const std::string
64 to_buffers(BuffersContainer& container, int64_t& form_key_id) const override;
65
66 int64_t
67 length() const override;
68
69 void
70 clear() override;
71
76 bool
77 active() const override;
78
79 const BuilderPtr
80 null() override;
81
82 const BuilderPtr
83 boolean(bool x) override;
84
85 const BuilderPtr
86 integer(int64_t x) override;
87
88 const BuilderPtr
89 real(double x) override;
90
91 const BuilderPtr
92 complex(std::complex<double> x) override;
93
94 const BuilderPtr
95 datetime(int64_t x, const std::string& unit) override;
96
97 const BuilderPtr
98 timedelta(int64_t x, const std::string& unit) override;
99
100 const BuilderPtr
101 string(const char* x, int64_t length, const char* encoding) override;
102
103 const BuilderPtr
104 beginlist() override;
105
106 const BuilderPtr
107 endlist() override;
108
109 const BuilderPtr
110 begintuple(int64_t numfields) override;
111
112 const BuilderPtr
113 index(int64_t index) override;
114
115 const BuilderPtr
116 endtuple() override;
117
118 const BuilderPtr
119 beginrecord(const char* name, bool check) override;
120
121 void
122 field(const char* key, bool check) override;
123
124 const BuilderPtr
125 endrecord() override;
126
127 const BuilderOptions&
128 options() const { return options_; }
129
130 const std::vector<std::string>& keys() const { return keys_; }
131
132 const std::vector<BuilderPtr>& builders() const { return contents_; }
133
134 bool begun() { return begun_; }
135
136 int64_t nextindex() { return nextindex_; }
137
138 void
139 maybeupdate(int64_t i, const BuilderPtr builder);
140
141 private:
142 void
143 field_fast(const char* key);
144
145 void
146 field_check(const char* key);
147
148 const BuilderOptions options_;
149 std::vector<BuilderPtr> contents_;
150 std::vector<std::string> keys_;
151 std::vector<const char*> pointers_;
152 std::string name_;
153 const char* nameptr_;
154 int64_t length_;
155 bool begun_;
156 int64_t nextindex_;
157 int64_t nexttotry_;
158 int64_t keys_size_;
159 };
160}
161
162#endif // AWKWARD_RECORDBUILDER_H_
BuilderOptions.h
Builder.h
GrowableBuffer.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::Builder
Abstract base class for nodes within an ArrayBuilder that cumulatively discover an array's type and f...
Definition: Builder.h:41
awkward::RecordBuilder
Builder node for accumulated records.
Definition: RecordBuilder.h:18
awkward::RecordBuilder::nameptr
const char * nameptr() const
String pointer for the name of the record.
awkward::RecordBuilder::nextindex
int64_t nextindex()
Definition: RecordBuilder.h:136
awkward::RecordBuilder::real
const BuilderPtr real(double x) override
Adds a real value x to the accumulated data.
awkward::RecordBuilder::endlist
const BuilderPtr endlist() override
Ends a nested list.
awkward::RecordBuilder::fromempty
static const BuilderPtr fromempty(const BuilderOptions &options)
Create an empty RecordBuilder.
awkward::RecordBuilder::timedelta
const BuilderPtr timedelta(int64_t x, const std::string &unit) override
Adds a timedelta value x to the accumulated data.
awkward::RecordBuilder::field
void field(const char *key, bool check) override
Sets the pointer to a given record field key; the next command will fill that slot.
awkward::RecordBuilder::complex
const BuilderPtr complex(std::complex< double > x) override
Adds a complex value x to the accumulated data.
awkward::RecordBuilder::builders
const std::vector< BuilderPtr > & builders() const
Definition: RecordBuilder.h:132
awkward::RecordBuilder::index
const BuilderPtr index(int64_t index) override
Sets the pointer to a given tuple field index; the next command will fill that slot.
awkward::RecordBuilder::length
int64_t length() const override
Current length of the accumulated array.
awkward::RecordBuilder::endrecord
const BuilderPtr endrecord() override
Ends a record.
awkward::RecordBuilder::active
bool active() const override
If true, this node has started but has not finished a multi-step command (e.g. beginX ....
awkward::RecordBuilder::string
const BuilderPtr string(const char *x, int64_t length, const char *encoding) override
Adds a string value x with a given length and encoding to the accumulated data.
awkward::RecordBuilder::options
const BuilderOptions & options() const
Definition: RecordBuilder.h:128
awkward::RecordBuilder::keys
const std::vector< std::string > & keys() const
Definition: RecordBuilder.h:130
awkward::RecordBuilder::maybeupdate
void maybeupdate(int64_t i, const BuilderPtr builder)
awkward::RecordBuilder::integer
const BuilderPtr integer(int64_t x) override
Adds an integer value x to the accumulated data.
awkward::RecordBuilder::begun
bool begun()
Definition: RecordBuilder.h:134
awkward::RecordBuilder::datetime
const BuilderPtr datetime(int64_t x, const std::string &unit) override
Adds a datetime value x to the accumulated data.
awkward::RecordBuilder::beginrecord
const BuilderPtr beginrecord(const char *name, bool check) override
Begins building a record with an optional name.
awkward::RecordBuilder::null
const BuilderPtr null() override
Adds a null value to the accumulated data.
awkward::RecordBuilder::RecordBuilder
RecordBuilder(const BuilderOptions &options, const std::vector< BuilderPtr > &contents, const std::vector< std::string > &keys, const std::vector< const char * > &pointers, const std::string &name, const char *nameptr, int64_t length, bool begun, int64_t nextindex, int64_t nexttotry)
Create a RecordBuilder from a full set of parameters.
awkward::RecordBuilder::to_buffers
const std::string to_buffers(BuffersContainer &container, int64_t &form_key_id) const override
Copy the current snapshot into the BuffersContainer and return a Form as a std::string (JSON).
awkward::RecordBuilder::beginlist
const BuilderPtr beginlist() override
Begins building a nested list.
awkward::RecordBuilder::boolean
const BuilderPtr boolean(bool x) override
Adds a boolean value x to the accumulated data.
awkward::RecordBuilder::begintuple
const BuilderPtr begintuple(int64_t numfields) override
Begins building a tuple with a fixed number of fields.
awkward::RecordBuilder::endtuple
const BuilderPtr endtuple() override
Ends a tuple.
awkward::RecordBuilder::classname
const std::string classname() const override
User-friendly name of this class: "RecordBuilder".
awkward::RecordBuilder::clear
void clear() override
Removes all accumulated data without resetting the type knowledge.
awkward::RecordBuilder::name
const std::string name() const
Name of the record (STL wrapped nameptr).
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
awkward::Options
Container for all configuration options needed by ArrayBuilder, GrowableBuffer, LayoutBuilder and the...
Definition: BuilderOptions.h:20