Loading...
Searching...
No Matches
virtual.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 AWKWARDPY_VIRTUAL_H_
4#define AWKWARDPY_VIRTUAL_H_
5
6#include <pybind11/pybind11.h>
7
10
11namespace py = pybind11;
12namespace ak = awkward;
13
15
17public:
19 int64_t length,
20 const py::object& callable,
21 const py::tuple& args,
22 const py::dict& kwargs);
23
24 const py::object
25 callable() const;
26
27 const py::tuple
28 args() const;
29
30 const py::dict
31 kwargs() const;
32
33 const ak::ContentPtr
34 generate() const override;
35
36 void
37 caches(std::vector<ak::ArrayCachePtr>& out) const override;
38
39 const std::string
40 tostring_part(const std::string& indent,
41 const std::string& pre,
42 const std::string& post) const override;
43
44 const std::shared_ptr<ak::ArrayGenerator>
45 shallow_copy() const override;
46
47 const std::shared_ptr<ak::ArrayGenerator>
48 with_form(const ak::FormPtr& form) const override;
49
50 const std::shared_ptr<ak::ArrayGenerator>
51 with_length(int64_t length) const override;
52
53 const std::shared_ptr<ak::ArrayGenerator>
54 with_callable(const py::object& callable) const;
55
56 const std::shared_ptr<ak::ArrayGenerator>
57 with_args(const py::tuple& args) const;
58
59 const std::shared_ptr<ak::ArrayGenerator>
60 with_kwargs(const py::dict& kwargs) const;
61
62 virtual bool
63 referentially_equal(const ak::ArrayGeneratorPtr& other) const override;
64
65private:
66 const py::object callable_;
67 const py::tuple args_;
68 const py::dict kwargs_;
69};
70
71py::class_<PyArrayGenerator, std::shared_ptr<PyArrayGenerator>>
72make_PyArrayGenerator(const py::handle& m, const std::string& name);
73
75
76py::class_<ak::SliceGenerator, std::shared_ptr<ak::SliceGenerator>>
77make_SliceGenerator(const py::handle& m, const std::string& name);
78
80
82public:
83 PyArrayCache(const py::object& mutablemapping);
84
85 const py::object
87
89 get(const std::string& key) const override;
90
91 void
92 set(const std::string& key, const ak::ContentPtr& value) override;
93
94 bool
95 is_broken() const override;
96
97 const std::string
98 tostring_part(const std::string& indent,
99 const std::string& pre,
100 const std::string& post) const override;
101
102private:
103 const py::object mutablemapping_;
104};
105
106py::class_<PyArrayCache, std::shared_ptr<PyArrayCache>>
107make_PyArrayCache(const py::handle& m, const std::string& name);
108
109#endif // AWKWARDPY_VIRTUAL_H_
Definition: virtual.h:81
void set(const std::string &key, const ak::ContentPtr &value) override
Writes or overwrites an array at key.
ak::ContentPtr get(const std::string &key) const override
Attempts to get an array; may be nullptr if not available.
const py::object mutablemapping() const
const std::string tostring_part(const std::string &indent, const std::string &pre, const std::string &post) const override
bool is_broken() const override
Returns true if the cache cannot be used for any reason.
PyArrayCache(const py::object &mutablemapping)
Definition: virtual.h:16
const std::shared_ptr< ak::ArrayGenerator > with_args(const py::tuple &args) const
const py::object callable() const
virtual bool referentially_equal(const ak::ArrayGeneratorPtr &other) const override
Returns true if this generator has all the same buffers and parameters as other; false otherwise.
const std::shared_ptr< ak::ArrayGenerator > with_kwargs(const py::dict &kwargs) const
PyArrayGenerator(const ak::FormPtr &form, int64_t length, const py::object &callable, const py::tuple &args, const py::dict &kwargs)
const std::shared_ptr< ak::ArrayGenerator > shallow_copy() const override
Copies this ArrayGenerator, referencing any contents.
void caches(std::vector< ak::ArrayCachePtr > &out) const override
Accumulates all the unique #ArrayCache objects from nested #VirtualArray nodes. (Uniqueness is determ...
const std::shared_ptr< ak::ArrayGenerator > with_length(int64_t length) const override
Return a copy of this ArrayGenerator with a different length (or a now-known length,...
const std::string tostring_part(const std::string &indent, const std::string &pre, const std::string &post) const override
Returns a string representation of this ArrayGenerator.
const py::tuple args() const
const std::shared_ptr< ak::ArrayGenerator > with_callable(const py::object &callable) const
const std::shared_ptr< ak::ArrayGenerator > with_form(const ak::FormPtr &form) const override
Return a copy of this ArrayGenerator with a different form (or a now-known form, whereas it might hav...
const py::dict kwargs() const
const ak::ContentPtr generate() const override
Creates an array but does not check it against the form.
Abstract superclass of cache for VirtualArray, defining the interface.
Definition: ArrayCache.h:17
Abstract superclass to generate arrays for VirtualArray, defining the interface.
Definition: ArrayGenerator.h:24
const FormPtr form() const
The Form the generated array is expected to take; may be nullptr.
int64_t length() const
The length the generated array is expected to have; may be negative to indicate that the length is un...
Definition: BitMaskedArray.h:15
std::shared_ptr< ArrayGenerator > ArrayGeneratorPtr
Definition: ArrayGenerator.h:14
std::shared_ptr< Content > ContentPtr
Definition: Content.h:15
std::shared_ptr< Form > FormPtr
Definition: Content.h:18
py::class_< PyArrayGenerator, std::shared_ptr< PyArrayGenerator > > make_PyArrayGenerator(const py::handle &m, const std::string &name)
py::class_< ak::SliceGenerator, std::shared_ptr< ak::SliceGenerator > > make_SliceGenerator(const py::handle &m, const std::string &name)
py::class_< PyArrayCache, std::shared_ptr< PyArrayCache > > make_PyArrayCache(const py::handle &m, const std::string &name)