Awkward Array: src/awkward/_v2/cpp-headers/rdataframe/jagged_builders.h Source File

Loading...
Searching...
No Matches
jagged_builders.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_RDATAFRAME_JAGGED_BUILDERS_H_
4#define AWKWARD_RDATAFRAME_JAGGED_BUILDERS_H_
5
6#include <stdlib.h>
7#include <string>
8#include "awkward/GrowableBuffer.h"
9#include "awkward/LayoutBuilder.h"
10#include "awkward/utils.h"
11
12namespace awkward {
13
14 template <typename T>
15 class CppBuffers {
16 public:
17 CppBuffers(ROOT::RDF::RResultPtr<std::vector<T>>& result)
18 : result_(result) {
19 }
20
21 ~CppBuffers() {}
22
23 template<class BUILDER>
24 const std::map<std::string, size_t>&
25 names_nbytes(BUILDER& builder) {
26 builder.buffer_nbytes(map_names_nbytes_);
27 return map_names_nbytes_;
28 }
29
30 void
31 append(const std::string& key, uint8_t* ptr) {
32 buffers_uint8_ptr_[key] = ptr;
33 }
34
35 void
36 check_buffers() const {
37 std::cout << "CPPBuffers check buffers: " << buffers_uint8_ptr_.size() << ".";
38 for (auto const& it : buffers_uint8_ptr_) {
39 uint8_t* data = it.second;
40 for (int i = 0; i < map_names_nbytes_[it.first]; i++) {
41 std::cout << (int64_t)data[i] << ",";
42 }
43 }
44 std::cout << std::endl;
45 }
46
47 template<class BUILDER, typename PRIMITIVE>
48 void
49 fill_from(BUILDER& builder, ROOT::RDF::RResultPtr<std::vector<PRIMITIVE>>& result) const {
50 for (auto it : result) {
51 builder.append(it);
52 }
53 }
54
55 template<class BUILDER>
56 void
57 to_char_buffers(BUILDER& builder) {
58 builder.to_char_buffers(buffers_uint8_ptr_);
59 }
60
61 private:
62 ROOT::RDF::RResultPtr<std::vector<T>>& result_;
63 std::map<std::string, size_t> map_names_nbytes_;
64 std::map<std::string, uint8_t*> buffers_uint8_ptr_;
65
66 };
67
68} // namespace awkward
69
70#endif // AWKWARD_RDATAFRAME_JAGGED_BUILDERS_H_
GrowableBuffer.h
awkward::CppBuffers
Definition: jagged_builders.h:15
awkward::CppBuffers::fill_from
void fill_from(BUILDER &builder, ROOT::RDF::RResultPtr< std::vector< PRIMITIVE > > &result) const
Definition: jagged_builders.h:49
awkward::CppBuffers::~CppBuffers
~CppBuffers()
Definition: jagged_builders.h:21
awkward::CppBuffers::check_buffers
void check_buffers() const
Definition: jagged_builders.h:36
awkward::CppBuffers::names_nbytes
const std::map< std::string, size_t > & names_nbytes(BUILDER &builder)
Definition: jagged_builders.h:25
awkward::CppBuffers::append
void append(const std::string &key, uint8_t *ptr)
Definition: jagged_builders.h:31
awkward::CppBuffers::CppBuffers
CppBuffers(ROOT::RDF::RResultPtr< std::vector< T > > &result)
Definition: jagged_builders.h:17
awkward::CppBuffers::to_char_buffers
void to_char_buffers(BUILDER &builder)
Definition: jagged_builders.h:57
awkward
Definition: BitMaskedArray.h:15
LayoutBuilder.h
utils.h