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

Loading...
Searching...
No Matches
ListArrayBuilder.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_LISTARRAYBUILDER_H_
4#define AWKWARD_LISTARRAYBUILDER_H_
5
6#include "awkward/layoutbuilder/FormBuilder.h"
7
8namespace awkward {
9
13 template <typename T, typename I>
14 class LIBAWKWARD_EXPORT_SYMBOL ListArrayBuilder : public FormBuilder<T, I> {
15 public:
17 ListArrayBuilder(FormBuilderPtr<T, I> content,
18 const util::Parameters& parameters,
19 const std::string& form_key,
20 const std::string& form_starts,
21 const std::string attribute = "offsets",
22 const std::string partition = "0");
23
25 const std::string
26 classname() const override;
27
28 const std::string
29 to_buffers(BuffersContainer& container, const ForthOutputBufferMap& outputs) const override;
30
32 const std::string
33 vm_output() const override;
34
36 const std::string
37 vm_output_data() const override;
38
40 const std::string
41 vm_func() const override;
42
44 const std::string
45 vm_func_name() const override;
46
48 const std::string
49 vm_func_type() const override;
50
53 const std::string
54 vm_from_stack() const override;
55
57 const std::string
58 vm_error() const override;
59
61 void
62 boolean(bool x, LayoutBuilderPtr<T, I> builder) override;
63
65 void
66 int64(int64_t x, LayoutBuilderPtr<T, I> builder) override;
67
69 void
70 float64(double x, LayoutBuilderPtr<T, I> builder) override;
71
73 void
74 complex(std::complex<double> x, LayoutBuilderPtr<T, I> builder) override;
75
78 void
79 bytestring(const std::string& x, LayoutBuilderPtr<T, I> builder) override;
80
83 void
84 string(const std::string& x, LayoutBuilderPtr<T, I> builder) override;
85
87 void
88 begin_list(LayoutBuilderPtr<T, I> builder) override;
89
91 void
92 end_list(LayoutBuilderPtr<T, I> builder) override;
93
95 bool
96 active() override;
97
98 const
99 FormBuilderPtr<T, I> content() const { return content_; }
100
101 const std::string&
102 form_starts() const { return form_starts_; }
103
104 const util::Parameters&
105 form_parameters() const { return parameters_; }
106
107 const std::string&
108 form_key() const {return form_key_; }
109
110 ssize_t
111 len(const ForthOutputBufferMap& outputs) const override {
112 auto search = outputs.find(vm_output_data());
113 if (search != outputs.end()) {
114 return (ssize_t)search->second.get()->len();
115 }
116 return 0;
117 }
118
119 private:
121 FormBuilderPtr<T, I> content_;
122
124 const util::Parameters parameters_;
125
129 bool begun_;
130
131 const std::string form_starts_;
132 const std::string form_key_;
133
136 std::string vm_output_data_;
137 std::string vm_output_;
138 std::string vm_func_name_;
139 std::string vm_func_;
140 std::string vm_func_type_;
141 std::string vm_data_from_stack_;
142 std::string vm_error_;
143 };
144
145}
146
147#endif // AWKWARD_LISTARRAYBUILDER_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::ListArrayBuilder
Definition: ListArrayBuilder.h:14
awkward::ListArrayBuilder::form_starts
const std::string & form_starts() const
Definition: ListArrayBuilder.h:102
awkward::ListArrayBuilder::vm_output
const std::string vm_output() const override
AwkwardForth virtual machine instructions of the data outputs.
awkward::ListArrayBuilder::begin_list
void begin_list(LayoutBuilderPtr< T, I > builder) override
Begins building a nested list.
awkward::ListArrayBuilder::len
ssize_t len(const ForthOutputBufferMap &outputs) const override
The builder's output buffer length.
Definition: ListArrayBuilder.h:111
awkward::ListArrayBuilder::float64
void float64(double x, LayoutBuilderPtr< T, I > builder) override
Adds a real value x to the accumulated data.
awkward::ListArrayBuilder::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::ListArrayBuilder::form_key
const std::string & form_key() const
Definition: ListArrayBuilder.h:108
awkward::ListArrayBuilder::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::ListArrayBuilder::int64
void int64(int64_t x, LayoutBuilderPtr< T, I > builder) override
Adds an integer value x to the accumulated data.
awkward::ListArrayBuilder::form_parameters
const util::Parameters & form_parameters() const
Definition: ListArrayBuilder.h:105
awkward::ListArrayBuilder::vm_func_name
const std::string vm_func_name() const override
The array builder VM function name.
awkward::ListArrayBuilder::vm_output_data
const std::string vm_output_data() const override
AwkwardForth virtual machine data output key.
awkward::ListArrayBuilder::vm_func
const std::string vm_func() const override
AwkwardForth virtual machine instructions of the array builder function.
awkward::ListArrayBuilder::content
const FormBuilderPtr< T, I > content() const
Definition: ListArrayBuilder.h:99
awkward::ListArrayBuilder::vm_func_type
const std::string vm_func_type() const override
The array builder VM function type.
awkward::ListArrayBuilder::boolean
void boolean(bool x, LayoutBuilderPtr< T, I > builder) override
Adds a boolean value x to the accumulated data.
awkward::ListArrayBuilder::vm_error
const std::string vm_error() const override
Error messages in the AwkwardForth virtual machine instructions.
awkward::ListArrayBuilder::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::ListArrayBuilder::complex
void complex(std::complex< double > x, LayoutBuilderPtr< T, I > builder) override
Adds a complex value x to the accumulated data.
awkward::ListArrayBuilder::active
bool active() override
true if the builder is accumulating data
awkward::ListArrayBuilder::vm_from_stack
const std::string vm_from_stack() const override
AwkwardForth virtual machine instructions to retrieve the data from the VM stack.
awkward::ListArrayBuilder::end_list
void end_list(LayoutBuilderPtr< T, I > builder) override
Ends a nested list.
awkward::ListArrayBuilder::classname
const std::string classname() const override
User-friendly name of this class.
awkward::ListArrayBuilder::ListArrayBuilder
ListArrayBuilder(FormBuilderPtr< T, I > content, const util::Parameters &parameters, const std::string &form_key, const std::string &form_starts, const std::string attribute="offsets", const std::string partition="0")
Creates a ListArrayBuilder from a full set of parameters.
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