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

Loading...
Searching...
No Matches
UnionBuilder.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_UNIONBUILDER_H_
4#define AWKWARD_UNIONBUILDER_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 class TupleBuilder;
15 class RecordBuilder;
16
20 class LIBAWKWARD_EXPORT_SYMBOL UnionBuilder: public Builder {
21 public:
22 static const BuilderPtr
23 fromsingle(const BuilderOptions& options,
24 const BuilderPtr& firstcontent);
25
35 UnionBuilder(const BuilderOptions& options,
36 GrowableBuffer<int8_t> tags,
37 GrowableBuffer<int64_t> index,
38 std::vector<BuilderPtr>& contents);
39
41 const std::string
42 classname() const override;
43
44 const std::string
45 to_buffers(BuffersContainer& container, int64_t& form_key_id) const override;
46
47 int64_t
48 length() const override;
49
50 void
51 clear() override;
52
57 bool
58 active() const override;
59
60 const BuilderPtr
61 null() override;
62
63 const BuilderPtr
64 boolean(bool x) override;
65
66 const BuilderPtr
67 integer(int64_t x) override;
68
69 const BuilderPtr
70 real(double x) override;
71
72 const BuilderPtr
73 complex(std::complex<double> x) override;
74
75 const BuilderPtr
76 datetime(int64_t x, const std::string& unit) override;
77
78 const BuilderPtr
79 timedelta(int64_t x, const std::string& unit) override;
80
81 const BuilderPtr
82 string(const char* x, int64_t length, const char* encoding) override;
83
84 const BuilderPtr
85 beginlist() override;
86
87 const BuilderPtr
88 endlist() override;
89
90 const BuilderPtr
91 begintuple(int64_t numfields) override;
92
93 const BuilderPtr
94 index(int64_t index) override;
95
96 const BuilderPtr
97 endtuple() override;
98
99 const BuilderPtr
100 beginrecord(const char* name, bool check) override;
101
102 void
103 field(const char* key, bool check) override;
104
105 const BuilderPtr
106 endrecord() override;
107
108 const BuilderOptions&
109 options() const { return options_; }
110
111 const GrowableBuffer<int8_t>& tags() const { return tags_; }
112 GrowableBuffer<int8_t>& tags_buffer() { return tags_; }
113
114 const GrowableBuffer<int64_t>& index() const { return index_; }
115 GrowableBuffer<int64_t>& index_buffer() { return index_; }
116
117 const std::vector<BuilderPtr>& contents() const { return contents_; }
118 std::vector<BuilderPtr>& builders() { return contents_; }
119
120 int8_t current() { return current_;}
121
122 private:
123 const BuilderOptions options_;
124 GrowableBuffer<int8_t> tags_;
125 GrowableBuffer<int64_t> index_;
126 std::vector<BuilderPtr> contents_;
127 int8_t current_;
128 };
129}
130
131#endif // AWKWARD_UNIONBUILDER_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::GrowableBuffer
Discontiguous, one-dimensional buffer (which consists of multiple contiguous, one-dimensional panels)...
Definition: GrowableBuffer.h:174
awkward::UnionBuilder
Builder node for accumulated heterogeneous data.
Definition: UnionBuilder.h:20
awkward::UnionBuilder::real
const BuilderPtr real(double x) override
Adds a real value x to the accumulated data.
awkward::UnionBuilder::endlist
const BuilderPtr endlist() override
Ends a nested list.
awkward::UnionBuilder::timedelta
const BuilderPtr timedelta(int64_t x, const std::string &unit) override
Adds a timedelta value x to the accumulated data.
awkward::UnionBuilder::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::UnionBuilder::complex
const BuilderPtr complex(std::complex< double > x) override
Adds a complex value x to the accumulated data.
awkward::UnionBuilder::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::UnionBuilder::length
int64_t length() const override
Current length of the accumulated array.
awkward::UnionBuilder::endrecord
const BuilderPtr endrecord() override
Ends a record.
awkward::UnionBuilder::active
bool active() const override
If true, this node has started but has not finished a multi-step command (e.g. beginX ....
awkward::UnionBuilder::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::UnionBuilder::options
const BuilderOptions & options() const
Definition: UnionBuilder.h:109
awkward::UnionBuilder::fromsingle
static const BuilderPtr fromsingle(const BuilderOptions &options, const BuilderPtr &firstcontent)
awkward::UnionBuilder::integer
const BuilderPtr integer(int64_t x) override
Adds an integer value x to the accumulated data.
awkward::UnionBuilder::current
int8_t current()
Definition: UnionBuilder.h:120
awkward::UnionBuilder::index_buffer
GrowableBuffer< int64_t > & index_buffer()
Definition: UnionBuilder.h:115
awkward::UnionBuilder::tags
const GrowableBuffer< int8_t > & tags() const
Definition: UnionBuilder.h:111
awkward::UnionBuilder::UnionBuilder
UnionBuilder(const BuilderOptions &options, GrowableBuffer< int8_t > tags, GrowableBuffer< int64_t > index, std::vector< BuilderPtr > &contents)
Create a UnionBuilder from a full set of parameters.
awkward::UnionBuilder::datetime
const BuilderPtr datetime(int64_t x, const std::string &unit) override
Adds a datetime value x to the accumulated data.
awkward::UnionBuilder::beginrecord
const BuilderPtr beginrecord(const char *name, bool check) override
Begins building a record with an optional name.
awkward::UnionBuilder::tags_buffer
GrowableBuffer< int8_t > & tags_buffer()
Definition: UnionBuilder.h:112
awkward::UnionBuilder::null
const BuilderPtr null() override
Adds a null value to the accumulated data.
awkward::UnionBuilder::index
const GrowableBuffer< int64_t > & index() const
Definition: UnionBuilder.h:114
awkward::UnionBuilder::contents
const std::vector< BuilderPtr > & contents() const
Definition: UnionBuilder.h:117
awkward::UnionBuilder::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::UnionBuilder::beginlist
const BuilderPtr beginlist() override
Begins building a nested list.
awkward::UnionBuilder::boolean
const BuilderPtr boolean(bool x) override
Adds a boolean value x to the accumulated data.
awkward::UnionBuilder::builders
std::vector< BuilderPtr > & builders()
Definition: UnionBuilder.h:118
awkward::UnionBuilder::begintuple
const BuilderPtr begintuple(int64_t numfields) override
Begins building a tuple with a fixed number of fields.
awkward::UnionBuilder::endtuple
const BuilderPtr endtuple() override
Ends a tuple.
awkward::UnionBuilder::classname
const std::string classname() const override
User-friendly name of this class: "UnionBuilder".
awkward::UnionBuilder::clear
void clear() override
Removes all accumulated data without resetting the type knowledge.
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