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

Loading...
Searching...
No Matches
IndexedArrayBuilder.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_INDEXEDARRAYBUILDER_H_
4#define AWKWARD_INDEXEDARRAYBUILDER_H_
5
6#include "awkward/layoutbuilder/FormBuilder.h"
7
8#include <complex>
9
10namespace awkward {
11
15 template <typename T, typename I>
16 class LIBAWKWARD_EXPORT_SYMBOL IndexedArrayBuilder : public FormBuilder<T, I> {
17 public:
19 IndexedArrayBuilder(const FormBuilderPtr<T, I> content,
20 const util::Parameters& parameters,
21 const std::string& json_form_key,
22 const std::string& json_form_index,
23 bool is_categorical,
24 const std::string attribute = "index",
25 const std::string partition = "0");
26
28 const std::string
29 classname() const override;
30
31 const std::string
32 to_buffers(BuffersContainer& container, const ForthOutputBufferMap& outputs) const override;
33
35 const std::string
36 vm_output() const override;
37
39 const std::string
40 vm_output_data() const override;
41
43 const std::string
44 vm_func() const override;
45
47 const std::string
48 vm_func_name() const override;
49
51 const std::string
52 vm_func_type() const override;
53
56 const std::string
57 vm_from_stack() const override;
58
60 const std::string
61 vm_error() const override;
62
64 void
65 boolean(bool x, LayoutBuilderPtr<T, I> builder) override;
66
68 void
69 int64(int64_t x, LayoutBuilderPtr<T, I> builder) override;
70
72 void
73 float64(double x, LayoutBuilderPtr<T, I> builder) override;
74
76 void
77 complex(std::complex<double> x, LayoutBuilderPtr<T, I> builder) override;
78
81 void
82 bytestring(const std::string& x, LayoutBuilderPtr<T, I> builder) override;
83
86 void
87 string(const std::string& x, LayoutBuilderPtr<T, I> builder) override;
88
90 void
91 begin_list(LayoutBuilderPtr<T, I> builder) override;
92
94 void
95 end_list(LayoutBuilderPtr<T, I> builder) override;
96
97 const
98 FormBuilderPtr<T, I> content() const { return content_; }
99
100 const std::string&
101 form_index() const { return form_index_; }
102
103 const util::Parameters&
104 form_parameters() const { return parameters_; }
105
106 const std::string&
107 form_key() const {return form_key_; }
108
109 ssize_t
110 len(const ForthOutputBufferMap& outputs) const override {
111 auto search = outputs.find(vm_output_data());
112 if (search != outputs.end()) {
113 return (ssize_t)search->second.get()->len();
114 }
115 return 0;
116 }
117
118 private:
120 const FormBuilderPtr<T, I> content_;
121
123 const util::Parameters parameters_;
124
126 bool is_categorical_;
127
128 const std::string form_index_;
129 const std::string form_key_;
130
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_INDEXEDARRAYBUILDER_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::IndexedArrayBuilder
Definition: IndexedArrayBuilder.h:16
awkward::IndexedArrayBuilder::vm_output
const std::string vm_output() const override
AwkwardForth virtual machine instructions of the data outputs.
awkward::IndexedArrayBuilder::begin_list
void begin_list(LayoutBuilderPtr< T, I > builder) override
Begins building a nested list.
awkward::IndexedArrayBuilder::len
ssize_t len(const ForthOutputBufferMap &outputs) const override
The builder's output buffer length.
Definition: IndexedArrayBuilder.h:110
awkward::IndexedArrayBuilder::float64
void float64(double x, LayoutBuilderPtr< T, I > builder) override
Adds a real value x to the accumulated data.
awkward::IndexedArrayBuilder::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::IndexedArrayBuilder::form_key
const std::string & form_key() const
Definition: IndexedArrayBuilder.h:107
awkward::IndexedArrayBuilder::form_index
const std::string & form_index() const
Definition: IndexedArrayBuilder.h:101
awkward::IndexedArrayBuilder::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::IndexedArrayBuilder::int64
void int64(int64_t x, LayoutBuilderPtr< T, I > builder) override
Adds an integer value x to the accumulated data.
awkward::IndexedArrayBuilder::form_parameters
const util::Parameters & form_parameters() const
Definition: IndexedArrayBuilder.h:104
awkward::IndexedArrayBuilder::vm_func_name
const std::string vm_func_name() const override
The array builder VM function name.
awkward::IndexedArrayBuilder::vm_output_data
const std::string vm_output_data() const override
AwkwardForth virtual machine data output key.
awkward::IndexedArrayBuilder::vm_func
const std::string vm_func() const override
AwkwardForth virtual machine instructions of the array builder function.
awkward::IndexedArrayBuilder::IndexedArrayBuilder
IndexedArrayBuilder(const FormBuilderPtr< T, I > content, const util::Parameters &parameters, const std::string &json_form_key, const std::string &json_form_index, bool is_categorical, const std::string attribute="index", const std::string partition="0")
Creates an IndexedArrayBuilder from a full set of parameters.
awkward::IndexedArrayBuilder::content
const FormBuilderPtr< T, I > content() const
Definition: IndexedArrayBuilder.h:98
awkward::IndexedArrayBuilder::vm_func_type
const std::string vm_func_type() const override
The array builder VM function type.
awkward::IndexedArrayBuilder::boolean
void boolean(bool x, LayoutBuilderPtr< T, I > builder) override
Adds a boolean value x to the accumulated data.
awkward::IndexedArrayBuilder::vm_error
const std::string vm_error() const override
Error messages in the AwkwardForth virtual machine instructions.
awkward::IndexedArrayBuilder::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::IndexedArrayBuilder::complex
void complex(std::complex< double > x, LayoutBuilderPtr< T, I > builder) override
Adds a complex value x to the accumulated data.
awkward::IndexedArrayBuilder::vm_from_stack
const std::string vm_from_stack() const override
AwkwardForth virtual machine instructions to retrieve the data from the VM stack.
awkward::IndexedArrayBuilder::end_list
void end_list(LayoutBuilderPtr< T, I > builder) override
Ends a nested list.
awkward::IndexedArrayBuilder::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