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

Loading...
Searching...
No Matches
LayoutBuilder.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_LAYOUTBUILDER_H_
4#define AWKWARD_LAYOUTBUILDER_H_
5
6#include "awkward/BuilderOptions.h"
7#include "awkward/GrowableBuffer.h"
8#include "awkward/utils.h"
9
10#include <map>
11#include <algorithm>
12#include <tuple>
13#include <string>
14
15namespace awkward {
16
17 namespace LayoutBuilder {
18
21 awkward::BuilderOptions default_options(1024, 1);
22
30 template <std::size_t ENUM, typename BUILDER>
31 class Field {
32 public:
33 using Builder = BUILDER;
34
36 std::string
37 index_as_field() const {
38 return std::to_string(reinterpret_cast<size_t>(index));
39 }
40
42 const std::size_t index = ENUM;
44 Builder builder;
45 };
46
53 template <typename PRIMITIVE>
54 class Numpy {
55 public:
58 Numpy()
59 : data_(
60 awkward::GrowableBuffer<PRIMITIVE>(default_options)) {
61 size_t id = 0;
62 set_id(id);
63 }
64
70 Numpy(const awkward::BuilderOptions& options)
71 : data_(awkward::GrowableBuffer<PRIMITIVE>(options)) {
72 size_t id = 0;
73 set_id(id);
74 }
75
77 void
78 append(PRIMITIVE x) noexcept {
79 data_.append(x);
80 }
81
85 void
86 extend(PRIMITIVE* ptr, size_t size) noexcept {
87 data_.extend(ptr, size);
88 }
89
91 const std::string&
92 parameters() const noexcept {
93 return parameters_;
94 }
95
97 void
98 set_parameters(std::string parameter) noexcept {
99 parameters_ = parameter;
100 }
101
103 void
104 set_id(size_t& id) noexcept {
105 id_ = id;
106 id++;
107 }
108
110 void
111 clear() noexcept {
112 data_.clear();
113 }
114
116 size_t
117 length() const noexcept {
118 return data_.length();
119 }
120
122 bool
123 is_valid(std::string& error) const noexcept {
124 return true;
125 }
126
128 void
129 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
130 noexcept {
131 names_nbytes["node" + std::to_string(id_) + "-data"] = data_.nbytes();
132 }
133
139 void
140 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
141 data_.concatenate(reinterpret_cast<PRIMITIVE*>(
142 buffers["node" + std::to_string(id_) + "-data"]));
143 }
144
149 void
150 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
151 data_.concatenate(reinterpret_cast<PRIMITIVE*>(
152 buffers["node" + std::to_string(id_) + "-data"]));
153 }
154
157 std::string
158 form() const {
159 std::stringstream form_key;
160 form_key << "node" << id_;
161
162 std::string params("");
163 if (parameters_ == "") {
164 } else {
165 params = std::string(", \"parameters\": { " + parameters_ + " }");
166 }
167
168 if (std::is_arithmetic<PRIMITIVE>::value) {
169 return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
170 type_to_name<PRIMITIVE>() + "\"" + params +
171 ", \"form_key\": \"" + form_key.str() + "\" }";
172 } else if (is_specialization<PRIMITIVE, std::complex>::value) {
173 return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
174 type_to_name<PRIMITIVE>() + "\"" + params +
175 ", \"form_key\": \"" + form_key.str() + "\" }";
176 } else {
177 throw std::runtime_error("type " +
178 std::string(typeid(PRIMITIVE).name()) +
179 "is not supported");
180 }
181 }
182
183 private:
185 awkward::GrowableBuffer<PRIMITIVE> data_;
186
188 std::string parameters_;
189
191 size_t id_;
192 };
193
208 template <typename PRIMITIVE, typename BUILDER>
209 class ListOffset {
210 public:
213 ListOffset()
214 : offsets_(
215 awkward::GrowableBuffer<PRIMITIVE>(default_options)) {
216 offsets_.append(0);
217 size_t id = 0;
218 set_id(id);
219 }
220
226 ListOffset(const awkward::BuilderOptions& options)
227 : offsets_(awkward::GrowableBuffer<PRIMITIVE>(options)) {
228 offsets_.append(0);
229 size_t id = 0;
230 set_id(id);
231 }
232
234 BUILDER&
235 content() noexcept {
236 return content_;
237 }
238
240 BUILDER&
241 begin_list() noexcept {
242 return content_;
243 }
244
247 void
248 end_list() noexcept {
249 offsets_.append(content_.length());
250 }
251
253 const std::string&
254 parameters() const noexcept {
255 return parameters_;
256 }
257
259 void
260 set_parameters(std::string parameter) noexcept {
261 parameters_ = parameter;
262 }
263
265 void
266 set_id(size_t& id) noexcept {
267 id_ = id;
268 id++;
269 content_.set_id(id);
270 }
271
273 void
274 clear() noexcept {
275 offsets_.clear();
276 offsets_.append(0);
277 content_.clear();
278 }
279
281 size_t
282 length() const noexcept {
283 return offsets_.length() - 1;
284 }
285
287 bool
288 is_valid(std::string& error) const noexcept {
289 if (content_.length() != offsets_.last()) {
290 std::stringstream out;
291 out << "ListOffset node" << id_ << "has content length "
292 << content_.length() << "but last offset " << offsets_.last()
293 << "\n";
294 error.append(out.str());
295
296 return false;
297 } else {
298 return content_.is_valid(error);
299 }
300 }
301
304 void
305 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
306 noexcept {
307 names_nbytes["node" + std::to_string(id_) + "-offsets"] =
308 offsets_.nbytes();
309 content_.buffer_nbytes(names_nbytes);
310 }
311
317 void
318 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
319 offsets_.concatenate(reinterpret_cast<PRIMITIVE*>(
320 buffers["node" + std::to_string(id_) + "-offsets"]));
321 content_.to_buffers(buffers);
322 }
323
328 void
329 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
330 offsets_.concatenate(reinterpret_cast<PRIMITIVE*>(
331 buffers["node" + std::to_string(id_) + "-offsets"]));
332 content_.to_char_buffers(buffers);
333 }
334
337 std::string
338 form() const noexcept {
339 std::stringstream form_key;
340 form_key << "node" << id_;
341 std::string params("");
342 if (parameters_ == "") {
343 } else {
344 params = std::string(", \"parameters\": { " + parameters_ + " }");
345 }
346 return "{ \"class\": \"ListOffsetArray\", \"offsets\": \"" +
347 type_to_numpy_like<PRIMITIVE>() +
348 "\", \"content\": " + content_.form() + params +
349 ", \"form_key\": \"" + form_key.str() + "\" }";
350 }
351
352 private:
356 GrowableBuffer<PRIMITIVE> offsets_;
357
359 BUILDER content_;
360
362 std::string parameters_;
363
365 size_t id_;
366 };
367
380 template <typename PRIMITIVE, typename BUILDER>
381 class List {
382 public:
385 List()
386 : starts_(
387 awkward::GrowableBuffer<PRIMITIVE>(default_options)),
388 stops_(
389 awkward::GrowableBuffer<PRIMITIVE>(default_options)) {
390 size_t id = 0;
391 set_id(id);
392 }
393
399 List(const awkward::BuilderOptions& options)
400 : starts_(awkward::GrowableBuffer<PRIMITIVE>(options)),
401 stops_(awkward::GrowableBuffer<PRIMITIVE>(options)) {
402 size_t id = 0;
403 set_id(id);
404 }
405
407 BUILDER&
408 content() noexcept {
409 return content_;
410 }
411
415 BUILDER&
416 begin_list() noexcept {
417 starts_.append(content_.length());
418 return content_;
419 }
420
423 void
424 end_list() noexcept {
425 stops_.append(content_.length());
426 }
427
429 const std::string&
430 parameters() const noexcept {
431 return parameters_;
432 }
433
435 void
436 set_parameters(std::string parameter) noexcept {
437 parameters_ = parameter;
438 }
439
441 void
442 set_id(size_t& id) noexcept {
443 id_ = id;
444 id++;
445 content_.set_id(id);
446 }
447
450 void
451 clear() noexcept {
452 starts_.clear();
453 stops_.clear();
454 content_.clear();
455 }
456
458 size_t
459 length() const noexcept {
460 return starts_.length();
461 }
462
464 bool
465 is_valid(std::string& error) const noexcept {
466 if (starts_.length() != stops_.length()) {
467 std::stringstream out;
468 out << "List node" << id_ << " has starts length " << starts_.length()
469 << " but stops length " << stops_.length() << "\n";
470 error.append(out.str());
471
472 return false;
473 } else if (stops_.length() > 0 && content_.length() != stops_.last()) {
474 std::stringstream out;
475 out << "List node" << id_ << " has content length "
476 << content_.length() << " but last stops " << stops_.last()
477 << "\n";
478 error.append(out.str());
479
480 return false;
481 } else {
482 return content_.is_valid(error);
483 }
484 }
485
488 void
489 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
490 noexcept {
491 names_nbytes["node" + std::to_string(id_) + "-starts"] =
492 starts_.nbytes();
493 names_nbytes["node" + std::to_string(id_) + "-stops"] = stops_.nbytes();
494 content_.buffer_nbytes(names_nbytes);
495 }
496
502 void
503 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
504 starts_.concatenate(reinterpret_cast<PRIMITIVE*>(
505 buffers["node" + std::to_string(id_) + "-starts"]));
506 stops_.concatenate(reinterpret_cast<PRIMITIVE*>(
507 buffers["node" + std::to_string(id_) + "-stops"]));
508 content_.to_buffers(buffers);
509 }
510
515 void
516 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
517 starts_.concatenate(reinterpret_cast<PRIMITIVE*>(
518 buffers["node" + std::to_string(id_) + "-starts"]));
519 stops_.concatenate(reinterpret_cast<PRIMITIVE*>(
520 buffers["node" + std::to_string(id_) + "-stops"]));
521 content_.to_char_buffers(buffers);
522 }
523
526 std::string
527 form() const noexcept {
528 std::stringstream form_key;
529 form_key << "node" << id_;
530 std::string params("");
531 if (parameters_ == "") {
532 } else {
533 params = std::string(", \"parameters\": { " + parameters_ + " }");
534 }
535 return "{ \"class\": \"ListArray\", \"starts\": \"" +
536 type_to_numpy_like<PRIMITIVE>() + "\", \"stops\": \"" +
537 type_to_numpy_like<PRIMITIVE>() +
538 "\", \"content\": " + content_.form() + params +
539 ", \"form_key\": \"" + form_key.str() + "\" }";
540 }
541
542 private:
546 GrowableBuffer<PRIMITIVE> starts_;
547
551 GrowableBuffer<PRIMITIVE> stops_;
552
554 BUILDER content_;
555
557 std::string parameters_;
558
560 size_t id_;
561 };
562
567 class Empty {
568 public:
570 Empty() {
571 size_t id = 0;
572 set_id(id);
573 }
574
576 const std::string&
577 parameters() const noexcept {
578 return parameters_;
579 }
580
582 void
583 set_parameters(std::string parameter) noexcept {
584 parameters_ = parameter;
585 }
586
587 void
588 set_id(size_t& id) noexcept {}
589
590 void
591 clear() noexcept {}
592
594 size_t
595 length() const noexcept {
596 return 0;
597 }
598
600 bool
601 is_valid(std::string& /* error */) const noexcept {
602 return true;
603 }
604
605 void
606 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
607 noexcept {}
608
609 void
610 to_buffers(std::map<std::string, void*>& buffers) const noexcept {}
611
616 void
617 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {}
618
621 std::string
622 form() const noexcept {
623 std::string params("");
624 if (parameters_ == "") {
625 } else {
626 params = std::string(", \"parameters\": { " + parameters_ + " }");
627 }
628 return "{ \"class\": \"EmptyArray\"" + params + " }";
629 }
630
631 private:
633 std::string parameters_;
634
636 size_t id_;
637 };
638
647 template <bool IS_TUPLE>
648 class EmptyRecord {
649 public:
651 EmptyRecord() : length_(0) {
652 size_t id = 0;
653 set_id(id);
654 }
655
657 void
658 append() noexcept {
659 length_++;
660 }
661
665 void
666 extend(size_t size) noexcept {
667 length_ += size;
668 }
669
671 const std::string&
672 parameters() const noexcept {
673 return parameters_;
674 }
675
677 void
678 set_parameters(std::string parameter) noexcept {
679 parameters_ = parameter;
680 }
681
683 void
684 set_id(size_t& id) noexcept {
685 id_ = id;
686 id++;
687 }
688
690 void
691 clear() noexcept {
692 length_ = 0;
693 }
694
696 size_t
697 length() const noexcept {
698 return length_;
699 }
700
702 bool
703 is_valid(std::string& /* error */) const noexcept {
704 return true;
705 }
706
707 void
708 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
709 noexcept {}
710
711 void
712 to_buffers(std::map<std::string, void*>& buffers) const noexcept {}
713
718 void
719 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {}
720
723 std::string
724 form() const noexcept {
725 std::stringstream form_key;
726 form_key << "node" << id_;
727 std::string params("");
728 if (parameters_ == "") {
729 } else {
730 params = std::string(", \"parameters\": { " + parameters_ + " }");
731 }
732
733 if (is_tuple_) {
734 return "{ \"class\": \"RecordArray\", \"contents\": []" + params +
735 ", \"form_key\": \"" + form_key.str() + "\" }";
736 } else {
737 return "{ \"class\": \"RecordArray\", \"contents\": {}" + params +
738 ", \"form_key\": \"" + form_key.str() + "\" }";
739 }
740 }
741
742 private:
744 std::string parameters_;
745
747 size_t id_;
748
750 size_t length_;
751
756 bool is_tuple_ = IS_TUPLE;
757 };
758
768 template <class MAP = std::map<std::size_t, std::string>,
769 typename... BUILDERS>
770 class Record {
771 public:
772 using RecordContents = typename std::tuple<BUILDERS...>;
773 using UserDefinedMap = MAP;
774
775 template <std::size_t INDEX>
776 using RecordFieldType = std::tuple_element_t<INDEX, RecordContents>;
777
779 Record() {
780 size_t id = 0;
781 set_id(id);
782 map_fields(std::index_sequence_for<BUILDERS...>());
783 }
784
791 Record(UserDefinedMap user_defined_field_id_to_name_map)
792 : content_names_(user_defined_field_id_to_name_map) {
793 assert(content_names_.size() == fields_count_);
794 size_t id = 0;
795 set_id(id);
796 }
797
799 const std::vector<std::string>
800 field_names() const noexcept {
801 if (content_names_.empty()) {
802 return field_names_;
803 } else {
804 std::vector<std::string> result;
805 for (auto it : content_names_) {
806 result.emplace_back(it.second);
807 }
808 return result;
809 }
810 }
811
816 void
817 set_field_names(MAP user_defined_field_id_to_name_map) noexcept {
818 content_names_ = user_defined_field_id_to_name_map;
819 }
820
822 template <std::size_t INDEX>
823 typename RecordFieldType<INDEX>::Builder&
824 field() noexcept {
825 return std::get<INDEX>(contents).builder;
826 }
827
829 const std::string&
830 parameters() const noexcept {
831 return parameters_;
832 }
833
835 void
836 set_parameters(std::string parameter) noexcept {
837 parameters_ = parameter;
838 }
839
841 void
842 set_id(size_t& id) noexcept {
843 id_ = id;
844 id++;
845 for (size_t i = 0; i < fields_count_; i++) {
846 visit_at(contents, i, [&id](auto& content) {
847 content.builder.set_id(id);
848 });
849 }
850 }
851
856 void
857 clear() noexcept {
858 for (size_t i = 0; i < fields_count_; i++)
859 visit_at(contents, i, [](auto& content) {
860 content.builder.clear();
861 });
862 }
863
865 const size_t
866 length() const noexcept {
867 return (std::get<0>(contents).builder.length());
868 }
869
871 bool
872 is_valid(std::string& error) const noexcept {
873 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
874
875 size_t length = -1;
876 bool result = false;
877 std::vector<size_t> lengths = field_lengths(index_sequence);
878 for (size_t i = 0; i < lengths.size(); i++) {
879 if (length == -1) {
880 length = lengths[i];
881 } else if (length != lengths[i]) {
882 std::stringstream out;
883 out << "Record node" << id_ << " has field \""
884 << field_names().at(i) << "\" length " << lengths[i]
885 << " that differs from the first length " << length << "\n";
886 error.append(out.str());
887
888 return false;
889 }
890 }
891
892 std::vector<bool> valid_fields = field_is_valid(index_sequence, error);
893 return std::none_of(std::cbegin(valid_fields),
894 std::cend(valid_fields),
895 std::logical_not<bool>());
896 }
897
900 void
901 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
902 noexcept {
903 for (size_t i = 0; i < fields_count_; i++)
904 visit_at(contents, i, [&names_nbytes](auto& content) {
905 content.builder.buffer_nbytes(names_nbytes);
906 });
907 }
908
914 void
915 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
916 for (size_t i = 0; i < fields_count_; i++)
917 visit_at(contents, i, [&buffers](auto& content) {
918 content.builder.to_buffers(buffers);
919 });
920 }
921
926 void
927 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
928 for (size_t i = 0; i < fields_count_; i++)
929 visit_at(contents, i, [&buffers](auto& content) {
930 content.builder.to_char_buffers(buffers);
931 });
932 }
933
936 std::string
937 form() const noexcept {
938 std::stringstream form_key;
939 form_key << "node" << id_;
940 std::string params("");
941 if (parameters_ == "") {
942 } else {
943 params = std::string("\"parameters\": { " + parameters_ + " }, ");
944 }
945 std::stringstream out;
946 out << "{ \"class\": \"RecordArray\", \"contents\": { ";
947 for (size_t i = 0; i < fields_count_; i++) {
948 if (i != 0) {
949 out << ", ";
950 }
951 auto contents_form = [&](auto& content) {
952 out << "\""
953 << (!content_names_.empty() ? content_names_.at(content.index)
954 : content.index_as_field())
955 << +"\": ";
956 out << content.builder.form();
957 };
958 visit_at(contents, i, contents_form);
959 }
960 out << " }, ";
961 out << params << "\"form_key\": \"" << form_key.str() << "\" }";
962 return out.str();
963 }
964
966 RecordContents contents;
967
968 private:
971 template <std::size_t... S>
972 void
973 map_fields(std::index_sequence<S...>) noexcept {
974 field_names_ = std::vector<std::string>(
975 {std::string(std::get<S>(contents).index_as_field())...});
976 }
977
980 template <std::size_t... S>
981 std::vector<size_t>
982 field_lengths(std::index_sequence<S...>) const noexcept {
983 return std::vector<size_t>({std::get<S>(contents).builder.length()...});
984 }
985
987 template <std::size_t... S>
988 std::vector<bool>
989 field_is_valid(std::index_sequence<S...>, std::string& error) const
990 noexcept {
991 return std::vector<bool>(
992 {std::get<S>(contents).builder.is_valid(error)...});
993 }
994
996 std::vector<std::string> field_names_;
997
999 UserDefinedMap content_names_;
1000
1002 std::string parameters_;
1003
1005 size_t id_;
1006
1008 static constexpr size_t fields_count_ = sizeof...(BUILDERS);
1009 };
1010
1017 template <typename... BUILDERS>
1018 class Tuple {
1019 using TupleContents = typename std::tuple<BUILDERS...>;
1020
1021 template <std::size_t INDEX>
1022 using TupleContentType = std::tuple_element_t<INDEX, TupleContents>;
1023
1024 public:
1026 Tuple() {
1027 size_t id = 0;
1028 set_id(id);
1029 }
1030
1032 template <std::size_t INDEX>
1033 TupleContentType<INDEX>&
1034 index() noexcept {
1035 return std::get<INDEX>(contents);
1036 }
1037
1039 const std::string&
1040 parameters() const noexcept {
1041 return parameters_;
1042 }
1043
1045 void
1046 set_parameters(std::string parameter) noexcept {
1047 parameters_ = parameter;
1048 }
1049
1051 void
1052 set_id(size_t& id) noexcept {
1053 id_ = id;
1054 id++;
1055 for (size_t i = 0; i < fields_count_; i++) {
1056 visit_at(contents, i, [&id](auto& content) {
1057 content.set_id(id);
1058 });
1059 }
1060 }
1061
1065 void
1066 clear() noexcept {
1067 for (size_t i = 0; i < fields_count_; i++)
1068 visit_at(contents, i, [](auto& content) {
1069 content.builder.clear();
1070 });
1071 }
1072
1074 const size_t
1075 length() const noexcept {
1076 return (std::get<0>(contents).builder.length());
1077 }
1078
1080 bool
1081 is_valid(std::string& error) const noexcept {
1082 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
1083
1084 size_t length = -1;
1085 bool result = false;
1086 std::vector<size_t> lengths = content_lengths(index_sequence);
1087 for (size_t i = 0; i < lengths.size(); i++) {
1088 if (length == -1) {
1089 length = lengths[i];
1090 } else if (length != lengths[i]) {
1091 std::stringstream out;
1092 out << "Record node" << id_ << " has index \"" << i << "\" length "
1093 << lengths[i] << " that differs from the first length "
1094 << length << "\n";
1095 error.append(out.str());
1096
1097 return false;
1098 }
1099 }
1100
1101 std::vector<bool> valid_fields =
1102 content_is_valid(index_sequence, error);
1103 return std::none_of(std::cbegin(valid_fields),
1104 std::cend(valid_fields),
1105 std::logical_not<bool>());
1106 }
1107
1110 void
1111 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
1112 noexcept {
1113 for (size_t i = 0; i < fields_count_; i++)
1114 visit_at(contents, i, [&names_nbytes](auto& content) {
1115 content.buffer_nbytes(names_nbytes);
1116 });
1117 }
1118
1124 void
1125 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
1126 for (size_t i = 0; i < fields_count_; i++)
1127 visit_at(contents, i, [&buffers](auto& content) {
1128 content.to_buffers(buffers);
1129 });
1130 }
1131
1136 void
1137 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
1138 for (size_t i = 0; i < fields_count_; i++)
1139 visit_at(contents, i, [&buffers](auto& content) {
1140 content.to_char_buffers(buffers);
1141 });
1142 }
1143
1146 std::string
1147 form() const noexcept {
1148 std::stringstream form_key;
1149 form_key << "node" << id_;
1150 std::string params("");
1151 if (parameters_ == "") {
1152 } else {
1153 params = std::string("\"parameters\": { " + parameters_ + " }, ");
1154 }
1155 std::stringstream out;
1156 out << "{ \"class\": \"RecordArray\", \"contents\": [";
1157 for (size_t i = 0; i < fields_count_; i++) {
1158 if (i != 0) {
1159 out << ", ";
1160 }
1161 auto contents_form = [&out](auto& content) {
1162 out << content.form();
1163 };
1164 visit_at(contents, i, contents_form);
1165 }
1166 out << "], ";
1167 out << params << "\"form_key\": \"" << form_key.str() << "\" }";
1168 return out.str();
1169 }
1170
1172 TupleContents contents;
1173
1174 private:
1177 template <std::size_t... S>
1178 std::vector<size_t>
1179 content_lengths(std::index_sequence<S...>) const noexcept {
1180 return std::vector<size_t>({std::get<S>(contents).length()...});
1181 }
1182
1184 template <std::size_t... S>
1185 std::vector<bool>
1186 content_is_valid(std::index_sequence<S...>, std::string& error) const
1187 noexcept {
1188 return std::vector<bool>({std::get<S>(contents).is_valid(error)...});
1189 }
1190
1192 std::vector<int64_t> field_index_;
1193
1195 std::string parameters_;
1196
1198 size_t id_;
1199
1201 static constexpr size_t fields_count_ = sizeof...(BUILDERS);
1202 };
1203
1217 template <unsigned SIZE, typename BUILDER>
1218 class Regular {
1219 public:
1221 Regular() : length_(0) {
1222 size_t id = 0;
1223 set_id(id);
1224 }
1225
1227 BUILDER&
1228 content() noexcept {
1229 return content_;
1230 }
1231
1234 BUILDER&
1235 begin_list() noexcept {
1236 return content_;
1237 }
1238
1240 void
1241 end_list() noexcept {
1242 length_++;
1243 }
1244
1246 const std::string&
1247 parameters() const noexcept {
1248 return parameters_;
1249 }
1250
1252 void
1253 set_parameters(std::string parameter) noexcept {
1254 parameters_ = parameter;
1255 }
1256
1258 void
1259 set_id(size_t& id) noexcept {
1260 id_ = id;
1261 id++;
1262 content_.set_id(id);
1263 }
1264
1266 void
1267 clear() noexcept {
1268 length_ = 0;
1269 content_.clear();
1270 }
1271
1273 size_t
1274 length() const noexcept {
1275 return length_;
1276 }
1277
1279 bool
1280 is_valid(std::string& error) const noexcept {
1281 if (content_.length() != length_ * size_) {
1282 std::stringstream out;
1283 out << "Regular node" << id_ << "has content length "
1284 << content_.length() << ", but length " << length_ << " and size "
1285 << size_ << "\n";
1286 error.append(out.str());
1287
1288 return false;
1289 } else {
1290 return content_.is_valid(error);
1291 }
1292 }
1293
1296 void
1297 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
1298 noexcept {
1299 content_.buffer_nbytes(names_nbytes);
1300 }
1301
1307 void
1308 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
1309 content_.to_buffers(buffers);
1310 }
1311
1316 void
1317 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
1318 content_.to_char_buffers(buffers);
1319 }
1320
1323 std::string
1324 form() const noexcept {
1325 std::stringstream form_key;
1326 form_key << "node" << id_;
1327 std::string params("");
1328 if (parameters_ == "") {
1329 } else {
1330 params = std::string(", \"parameters\": { " + parameters_ + " }");
1331 }
1332 return "{ \"class\": \"RegularArray\", \"content\": " +
1333 content_.form() + ", \"size\": " + std::to_string(size_) +
1334 params + ", \"form_key\": \"" + form_key.str() + "\" }";
1335 }
1336
1337 private:
1339 BUILDER content_;
1340
1342 std::string parameters_;
1343
1345 size_t id_;
1346
1348 size_t length_;
1349
1351 size_t size_ = SIZE;
1352 };
1353
1364 template <typename PRIMITIVE, typename BUILDER>
1365 class Indexed {
1366 public:
1369 Indexed()
1370 : index_(
1371 awkward::GrowableBuffer<PRIMITIVE>(default_options)),
1372 last_valid_(-1) {
1373 size_t id = 0;
1374 set_id(id);
1375 }
1376
1382 Indexed(const awkward::BuilderOptions& options)
1383 : index_(awkward::GrowableBuffer<PRIMITIVE>(options)),
1384 last_valid_(-1) {
1385 size_t id = 0;
1386 set_id(id);
1387 }
1388
1390 BUILDER&
1391 content() noexcept {
1392 return content_;
1393 }
1394
1397 BUILDER&
1398 append_index() noexcept {
1399 last_valid_ = content_.length();
1400 index_.append(last_valid_);
1401 return content_;
1402 }
1403
1408 BUILDER&
1409 extend_index(size_t size) noexcept {
1410 size_t start = content_.length();
1411 size_t stop = start + size;
1412 last_valid_ = stop - 1;
1413 for (size_t i = start; i < stop; i++) {
1414 index_.append(i);
1415 }
1416 return content_;
1417 }
1418
1420 const std::string&
1421 parameters() const noexcept {
1422 return parameters_;
1423 }
1424
1426 void
1427 set_parameters(std::string parameter) noexcept {
1428 parameters_ = parameter;
1429 }
1430
1432 void
1433 set_id(size_t& id) noexcept {
1434 id_ = id;
1435 id++;
1436 content_.set_id(id);
1437 }
1438
1441 void
1442 clear() noexcept {
1443 last_valid_ = -1;
1444 index_.clear();
1445 content_.clear();
1446 }
1447
1449 size_t
1450 length() const noexcept {
1451 return index_.length();
1452 }
1453
1455 bool
1456 is_valid(std::string& error) const noexcept {
1457 if (content_.length() != index_.length()) {
1458 std::stringstream out;
1459 out << "Indexed node" << id_ << " has content length "
1460 << content_.length() << " but index length " << index_.length()
1461 << "\n";
1462 error.append(out.str());
1463
1464 return false;
1465 } else if (content_.length() != last_valid_ + 1) {
1466 std::stringstream out;
1467 out << "Indexed node" << id_ << " has content length "
1468 << content_.length() << " but last valid index is " << last_valid_
1469 << "\n";
1470 error.append(out.str());
1471
1472 return false;
1473 } else {
1474 return content_.is_valid(error);
1475 }
1476 }
1477
1480 void
1481 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
1482 noexcept {
1483 names_nbytes["node" + std::to_string(id_) + "-index"] = index_.nbytes();
1484 content_.buffer_nbytes(names_nbytes);
1485 }
1486
1492 void
1493 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
1494 index_.concatenate(reinterpret_cast<PRIMITIVE*>(
1495 buffers["node" + std::to_string(id_) + "-index"]));
1496 content_.to_buffers(buffers);
1497 }
1498
1503 void
1504 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
1505 index_.concatenate(reinterpret_cast<PRIMITIVE*>(
1506 buffers["node" + std::to_string(id_) + "-index"]));
1507 content_.to_char_buffers(buffers);
1508 }
1509
1512 std::string
1513 form() const noexcept {
1514 std::stringstream form_key;
1515 form_key << "node" << id_;
1516 std::string params("");
1517 if (parameters_ == "") {
1518 } else {
1519 params = std::string(", \"parameters\": { " + parameters_ + " }");
1520 }
1521 return "{ \"class\": \"IndexedArray\", \"index\": \"" +
1522 type_to_numpy_like<PRIMITIVE>() +
1523 "\", \"content\": " + content_.form() + params +
1524 ", \"form_key\": \"" + form_key.str() + "\" }";
1525 }
1526
1527 private:
1531 GrowableBuffer<PRIMITIVE> index_;
1532
1534 BUILDER content_;
1535
1537 std::string parameters_;
1538
1540 size_t id_;
1541
1543 size_t last_valid_;
1544 };
1545
1556 template <typename PRIMITIVE, typename BUILDER>
1557 class IndexedOption {
1558 public:
1561 IndexedOption()
1562 : index_(
1563 awkward::GrowableBuffer<PRIMITIVE>(default_options)),
1564 last_valid_(-1) {
1565 size_t id = 0;
1566 set_id(id);
1567 }
1568
1574 IndexedOption(const awkward::BuilderOptions& options)
1575 : index_(awkward::GrowableBuffer<PRIMITIVE>(options)),
1576 last_valid_(-1) {
1577 size_t id = 0;
1578 set_id(id);
1579 }
1580
1582 BUILDER&
1583 content() noexcept {
1584 return content_;
1585 }
1586
1589 BUILDER&
1590 append_index() noexcept {
1591 last_valid_ = content_.length();
1592 index_.append(last_valid_);
1593 return content_;
1594 }
1595
1600 BUILDER&
1601 extend_index(size_t size) noexcept {
1602 size_t start = content_.length();
1603 size_t stop = start + size;
1604 last_valid_ = stop - 1;
1605 for (size_t i = start; i < stop; i++) {
1606 index_.append(i);
1607 }
1608 return content_;
1609 }
1610
1612 void
1613 append_null() noexcept {
1614 index_.append(-1);
1615 }
1616
1620 void
1621 extend_null(size_t size) noexcept {
1622 for (size_t i = 0; i < size; i++) {
1623 index_.append(-1);
1624 }
1625 }
1626
1628 const std::string&
1629 parameters() const noexcept {
1630 return parameters_;
1631 }
1632
1634 void
1635 set_parameters(std::string parameter) noexcept {
1636 parameters_ = parameter;
1637 }
1638
1640 void
1641 set_id(size_t& id) noexcept {
1642 id_ = id;
1643 id++;
1644 content_.set_id(id);
1645 }
1646
1649 void
1650 clear() noexcept {
1651 last_valid_ = -1;
1652 index_.clear();
1653 content_.clear();
1654 }
1655
1657 size_t
1658 length() const noexcept {
1659 return index_.length();
1660 }
1661
1663 bool
1664 is_valid(std::string& error) const noexcept {
1665 if (content_.length() != last_valid_ + 1) {
1666 std::stringstream out;
1667 out << "IndexedOption node" << id_ << " has content length "
1668 << content_.length() << " but last valid index is " << last_valid_
1669 << "\n";
1670 error.append(out.str());
1671
1672 return false;
1673 } else {
1674 return content_.is_valid(error);
1675 }
1676 }
1677
1680 void
1681 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
1682 noexcept {
1683 names_nbytes["node" + std::to_string(id_) + "-index"] = index_.nbytes();
1684 content_.buffer_nbytes(names_nbytes);
1685 }
1686
1692 void
1693 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
1694 index_.concatenate(reinterpret_cast<PRIMITIVE*>(
1695 buffers["node" + std::to_string(id_) + "-index"]));
1696 content_.to_buffers(buffers);
1697 }
1698
1703 void
1704 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
1705 index_.concatenate(reinterpret_cast<PRIMITIVE*>(
1706 buffers["node" + std::to_string(id_) + "-index"]));
1707 content_.to_char_buffers(buffers);
1708 }
1709
1712 std::string
1713 form() const noexcept {
1714 std::stringstream form_key;
1715 form_key << "node" << id_;
1716 std::string params("");
1717 if (parameters_ == "") {
1718 } else {
1719 params = std::string(", \"parameters\": { " + parameters_ + " }");
1720 }
1721 return "{ \"class\": \"IndexedOptionArray\", \"index\": \"" +
1722 type_to_numpy_like<PRIMITIVE>() +
1723 "\", \"content\": " + content_.form() + params +
1724 ", \"form_key\": \"" + form_key.str() + "\" }";
1725 }
1726
1727 private:
1731 GrowableBuffer<PRIMITIVE> index_;
1732
1734 BUILDER content_;
1735
1737 std::string parameters_;
1738
1740 size_t id_;
1741
1743 size_t last_valid_;
1744 };
1745
1757 template <typename BUILDER>
1758 class Unmasked {
1759 public:
1761 Unmasked() {
1762 size_t id = 0;
1763 set_id(id);
1764 }
1765
1767 BUILDER&
1768 content() noexcept {
1769 return content_;
1770 }
1771
1775 BUILDER&
1776 append_valid() noexcept {
1777 return content_;
1778 }
1784 BUILDER&
1785 extend_valid(size_t size) noexcept {
1786 return content_;
1787 }
1788
1790 const std::string&
1791 parameters() const noexcept {
1792 return parameters_;
1793 }
1794
1796 void
1797 set_parameters(std::string parameter) noexcept {
1798 parameters_ = parameter;
1799 }
1800
1802 void
1803 set_id(size_t& id) noexcept {
1804 id_ = id;
1805 id++;
1806 content_.set_id(id);
1807 }
1808
1810 void
1811 clear() noexcept {
1812 content_.clear();
1813 }
1814
1816 size_t
1817 length() const noexcept {
1818 return content_.length();
1819 }
1820
1822 bool
1823 is_valid(std::string& error) const noexcept {
1824 return content_.is_valid(error);
1825 }
1826
1829 void
1830 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
1831 noexcept {
1832 content_.buffer_nbytes(names_nbytes);
1833 }
1834
1840 void
1841 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
1842 content_.to_buffers(buffers);
1843 }
1844
1849 void
1850 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
1851 content_.to_char_buffers(buffers);
1852 }
1853
1856 std::string
1857 form() const noexcept {
1858 std::stringstream form_key;
1859 form_key << "node" << id_;
1860 std::string params("");
1861 if (parameters_ == "") {
1862 } else {
1863 params = std::string(", \"parameters\": { " + parameters_ + " }");
1864 }
1865 return "{ \"class\": \"UnmaskedArray\", \"content\": " +
1866 content_.form() + params + ", \"form_key\": \"" +
1867 form_key.str() + "\" }";
1868 }
1869
1870 private:
1872 BUILDER content_;
1873
1875 std::string parameters_;
1876
1878 size_t id_;
1879 };
1880
1897 template <bool VALID_WHEN, typename BUILDER>
1898 class ByteMasked {
1899 public:
1902 ByteMasked()
1903 : mask_(awkward::GrowableBuffer<int8_t>(default_options)) {
1904 size_t id = 0;
1905 set_id(id);
1906 }
1907
1913 ByteMasked(const awkward::BuilderOptions& options)
1914 : mask_(awkward::GrowableBuffer<int8_t>(options)) {
1915 size_t id = 0;
1916 set_id(id);
1917 }
1918
1920 BUILDER&
1921 content() noexcept {
1922 return content_;
1923 }
1924
1926 bool
1927 valid_when() const noexcept {
1928 return valid_when_;
1929 }
1930
1934 BUILDER&
1935 append_valid() noexcept {
1936 mask_.append(valid_when_);
1937 return content_;
1938 }
1939
1945 BUILDER&
1946 extend_valid(size_t size) noexcept {
1947 for (size_t i = 0; i < size; i++) {
1948 mask_.append(valid_when_);
1949 }
1950 return content_;
1951 }
1952
1956 BUILDER&
1957 append_null() noexcept {
1958 mask_.append(!valid_when_);
1959 return content_;
1960 }
1961
1967 BUILDER&
1968 extend_null(size_t size) noexcept {
1969 for (size_t i = 0; i < size; i++) {
1970 mask_.append(!valid_when_);
1971 }
1972 return content_;
1973 }
1974
1976 const std::string&
1977 parameters() const noexcept {
1978 return parameters_;
1979 }
1980
1982 void
1983 set_parameters(std::string parameter) noexcept {
1984 parameters_ = parameter;
1985 }
1986
1988 void
1989 set_id(size_t& id) noexcept {
1990 id_ = id;
1991 id++;
1992 content_.set_id(id);
1993 }
1994
1997 void
1998 clear() noexcept {
1999 mask_.clear();
2000 content_.clear();
2001 }
2002
2004 size_t
2005 length() const noexcept {
2006 return mask_.length();
2007 }
2008
2010 bool
2011 is_valid(std::string& error) const noexcept {
2012 if (content_.length() != mask_.length()) {
2013 std::stringstream out;
2014 out << "ByteMasked node" << id_ << "has content length "
2015 << content_.length() << "but mask length " << mask_.length()
2016 << "\n";
2017 error.append(out.str());
2018
2019 return false;
2020 } else {
2021 return content_.is_valid(error);
2022 }
2023 }
2024
2027 void
2028 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
2029 noexcept {
2030 names_nbytes["node" + std::to_string(id_) + "-mask"] = mask_.nbytes();
2031 content_.buffer_nbytes(names_nbytes);
2032 }
2033
2039 void
2040 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
2041 mask_.concatenate(reinterpret_cast<int8_t*>(
2042 buffers["node" + std::to_string(id_) + "-mask"]));
2043 content_.to_buffers(buffers);
2044 }
2045
2050 void
2051 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
2052 mask_.concatenate(reinterpret_cast<int8_t*>(
2053 buffers["node" + std::to_string(id_) + "-mask"]));
2054 content_.to_char_buffers(buffers);
2055 }
2056
2059 std::string
2060 form() const noexcept {
2061 std::stringstream form_key, form_valid_when;
2062 form_key << "node" << id_;
2063 form_valid_when << std::boolalpha << valid_when_;
2064 std::string params("");
2065 if (parameters_ == "") {
2066 } else {
2067 params = std::string(", \"parameters\": { " + parameters_ + " }");
2068 }
2069 return "{ \"class\": \"ByteMaskedArray\", \"mask\": \"i8\", "
2070 "\"content\": " +
2071 content_.form() + ", \"valid_when\": " + form_valid_when.str() +
2072 params + ", \"form_key\": \"" + form_key.str() + "\" }";
2073 }
2074
2075 private:
2079 GrowableBuffer<int8_t> mask_;
2080
2082 BUILDER content_;
2083
2085 std::string parameters_;
2086
2088 size_t id_;
2089
2091 bool valid_when_ = VALID_WHEN;
2092 };
2093
2110 template <bool VALID_WHEN, bool LSB_ORDER, typename BUILDER>
2111 class BitMasked {
2112 public:
2115 BitMasked()
2116 : mask_(awkward::GrowableBuffer<uint8_t>(default_options)),
2117 current_byte_(uint8_t(0)),
2118 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
2119 current_index_(0) {
2120 size_t id = 0;
2121 set_id(id);
2122 if (lsb_order_) {
2123 for (size_t i = 0; i < 8; i++) {
2124 cast_[i] = 1 << i;
2125 }
2126 } else {
2127 for (size_t i = 0; i < 8; i++) {
2128 cast_[i] = 128 >> i;
2129 }
2130 }
2131 }
2132
2138 BitMasked(const awkward::BuilderOptions& options)
2139 : mask_(awkward::GrowableBuffer<uint8_t>(options)),
2140 current_byte_(uint8_t(0)),
2141 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
2142 current_index_(0) {
2143 size_t id = 0;
2144 set_id(id);
2145 if (lsb_order_) {
2146 for (size_t i = 0; i < 8; i++) {
2147 cast_[i] = 1 << i;
2148 }
2149 } else {
2150 for (size_t i = 0; i < 8; i++) {
2151 cast_[i] = 128 >> i;
2152 }
2153 }
2154 }
2155
2157 BUILDER&
2158 content() noexcept {
2159 return content_;
2160 }
2161
2163 bool
2164 valid_when() const noexcept {
2165 return valid_when_;
2166 }
2167
2170 bool
2171 lsb_order() const noexcept {
2172 return lsb_order_;
2173 }
2174
2179 BUILDER&
2180 append_valid() noexcept {
2181 append_begin();
2182 current_byte_ |= cast_[current_index_];
2183 append_end();
2184 return content_;
2185 }
2186
2193 BUILDER&
2194 extend_valid(size_t size) noexcept {
2195 for (size_t i = 0; i < size; i++) {
2196 append_valid();
2197 }
2198 return content_;
2199 }
2200
2204 BUILDER&
2205 append_null() noexcept {
2206 append_begin();
2207 append_end();
2208 return content_;
2209 }
2210
2216 BUILDER&
2217 extend_null(size_t size) noexcept {
2218 for (size_t i = 0; i < size; i++) {
2219 append_null();
2220 }
2221 return content_;
2222 }
2223
2225 const std::string&
2226 parameters() const noexcept {
2227 return parameters_;
2228 }
2229
2231 void
2232 set_parameters(std::string parameter) noexcept {
2233 parameters_ = parameter;
2234 }
2235
2237 void
2238 set_id(size_t& id) noexcept {
2239 id_ = id;
2240 id++;
2241 content_.set_id(id);
2242 }
2243
2246 void
2247 clear() noexcept {
2248 mask_.clear();
2249 content_.clear();
2250 }
2251
2253 size_t
2254 length() const noexcept {
2255 return (mask_.length() - 1) * 8 + current_index_;
2256 }
2257
2259 bool
2260 is_valid(std::string& error) const noexcept {
2261 if (content_.length() != length()) {
2262 std::stringstream out;
2263 out << "BitMasked node" << id_ << "has content length "
2264 << content_.length() << "but bit mask length " << mask_.length()
2265 << "\n";
2266 error.append(out.str());
2267
2268 return false;
2269 } else {
2270 return content_.is_valid(error);
2271 }
2272 }
2273
2276 void
2277 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
2278 noexcept {
2279 names_nbytes["node" + std::to_string(id_) + "-mask"] = mask_.nbytes();
2280 content_.buffer_nbytes(names_nbytes);
2281 }
2282
2288 void
2289 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
2290 mask_.concatenate_from(reinterpret_cast<uint8_t*>(
2291 buffers["node" + std::to_string(id_) + "-mask"]), 0, 1);
2292 mask_.append(reinterpret_cast<uint8_t*>(
2293 buffers["node" + std::to_string(id_) + "-mask"]), mask_.length() - 1, 0, 1);
2294 content_.to_buffers(buffers);
2295 }
2296
2301 void
2302 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
2303 mask_.concatenate_from(reinterpret_cast<uint8_t*>(
2304 buffers["node" + std::to_string(id_) + "-mask"]), 0, 1);
2305 mask_.append(reinterpret_cast<uint8_t*>(
2306 buffers["node" + std::to_string(id_) + "-mask"]), mask_.length() - 1, 0, 1);
2307 content_.to_char_buffers(buffers);
2308 }
2309
2312 std::string
2313 form() const noexcept {
2314 std::stringstream form_key, form_valid_when, form_lsb_order;
2315 form_key << "node" << id_;
2316 form_valid_when << std::boolalpha << valid_when_;
2317 form_lsb_order << std::boolalpha << lsb_order_;
2318 std::string params("");
2319 if (parameters_ == "") {
2320 } else {
2321 params = std::string(", \"parameters\": { " + parameters_ + " }");
2322 }
2323 return "{ \"class\": \"BitMaskedArray\", \"mask\": \"u8\", "
2324 "\"content\": " +
2325 content_.form() + ", \"valid_when\": " + form_valid_when.str() +
2326 ", \"lsb_order\": " + form_lsb_order.str() + params +
2327 ", \"form_key\": \"" + form_key.str() + "\" }";
2328 }
2329
2330 private:
2334 void
2335 append_begin() {
2336 if (current_index_ == 8) {
2337 current_byte_ref_ = mask_.append_and_get_ref(current_byte_);
2338 current_byte_ = uint8_t(0);
2339 current_index_ = 0;
2340 }
2341 }
2342
2348 void
2349 append_end() {
2350 current_index_ += 1;
2351 if (valid_when_) {
2352 current_byte_ref_ = current_byte_;
2353 } else {
2354 current_byte_ref_ = ~current_byte_;
2355 }
2356 }
2357
2361 GrowableBuffer<uint8_t> mask_;
2362
2364 BUILDER content_;
2365
2367 std::string parameters_;
2368
2370 size_t id_;
2371
2373 uint8_t current_byte_;
2374
2376 uint8_t& current_byte_ref_;
2377
2379 size_t current_index_;
2380
2382 uint8_t cast_[8];
2383
2385 bool valid_when_ = VALID_WHEN;
2386
2389 bool lsb_order_ = LSB_ORDER;
2390 };
2391
2407 template <typename TAGS, typename INDEX, typename... BUILDERS>
2408 class Union {
2409 public:
2410 using Contents = typename std::tuple<BUILDERS...>;
2411
2412 template <std::size_t I>
2413 using ContentType = std::tuple_element_t<I, Contents>;
2414
2417 Union()
2418 : tags_(awkward::GrowableBuffer<TAGS>(default_options)),
2419 index_(awkward::GrowableBuffer<INDEX>(default_options)) {
2420 size_t id = 0;
2421 set_id(id);
2422 for (size_t i = 0; i < contents_count_; i++)
2423 last_valid_index_[i] = -1;
2424 }
2425
2431 Union(const awkward::BuilderOptions& options)
2432 : tags_(awkward::GrowableBuffer<TAGS>(options)),
2433 index_(awkward::GrowableBuffer<INDEX>(options)) {
2434 size_t id = 0;
2435 set_id(id);
2436 for (size_t i = 0; i < contents_count_; i++)
2437 last_valid_index_[i] = -1;
2438 }
2439
2440 template <std::size_t I>
2441 ContentType<I>&
2442 content() noexcept {
2443 return std::get<I>(contents_);
2444 }
2445
2448 template <std::size_t TAG>
2449 ContentType<TAG>&
2450 append_index() noexcept {
2451 auto& which_content = std::get<TAG>(contents_);
2452 INDEX next_index = which_content.length();
2453
2454 TAGS tag = (TAGS)TAG;
2455 last_valid_index_[tag] = next_index;
2456 tags_.append(tag);
2457 index_.append(next_index);
2458
2459 return which_content;
2460 }
2461
2463 const std::string&
2464 parameters() const noexcept {
2465 return parameters_;
2466 }
2467
2469 void
2470 set_parameters(std::string parameter) noexcept {
2471 parameters_ = parameter;
2472 }
2473
2475 void
2476 set_id(size_t& id) noexcept {
2477 id_ = id;
2478 id++;
2479 auto contents_id = [&id](auto& content) {
2480 content.set_id(id);
2481 };
2482 for (size_t i = 0; i < contents_count_; i++)
2483 visit_at(contents_, i, contents_id);
2484 }
2485
2490 void
2491 clear() noexcept {
2492 for (size_t i = 0; i < contents_count_; i++)
2493 last_valid_index_[i] = -1;
2494 tags_.clear();
2495 index_.clear();
2496 auto clear_contents = [](auto& content) {
2497 content.builder.clear();
2498 };
2499 for (size_t i = 0; i < contents_count_; i++)
2500 visit_at(contents_, i, clear_contents);
2501 }
2502
2504 size_t
2505 length() const noexcept {
2506 return tags_.length();
2507 }
2508
2510 bool
2511 is_valid(std::string& error) const noexcept {
2512 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2513
2514 std::vector<size_t> lengths = content_lengths(index_sequence);
2515 for (size_t tag = 0; tag < contents_count_; tag++) {
2516 if (lengths[tag] != last_valid_index_[tag] + 1) {
2517 std::stringstream out;
2518 out << "Union node" << id_ << " has content length " << lengths[tag]
2519 << " but index length " << last_valid_index_[tag] << "\n";
2520 error.append(out.str());
2521
2522 return false;
2523 }
2524 }
2525
2526 std::vector<bool> valid_contents =
2527 content_is_valid(index_sequence, error);
2528 return std::none_of(std::cbegin(valid_contents),
2529 std::cend(valid_contents),
2530 std::logical_not<bool>());
2531 }
2532
2535 void
2536 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
2537 noexcept {
2538 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2539
2540 names_nbytes["node" + std::to_string(id_) + "-tags"] = tags_.nbytes();
2541 names_nbytes["node" + std::to_string(id_) + "-index"] = index_.nbytes();
2542
2543 for (size_t i = 0; i < contents_count_; i++)
2544 visit_at(contents_, i, [&names_nbytes](auto& content) {
2545 content.buffer_nbytes(names_nbytes);
2546 });
2547 }
2548
2554 void
2555 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
2556 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2557
2558 tags_.concatenate(reinterpret_cast<TAGS*>(
2559 buffers["node" + std::to_string(id_) + "-tags"]));
2560 index_.concatenate(reinterpret_cast<INDEX*>(
2561 buffers["node" + std::to_string(id_) + "-index"]));
2562
2563 for (size_t i = 0; i < contents_count_; i++)
2564 visit_at(contents_, i, [&buffers](auto& content) {
2565 content.to_buffers(buffers);
2566 });
2567 }
2568
2573 void
2574 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
2575 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2576
2577 tags_.concatenate(reinterpret_cast<TAGS*>(
2578 buffers["node" + std::to_string(id_) + "-tags"]));
2579 index_.concatenate(reinterpret_cast<INDEX*>(
2580 buffers["node" + std::to_string(id_) + "-index"]));
2581
2582 for (size_t i = 0; i < contents_count_; i++)
2583 visit_at(contents_, i, [&buffers](auto& content) {
2584 content.to_char_buffers(buffers);
2585 });
2586 }
2587
2590 std::string
2591 form() const noexcept {
2592 std::stringstream form_key;
2593 form_key << "node" << id_;
2594 std::string params("");
2595 if (parameters_ == "") {
2596 } else {
2597 params = std::string(", \"parameters\": { " + parameters_ + " }");
2598 }
2599 std::stringstream out;
2600 out << "{ \"class\": \"UnionArray\", \"tags\": \"" +
2601 type_to_numpy_like<TAGS>() + "\", \"index\": \"" +
2602 type_to_numpy_like<INDEX>() + "\", \"contents\": [";
2603 for (size_t i = 0; i < contents_count_; i++) {
2604 if (i != 0) {
2605 out << ", ";
2606 }
2607 auto contents_form = [&](auto& content) {
2608 out << content.form();
2609 };
2610 visit_at(contents_, i, contents_form);
2611 }
2612 out << "], ";
2613 out << params << "\"form_key\": \"" << form_key.str() << "\" }";
2614 return out.str();
2615 }
2616
2617 private:
2620 template <std::size_t... S>
2621 std::vector<size_t>
2622 content_lengths(std::index_sequence<S...>) const {
2623 return std::vector<size_t>({std::get<S>(contents_).length()...});
2624 }
2625
2627 template <std::size_t... S>
2628 std::vector<bool>
2629 content_is_valid(std::index_sequence<S...>, std::string& error) const {
2630 return std::vector<bool>({std::get<S>(contents_).is_valid(error)...});
2631 }
2632
2636 GrowableBuffer<TAGS> tags_;
2637
2641 GrowableBuffer<INDEX> index_;
2642
2644 Contents contents_;
2645
2647 std::string parameters_;
2648
2650 size_t id_;
2651
2653 size_t last_valid_index_[sizeof...(BUILDERS)];
2654
2656 static constexpr size_t contents_count_ = sizeof...(BUILDERS);
2657 };
2658
2659 } // namespace LayoutBuilder
2660} // namespace awkward
2661
2662#endif // AWKWARD_LAYOUTBUILDER_H_
BuilderOptions.h
GrowableBuffer.h
awkward::GrowableBuffer
Discontiguous, one-dimensional buffer (which consists of multiple contiguous, one-dimensional panels)...
Definition: GrowableBuffer.h:174
awkward::GrowableBuffer::concatenate_from
void concatenate_from(PRIMITIVE *external_pointer, size_t to, size_t from) const noexcept
Copies and concatenates all accumulated data from multiple panels to one contiguously allocated exter...
Definition: GrowableBuffer.h:435
awkward::GrowableBuffer::nbytes
size_t nbytes() const
Currently used number of bytes.
Definition: GrowableBuffer.h:374
awkward::GrowableBuffer::concatenate
void concatenate(PRIMITIVE *external_pointer) const noexcept
Copies and concatenates all accumulated data from multiple panels to one contiguously allocated exter...
Definition: GrowableBuffer.h:426
awkward::GrowableBuffer::append_and_get_ref
PRIMITIVE & append_and_get_ref(PRIMITIVE datum)
Like append, but the type signature returns the reference to PRIMITIVE.
Definition: GrowableBuffer.h:418
awkward::GrowableBuffer::length
size_t length() const
Currently used number of elements.
Definition: GrowableBuffer.h:343
awkward::GrowableBuffer::append
void append(PRIMITIVE datum)
Inserts one datum into the panel, possibly triggering allocation of a new panel.
Definition: GrowableBuffer.h:384
awkward::GrowableBuffer::clear
void clear()
Discards accumulated data, the #reserved returns to options.initial(), and a new #ptr is allocated.
Definition: GrowableBuffer.h:356
awkward::LayoutBuilder::BitMasked
Builds a BitMaskedArray in which mask values are packed into a bitmap.
Definition: LayoutBuilder.h:2111
awkward::LayoutBuilder::BitMasked::valid_when
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition: LayoutBuilder.h:2164
awkward::LayoutBuilder::BitMasked::clear
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition: LayoutBuilder.h:2247
awkward::LayoutBuilder::BitMasked::lsb_order
bool lsb_order() const noexcept
Determines whether the position of each bit is in Least-Significant Bit order (LSB) or not.
Definition: LayoutBuilder.h:2171
awkward::LayoutBuilder::BitMasked::extend_valid
BUILDER & extend_valid(size_t size) noexcept
Sets size number of bits in the mask. If current_byte_ and cast_: 0 indicates null,...
Definition: LayoutBuilder.h:2194
awkward::LayoutBuilder::BitMasked::form
std::string form() const noexcept
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition: LayoutBuilder.h:2313
awkward::LayoutBuilder::BitMasked::extend_null
BUILDER & extend_null(size_t size) noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition: LayoutBuilder.h:2217
awkward::LayoutBuilder::BitMasked::parameters
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:2226
awkward::LayoutBuilder::BitMasked::set_parameters
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:2232
awkward::LayoutBuilder::BitMasked::content
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:2158
awkward::LayoutBuilder::BitMasked::length
size_t length() const noexcept
Current length of the mask buffer.
Definition: LayoutBuilder.h:2254
awkward::LayoutBuilder::BitMasked::to_char_buffers
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition: LayoutBuilder.h:2302
awkward::LayoutBuilder::BitMasked::set_id
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:2238
awkward::LayoutBuilder::BitMasked::is_valid
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:2260
awkward::LayoutBuilder::BitMasked::BitMasked
BitMasked(const awkward::BuilderOptions &options)
Creates a new BitMasked layout builder by allocating a new mask buffer, taking options from BuilderOp...
Definition: LayoutBuilder.h:2138
awkward::LayoutBuilder::BitMasked::append_valid
BUILDER & append_valid() noexcept
Sets a bit in the mask. If current_byte_ and cast_: 0 indicates null, 1 indicates valid and vice vers...
Definition: LayoutBuilder.h:2180
awkward::LayoutBuilder::BitMasked::buffer_nbytes
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Retrieves the names and sizes (in bytes) of the buffers used in the builder and its contents.
Definition: LayoutBuilder.h:2277
awkward::LayoutBuilder::BitMasked::BitMasked
BitMasked()
Creates a new BitMasked layout builder by allocating a new mask buffer, using default_options for ini...
Definition: LayoutBuilder.h:2115
awkward::LayoutBuilder::BitMasked::append_null
BUILDER & append_null() noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition: LayoutBuilder.h:2205
awkward::LayoutBuilder::BitMasked::to_buffers
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Copies and concatenates all the accumulated data in each of the buffers of the builder and its conten...
Definition: LayoutBuilder.h:2289
awkward::LayoutBuilder::ByteMasked
Builds a ByteMaskedArray using a mask which is an array of booleans that determines whether the corre...
Definition: LayoutBuilder.h:1898
awkward::LayoutBuilder::ByteMasked::valid_when
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition: LayoutBuilder.h:1927
awkward::LayoutBuilder::ByteMasked::clear
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition: LayoutBuilder.h:1998
awkward::LayoutBuilder::ByteMasked::extend_valid
BUILDER & extend_valid(size_t size) noexcept
Inserts size number of valid_when in the mask.
Definition: LayoutBuilder.h:1946
awkward::LayoutBuilder::ByteMasked::form
std::string form() const noexcept
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition: LayoutBuilder.h:2060
awkward::LayoutBuilder::ByteMasked::extend_null
BUILDER & extend_null(size_t size) noexcept
Inserts size number of !valid_when in the mask.
Definition: LayoutBuilder.h:1968
awkward::LayoutBuilder::ByteMasked::parameters
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:1977
awkward::LayoutBuilder::ByteMasked::ByteMasked
ByteMasked()
Creates a new ByteMasked layout builder by allocating a new mask buffer, using default_options for in...
Definition: LayoutBuilder.h:1902
awkward::LayoutBuilder::ByteMasked::set_parameters
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:1983
awkward::LayoutBuilder::ByteMasked::content
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:1921
awkward::LayoutBuilder::ByteMasked::ByteMasked
ByteMasked(const awkward::BuilderOptions &options)
Creates a new ByteMasked layout builder by allocating a new mask buffer, taking options from BuilderO...
Definition: LayoutBuilder.h:1913
awkward::LayoutBuilder::ByteMasked::length
size_t length() const noexcept
Current length of the mask buffer.
Definition: LayoutBuilder.h:2005
awkward::LayoutBuilder::ByteMasked::to_char_buffers
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition: LayoutBuilder.h:2051
awkward::LayoutBuilder::ByteMasked::set_id
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:1989
awkward::LayoutBuilder::ByteMasked::is_valid
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:2011
awkward::LayoutBuilder::ByteMasked::append_valid
BUILDER & append_valid() noexcept
Inserts valid_when in the mask.
Definition: LayoutBuilder.h:1935
awkward::LayoutBuilder::ByteMasked::buffer_nbytes
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Retrieves the names and sizes (in bytes) of the buffers used in the builder and its contents.
Definition: LayoutBuilder.h:2028
awkward::LayoutBuilder::ByteMasked::append_null
BUILDER & append_null() noexcept
Inserts !valid_when in the mask.
Definition: LayoutBuilder.h:1957
awkward::LayoutBuilder::ByteMasked::to_buffers
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Copies and concatenates all the accumulated data in each of the buffers of the builder and its conten...
Definition: LayoutBuilder.h:2040
awkward::LayoutBuilder::EmptyRecord
Builds an Empty RecordArray which has has zero contents. It still represents a non-empty array....
Definition: LayoutBuilder.h:648
awkward::LayoutBuilder::EmptyRecord::clear
void clear() noexcept
Clears the builder contents, the length returns to zero.
Definition: LayoutBuilder.h:691
awkward::LayoutBuilder::EmptyRecord::is_valid
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:703
awkward::LayoutBuilder::EmptyRecord::form
std::string form() const noexcept
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition: LayoutBuilder.h:724
awkward::LayoutBuilder::EmptyRecord::parameters
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:672
awkward::LayoutBuilder::EmptyRecord::set_parameters
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:678
awkward::LayoutBuilder::EmptyRecord::append
void append() noexcept
Inserts an empty record.
Definition: LayoutBuilder.h:658
awkward::LayoutBuilder::EmptyRecord::length
size_t length() const noexcept
Current number of records.
Definition: LayoutBuilder.h:697
awkward::LayoutBuilder::EmptyRecord::to_char_buffers
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition: LayoutBuilder.h:719
awkward::LayoutBuilder::EmptyRecord::set_id
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:684
awkward::LayoutBuilder::EmptyRecord::buffer_nbytes
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Definition: LayoutBuilder.h:708
awkward::LayoutBuilder::EmptyRecord::extend
void extend(size_t size) noexcept
Inserts size number of empty records.
Definition: LayoutBuilder.h:666
awkward::LayoutBuilder::EmptyRecord::EmptyRecord
EmptyRecord()
Creates a new EmptyRecord layout builder.
Definition: LayoutBuilder.h:651
awkward::LayoutBuilder::EmptyRecord::to_buffers
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Definition: LayoutBuilder.h:712
awkward::LayoutBuilder::Empty
Builds an EmptyArray which has no content in it. It is used whenever an array's type is not known bec...
Definition: LayoutBuilder.h:567
awkward::LayoutBuilder::Empty::clear
void clear() noexcept
Definition: LayoutBuilder.h:591
awkward::LayoutBuilder::Empty::is_valid
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:601
awkward::LayoutBuilder::Empty::form
std::string form() const noexcept
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition: LayoutBuilder.h:622
awkward::LayoutBuilder::Empty::parameters
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:577
awkward::LayoutBuilder::Empty::set_parameters
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:583
awkward::LayoutBuilder::Empty::Empty
Empty()
Creates a new Empty layout builder.
Definition: LayoutBuilder.h:570
awkward::LayoutBuilder::Empty::length
size_t length() const noexcept
Current length of the content.
Definition: LayoutBuilder.h:595
awkward::LayoutBuilder::Empty::to_char_buffers
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition: LayoutBuilder.h:617
awkward::LayoutBuilder::Empty::set_id
void set_id(size_t &id) noexcept
Definition: LayoutBuilder.h:588
awkward::LayoutBuilder::Empty::buffer_nbytes
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Definition: LayoutBuilder.h:606
awkward::LayoutBuilder::Empty::to_buffers
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Definition: LayoutBuilder.h:610
awkward::LayoutBuilder::Field
Helper class for sending a pair of field names (as enum) and field type as template parameters in Rec...
Definition: LayoutBuilder.h:31
awkward::LayoutBuilder::Field::index_as_field
std::string index_as_field() const
Converts index as field string.
Definition: LayoutBuilder.h:37
awkward::LayoutBuilder::Field::Builder
BUILDER Builder
Definition: LayoutBuilder.h:33
awkward::LayoutBuilder::Field::index
const std::size_t index
The index of a Record field.
Definition: LayoutBuilder.h:42
awkward::LayoutBuilder::Field::builder
Builder builder
The content type of field in a Record.
Definition: LayoutBuilder.h:44
awkward::LayoutBuilder::IndexedOption
Builds an IndexedOptionArray which consists of an index buffer. The negative values in the index are ...
Definition: LayoutBuilder.h:1557
awkward::LayoutBuilder::IndexedOption::clear
void clear() noexcept
Discards the accumulated index and clears the content of the builder. Also, last valid returns to -1.
Definition: LayoutBuilder.h:1650
awkward::LayoutBuilder::IndexedOption::extend_null
void extend_null(size_t size) noexcept
Inserts -1 in the index buffer size number of times.
Definition: LayoutBuilder.h:1621
awkward::LayoutBuilder::IndexedOption::form
std::string form() const noexcept
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition: LayoutBuilder.h:1713
awkward::LayoutBuilder::IndexedOption::parameters
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:1629
awkward::LayoutBuilder::IndexedOption::append_index
BUILDER & append_index() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition: LayoutBuilder.h:1590
awkward::LayoutBuilder::IndexedOption::set_parameters
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:1635
awkward::LayoutBuilder::IndexedOption::IndexedOption
IndexedOption(const awkward::BuilderOptions &options)
Creates a new IndexedOption layout builder by allocating a new index buffer, taking options from Buil...
Definition: LayoutBuilder.h:1574
awkward::LayoutBuilder::IndexedOption::content
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:1583
awkward::LayoutBuilder::IndexedOption::extend_index
BUILDER & extend_index(size_t size) noexcept
Inserts size number of valid index in the index buffer and returns the reference to the builder conte...
Definition: LayoutBuilder.h:1601
awkward::LayoutBuilder::IndexedOption::length
size_t length() const noexcept
Current length of the index buffer.
Definition: LayoutBuilder.h:1658
awkward::LayoutBuilder::IndexedOption::to_char_buffers
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition: LayoutBuilder.h:1704
awkward::LayoutBuilder::IndexedOption::set_id
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:1641
awkward::LayoutBuilder::IndexedOption::append_null
void append_null() noexcept
Inserts -1 in the index buffer.
Definition: LayoutBuilder.h:1613
awkward::LayoutBuilder::IndexedOption::is_valid
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:1664
awkward::LayoutBuilder::IndexedOption::IndexedOption
IndexedOption()
Creates a new IndexedOption layout builder by allocating a new index buffer, using default_options fo...
Definition: LayoutBuilder.h:1561
awkward::LayoutBuilder::IndexedOption::buffer_nbytes
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Retrieves the names and sizes (in bytes) of the buffers used in the builder and its contents.
Definition: LayoutBuilder.h:1681
awkward::LayoutBuilder::IndexedOption::to_buffers
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Copies and concatenates all the accumulated data in each of the buffers of the builder and its conten...
Definition: LayoutBuilder.h:1693
awkward::LayoutBuilder::Indexed
Builds an IndexedArray which consists of an index buffer. It is a general-purpose tool for changing t...
Definition: LayoutBuilder.h:1365
awkward::LayoutBuilder::Indexed::clear
void clear() noexcept
Discards the accumulated index and clears the content of the builder. Also, last valid returns to -1.
Definition: LayoutBuilder.h:1442
awkward::LayoutBuilder::Indexed::form
std::string form() const noexcept
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition: LayoutBuilder.h:1513
awkward::LayoutBuilder::Indexed::Indexed
Indexed(const awkward::BuilderOptions &options)
Creates a new Indexed layout builder by allocating a new index buffer, taking options from BuilderOpt...
Definition: LayoutBuilder.h:1382
awkward::LayoutBuilder::Indexed::parameters
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:1421
awkward::LayoutBuilder::Indexed::Indexed
Indexed()
Creates a new Indexed layout builder by allocating a new index buffer, using default_options for init...
Definition: LayoutBuilder.h:1369
awkward::LayoutBuilder::Indexed::append_index
BUILDER & append_index() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition: LayoutBuilder.h:1398
awkward::LayoutBuilder::Indexed::set_parameters
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:1427
awkward::LayoutBuilder::Indexed::content
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:1391
awkward::LayoutBuilder::Indexed::extend_index
BUILDER & extend_index(size_t size) noexcept
Inserts size number of valid index in the index buffer and returns the reference to the builder conte...
Definition: LayoutBuilder.h:1409
awkward::LayoutBuilder::Indexed::length
size_t length() const noexcept
Current length of the content and the index buffer.
Definition: LayoutBuilder.h:1450
awkward::LayoutBuilder::Indexed::to_char_buffers
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition: LayoutBuilder.h:1504
awkward::LayoutBuilder::Indexed::set_id
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:1433
awkward::LayoutBuilder::Indexed::is_valid
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:1456
awkward::LayoutBuilder::Indexed::buffer_nbytes
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Retrieves the names and sizes (in bytes) of the buffers used in the builder and its contents.
Definition: LayoutBuilder.h:1481
awkward::LayoutBuilder::Indexed::to_buffers
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Copies and concatenates all the accumulated data in each of the buffers of the builder and its conten...
Definition: LayoutBuilder.h:1493
awkward::LayoutBuilder::ListOffset
Builds a ListOffsetArray which describes unequal-length lists (often called a "jagged" or "ragged" ar...
Definition: LayoutBuilder.h:209
awkward::LayoutBuilder::ListOffset::clear
void clear() noexcept
Discards the accumulated offsets and clears the builder content.
Definition: LayoutBuilder.h:274
awkward::LayoutBuilder::ListOffset::begin_list
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the builder content.
Definition: LayoutBuilder.h:241
awkward::LayoutBuilder::ListOffset::ListOffset
ListOffset()
Creates a new ListOffset layout builder by allocating a new offset buffer, using default_options for ...
Definition: LayoutBuilder.h:213
awkward::LayoutBuilder::ListOffset::form
std::string form() const noexcept
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition: LayoutBuilder.h:338
awkward::LayoutBuilder::ListOffset::parameters
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:254
awkward::LayoutBuilder::ListOffset::set_parameters
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:260
awkward::LayoutBuilder::ListOffset::content
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:235
awkward::LayoutBuilder::ListOffset::length
size_t length() const noexcept
Current length of the content.
Definition: LayoutBuilder.h:282
awkward::LayoutBuilder::ListOffset::to_char_buffers
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition: LayoutBuilder.h:329
awkward::LayoutBuilder::ListOffset::set_id
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:266
awkward::LayoutBuilder::ListOffset::is_valid
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:288
awkward::LayoutBuilder::ListOffset::end_list
void end_list() noexcept
Ends a list and appends the current length of the list contents in the offsets buffer.
Definition: LayoutBuilder.h:248
awkward::LayoutBuilder::ListOffset::buffer_nbytes
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Retrieves the names and sizes (in bytes) of the buffers used in the builder and its contents.
Definition: LayoutBuilder.h:305
awkward::LayoutBuilder::ListOffset::ListOffset
ListOffset(const awkward::BuilderOptions &options)
Creates a new ListOffset layout builder by allocating a new offset buffer, taking options from Builde...
Definition: LayoutBuilder.h:226
awkward::LayoutBuilder::ListOffset::to_buffers
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Copies and concatenates all the accumulated data in each of the buffers of the builder and its conten...
Definition: LayoutBuilder.h:318
awkward::LayoutBuilder::List
Builds a ListArray which generalizes ListOffsetArray. Instead of a single offsets array,...
Definition: LayoutBuilder.h:381
awkward::LayoutBuilder::List::clear
void clear() noexcept
Discards the accumulated starts and stops, and clears the builder content.
Definition: LayoutBuilder.h:451
awkward::LayoutBuilder::List::begin_list
BUILDER & begin_list() noexcept
Begins a list, appends the current length of the list contents in the starts buffer and returns the r...
Definition: LayoutBuilder.h:416
awkward::LayoutBuilder::List::List
List()
Creates a new List layout builder by allocating new starts and stops buffer, using default_options fo...
Definition: LayoutBuilder.h:385
awkward::LayoutBuilder::List::form
std::string form() const noexcept
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition: LayoutBuilder.h:527
awkward::LayoutBuilder::List::parameters
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:430
awkward::LayoutBuilder::List::set_parameters
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:436
awkward::LayoutBuilder::List::content
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:408
awkward::LayoutBuilder::List::length
size_t length() const noexcept
Current length of the content and starts buffer.
Definition: LayoutBuilder.h:459
awkward::LayoutBuilder::List::to_char_buffers
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition: LayoutBuilder.h:516
awkward::LayoutBuilder::List::set_id
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:442
awkward::LayoutBuilder::List::is_valid
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:465
awkward::LayoutBuilder::List::end_list
void end_list() noexcept
Ends a list and appends the current length of the list contents in the stops buffer.
Definition: LayoutBuilder.h:424
awkward::LayoutBuilder::List::buffer_nbytes
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Retrieves the names and sizes (in bytes) of the buffers used in the builder and its contents.
Definition: LayoutBuilder.h:489
awkward::LayoutBuilder::List::List
List(const awkward::BuilderOptions &options)
Creates a new List layout builder by allocating new starts and stops buffer, taking options from Buil...
Definition: LayoutBuilder.h:399
awkward::LayoutBuilder::List::to_buffers
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Copies and concatenates all the accumulated data in each of the buffers of the builder and its conten...
Definition: LayoutBuilder.h:503
awkward::LayoutBuilder::Numpy
Builds a NumpyArray which describes multi-dimensional data of PRIMITIVE type.
Definition: LayoutBuilder.h:54
awkward::LayoutBuilder::Numpy::clear
void clear() noexcept
Discards the accumulated data in the builder.
Definition: LayoutBuilder.h:111
awkward::LayoutBuilder::Numpy::Numpy
Numpy(const awkward::BuilderOptions &options)
Creates a new Numpy layout builder by allocating a new buffer, taking options from BuilderOptions for...
Definition: LayoutBuilder.h:70
awkward::LayoutBuilder::Numpy::parameters
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:92
awkward::LayoutBuilder::Numpy::set_parameters
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:98
awkward::LayoutBuilder::Numpy::length
size_t length() const noexcept
Current length of the data.
Definition: LayoutBuilder.h:117
awkward::LayoutBuilder::Numpy::to_char_buffers
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition: LayoutBuilder.h:150
awkward::LayoutBuilder::Numpy::append
void append(PRIMITIVE x) noexcept
Inserts a PRIMITIVE type data.
Definition: LayoutBuilder.h:78
awkward::LayoutBuilder::Numpy::Numpy
Numpy()
Creates a new Numpy layout builder by allocating a new buffer, using default_options for initializing...
Definition: LayoutBuilder.h:58
awkward::LayoutBuilder::Numpy::set_id
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:104
awkward::LayoutBuilder::Numpy::is_valid
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:123
awkward::LayoutBuilder::Numpy::buffer_nbytes
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Retrieves the name and size (in bytes) of the buffer.
Definition: LayoutBuilder.h:129
awkward::LayoutBuilder::Numpy::extend
void extend(PRIMITIVE *ptr, size_t size) noexcept
Inserts an entire array of PRIMITIVE type data.
Definition: LayoutBuilder.h:86
awkward::LayoutBuilder::Numpy::to_buffers
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a user-defined pointer.
Definition: LayoutBuilder.h:140
awkward::LayoutBuilder::Numpy::form
std::string form() const
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition: LayoutBuilder.h:158
awkward::LayoutBuilder::Record
Builds a RecordArray which represents an array of records, which can be of same or different types....
Definition: LayoutBuilder.h:770
awkward::LayoutBuilder::Record::clear
void clear() noexcept
Clears the builder contents.
Definition: LayoutBuilder.h:857
awkward::LayoutBuilder::Record::Record
Record()
Creates a new Record layout builder.
Definition: LayoutBuilder.h:779
awkward::LayoutBuilder::Record::UserDefinedMap
MAP UserDefinedMap
Definition: LayoutBuilder.h:773
awkward::LayoutBuilder::Record::form
std::string form() const noexcept
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition: LayoutBuilder.h:937
awkward::LayoutBuilder::Record::RecordFieldType
std::tuple_element_t< INDEX, RecordContents > RecordFieldType
Definition: LayoutBuilder.h:776
awkward::LayoutBuilder::Record::field_names
const std::vector< std::string > field_names() const noexcept
Returns a vector of strings sontaining all the field names.
Definition: LayoutBuilder.h:800
awkward::LayoutBuilder::Record::Record
Record(UserDefinedMap user_defined_field_id_to_name_map)
Creates a new Record layout builder, taking a user-defined map with enumerated type field ID as keys ...
Definition: LayoutBuilder.h:791
awkward::LayoutBuilder::Record::parameters
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:830
awkward::LayoutBuilder::Record::RecordContents
typename std::tuple< BUILDERS... > RecordContents
Definition: LayoutBuilder.h:772
awkward::LayoutBuilder::Record::set_parameters
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:836
awkward::LayoutBuilder::Record::length
const size_t length() const noexcept
Current number of records in first field.
Definition: LayoutBuilder.h:866
awkward::LayoutBuilder::Record::set_field_names
void set_field_names(MAP user_defined_field_id_to_name_map) noexcept
Sets the field names.
Definition: LayoutBuilder.h:817
awkward::LayoutBuilder::Record::to_char_buffers
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition: LayoutBuilder.h:927
awkward::LayoutBuilder::Record::set_id
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:842
awkward::LayoutBuilder::Record::is_valid
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:872
awkward::LayoutBuilder::Record::field
RecordFieldType< INDEX >::Builder & field() noexcept
Returns the reference to the builder contents at INDEX.
Definition: LayoutBuilder.h:824
awkward::LayoutBuilder::Record::buffer_nbytes
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Retrieves the names and sizes (in bytes) of the buffers used in the builder and its contents.
Definition: LayoutBuilder.h:901
awkward::LayoutBuilder::Record::to_buffers
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Copies and concatenates all the accumulated data in each of the buffers of the builder and its conten...
Definition: LayoutBuilder.h:915
awkward::LayoutBuilder::Record::contents
RecordContents contents
The contents of the RecordArray.
Definition: LayoutBuilder.h:966
awkward::LayoutBuilder::Regular
Builds a RegularArray that describes lists that have the same length, a single integer size....
Definition: LayoutBuilder.h:1218
awkward::LayoutBuilder::Regular::clear
void clear() noexcept
Clears the builder content.
Definition: LayoutBuilder.h:1267
awkward::LayoutBuilder::Regular::begin_list
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the content of the builder.
Definition: LayoutBuilder.h:1235
awkward::LayoutBuilder::Regular::form
std::string form() const noexcept
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition: LayoutBuilder.h:1324
awkward::LayoutBuilder::Regular::parameters
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:1247
awkward::LayoutBuilder::Regular::set_parameters
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:1253
awkward::LayoutBuilder::Regular::content
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:1228
awkward::LayoutBuilder::Regular::length
size_t length() const noexcept
Current number of lists of length SIZE.
Definition: LayoutBuilder.h:1274
awkward::LayoutBuilder::Regular::to_char_buffers
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition: LayoutBuilder.h:1317
awkward::LayoutBuilder::Regular::set_id
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:1259
awkward::LayoutBuilder::Regular::is_valid
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:1280
awkward::LayoutBuilder::Regular::end_list
void end_list() noexcept
Ends a list and increments the number of lists.
Definition: LayoutBuilder.h:1241
awkward::LayoutBuilder::Regular::buffer_nbytes
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Retrieves the names and sizes (in bytes) of the buffers used in the builder and its contents.
Definition: LayoutBuilder.h:1297
awkward::LayoutBuilder::Regular::Regular
Regular()
Creates a new Regular layout builder.
Definition: LayoutBuilder.h:1221
awkward::LayoutBuilder::Regular::to_buffers
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Copies and concatenates all the accumulated data in each of the buffers of the builder and its conten...
Definition: LayoutBuilder.h:1308
awkward::LayoutBuilder::Tuple
Builds a RecordArray which represents an array of tuples which can be of same or different types with...
Definition: LayoutBuilder.h:1018
awkward::LayoutBuilder::Tuple::clear
void clear() noexcept
Clears the builder contents.
Definition: LayoutBuilder.h:1066
awkward::LayoutBuilder::Tuple::contents
TupleContents contents
The contents of the RecordArray without fields.
Definition: LayoutBuilder.h:1172
awkward::LayoutBuilder::Tuple::index
TupleContentType< INDEX > & index() noexcept
Returns the reference to the builder contents at INDEX.
Definition: LayoutBuilder.h:1034
awkward::LayoutBuilder::Tuple::form
std::string form() const noexcept
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition: LayoutBuilder.h:1147
awkward::LayoutBuilder::Tuple::Tuple
Tuple()
Creates a new Tuple layout builder.
Definition: LayoutBuilder.h:1026
awkward::LayoutBuilder::Tuple::parameters
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:1040
awkward::LayoutBuilder::Tuple::set_parameters
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:1046
awkward::LayoutBuilder::Tuple::length
const size_t length() const noexcept
Current number of records in the first index of the tuple.
Definition: LayoutBuilder.h:1075
awkward::LayoutBuilder::Tuple::to_char_buffers
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition: LayoutBuilder.h:1137
awkward::LayoutBuilder::Tuple::set_id
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:1052
awkward::LayoutBuilder::Tuple::is_valid
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:1081
awkward::LayoutBuilder::Tuple::buffer_nbytes
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Retrieves the names and sizes (in bytes) of the buffers used in the builder and its contents.
Definition: LayoutBuilder.h:1111
awkward::LayoutBuilder::Tuple::to_buffers
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Copies and concatenates all the accumulated data in each of the buffers of the builder and its conten...
Definition: LayoutBuilder.h:1125
awkward::LayoutBuilder::Union
Builds a UnionArray which represents data drawn from an ordered list of contents, which can have diff...
Definition: LayoutBuilder.h:2408
awkward::LayoutBuilder::Union::clear
void clear() noexcept
Discards the accumulated tags and index, and clears the builder contents.
Definition: LayoutBuilder.h:2491
awkward::LayoutBuilder::Union::Union
Union(const awkward::BuilderOptions &options)
Creates a new Union layout builder by allocating new tags and index buffers, taking options from Buil...
Definition: LayoutBuilder.h:2431
awkward::LayoutBuilder::Union::Contents
typename std::tuple< BUILDERS... > Contents
Definition: LayoutBuilder.h:2410
awkward::LayoutBuilder::Union::ContentType
std::tuple_element_t< I, Contents > ContentType
Definition: LayoutBuilder.h:2413
awkward::LayoutBuilder::Union::form
std::string form() const noexcept
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition: LayoutBuilder.h:2591
awkward::LayoutBuilder::Union::parameters
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:2464
awkward::LayoutBuilder::Union::set_parameters
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:2470
awkward::LayoutBuilder::Union::length
size_t length() const noexcept
Current length of the tags buffer.
Definition: LayoutBuilder.h:2505
awkward::LayoutBuilder::Union::to_char_buffers
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition: LayoutBuilder.h:2574
awkward::LayoutBuilder::Union::Union
Union()
Creates a new Union layout builder by allocating new tags and index buffers, using default_options fo...
Definition: LayoutBuilder.h:2417
awkward::LayoutBuilder::Union::content
ContentType< I > & content() noexcept
Definition: LayoutBuilder.h:2442
awkward::LayoutBuilder::Union::set_id
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:2476
awkward::LayoutBuilder::Union::is_valid
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:2511
awkward::LayoutBuilder::Union::buffer_nbytes
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Retrieves the names and sizes (in bytes) of the buffers used in the builder and its contents.
Definition: LayoutBuilder.h:2536
awkward::LayoutBuilder::Union::append_index
ContentType< TAG > & append_index() noexcept
Inserts the current tag in the tags buffer and the next index in the index buffer and returns the ref...
Definition: LayoutBuilder.h:2450
awkward::LayoutBuilder::Union::to_buffers
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Copies and concatenates all the accumulated data in each of the buffers of the builder and its conten...
Definition: LayoutBuilder.h:2555
awkward::LayoutBuilder::Unmasked
Builds an UnmaskedArray which the values are never, in fact, missing. It exists to satisfy systems th...
Definition: LayoutBuilder.h:1758
awkward::LayoutBuilder::Unmasked::clear
void clear() noexcept
Clears the builder content.
Definition: LayoutBuilder.h:1811
awkward::LayoutBuilder::Unmasked::Unmasked
Unmasked()
Creates a new Unmasked layout builder.
Definition: LayoutBuilder.h:1761
awkward::LayoutBuilder::Unmasked::extend_valid
BUILDER & extend_valid(size_t size) noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:1785
awkward::LayoutBuilder::Unmasked::form
std::string form() const noexcept
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition: LayoutBuilder.h:1857
awkward::LayoutBuilder::Unmasked::parameters
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:1791
awkward::LayoutBuilder::Unmasked::set_parameters
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:1797
awkward::LayoutBuilder::Unmasked::content
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:1768
awkward::LayoutBuilder::Unmasked::length
size_t length() const noexcept
Current length of the content.
Definition: LayoutBuilder.h:1817
awkward::LayoutBuilder::Unmasked::to_char_buffers
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition: LayoutBuilder.h:1850
awkward::LayoutBuilder::Unmasked::set_id
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:1803
awkward::LayoutBuilder::Unmasked::is_valid
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:1823
awkward::LayoutBuilder::Unmasked::append_valid
BUILDER & append_valid() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:1776
awkward::LayoutBuilder::Unmasked::buffer_nbytes
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Retrieves the names and sizes (in bytes) of the buffers used in the builder and its contents.
Definition: LayoutBuilder.h:1830
awkward::LayoutBuilder::Unmasked::to_buffers
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Copies and concatenates all the accumulated data in each of the buffers of the builder and its conten...
Definition: LayoutBuilder.h:1841
awkward::LayoutBuilder
User interface to the FormBuilder system: the LayoutBuilder is a fixed reference while the FormBuilde...
Definition: LayoutBuilder.h:62
awkward::LayoutBuilder::default_options
awkward::BuilderOptions default_options(1024, 1)
Object of BuilderOptions which sets the values of the default options.
awkward
Definition: BitMaskedArray.h:15
awkward::visit_at
void visit_at(std::tuple< CONTENTs... > const &contents, size_t index, FUNCTION fun)
Visits the tuple contents at index.
Definition: utils.h:297
awkward::state::tag
@ tag
awkward::Options
Container for all configuration options needed by ArrayBuilder, GrowableBuffer, LayoutBuilder and the...
Definition: BuilderOptions.h:20
awkward::is_specialization
Definition: utils.h:203
utils.h