All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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
8#include "awkward/utils.h"
9
10#include <map>
11#include <algorithm>
12#include <tuple>
13#include <string>
14#include <functional>
15
18#define AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS awkward::BuilderOptions(1024, 1)
19
20namespace awkward {
21
22 namespace LayoutBuilder {
23
31 template <std::size_t ENUM, typename BUILDER>
32 class Field {
33 public:
34 using Builder = BUILDER;
35
37 std::string
39 return std::to_string(index);
40 }
41
43 const std::size_t index = ENUM;
46 };
47
54 template <typename PRIMITIVE>
55 class Numpy {
56 public:
60 : data_(
62 size_t id = 0;
63 set_id(id);
64 }
65
72 : data_(awkward::GrowableBuffer<PRIMITIVE>(options)) {
73 size_t id = 0;
74 set_id(id);
75 }
76
78 void
79 append(PRIMITIVE x) noexcept {
80 data_.append(x);
81 }
82
86 void
87 extend(PRIMITIVE* ptr, size_t size) noexcept {
88 data_.extend(ptr, size);
89 }
90
92 const std::string&
93 parameters() const noexcept {
94 return parameters_;
95 }
96
98 void
99 set_parameters(std::string parameter) noexcept {
100 parameters_ = parameter;
101 }
102
104 void
105 set_id(size_t& id) noexcept {
106 id_ = id;
107 id++;
108 }
109
111 void
112 clear() noexcept {
113 data_.clear();
114 }
115
117 size_t
118 length() const noexcept {
119 return data_.length();
120 }
121
123 bool
124 is_valid(std::string& /* error */) const noexcept {
125 return true;
126 }
127
129 void
130 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
131 noexcept {
132 names_nbytes["node" + std::to_string(id_) + "-data"] = data_.nbytes();
133 }
134
140 void
141 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
142 data_.concatenate(reinterpret_cast<PRIMITIVE*>(
143 buffers["node" + std::to_string(id_) + "-data"]));
144 }
145
149 void
150 to_buffer(void* buffer, const char* name) const noexcept {
151 if (std::string(name) == std::string("node" + std::to_string(id_) + "-data")) {
152 data_.concatenate(reinterpret_cast<PRIMITIVE*>(buffer));
153 }
154 }
155
160 void
161 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
162 data_.concatenate(reinterpret_cast<PRIMITIVE*>(
163 buffers["node" + std::to_string(id_) + "-data"]));
164 }
165
168 std::string
169 form() const {
170 std::stringstream form_key;
171 form_key << "node" << id_;
172
173 std::string params("");
174 if (parameters_ == "") {
175 } else {
176 params = std::string(", \"parameters\": { " + parameters_ + " }");
177 }
178
179 if (std::is_arithmetic<PRIMITIVE>::value) {
180 return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
181 type_to_name<PRIMITIVE>() + "\"" + params +
182 ", \"form_key\": \"" + form_key.str() + "\" }";
184 return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
185 type_to_name<PRIMITIVE>() + "\"" + params +
186 ", \"form_key\": \"" + form_key.str() + "\" }";
187 } else {
188 throw std::runtime_error("type " +
189 std::string(typeid(PRIMITIVE).name()) +
190 "is not supported");
191 }
192 }
193
194 private:
197
199 std::string parameters_;
200
202 size_t id_;
203 };
204
219 template <typename PRIMITIVE, typename BUILDER>
221 public:
225 : offsets_(
227 offsets_.append(0);
228 size_t id = 0;
229 set_id(id);
230 }
231
238 : offsets_(awkward::GrowableBuffer<PRIMITIVE>(options)) {
239 offsets_.append(0);
240 size_t id = 0;
241 set_id(id);
242 }
243
245 BUILDER&
246 content() noexcept {
247 return content_;
248 }
249
251 BUILDER&
252 begin_list() noexcept {
253 return content_;
254 }
255
258 void
259 end_list() noexcept {
260 offsets_.append(content_.length());
261 }
262
264 const std::string&
265 parameters() const noexcept {
266 return parameters_;
267 }
268
270 void
271 set_parameters(std::string parameter) noexcept {
272 parameters_ = parameter;
273 }
274
276 void
277 set_id(size_t& id) noexcept {
278 id_ = id;
279 id++;
280 content_.set_id(id);
281 }
282
284 void
285 clear() noexcept {
286 offsets_.clear();
287 offsets_.append(0);
288 content_.clear();
289 }
290
292 size_t
293 length() const noexcept {
294 return offsets_.length() - 1;
295 }
296
298 bool
299 is_valid(std::string& error) const noexcept {
300 if ((int64_t)content_.length() != (int64_t)offsets_.last()) {
301 std::stringstream out;
302 out << "ListOffset node" << id_ << "has content length "
303 << content_.length() << "but last offset " << offsets_.last()
304 << "\n";
305 error.append(out.str());
306
307 return false;
308 } else {
309 return content_.is_valid(error);
310 }
311 }
312
315 void
316 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
317 noexcept {
318 names_nbytes["node" + std::to_string(id_) + "-offsets"] =
319 offsets_.nbytes();
320 content_.buffer_nbytes(names_nbytes);
321 }
322
328 void
329 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
330 offsets_.concatenate(reinterpret_cast<PRIMITIVE*>(
331 buffers["node" + std::to_string(id_) + "-offsets"]));
332 content_.to_buffers(buffers);
333 }
334
339 void
340 to_buffer(void* buffer, const char* name) const noexcept {
341 if (std::string(name) == std::string("node" + std::to_string(id_) + "-offsets")) {
342 offsets_.concatenate(reinterpret_cast<PRIMITIVE*>(buffer));
343 }
344 content_.to_buffer(buffer, name);
345 }
346
351 void
352 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
353 offsets_.concatenate(reinterpret_cast<PRIMITIVE*>(
354 buffers["node" + std::to_string(id_) + "-offsets"]));
355 content_.to_char_buffers(buffers);
356 }
357
360 std::string
361 form() const noexcept {
362 std::stringstream form_key;
363 form_key << "node" << id_;
364 std::string params("");
365 if (parameters_ == "") {
366 } else {
367 params = std::string(", \"parameters\": { " + parameters_ + " }");
368 }
369 return "{ \"class\": \"ListOffsetArray\", \"offsets\": \"" +
370 type_to_numpy_like<PRIMITIVE>() +
371 "\", \"content\": " + content_.form() + params +
372 ", \"form_key\": \"" + form_key.str() + "\" }";
373 }
374
375 private:
380
382 BUILDER content_;
383
385 std::string parameters_;
386
388 size_t id_;
389 };
390
391
396 class Empty {
397 public:
400 size_t id = 0;
401 set_id(id);
402 }
403
404 void
405 set_id(size_t& /* id */) noexcept {}
406
407 void
408 clear() noexcept {}
409
411 size_t
412 length() const noexcept {
413 return 0;
414 }
415
417 bool
418 is_valid(std::string& /* error */) const noexcept {
419 return true;
420 }
421
422 void
423 buffer_nbytes(std::map<std::string, size_t>& /* names_nbytes */) const
424 noexcept {}
425
426 void
427 to_buffers(std::map<std::string, void*>& /* buffers */) const noexcept {}
428
429 void
430 to_buffer(void* /* buffer */, const char* /* name */) const noexcept {}
431
436 void
437 to_char_buffers(std::map<std::string, uint8_t*>& /* buffers */) const noexcept {}
438
441 std::string
442 form() const noexcept {
443 return "{ \"class\": \"EmptyArray\" }";
444 }
445
446 private:
448 size_t id_;
449 };
450
451
461 template <class MAP = std::map<std::size_t, std::string>,
462 typename... BUILDERS>
463 class Record {
464 public:
465 using RecordContents = typename std::tuple<BUILDERS...>;
466 using UserDefinedMap = MAP;
467
468 template <std::size_t INDEX>
469 using RecordFieldType = std::tuple_element_t<INDEX, RecordContents>;
470
473 size_t id = 0;
474 set_id(id);
475 map_fields(std::index_sequence_for<BUILDERS...>());
476 }
477
484 Record(UserDefinedMap user_defined_field_id_to_name_map)
485 : content_names_(user_defined_field_id_to_name_map) {
486 assert(content_names_.size() == fields_count_);
487 size_t id = 0;
488 set_id(id);
489 }
490
492 const std::vector<std::string>
493 fields() const noexcept {
494 if (content_names_.empty()) {
495 return fields_;
496 } else {
497 std::vector<std::string> result;
498 for (auto it : content_names_) {
499 result.emplace_back(it.second);
500 }
501 return result;
502 }
503 }
504
509 void
510 set_fields(MAP user_defined_field_id_to_name_map) noexcept {
511 content_names_ = user_defined_field_id_to_name_map;
512 }
513
515 template <std::size_t INDEX>
516 typename RecordFieldType<INDEX>::Builder&
517 content() noexcept {
518 return std::get<INDEX>(contents).builder;
519 }
520
522 const std::string&
523 parameters() const noexcept {
524 return parameters_;
525 }
526
528 void
529 set_parameters(std::string parameter) noexcept {
530 parameters_ = parameter;
531 }
532
534 void
535 set_id(size_t& id) noexcept {
536 id_ = id;
537 id++;
538 for (size_t i = 0; i < fields_count_; i++) {
539 visit_at(contents, i, [&id](auto& content) {
540 content.builder.set_id(id);
541 });
542 }
543 }
544
549 void
550 clear() noexcept {
551 for (size_t i = 0; i < fields_count_; i++) {
552 visit_at(contents, i, [](auto& content) {
553 content.builder.clear();
554 });
555 }
556 }
557
559 size_t
560 length() const noexcept {
561 return (std::get<0>(contents).builder.length());
562 }
563
565 bool
566 is_valid(std::string& error) const noexcept {
567 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
568
569 int64_t length = -1;
570 std::vector<size_t> lengths = field_lengths(index_sequence);
571 for (size_t i = 0; i < lengths.size(); i++) {
572 if (length == -1) {
573 length = lengths[i];
574 }
575 else if (length != (int64_t)lengths[i]) {
576 std::stringstream out;
577 out << "Record node" << id_ << " has field \""
578 << fields().at(i) << "\" length " << lengths[i]
579 << " that differs from the first length " << length << "\n";
580 error.append(out.str());
581
582 return false;
583 }
584 }
585
586 std::vector<bool> valid_fields = field_is_valid(index_sequence, error);
587 return std::none_of(std::cbegin(valid_fields),
588 std::cend(valid_fields),
589 std::logical_not<bool>());
590 }
591
594 void
595 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
596 noexcept {
597 for (size_t i = 0; i < fields_count_; i++) {
598 visit_at(contents, i, [&names_nbytes](auto& content) {
599 content.builder.buffer_nbytes(names_nbytes);
600 });
601 }
602 }
603
609 void
610 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
611 for (size_t i = 0; i < fields_count_; i++) {
612 visit_at(contents, i, [&buffers](auto& content) {
613 content.builder.to_buffers(buffers);
614 });
615 }
616 }
617
621 void
622 to_buffer(void* buffer, const char* name) const noexcept {
623 for (size_t i = 0; i < fields_count_; i++) {
624 visit_at(contents, i, [&buffer, &name](auto& content) {
625 content.builder.to_buffer(buffer, name);
626 });
627 }
628 }
629
634 void
635 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
636 for (size_t i = 0; i < fields_count_; i++) {
637 visit_at(contents, i, [&buffers](auto& content) {
638 content.builder.to_char_buffers(buffers);
639 });
640 }
641 }
642
645 std::string
646 form() const noexcept {
647 std::stringstream form_key;
648 form_key << "node" << id_;
649 std::string params("");
650 if (parameters_ == "") {
651 } else {
652 params = std::string("\"parameters\": { " + parameters_ + " }, ");
653 }
654 std::stringstream out;
655 out << "{ \"class\": \"RecordArray\", \"contents\": { ";
656 for (size_t i = 0; i < fields_count_; i++) {
657 if (i != 0) {
658 out << ", ";
659 }
660 auto contents_form = [&](auto& content) {
661 out << "\""
662 << (!content_names_.empty() ? content_names_.at(content.index)
663 : content.index_as_field())
664 << +"\": ";
665 out << content.builder.form();
666 };
667 visit_at(contents, i, contents_form);
668 }
669 out << " }, ";
670 out << params << "\"form_key\": \"" << form_key.str() << "\" }";
671 return out.str();
672 }
673
676
677 private:
680 template <std::size_t... S>
681 void
682 map_fields(std::index_sequence<S...>) noexcept {
683 fields_ = std::vector<std::string>(
684 {std::string(std::get<S>(contents).index_as_field())...});
685 }
686
689 template <std::size_t... S>
690 std::vector<size_t>
691 field_lengths(std::index_sequence<S...>) const noexcept {
692 return std::vector<size_t>({std::get<S>(contents).builder.length()...});
693 }
694
696 template <std::size_t... S>
697 std::vector<bool>
698 field_is_valid(std::index_sequence<S...>, std::string& error) const
699 noexcept {
700 return std::vector<bool>(
701 {std::get<S>(contents).builder.is_valid(error)...});
702 }
703
705 std::vector<std::string> fields_;
706
708 UserDefinedMap content_names_;
709
711 std::string parameters_;
712
714 size_t id_;
715
717 static constexpr size_t fields_count_ = sizeof...(BUILDERS);
718 };
719
726 template <typename... BUILDERS>
727 class Tuple {
728 using TupleContents = typename std::tuple<BUILDERS...>;
729
730 template <std::size_t INDEX>
731 using TupleContentType = std::tuple_element_t<INDEX, TupleContents>;
732
733 public:
736 size_t id = 0;
737 set_id(id);
738 }
739
741 template <std::size_t INDEX>
742 TupleContentType<INDEX>&
743 content() noexcept {
744 return std::get<INDEX>(contents);
745 }
746
748 const std::string&
749 parameters() const noexcept {
750 return parameters_;
751 }
752
754 void
755 set_parameters(std::string parameter) noexcept {
756 parameters_ = parameter;
757 }
758
760 void
761 set_id(size_t& id) noexcept {
762 id_ = id;
763 id++;
764 for (size_t i = 0; i < fields_count_; i++) {
765 visit_at(contents, i, [&id](auto& content) {
766 content.set_id(id);
767 });
768 }
769 }
770
774 void
775 clear() noexcept {
776 for (size_t i = 0; i < fields_count_; i++) {
777 visit_at(contents, i, [](auto& content) {
778 content.clear();
779 });
780 }
781 }
782
784 size_t
785 length() const noexcept {
786 return (std::get<0>(contents).length());
787 }
788
790 bool
791 is_valid(std::string& error) const noexcept {
792 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
793
794 int64_t length = -1;
795 std::vector<size_t> lengths = content_lengths(index_sequence);
796 for (size_t i = 0; i < lengths.size(); i++) {
797 if (length == -1) {
798 length = (int64_t)lengths[i];
799 }
800 else if (length != (int64_t)lengths[i]) {
801 std::stringstream out;
802 out << "Record node" << id_ << " has index \"" << i << "\" length "
803 << lengths[i] << " that differs from the first length "
804 << length << "\n";
805 error.append(out.str());
806
807 return false;
808 }
809 }
810
811 std::vector<bool> valid_fields =
812 content_is_valid(index_sequence, error);
813 return std::none_of(std::cbegin(valid_fields),
814 std::cend(valid_fields),
815 std::logical_not<bool>());
816 }
817
820 void
821 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
822 noexcept {
823 for (size_t i = 0; i < fields_count_; i++) {
824 visit_at(contents, i, [&names_nbytes](auto& content) {
825 content.buffer_nbytes(names_nbytes);
826 });
827 }
828 }
829
835 void
836 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
837 for (size_t i = 0; i < fields_count_; i++) {
838 visit_at(contents, i, [&buffers](auto& content) {
839 content.to_buffers(buffers);
840 });
841 }
842 }
843
847 void
848 to_buffer(void* buffer, const char* name) const noexcept {
849 for (size_t i = 0; i < fields_count_; i++) {
850 visit_at(contents, i, [&buffer, &name](auto& content) {
851 content.to_buffer(buffer, name);
852 });
853 }
854 }
855
860 void
861 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
862 for (size_t i = 0; i < fields_count_; i++) {
863 visit_at(contents, i, [&buffers](auto& content) {
864 content.to_char_buffers(buffers);
865 });
866 }
867 }
868
871 std::string
872 form() const noexcept {
873 std::stringstream form_key;
874 form_key << "node" << id_;
875 std::string params("");
876 if (parameters_ == "") {
877 } else {
878 params = std::string("\"parameters\": { " + parameters_ + " }, ");
879 }
880 std::stringstream out;
881 out << "{ \"class\": \"RecordArray\", \"contents\": [";
882 for (size_t i = 0; i < fields_count_; i++) {
883 if (i != 0) {
884 out << ", ";
885 }
886 auto contents_form = [&out](auto& content) {
887 out << content.form();
888 };
889 visit_at(contents, i, contents_form);
890 }
891 out << "], ";
892 out << params << "\"form_key\": \"" << form_key.str() << "\" }";
893 return out.str();
894 }
895
897 TupleContents contents;
898
899 private:
902 template <std::size_t... S>
903 std::vector<size_t>
904 content_lengths(std::index_sequence<S...>) const noexcept {
905 return std::vector<size_t>({std::get<S>(contents).length()...});
906 }
907
909 template <std::size_t... S>
910 std::vector<bool>
911 content_is_valid(std::index_sequence<S...>, std::string& error) const
912 noexcept {
913 return std::vector<bool>({std::get<S>(contents).is_valid(error)...});
914 }
915
917 std::vector<int64_t> field_index_;
918
920 std::string parameters_;
921
923 size_t id_;
924
926 static constexpr size_t fields_count_ = sizeof...(BUILDERS);
927 };
928
942 template <unsigned SIZE, typename BUILDER>
943 class Regular {
944 public:
946 Regular() : length_(0) {
947 size_t id = 0;
948 set_id(id);
949 }
950
952 BUILDER&
953 content() noexcept {
954 return content_;
955 }
956
959 BUILDER&
960 begin_list() noexcept {
961 return content_;
962 }
963
965 void
966 end_list() noexcept {
967 length_++;
968 }
969
971 const std::string&
972 parameters() const noexcept {
973 return parameters_;
974 }
975
977 void
978 set_parameters(std::string parameter) noexcept {
979 parameters_ = parameter;
980 }
981
983 void
984 set_id(size_t& id) noexcept {
985 id_ = id;
986 id++;
987 content_.set_id(id);
988 }
989
991 void
992 clear() noexcept {
993 length_ = 0;
994 content_.clear();
995 }
996
998 size_t
999 length() const noexcept {
1000 return length_;
1001 }
1002
1004 bool
1005 is_valid(std::string& error) const noexcept {
1006 if (content_.length() != length_ * size_) {
1007 std::stringstream out;
1008 out << "Regular node" << id_ << "has content length "
1009 << content_.length() << ", but length " << length_ << " and size "
1010 << size_ << "\n";
1011 error.append(out.str());
1012
1013 return false;
1014 } else {
1015 return content_.is_valid(error);
1016 }
1017 }
1018
1021 void
1022 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
1023 noexcept {
1024 content_.buffer_nbytes(names_nbytes);
1025 }
1026
1032 void
1033 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
1034 content_.to_buffers(buffers);
1035 }
1036
1040 void
1041 to_buffer(void* buffer, const char* name) const noexcept {
1042 content_.to_buffer(buffer, name);
1043 }
1044
1049 void
1050 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
1051 content_.to_char_buffers(buffers);
1052 }
1053
1056 std::string
1057 form() const noexcept {
1058 std::stringstream form_key;
1059 form_key << "node" << id_;
1060 std::string params("");
1061 if (parameters_ == "") {
1062 } else {
1063 params = std::string(", \"parameters\": { " + parameters_ + " }");
1064 }
1065 return "{ \"class\": \"RegularArray\", \"content\": " +
1066 content_.form() + ", \"size\": " + std::to_string(size_) +
1067 params + ", \"form_key\": \"" + form_key.str() + "\" }";
1068 }
1069
1070 private:
1072 BUILDER content_;
1073
1075 std::string parameters_;
1076
1078 size_t id_;
1079
1081 size_t length_;
1082
1084 size_t size_ = SIZE;
1085 };
1086
1087
1098 template <typename PRIMITIVE, typename BUILDER>
1100 public:
1104 : index_(
1106 last_valid_(-1) {
1107 size_t id = 0;
1108 set_id(id);
1109 }
1110
1117 : index_(awkward::GrowableBuffer<PRIMITIVE>(options)),
1118 last_valid_(-1) {
1119 size_t id = 0;
1120 set_id(id);
1121 }
1122
1124 BUILDER&
1125 content() noexcept {
1126 return content_;
1127 }
1128
1131 BUILDER&
1132 append_valid() noexcept {
1133 last_valid_ = content_.length();
1134 index_.append(last_valid_);
1135 return content_;
1136 }
1137
1142 BUILDER&
1143 extend_valid(size_t size) noexcept {
1144 size_t start = content_.length();
1145 size_t stop = start + size;
1146 last_valid_ = stop - 1;
1147 for (size_t i = start; i < stop; i++) {
1148 index_.append(i);
1149 }
1150 return content_;
1151 }
1152
1154 void
1155 append_invalid() noexcept {
1156 index_.append(-1);
1157 }
1158
1162 void
1163 extend_invalid(size_t size) noexcept {
1164 for (size_t i = 0; i < size; i++) {
1165 index_.append(-1);
1166 }
1167 }
1168
1170 const std::string&
1171 parameters() const noexcept {
1172 return parameters_;
1173 }
1174
1176 void
1177 set_parameters(std::string parameter) noexcept {
1178 parameters_ = parameter;
1179 }
1180
1182 void
1183 set_id(size_t& id) noexcept {
1184 id_ = id;
1185 id++;
1186 content_.set_id(id);
1187 }
1188
1191 void
1192 clear() noexcept {
1193 last_valid_ = -1;
1194 index_.clear();
1195 content_.clear();
1196 }
1197
1199 size_t
1200 length() const noexcept {
1201 return index_.length();
1202 }
1203
1205 bool
1206 is_valid(std::string& error) const noexcept {
1207 if (content_.length() != last_valid_ + 1) {
1208 std::stringstream out;
1209 out << "IndexedOption node" << id_ << " has content length "
1210 << content_.length() << " but last valid index is " << last_valid_
1211 << "\n";
1212 error.append(out.str());
1213
1214 return false;
1215 } else {
1216 return content_.is_valid(error);
1217 }
1218 }
1219
1222 void
1223 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
1224 noexcept {
1225 names_nbytes["node" + std::to_string(id_) + "-index"] = index_.nbytes();
1226 content_.buffer_nbytes(names_nbytes);
1227 }
1228
1234 void
1235 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
1236 index_.concatenate(reinterpret_cast<PRIMITIVE*>(
1237 buffers["node" + std::to_string(id_) + "-index"]));
1238 content_.to_buffers(buffers);
1239 }
1240
1245 void
1246 to_buffer(void* buffer, const char* name) const noexcept {
1247 if (std::string(name) == std::string("node" + std::to_string(id_) + "-index")) {
1248 index_.concatenate(reinterpret_cast<PRIMITIVE*>(buffer));
1249 }
1250 content_.to_buffer(buffer, name);
1251 }
1252
1257 void
1258 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
1259 index_.concatenate(reinterpret_cast<PRIMITIVE*>(
1260 buffers["node" + std::to_string(id_) + "-index"]));
1261 content_.to_char_buffers(buffers);
1262 }
1263
1266 std::string
1267 form() const noexcept {
1268 std::stringstream form_key;
1269 form_key << "node" << id_;
1270 std::string params("");
1271 if (parameters_ == "") {
1272 } else {
1273 params = std::string(", \"parameters\": { " + parameters_ + " }");
1274 }
1275 return "{ \"class\": \"IndexedOptionArray\", \"index\": \"" +
1276 type_to_numpy_like<PRIMITIVE>() +
1277 "\", \"content\": " + content_.form() + params +
1278 ", \"form_key\": \"" + form_key.str() + "\" }";
1279 }
1280
1281 private:
1286
1288 BUILDER content_;
1289
1291 std::string parameters_;
1292
1294 size_t id_;
1295
1297 size_t last_valid_;
1298 };
1299
1311 template <typename BUILDER>
1312 class Unmasked {
1313 public:
1316 size_t id = 0;
1317 set_id(id);
1318 }
1319
1321 BUILDER&
1322 content() noexcept {
1323 return content_;
1324 }
1325
1327 const std::string&
1328 parameters() const noexcept {
1329 return parameters_;
1330 }
1331
1333 void
1334 set_parameters(std::string parameter) noexcept {
1335 parameters_ = parameter;
1336 }
1337
1339 void
1340 set_id(size_t& id) noexcept {
1341 id_ = id;
1342 id++;
1343 content_.set_id(id);
1344 }
1345
1347 void
1348 clear() noexcept {
1349 content_.clear();
1350 }
1351
1353 size_t
1354 length() const noexcept {
1355 return content_.length();
1356 }
1357
1359 bool
1360 is_valid(std::string& error) const noexcept {
1361 return content_.is_valid(error);
1362 }
1363
1366 void
1367 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
1368 noexcept {
1369 content_.buffer_nbytes(names_nbytes);
1370 }
1371
1377 void
1378 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
1379 content_.to_buffers(buffers);
1380 }
1381
1385 void
1386 to_buffer(void* buffer, const char* name) const noexcept {
1387 content_.to_buffer(buffer, name);
1388 }
1389
1394 void
1395 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
1396 content_.to_char_buffers(buffers);
1397 }
1398
1401 std::string
1402 form() const noexcept {
1403 std::stringstream form_key;
1404 form_key << "node" << id_;
1405 std::string params("");
1406 if (parameters_ == "") {
1407 } else {
1408 params = std::string(", \"parameters\": { " + parameters_ + " }");
1409 }
1410 return "{ \"class\": \"UnmaskedArray\", \"content\": " +
1411 content_.form() + params + ", \"form_key\": \"" +
1412 form_key.str() + "\" }";
1413 }
1414
1415 private:
1417 BUILDER content_;
1418
1420 std::string parameters_;
1421
1423 size_t id_;
1424 };
1425
1442 template <bool VALID_WHEN, typename BUILDER>
1444 public:
1449 size_t id = 0;
1450 set_id(id);
1451 }
1452
1459 : mask_(awkward::GrowableBuffer<int8_t>(options)) {
1460 size_t id = 0;
1461 set_id(id);
1462 }
1463
1465 BUILDER&
1466 content() noexcept {
1467 return content_;
1468 }
1469
1471 bool
1472 valid_when() const noexcept {
1473 return valid_when_;
1474 }
1475
1479 BUILDER&
1480 append_valid() noexcept {
1481 mask_.append(valid_when_);
1482 return content_;
1483 }
1484
1490 BUILDER&
1491 extend_valid(size_t size) noexcept {
1492 for (size_t i = 0; i < size; i++) {
1493 mask_.append(valid_when_);
1494 }
1495 return content_;
1496 }
1497
1501 BUILDER&
1502 append_invalid() noexcept {
1503 mask_.append(!valid_when_);
1504 return content_;
1505 }
1506
1512 BUILDER&
1513 extend_invalid(size_t size) noexcept {
1514 for (size_t i = 0; i < size; i++) {
1515 mask_.append(!valid_when_);
1516 }
1517 return content_;
1518 }
1519
1521 const std::string&
1522 parameters() const noexcept {
1523 return parameters_;
1524 }
1525
1527 void
1528 set_parameters(std::string parameter) noexcept {
1529 parameters_ = parameter;
1530 }
1531
1533 void
1534 set_id(size_t& id) noexcept {
1535 id_ = id;
1536 id++;
1537 content_.set_id(id);
1538 }
1539
1542 void
1543 clear() noexcept {
1544 mask_.clear();
1545 content_.clear();
1546 }
1547
1549 size_t
1550 length() const noexcept {
1551 return mask_.length();
1552 }
1553
1555 bool
1556 is_valid(std::string& error) const noexcept {
1557 if (content_.length() != mask_.length()) {
1558 std::stringstream out;
1559 out << "ByteMasked node" << id_ << "has content length "
1560 << content_.length() << "but mask length " << mask_.length()
1561 << "\n";
1562 error.append(out.str());
1563
1564 return false;
1565 } else {
1566 return content_.is_valid(error);
1567 }
1568 }
1569
1572 void
1573 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
1574 noexcept {
1575 names_nbytes["node" + std::to_string(id_) + "-mask"] = mask_.nbytes();
1576 content_.buffer_nbytes(names_nbytes);
1577 }
1578
1584 void
1585 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
1586 mask_.concatenate(reinterpret_cast<int8_t*>(
1587 buffers["node" + std::to_string(id_) + "-mask"]));
1588 content_.to_buffers(buffers);
1589 }
1590
1595 void
1596 to_buffer(void* buffer, const char* name) const noexcept {
1597 if (std::string(name) == std::string("node" + std::to_string(id_) + "-mask")) {
1598 mask_.concatenate(reinterpret_cast<int8_t*>(buffer));
1599 }
1600 content_.to_buffer(buffer, name);
1601 }
1602
1607 void
1608 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
1609 mask_.concatenate(reinterpret_cast<int8_t*>(
1610 buffers["node" + std::to_string(id_) + "-mask"]));
1611 content_.to_char_buffers(buffers);
1612 }
1613
1616 std::string
1617 form() const noexcept {
1618 std::stringstream form_key, form_valid_when;
1619 form_key << "node" << id_;
1620 form_valid_when << std::boolalpha << valid_when_;
1621 std::string params("");
1622 if (parameters_ == "") {
1623 } else {
1624 params = std::string(", \"parameters\": { " + parameters_ + " }");
1625 }
1626 return "{ \"class\": \"ByteMaskedArray\", \"mask\": \"i8\", "
1627 "\"content\": " +
1628 content_.form() + ", \"valid_when\": " + form_valid_when.str() +
1629 params + ", \"form_key\": \"" + form_key.str() + "\" }";
1630 }
1631
1632 private:
1637
1639 BUILDER content_;
1640
1642 std::string parameters_;
1643
1645 size_t id_;
1646
1648 bool valid_when_ = VALID_WHEN;
1649 };
1650
1667 template <bool VALID_WHEN, bool LSB_ORDER, typename BUILDER>
1669 public:
1674 current_byte_(uint8_t(0)),
1675 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
1676 current_index_(0) {
1677 size_t id = 0;
1678 set_id(id);
1679 if (lsb_order_) {
1680 for (size_t i = 0; i < 8; i++) {
1681 cast_[i] = 1 << i;
1682 }
1683 } else {
1684 for (size_t i = 0; i < 8; i++) {
1685 cast_[i] = 128 >> i;
1686 }
1687 }
1688 }
1689
1696 : mask_(awkward::GrowableBuffer<uint8_t>(options)),
1697 current_byte_(uint8_t(0)),
1698 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
1699 current_index_(0) {
1700 size_t id = 0;
1701 set_id(id);
1702 if (lsb_order_) {
1703 for (size_t i = 0; i < 8; i++) {
1704 cast_[i] = 1 << i;
1705 }
1706 } else {
1707 for (size_t i = 0; i < 8; i++) {
1708 cast_[i] = 128 >> i;
1709 }
1710 }
1711 }
1712
1714 BUILDER&
1715 content() noexcept {
1716 return content_;
1717 }
1718
1720 bool
1721 valid_when() const noexcept {
1722 return valid_when_;
1723 }
1724
1727 bool
1728 lsb_order() const noexcept {
1729 return lsb_order_;
1730 }
1731
1736 BUILDER&
1737 append_valid() noexcept {
1738 append_begin();
1739 current_byte_ |= cast_[current_index_];
1740 append_end();
1741 return content_;
1742 }
1743
1750 BUILDER&
1751 extend_valid(size_t size) noexcept {
1752 for (size_t i = 0; i < size; i++) {
1753 append_valid();
1754 }
1755 return content_;
1756 }
1757
1761 BUILDER&
1762 append_invalid() noexcept {
1763 append_begin();
1764 append_end();
1765 return content_;
1766 }
1767
1773 BUILDER&
1774 extend_invalid(size_t size) noexcept {
1775 for (size_t i = 0; i < size; i++) {
1777 }
1778 return content_;
1779 }
1780
1782 const std::string&
1783 parameters() const noexcept {
1784 return parameters_;
1785 }
1786
1788 void
1789 set_parameters(std::string parameter) noexcept {
1790 parameters_ = parameter;
1791 }
1792
1794 void
1795 set_id(size_t& id) noexcept {
1796 id_ = id;
1797 id++;
1798 content_.set_id(id);
1799 }
1800
1803 void
1804 clear() noexcept {
1805 mask_.clear();
1806 content_.clear();
1807 current_byte_ = 0;
1808 current_byte_ref_ = mask_.append_and_get_ref(current_byte_);
1809 current_index_ = 0;
1810 }
1811
1813 size_t
1814 length() const noexcept {
1815 return mask_.length() > 0 ?
1816 (mask_.length() - 1) * 8 + current_index_ : current_index_;
1817 }
1818
1820 bool
1821 is_valid(std::string& error) const noexcept {
1822 if (content_.length() != length()) {
1823 std::stringstream out;
1824 out << "BitMasked node" << id_ << "has content length "
1825 << content_.length() << "but bit mask length " << mask_.length()
1826 << "\n";
1827 error.append(out.str());
1828
1829 return false;
1830 } else {
1831 return content_.is_valid(error);
1832 }
1833 }
1834
1837 void
1838 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
1839 noexcept {
1840 names_nbytes["node" + std::to_string(id_) + "-mask"] = mask_.nbytes();
1841 content_.buffer_nbytes(names_nbytes);
1842 }
1843
1849 void
1850 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
1851 mask_.concatenate_from(reinterpret_cast<uint8_t*>(
1852 buffers["node" + std::to_string(id_) + "-mask"]), 0, 1);
1853 mask_.append(reinterpret_cast<uint8_t*>(
1854 buffers["node" + std::to_string(id_) + "-mask"]), mask_.length() - 1, 0, 1);
1855 content_.to_buffers(buffers);
1856 }
1857
1862 void
1863 to_buffer(void* buffer, const char* name) const noexcept {
1864 if (std::string(name) == std::string("node" + std::to_string(id_) + "-mask")) {
1865 mask_.concatenate_from(reinterpret_cast<uint8_t*>(buffer), 0, 1);
1866 mask_.append(reinterpret_cast<uint8_t*>(buffer), mask_.length() - 1, 0, 1);
1867 }
1868 content_.to_buffer(buffer, name);
1869 }
1870
1875 void
1876 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
1877 mask_.concatenate_from(reinterpret_cast<uint8_t*>(
1878 buffers["node" + std::to_string(id_) + "-mask"]), 0, 1);
1879 mask_.append(reinterpret_cast<uint8_t*>(
1880 buffers["node" + std::to_string(id_) + "-mask"]), mask_.length() - 1, 0, 1);
1881 content_.to_char_buffers(buffers);
1882 }
1883
1886 std::string
1887 form() const noexcept {
1888 std::stringstream form_key, form_valid_when, form_lsb_order;
1889 form_key << "node" << id_;
1890 form_valid_when << std::boolalpha << valid_when_;
1891 form_lsb_order << std::boolalpha << lsb_order_;
1892 std::string params("");
1893 if (parameters_ == "") {
1894 } else {
1895 params = std::string(", \"parameters\": { " + parameters_ + " }");
1896 }
1897 return "{ \"class\": \"BitMaskedArray\", \"mask\": \"u8\", "
1898 "\"content\": " +
1899 content_.form() + ", \"valid_when\": " + form_valid_when.str() +
1900 ", \"lsb_order\": " + form_lsb_order.str() + params +
1901 ", \"form_key\": \"" + form_key.str() + "\" }";
1902 }
1903
1904 private:
1908 void
1909 append_begin() {
1910 if (current_index_ == 8) {
1911 current_byte_ref_ = mask_.append_and_get_ref(current_byte_);
1912 current_byte_ = uint8_t(0);
1913 current_index_ = 0;
1914 }
1915 }
1916
1922 void
1923 append_end() {
1924 current_index_ += 1;
1925 if (valid_when_) {
1926 current_byte_ref_ = current_byte_;
1927 } else {
1928 current_byte_ref_ = ~current_byte_;
1929 }
1930 }
1931
1935 GrowableBuffer<uint8_t> mask_;
1936
1938 BUILDER content_;
1939
1941 std::string parameters_;
1942
1944 size_t id_;
1945
1947 uint8_t current_byte_;
1948
1950 uint8_t& current_byte_ref_;
1951
1953 size_t current_index_;
1954
1956 uint8_t cast_[8];
1957
1959 bool valid_when_ = VALID_WHEN;
1960
1963 bool lsb_order_ = LSB_ORDER;
1964 };
1965
1981 template <typename TAGS, typename INDEX, typename... BUILDERS>
1982 class Union {
1983 public:
1984 using Contents = typename std::tuple<BUILDERS...>;
1985
1986 template <std::size_t I>
1987 using ContentType = std::tuple_element_t<I, Contents>;
1988
1994 size_t id = 0;
1995 set_id(id);
1996 for (size_t i = 0; i < contents_count_; i++) {
1997 last_valid_index_[i] = -1;
1998 }
1999 }
2000
2007 : tags_(awkward::GrowableBuffer<TAGS>(options)),
2008 index_(awkward::GrowableBuffer<INDEX>(options)) {
2009 size_t id = 0;
2010 set_id(id);
2011 for (size_t i = 0; i < contents_count_; i++) {
2012 last_valid_index_[i] = -1;
2013 }
2014 }
2015
2016 template <std::size_t I>
2017 ContentType<I>&
2018 content() noexcept {
2019 return std::get<I>(contents_);
2020 }
2021
2024 template <std::size_t TAG>
2025 ContentType<TAG>&
2026 append_content() noexcept {
2027 auto& which_content = std::get<TAG>(contents_);
2028 INDEX next_index = which_content.length();
2029
2030 TAGS tag = (TAGS)TAG;
2031 last_valid_index_[tag] = next_index;
2032 tags_.append(tag);
2033 index_.append(next_index);
2034
2035 return which_content;
2036 }
2037
2039 const std::string&
2040 parameters() const noexcept {
2041 return parameters_;
2042 }
2043
2045 void
2046 set_parameters(std::string parameter) noexcept {
2047 parameters_ = parameter;
2048 }
2049
2051 void
2052 set_id(size_t& id) noexcept {
2053 id_ = id;
2054 id++;
2055 auto contents_id = [&id](auto& content) {
2056 content.set_id(id);
2057 };
2058 for (size_t i = 0; i < contents_count_; i++) {
2059 visit_at(contents_, i, contents_id);
2060 }
2061 }
2062
2067 void
2068 clear() noexcept {
2069 for (size_t i = 0; i < contents_count_; i++) {
2070 last_valid_index_[i] = -1;
2071 }
2072 tags_.clear();
2073 index_.clear();
2074 auto clear_contents = [](auto& content) {
2075 content.clear();
2076 };
2077 for (size_t i = 0; i < contents_count_; i++) {
2078 visit_at(contents_, i, clear_contents);
2079 }
2080 }
2081
2083 size_t
2084 length() const noexcept {
2085 return tags_.length();
2086 }
2087
2089 bool
2090 is_valid(std::string& error) const noexcept {
2091 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2092
2093 std::vector<size_t> lengths = content_lengths(index_sequence);
2094 for (size_t tag = 0; tag < contents_count_; tag++) {
2095 if (lengths[tag] != last_valid_index_[tag] + 1) {
2096 std::stringstream out;
2097 out << "Union node" << id_ << " has content length " << lengths[tag]
2098 << " but index length " << last_valid_index_[tag] << "\n";
2099 error.append(out.str());
2100
2101 return false;
2102 }
2103 }
2104
2105 std::vector<bool> valid_contents =
2106 content_is_valid(index_sequence, error);
2107 return std::none_of(std::cbegin(valid_contents),
2108 std::cend(valid_contents),
2109 std::logical_not<bool>());
2110 }
2111
2114 void
2115 buffer_nbytes(std::map<std::string, size_t>& names_nbytes) const
2116 noexcept {
2117 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2118
2119 names_nbytes["node" + std::to_string(id_) + "-tags"] = tags_.nbytes();
2120 names_nbytes["node" + std::to_string(id_) + "-index"] = index_.nbytes();
2121
2122 for (size_t i = 0; i < contents_count_; i++) {
2123 visit_at(contents_, i, [&names_nbytes](auto& content) {
2124 content.buffer_nbytes(names_nbytes);
2125 });
2126 }
2127 }
2128
2134 void
2135 to_buffers(std::map<std::string, void*>& buffers) const noexcept {
2136 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2137
2138 tags_.concatenate(reinterpret_cast<TAGS*>(
2139 buffers["node" + std::to_string(id_) + "-tags"]));
2140 index_.concatenate(reinterpret_cast<INDEX*>(
2141 buffers["node" + std::to_string(id_) + "-index"]));
2142
2143 for (size_t i = 0; i < contents_count_; i++) {
2144 visit_at(contents_, i, [&buffers](auto& content) {
2145 content.to_buffers(buffers);
2146 });
2147 }
2148 }
2149
2154 void
2155 to_buffer(void* buffer, const char* name) const noexcept {
2156 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2157
2158 if (std::string(name) == std::string("node" + std::to_string(id_) + "-tags")) {
2159 tags_.concatenate(reinterpret_cast<TAGS*>(buffer));
2160 }
2161 else if (std::string(name) == std::string("node" + std::to_string(id_) + "-index")) {
2162 index_.concatenate(reinterpret_cast<INDEX*>(buffer));
2163 }
2164
2165 for (size_t i = 0; i < contents_count_; i++) {
2166 visit_at(contents_, i, [&buffer, &name](auto& content) {
2167 content.to_buffer(buffer, name);
2168 });
2169 }
2170 }
2171
2176 void
2177 to_char_buffers(std::map<std::string, uint8_t*>& buffers) const noexcept {
2178 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2179
2180 tags_.concatenate(reinterpret_cast<TAGS*>(
2181 buffers["node" + std::to_string(id_) + "-tags"]));
2182 index_.concatenate(reinterpret_cast<INDEX*>(
2183 buffers["node" + std::to_string(id_) + "-index"]));
2184
2185 for (size_t i = 0; i < contents_count_; i++) {
2186 visit_at(contents_, i, [&buffers](auto& content) {
2187 content.to_char_buffers(buffers);
2188 });
2189 }
2190 }
2191
2194 std::string
2195 form() const noexcept {
2196 std::stringstream form_key;
2197 form_key << "node" << id_;
2198 std::string params("");
2199 if (parameters_ == "") {
2200 } else {
2201 params = std::string(", \"parameters\": { " + parameters_ + " }");
2202 }
2203 std::stringstream out;
2204 out << "{ \"class\": \"UnionArray\", \"tags\": \"" +
2205 type_to_numpy_like<TAGS>() + "\", \"index\": \"" +
2206 type_to_numpy_like<INDEX>() + "\", \"contents\": [";
2207 for (size_t i = 0; i < contents_count_; i++) {
2208 if (i != 0) {
2209 out << ", ";
2210 }
2211 auto contents_form = [&](auto& content) {
2212 out << content.form();
2213 };
2214 visit_at(contents_, i, contents_form);
2215 }
2216 out << "], ";
2217 out << params << "\"form_key\": \"" << form_key.str() << "\" }";
2218 return out.str();
2219 }
2220
2221 private:
2224 template <std::size_t... S>
2225 std::vector<size_t>
2226 content_lengths(std::index_sequence<S...>) const {
2227 return std::vector<size_t>({std::get<S>(contents_).length()...});
2228 }
2229
2231 template <std::size_t... S>
2232 std::vector<bool>
2233 content_is_valid(std::index_sequence<S...>, std::string& error) const {
2234 return std::vector<bool>({std::get<S>(contents_).is_valid(error)...});
2235 }
2236
2240 GrowableBuffer<TAGS> tags_;
2241
2245 GrowableBuffer<INDEX> index_;
2246
2248 Contents contents_;
2249
2251 std::string parameters_;
2252
2254 size_t id_;
2255
2257 size_t last_valid_index_[sizeof...(BUILDERS)];
2258
2260 static constexpr size_t contents_count_ = sizeof...(BUILDERS);
2261 };
2262
2263 } // namespace LayoutBuilder
2264} // namespace awkward
2265
2266#endif // AWKWARD_LAYOUTBUILDER_H_
#define AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS
Object of BuilderOptions which sets the values of the default options.
Definition LayoutBuilder.h:18
virtual const std::string to_buffers(BuffersContainer &container, int64_t &form_key_id) const =0
Copy the current snapshot into the BuffersContainer and return a Form as a std::string (JSON).
virtual void clear()=0
Removes all accumulated data without resetting the type knowledge.
virtual const BuilderPtr index(int64_t index)=0
Sets the pointer to a given tuple field index; the next command will fill that slot.
Discontiguous, one-dimensional buffer (which consists of multiple contiguous, one-dimensional panels)...
Definition GrowableBuffer.h:233
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:517
size_t nbytes() const
Currently used number of bytes.
Definition GrowableBuffer.h:440
void concatenate(PRIMITIVE *external_pointer) const noexcept
Copies and concatenates all accumulated data from multiple panels to one contiguously allocated exter...
Definition GrowableBuffer.h:492
PRIMITIVE & append_and_get_ref(PRIMITIVE datum)
Like append, but the type signature returns the reference to PRIMITIVE.
Definition GrowableBuffer.h:484
size_t length() const
Currently used number of elements.
Definition GrowableBuffer.h:408
void append(PRIMITIVE datum)
Inserts one datum into the panel, possibly triggering allocation of a new panel.
Definition GrowableBuffer.h:450
void clear()
Discards accumulated data, the #reserved returns to options.initial(), and a new #ptr is allocated.
Definition GrowableBuffer.h:421
Builds a BitMaskedArray in which mask values are packed into a bitmap.
Definition LayoutBuilder.h:1668
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition LayoutBuilder.h:1721
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:1804
bool lsb_order() const noexcept
Determines whether the position of each bit is in Least-Significant Bit order (LSB) or not.
Definition LayoutBuilder.h:1728
BUILDER & append_invalid() noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:1762
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:1751
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:1887
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1783
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1789
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1715
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:1814
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:1876
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1795
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1821
BitMasked(const awkward::BuilderOptions &options)
Creates a new BitMasked layout builder by allocating a new mask buffer, taking options from BuilderOp...
Definition LayoutBuilder.h:1695
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:1737
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:1838
BUILDER & extend_invalid(size_t size) noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:1774
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the builder buffer to a user-defined pointer if the g...
Definition LayoutBuilder.h:1863
BitMasked()
Creates a new BitMasked layout builder by allocating a new mask buffer, using AWKWARD_LAYOUTBUILDER_D...
Definition LayoutBuilder.h:1672
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:1850
Builds a ByteMaskedArray using a mask which is an array of booleans that determines whether the corre...
Definition LayoutBuilder.h:1443
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition LayoutBuilder.h:1472
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:1543
BUILDER & append_invalid() noexcept
Inserts !valid_when in the mask.
Definition LayoutBuilder.h:1502
BUILDER & extend_valid(size_t size) noexcept
Inserts size number of valid_when in the mask.
Definition LayoutBuilder.h:1491
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:1617
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1522
ByteMasked()
Creates a new ByteMasked layout builder by allocating a new mask buffer, using AWKWARD_LAYOUTBUILDER_...
Definition LayoutBuilder.h:1447
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1528
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1466
ByteMasked(const awkward::BuilderOptions &options)
Creates a new ByteMasked layout builder by allocating a new mask buffer, taking options from BuilderO...
Definition LayoutBuilder.h:1458
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:1550
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:1608
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1534
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1556
BUILDER & append_valid() noexcept
Inserts valid_when in the mask.
Definition LayoutBuilder.h:1480
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:1573
BUILDER & extend_invalid(size_t size) noexcept
Inserts size number of !valid_when in the mask.
Definition LayoutBuilder.h:1513
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the builder buffer to a user-defined pointer if the g...
Definition LayoutBuilder.h:1596
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:1585
Builds an EmptyArray which has no content in it. It is used whenever an array's type is not known bec...
Definition LayoutBuilder.h:396
void clear() noexcept
Definition LayoutBuilder.h:408
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:418
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:442
void to_buffers(std::map< std::string, void * > &) const noexcept
Definition LayoutBuilder.h:427
void to_buffer(void *, const char *) const noexcept
Definition LayoutBuilder.h:430
Empty()
Creates a new Empty layout builder.
Definition LayoutBuilder.h:399
void set_id(size_t &) noexcept
Definition LayoutBuilder.h:405
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:412
void buffer_nbytes(std::map< std::string, size_t > &) const noexcept
Definition LayoutBuilder.h:423
void to_char_buffers(std::map< std::string, uint8_t * > &) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition LayoutBuilder.h:437
Helper class for sending a pair of field names (as enum) and field type as template parameters in Rec...
Definition LayoutBuilder.h:32
std::string index_as_field() const
Converts index as field string.
Definition LayoutBuilder.h:38
BUILDER Builder
Definition LayoutBuilder.h:34
const std::size_t index
The index of a Record field.
Definition LayoutBuilder.h:43
Builder builder
The content type of field in a Record.
Definition LayoutBuilder.h:45
Builds an IndexedOptionArray which consists of an index buffer. The negative values in the index are ...
Definition LayoutBuilder.h:1099
void clear() noexcept
Discards the accumulated index and clears the content of the builder. Also, last valid returns to -1.
Definition LayoutBuilder.h:1192
void extend_invalid(size_t size) noexcept
Inserts -1 in the index buffer size number of times.
Definition LayoutBuilder.h:1163
BUILDER & extend_valid(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:1143
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:1267
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1171
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1177
IndexedOption(const awkward::BuilderOptions &options)
Creates a new IndexedOption layout builder by allocating a new index buffer, taking options from Buil...
Definition LayoutBuilder.h:1116
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1125
size_t length() const noexcept
Current length of the index buffer.
Definition LayoutBuilder.h:1200
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:1258
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1183
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1206
IndexedOption()
Creates a new IndexedOption layout builder by allocating a new index buffer, using AWKWARD_LAYOUTBUIL...
Definition LayoutBuilder.h:1103
BUILDER & append_valid() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1132
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:1223
void append_invalid() noexcept
Inserts -1 in the index buffer.
Definition LayoutBuilder.h:1155
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the builder buffer to a user-defined pointer if the g...
Definition LayoutBuilder.h:1246
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:1235
Builds a ListOffsetArray which describes unequal-length lists (often called a "jagged" or "ragged" ar...
Definition LayoutBuilder.h:220
void clear() noexcept
Discards the accumulated offsets and clears the builder content.
Definition LayoutBuilder.h:285
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the builder content.
Definition LayoutBuilder.h:252
ListOffset()
Creates a new ListOffset layout builder by allocating a new offset buffer, using AWKWARD_LAYOUTBUILDE...
Definition LayoutBuilder.h:224
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:361
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:265
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:271
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:246
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:293
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:352
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:277
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:299
void end_list() noexcept
Ends a list and appends the current length of the list contents in the offsets buffer.
Definition LayoutBuilder.h:259
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:316
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the builder buffer to a user-defined pointer if the g...
Definition LayoutBuilder.h:340
ListOffset(const awkward::BuilderOptions &options)
Creates a new ListOffset layout builder by allocating a new offset buffer, taking options from Builde...
Definition LayoutBuilder.h:237
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:329
Builds a NumpyArray which describes multi-dimensional data of PRIMITIVE type.
Definition LayoutBuilder.h:55
void clear() noexcept
Discards the accumulated data in the builder.
Definition LayoutBuilder.h:112
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:124
Numpy(const awkward::BuilderOptions &options)
Creates a new Numpy layout builder by allocating a new buffer, taking options from BuilderOptions for...
Definition LayoutBuilder.h:71
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:93
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:99
size_t length() const noexcept
Current length of the data.
Definition LayoutBuilder.h:118
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:161
void append(PRIMITIVE x) noexcept
Inserts a PRIMITIVE type data.
Definition LayoutBuilder.h:79
Numpy()
Creates a new Numpy layout builder by allocating a new buffer, using AWKWARD_LAYOUTBUILDER_DEFAULT_OP...
Definition LayoutBuilder.h:59
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:105
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:130
void extend(PRIMITIVE *ptr, size_t size) noexcept
Inserts an entire array of PRIMITIVE type data.
Definition LayoutBuilder.h:87
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the builder buffer to a user-defined pointer if the g...
Definition LayoutBuilder.h:150
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:141
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:169
Builds a RecordArray which represents an array of records, which can be of same or different types....
Definition LayoutBuilder.h:463
void clear() noexcept
Clears the builder contents.
Definition LayoutBuilder.h:550
Record()
Creates a new Record layout builder.
Definition LayoutBuilder.h:472
MAP UserDefinedMap
Definition LayoutBuilder.h:466
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:646
RecordFieldType< INDEX >::Builder & content() noexcept
Returns the reference to the builder contents at INDEX.
Definition LayoutBuilder.h:517
std::tuple_element_t< INDEX, RecordContents > RecordFieldType
Definition LayoutBuilder.h:469
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:484
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:523
typename std::tuple< BUILDERS... > RecordContents
Definition LayoutBuilder.h:465
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:529
size_t length() const noexcept
Current number of records in first field.
Definition LayoutBuilder.h:560
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:635
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:535
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:566
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:595
void set_fields(MAP user_defined_field_id_to_name_map) noexcept
Sets the field names.
Definition LayoutBuilder.h:510
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the buffers of the builder contents to user-defined p...
Definition LayoutBuilder.h:622
const std::vector< std::string > fields() const noexcept
Returns a vector of strings sontaining all the field names.
Definition LayoutBuilder.h:493
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:610
RecordContents contents
The contents of the RecordArray.
Definition LayoutBuilder.h:675
Builds a RegularArray that describes lists that have the same length, a single integer size....
Definition LayoutBuilder.h:943
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:992
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the content of the builder.
Definition LayoutBuilder.h:960
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:1057
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:972
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:978
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:953
size_t length() const noexcept
Current number of lists of length SIZE.
Definition LayoutBuilder.h:999
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:1050
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:984
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1005
void end_list() noexcept
Ends a list and increments the number of lists.
Definition LayoutBuilder.h:966
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:1022
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the buffers of the builder content to user-defined po...
Definition LayoutBuilder.h:1041
Regular()
Creates a new Regular layout builder.
Definition LayoutBuilder.h:946
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:1033
Builds a RecordArray which represents an array of tuples which can be of same or different types with...
Definition LayoutBuilder.h:727
void clear() noexcept
Clears the builder contents.
Definition LayoutBuilder.h:775
TupleContents contents
The contents of the RecordArray without fields.
Definition LayoutBuilder.h:897
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:872
Tuple()
Creates a new Tuple layout builder.
Definition LayoutBuilder.h:735
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:749
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:755
size_t length() const noexcept
Current number of records in the first index of the tuple.
Definition LayoutBuilder.h:785
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:861
TupleContentType< INDEX > & content() noexcept
Returns the reference to the builder contents at INDEX.
Definition LayoutBuilder.h:743
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:761
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:791
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:821
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the buffers of the builder contents to user-defined p...
Definition LayoutBuilder.h:848
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:836
Builds a UnionArray which represents data drawn from an ordered list of contents, which can have diff...
Definition LayoutBuilder.h:1982
void clear() noexcept
Discards the accumulated tags and index, and clears the builder contents.
Definition LayoutBuilder.h:2068
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:2006
typename std::tuple< BUILDERS... > Contents
Definition LayoutBuilder.h:1984
std::tuple_element_t< I, Contents > ContentType
Definition LayoutBuilder.h:1987
ContentType< TAG > & append_content() noexcept
Inserts the current tag in the tags buffer and the next index in the index buffer and returns the ref...
Definition LayoutBuilder.h:2026
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:2195
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:2040
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:2046
size_t length() const noexcept
Current length of the tags buffer.
Definition LayoutBuilder.h:2084
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:2177
Union()
Creates a new Union layout builder by allocating new tags and index buffers, using AWKWARD_LAYOUTBUIL...
Definition LayoutBuilder.h:1991
ContentType< I > & content() noexcept
Definition LayoutBuilder.h:2018
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:2052
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2090
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:2115
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the builder buffers to user-defined pointers if the g...
Definition LayoutBuilder.h:2155
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:2135
Builds an UnmaskedArray which the values are never, in fact, missing. It exists to satisfy systems th...
Definition LayoutBuilder.h:1312
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:1348
Unmasked()
Creates a new Unmasked layout builder.
Definition LayoutBuilder.h:1315
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:1402
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1328
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1334
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1322
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:1354
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:1395
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1340
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1360
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:1367
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the buffers of the builder content to user-defined po...
Definition LayoutBuilder.h:1386
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:1378
Definition ArrayBuilder.h:14
void visit_at(std::tuple< CONTENTs... > const &contents, size_t index, FUNCTION fun)
Visits the tuple contents at index.
Definition utils.h:263
Container for all configuration options needed by ArrayBuilder, GrowableBuffer, LayoutBuilder and the...
Definition BuilderOptions.h:20
Definition utils.h:168
std::map< std::size_t, std::string > UserDefinedMap
Definition test_1494-layout-builder.cpp:39