Awkward Array: include/awkward/layoutbuilder/UnionArrayBuilder.h Source File

Loading...
Searching...
No Matches
UnionArrayBuilder.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_UNIONARRAYBUILDER_H_
4#define AWKWARD_UNIONARRAYBUILDER_H_
5
6#include "awkward/layoutbuilder/FormBuilder.h"
7
8namespace awkward {
9
13 template <typename T, typename I>
14 class LIBAWKWARD_EXPORT_SYMBOL UnionArrayBuilder : public FormBuilder<T, I> {
15 public:
17 UnionArrayBuilder(const std::vector<FormBuilderPtr<T, I>>& contents,
18 const util::Parameters& parameters,
19 const std::string& form_key,
20 const std::string& form_tags,
21 const std::string& form_index,
22 const std::string attribute = "union",
23 const std::string partition = "0");
24
26 const std::string
27 classname() const override;
28
29 const std::string
30 to_buffers(BuffersContainer& container, const ForthOutputBufferMap& outputs) const override;
31
33 const std::string
34 vm_output() const override;
35
37 const std::string
38 vm_output_data() const override;
39
41 const std::string
42 vm_func() const override;
43
45 const std::string
46 vm_func_name() const override;
47
49 const std::string
50 vm_func_type() const override;
51
54 const std::string
55 vm_from_stack() const override;
56
58 const std::string
59 vm_error() const override;
60
62 void
63 tag(int8_t x) override;
64
66 void
67 boolean(bool x, LayoutBuilderPtr<T, I> builder) override;
68
70 void
71 int64(int64_t x, LayoutBuilderPtr<T, I> builder) override;
72
74 void
75 float64(double x, LayoutBuilderPtr<T, I> builder) override;
76
78 void
79 complex(std::complex<double> x, LayoutBuilderPtr<T, I> builder) override;
80
83 void
84 bytestring(const std::string& x, LayoutBuilderPtr<T, I> builder) override;
85
88 void
89 string(const std::string& x, LayoutBuilderPtr<T, I> builder) override;
90
92 void
93 begin_list(LayoutBuilderPtr<T, I> builder) override;
94
96 void
97 end_list(LayoutBuilderPtr<T, I> builder) override;
98
99 const std::vector<FormBuilderPtr<T, I>>&
100 contents() const { return contents_; }
101
102 const std::string&
103 vm_output_tags() const { return vm_output_tags_; }
104
105 const std::string&
106 form_index() const { return form_index_; }
107
108 const util::Parameters&
109 form_parameters() const { return parameters_; }
110
111 const std::string&
112 form_key() const {return form_key_; }
113
114 ssize_t
115 len(const ForthOutputBufferMap& outputs) const override {
116 auto search = outputs.find(vm_output_tags());
117 if (search != outputs.end()) {
118 return (ssize_t)search->second.get()->len();
119 }
120 return 0;
121 }
122
123 private:
125 std::vector<FormBuilderPtr<T, I>> contents_;
126
128 const util::Parameters parameters_;
129 const std::string form_key_;
130
132 int8_t tag_;
133
134 const std::string form_index_;
135
138 std::string vm_output_data_;
139 std::string vm_output_;
140 std::string vm_func_name_;
141 std::string vm_func_;
142 std::string vm_func_type_;
143 std::string vm_data_from_stack_;
144 std::string vm_output_index_;
145 std::string vm_output_tags_;
146 std::string vm_error_;
147 };
148
149}
150
151#endif // AWKWARD_UNIONARRAYBUILDER_H_
FormBuilder.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::FormBuilder
Abstract base class for nodes within a LayoutBuilder Every builder will have an output buffer based o...
Definition: FormBuilder.h:30
awkward::LayoutBuilder
User interface to the FormBuilder system: the LayoutBuilder is a fixed reference while the FormBuilde...
Definition: LayoutBuilder.h:62
awkward::UnionArrayBuilder
Definition: UnionArrayBuilder.h:14
awkward::UnionArrayBuilder::UnionArrayBuilder
UnionArrayBuilder(const std::vector< FormBuilderPtr< T, I > > &contents, const util::Parameters &parameters, const std::string &form_key, const std::string &form_tags, const std::string &form_index, const std::string attribute="union", const std::string partition="0")
Creates a UnionArrayBuilder from a full set of parameters.
awkward::UnionArrayBuilder::contents
const std::vector< FormBuilderPtr< T, I > > & contents() const
Definition: UnionArrayBuilder.h:100
awkward::UnionArrayBuilder::vm_output
const std::string vm_output() const override
AwkwardForth virtual machine instructions of the data outputs.
awkward::UnionArrayBuilder::tag
void tag(int8_t x) override
Sets the tag for next input data.
awkward::UnionArrayBuilder::begin_list
void begin_list(LayoutBuilderPtr< T, I > builder) override
Begins building a nested list.
awkward::UnionArrayBuilder::len
ssize_t len(const ForthOutputBufferMap &outputs) const override
The builder's output buffer length.
Definition: UnionArrayBuilder.h:115
awkward::UnionArrayBuilder::float64
void float64(double x, LayoutBuilderPtr< T, I > builder) override
Adds a real value x to the accumulated data.
awkward::UnionArrayBuilder::vm_output_tags
const std::string & vm_output_tags() const
Definition: UnionArrayBuilder.h:103
awkward::UnionArrayBuilder::to_buffers
const std::string to_buffers(BuffersContainer &container, const ForthOutputBufferMap &outputs) const override
Copy the current snapshot into the BuffersContainer and return a Form as a std::string (JSON).
awkward::UnionArrayBuilder::form_key
const std::string & form_key() const
Definition: UnionArrayBuilder.h:112
awkward::UnionArrayBuilder::form_index
const std::string & form_index() const
Definition: UnionArrayBuilder.h:106
awkward::UnionArrayBuilder::string
void string(const std::string &x, LayoutBuilderPtr< T, I > builder) override
Adds a UTF-8 encoded bytestring x in STL format to the accumulated data.
awkward::UnionArrayBuilder::int64
void int64(int64_t x, LayoutBuilderPtr< T, I > builder) override
Adds an integer value x to the accumulated data.
awkward::UnionArrayBuilder::form_parameters
const util::Parameters & form_parameters() const
Definition: UnionArrayBuilder.h:109
awkward::UnionArrayBuilder::vm_func_name
const std::string vm_func_name() const override
The array builder VM function name.
awkward::UnionArrayBuilder::vm_output_data
const std::string vm_output_data() const override
AwkwardForth virtual machine data output key.
awkward::UnionArrayBuilder::vm_func
const std::string vm_func() const override
AwkwardForth virtual machine instructions of the array builder function.
awkward::UnionArrayBuilder::vm_func_type
const std::string vm_func_type() const override
The array builder VM function type.
awkward::UnionArrayBuilder::boolean
void boolean(bool x, LayoutBuilderPtr< T, I > builder) override
Adds a boolean value x to the accumulated data.
awkward::UnionArrayBuilder::vm_error
const std::string vm_error() const override
Error messages in the AwkwardForth virtual machine instructions.
awkward::UnionArrayBuilder::bytestring
void bytestring(const std::string &x, LayoutBuilderPtr< T, I > builder) override
Adds an unencoded bytestring x in STL format to the accumulated data.
awkward::UnionArrayBuilder::complex
void complex(std::complex< double > x, LayoutBuilderPtr< T, I > builder) override
Adds a complex value x to the accumulated data.
awkward::UnionArrayBuilder::vm_from_stack
const std::string vm_from_stack() const override
AwkwardForth virtual machine instructions to retrieve the data from the VM stack.
awkward::UnionArrayBuilder::end_list
void end_list(LayoutBuilderPtr< T, I > builder) override
Ends a nested list.
awkward::UnionArrayBuilder::classname
const std::string classname() const override
User-friendly name of this class.
LIBAWKWARD_EXPORT_SYMBOL
#define LIBAWKWARD_EXPORT_SYMBOL
Definition: common.h:45
awkward::util::Parameters
std::map< std::string, std::string > Parameters
Definition: util.h:165
awkward
Definition: BitMaskedArray.h:15
awkward::ForthOutputBufferMap
std::map< std::string, std::shared_ptr< ForthOutputBuffer > > ForthOutputBufferMap
Definition: FormBuilder.h:16
awkward::FormBuilderPtr
std::shared_ptr< FormBuilder< T, I > > FormBuilderPtr
Definition: FormBuilder.h:177