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

Loading...
Searching...
No Matches
IndexedOptionArrayBuilder.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_INDEXEDOPTIONARRAYBUILDER_H_
4#define AWKWARD_INDEXEDOPTIONARRAYBUILDER_H_
5
6#include "awkward/layoutbuilder/FormBuilder.h"
7
8namespace awkward {
9
13 template <typename T, typename I>
14 class LIBAWKWARD_EXPORT_SYMBOL IndexedOptionArrayBuilder : public FormBuilder<T, I> {
15 public:
17 IndexedOptionArrayBuilder(const FormBuilderPtr<T, I> content,
18 const util::Parameters& parameters,
19 const std::string& form_key,
20 const std::string& form_index,
21 bool is_categorical,
22 const std::string attribute = "index",
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 boolean(bool x, LayoutBuilderPtr<T, I> builder) override;
64
66 void
67 int64(int64_t x, LayoutBuilderPtr<T, I> builder) override;
68
70 void
71 float64(double x, LayoutBuilderPtr<T, I> builder) override;
72
74 void
75 complex(std::complex<double> x, LayoutBuilderPtr<T, I> builder) override;
76
79 void
80 bytestring(const std::string& x, LayoutBuilderPtr<T, I> builder) override;
81
84 void
85 string(const std::string& x, LayoutBuilderPtr<T, I> builder) override;
86
88 void
89 begin_list(LayoutBuilderPtr<T, I> builder) override;
90
92 void
93 end_list(LayoutBuilderPtr<T, I> builder) override;
94
95 const
96 FormBuilderPtr<T, I> content() const { return content_; }
97
98 const std::string&
99 form_index() const { return form_index_; }
100
101 const util::Parameters&
102 form_parameters() const { return parameters_; }
103
104 const std::string&
105 form_key() const {return form_key_; }
106
107 ssize_t
108 len(const ForthOutputBufferMap& outputs) const override {
109 auto search = outputs.find(vm_output_data());
110 if (search != outputs.end()) {
111 return (ssize_t)search->second.get()->len();
112 }
113 return 0;
114 }
115
116 private:
118 const FormBuilderPtr<T, I> content_;
119
121 const util::Parameters parameters_;
122
124 bool is_categorical_;
125
126 const std::string form_index_;
127 const std::string form_key_;
128
129 void validate() const;
130
133 std::string vm_output_data_;
134 std::string vm_output_;
135 std::string vm_func_name_;
136 std::string vm_func_;
137 std::string vm_func_type_;
138 std::string vm_data_from_stack_;
139 std::string vm_error_;
140 };
141
142}
143
144#endif // AWKWARD_INDEXEDOPTIONARRAYBUILDER_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::IndexedOptionArrayBuilder
Definition: IndexedOptionArrayBuilder.h:14
awkward::IndexedOptionArrayBuilder::vm_output
const std::string vm_output() const override
AwkwardForth virtual machine instructions of the data outputs.
awkward::IndexedOptionArrayBuilder::begin_list
void begin_list(LayoutBuilderPtr< T, I > builder) override
Begins building a nested list.
awkward::IndexedOptionArrayBuilder::len
ssize_t len(const ForthOutputBufferMap &outputs) const override
The builder's output buffer length.
Definition: IndexedOptionArrayBuilder.h:108
awkward::IndexedOptionArrayBuilder::float64
void float64(double x, LayoutBuilderPtr< T, I > builder) override
Adds a real value x to the accumulated data.
awkward::IndexedOptionArrayBuilder::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::IndexedOptionArrayBuilder::form_key
const std::string & form_key() const
Definition: IndexedOptionArrayBuilder.h:105
awkward::IndexedOptionArrayBuilder::form_index
const std::string & form_index() const
Definition: IndexedOptionArrayBuilder.h:99
awkward::IndexedOptionArrayBuilder::IndexedOptionArrayBuilder
IndexedOptionArrayBuilder(const FormBuilderPtr< T, I > content, const util::Parameters &parameters, const std::string &form_key, const std::string &form_index, bool is_categorical, const std::string attribute="index", const std::string partition="0")
Creates an IndexedOptionArrayBuilder from a full set of parameters.
awkward::IndexedOptionArrayBuilder::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::IndexedOptionArrayBuilder::int64
void int64(int64_t x, LayoutBuilderPtr< T, I > builder) override
Adds an integer value x to the accumulated data.
awkward::IndexedOptionArrayBuilder::form_parameters
const util::Parameters & form_parameters() const
Definition: IndexedOptionArrayBuilder.h:102
awkward::IndexedOptionArrayBuilder::vm_func_name
const std::string vm_func_name() const override
The array builder VM function name.
awkward::IndexedOptionArrayBuilder::vm_output_data
const std::string vm_output_data() const override
AwkwardForth virtual machine data output key.
awkward::IndexedOptionArrayBuilder::vm_func
const std::string vm_func() const override
AwkwardForth virtual machine instructions of the array builder function.
awkward::IndexedOptionArrayBuilder::content
const FormBuilderPtr< T, I > content() const
Definition: IndexedOptionArrayBuilder.h:96
awkward::IndexedOptionArrayBuilder::vm_func_type
const std::string vm_func_type() const override
The array builder VM function type.
awkward::IndexedOptionArrayBuilder::boolean
void boolean(bool x, LayoutBuilderPtr< T, I > builder) override
Adds a boolean value x to the accumulated data.
awkward::IndexedOptionArrayBuilder::vm_error
const std::string vm_error() const override
Error messages in the AwkwardForth virtual machine instructions.
awkward::IndexedOptionArrayBuilder::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::IndexedOptionArrayBuilder::complex
void complex(std::complex< double > x, LayoutBuilderPtr< T, I > builder) override
Adds a complex value x to the accumulated data.
awkward::IndexedOptionArrayBuilder::vm_from_stack
const std::string vm_from_stack() const override
AwkwardForth virtual machine instructions to retrieve the data from the VM stack.
awkward::IndexedOptionArrayBuilder::end_list
void end_list(LayoutBuilderPtr< T, I > builder) override
Ends a nested list.
awkward::IndexedOptionArrayBuilder::classname
const std::string classname() const override
User-friendly name of this class.
awkward::LayoutBuilder
User interface to the FormBuilder system: the LayoutBuilder is a fixed reference while the FormBuilde...
Definition: LayoutBuilder.h:62
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