3#ifndef AWKWARD_LAYOUTBUILDER_H_
4#define AWKWARD_LAYOUTBUILDER_H_
17 namespace LayoutBuilder {
30 template <std::
size_t ENUM,
typename BUILDER>
38 return std::to_string(
index);
53 template <
typename PRIMITIVE>
86 extend(PRIMITIVE* ptr,
size_t size)
noexcept {
87 data_.extend(ptr, size);
99 parameters_ = parameter;
118 return data_.length();
131 names_nbytes[
"node" + std::to_string(id_) +
"-data"] = data_.nbytes();
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"]));
151 data_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
152 buffers[
"node" + std::to_string(id_) +
"-data"]));
159 std::stringstream form_key;
160 form_key <<
"node" << id_;
162 std::string params(
"");
163 if (parameters_ ==
"") {
165 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
168 if (std::is_arithmetic<PRIMITIVE>::value) {
169 return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
170 type_to_name<PRIMITIVE>() +
"\"" + params +
171 ", \"form_key\": \"" + form_key.str() +
"\" }";
173 return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
174 type_to_name<PRIMITIVE>() +
"\"" + params +
175 ", \"form_key\": \"" + form_key.str() +
"\" }";
177 throw std::runtime_error(
"type " +
178 std::string(
typeid(PRIMITIVE).name()) +
188 std::string parameters_;
208 template <
typename PRIMITIVE,
typename BUILDER>
249 offsets_.append(content_.length());
261 parameters_ = parameter;
283 return offsets_.length() - 1;
289 if ((int64_t)content_.length() != (int64_t)offsets_.last()) {
290 std::stringstream out;
291 out <<
"ListOffset node" << id_ <<
"has content length "
292 << content_.length() <<
"but last offset " << offsets_.last()
294 error.append(out.str());
298 return content_.is_valid(error);
307 names_nbytes[
"node" + std::to_string(id_) +
"-offsets"] =
309 content_.buffer_nbytes(names_nbytes);
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);
330 offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
331 buffers[
"node" + std::to_string(id_) +
"-offsets"]));
332 content_.to_char_buffers(buffers);
339 std::stringstream form_key;
340 form_key <<
"node" << id_;
341 std::string params(
"");
342 if (parameters_ ==
"") {
344 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
346 return "{ \"class\": \"ListOffsetArray\", \"offsets\": \"" +
347 type_to_numpy_like<PRIMITIVE>() +
348 "\", \"content\": " + content_.form() + params +
349 ", \"form_key\": \"" + form_key.str() +
"\" }";
362 std::string parameters_;
380 template <
typename PRIMITIVE,
typename BUILDER>
417 starts_.append(content_.length());
425 stops_.append(content_.length());
437 parameters_ = parameter;
460 return starts_.length();
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());
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()
478 error.append(out.str());
482 return content_.is_valid(error);
491 names_nbytes[
"node" + std::to_string(id_) +
"-starts"] =
493 names_nbytes[
"node" + std::to_string(id_) +
"-stops"] = stops_.nbytes();
494 content_.buffer_nbytes(names_nbytes);
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);
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);
528 std::stringstream form_key;
529 form_key <<
"node" << id_;
530 std::string params(
"");
531 if (parameters_ ==
"") {
533 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
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() +
"\" }";
557 std::string parameters_;
584 parameters_ = parameter;
623 std::string params(
"");
624 if (parameters_ ==
"") {
626 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
628 return "{ \"class\": \"EmptyArray\"" + params +
" }";
633 std::string parameters_;
647 template <
bool IS_TUPLE>
679 parameters_ = parameter;
725 std::stringstream form_key;
726 form_key <<
"node" << id_;
727 std::string params(
"");
728 if (parameters_ ==
"") {
730 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
734 return "{ \"class\": \"RecordArray\", \"contents\": []" + params +
735 ", \"form_key\": \"" + form_key.str() +
"\" }";
737 return "{ \"class\": \"RecordArray\", \"contents\": {}" + params +
738 ", \"form_key\": \"" + form_key.str() +
"\" }";
744 std::string parameters_;
756 bool is_tuple_ = IS_TUPLE;
768 template <
class MAP = std::map<std::
size_t, std::
string>,
769 typename... BUILDERS>
775 template <std::
size_t INDEX>
782 map_fields(std::index_sequence_for<BUILDERS...>());
792 : content_names_(user_defined_field_id_to_name_map) {
793 assert(content_names_.size() == fields_count_);
799 const std::vector<std::string>
801 if (content_names_.empty()) {
804 std::vector<std::string> result;
805 for (
auto it : content_names_) {
806 result.emplace_back(it.second);
818 content_names_ = user_defined_field_id_to_name_map;
822 template <std::
size_t INDEX>
823 typename RecordFieldType<INDEX>::Builder&
825 return std::get<INDEX>(
contents).builder;
837 parameters_ = parameter;
845 for (
size_t i = 0; i < fields_count_; i++) {
847 content.builder.set_id(
id);
858 for (
size_t i = 0; i < fields_count_; i++)
860 content.builder.clear();
867 return (std::get<0>(
contents).builder.length());
873 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
876 std::vector<size_t> lengths = field_lengths(index_sequence);
877 for (
size_t i = 0; i < lengths.size(); i++) {
881 else if (
length != (int64_t)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());
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>());
903 for (
size_t i = 0; i < fields_count_; i++)
905 content.builder.buffer_nbytes(names_nbytes);
915 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
916 for (
size_t i = 0; i < fields_count_; i++)
918 content.builder.to_buffers(buffers);
928 for (
size_t i = 0; i < fields_count_; i++)
930 content.builder.to_char_buffers(buffers);
938 std::stringstream form_key;
939 form_key <<
"node" << id_;
940 std::string params(
"");
941 if (parameters_ ==
"") {
943 params = std::string(
"\"parameters\": { " + parameters_ +
" }, ");
945 std::stringstream out;
946 out <<
"{ \"class\": \"RecordArray\", \"contents\": { ";
947 for (
size_t i = 0; i < fields_count_; i++) {
951 auto contents_form = [&](
auto& content) {
953 << (!content_names_.empty() ? content_names_.at(content.index)
954 : content.index_as_field())
956 out << content.builder.form();
961 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
971 template <std::size_t... S>
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())...});
980 template <std::size_t... S>
982 field_lengths(std::index_sequence<S...>)
const noexcept {
983 return std::vector<size_t>({std::get<S>(
contents).builder.length()...});
987 template <std::size_t... S>
989 field_is_valid(std::index_sequence<S...>, std::string& error)
const
991 return std::vector<bool>(
992 {std::get<S>(
contents).builder.is_valid(error)...});
996 std::vector<std::string> field_names_;
1002 std::string parameters_;
1008 static constexpr size_t fields_count_ =
sizeof...(BUILDERS);
1017 template <
typename... BUILDERS>
1019 using TupleContents =
typename std::tuple<BUILDERS...>;
1021 template <std::
size_t INDEX>
1022 using TupleContentType = std::tuple_element_t<INDEX, TupleContents>;
1032 template <std::
size_t INDEX>
1033 TupleContentType<INDEX>&
1047 parameters_ = parameter;
1055 for (
size_t i = 0; i < fields_count_; i++) {
1067 for (
size_t i = 0; i < fields_count_; i++)
1069 content.builder.clear();
1076 return (std::get<0>(
contents).builder.length());
1082 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
1085 std::vector<size_t> lengths = content_lengths(index_sequence);
1086 for (
size_t i = 0; i < lengths.size(); i++) {
1088 length = (int64_t)lengths[i];
1090 else if (
length != (int64_t)lengths[i]) {
1091 std::stringstream out;
1092 out <<
"Record node" << id_ <<
" has index \"" << i <<
"\" length "
1093 << lengths[i] <<
" that differs from the first length "
1095 error.append(out.str());
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>());
1113 for (
size_t i = 0; i < fields_count_; i++)
1115 content.buffer_nbytes(names_nbytes);
1125 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1126 for (
size_t i = 0; i < fields_count_; i++)
1128 content.to_buffers(buffers);
1138 for (
size_t i = 0; i < fields_count_; i++)
1140 content.to_char_buffers(buffers);
1148 std::stringstream form_key;
1149 form_key <<
"node" << id_;
1150 std::string params(
"");
1151 if (parameters_ ==
"") {
1153 params = std::string(
"\"parameters\": { " + parameters_ +
" }, ");
1155 std::stringstream out;
1156 out <<
"{ \"class\": \"RecordArray\", \"contents\": [";
1157 for (
size_t i = 0; i < fields_count_; i++) {
1161 auto contents_form = [&out](
auto& content) {
1162 out << content.form();
1167 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
1177 template <std::size_t... S>
1179 content_lengths(std::index_sequence<S...>)
const noexcept {
1180 return std::vector<size_t>({std::get<S>(
contents).length()...});
1184 template <std::size_t... S>
1186 content_is_valid(std::index_sequence<S...>, std::string& error)
const
1188 return std::vector<bool>({std::get<S>(
contents).is_valid(error)...});
1192 std::vector<int64_t> field_index_;
1195 std::string parameters_;
1201 static constexpr size_t fields_count_ =
sizeof...(BUILDERS);
1217 template <
unsigned SIZE,
typename BUILDER>
1254 parameters_ = parameter;
1262 content_.set_id(
id);
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 "
1286 error.append(out.str());
1290 return content_.is_valid(error);
1299 content_.buffer_nbytes(names_nbytes);
1308 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1309 content_.to_buffers(buffers);
1318 content_.to_char_buffers(buffers);
1325 std::stringstream form_key;
1326 form_key <<
"node" << id_;
1327 std::string params(
"");
1328 if (parameters_ ==
"") {
1330 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1332 return "{ \"class\": \"RegularArray\", \"content\": " +
1333 content_.form() +
", \"size\": " + std::to_string(size_) +
1334 params +
", \"form_key\": \"" + form_key.str() +
"\" }";
1342 std::string parameters_;
1351 size_t size_ = SIZE;
1364 template <
typename PRIMITIVE,
typename BUILDER>
1399 last_valid_ = content_.length();
1400 index_.append(last_valid_);
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++) {
1428 parameters_ = parameter;
1436 content_.set_id(
id);
1451 return index_.length();
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()
1462 error.append(out.str());
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_
1470 error.append(out.str());
1474 return content_.is_valid(error);
1483 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
1484 content_.buffer_nbytes(names_nbytes);
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);
1505 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1506 buffers[
"node" + std::to_string(id_) +
"-index"]));
1507 content_.to_char_buffers(buffers);
1514 std::stringstream form_key;
1515 form_key <<
"node" << id_;
1516 std::string params(
"");
1517 if (parameters_ ==
"") {
1519 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1521 return "{ \"class\": \"IndexedArray\", \"index\": \"" +
1522 type_to_numpy_like<PRIMITIVE>() +
1523 "\", \"content\": " + content_.form() + params +
1524 ", \"form_key\": \"" + form_key.str() +
"\" }";
1537 std::string parameters_;
1556 template <
typename PRIMITIVE,
typename BUILDER>
1591 last_valid_ = content_.length();
1592 index_.append(last_valid_);
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++) {
1622 for (
size_t i = 0; i < size; i++) {
1636 parameters_ = parameter;
1644 content_.set_id(
id);
1659 return index_.length();
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_
1670 error.append(out.str());
1674 return content_.is_valid(error);
1683 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
1684 content_.buffer_nbytes(names_nbytes);
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);
1705 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1706 buffers[
"node" + std::to_string(id_) +
"-index"]));
1707 content_.to_char_buffers(buffers);
1714 std::stringstream form_key;
1715 form_key <<
"node" << id_;
1716 std::string params(
"");
1717 if (parameters_ ==
"") {
1719 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1721 return "{ \"class\": \"IndexedOptionArray\", \"index\": \"" +
1722 type_to_numpy_like<PRIMITIVE>() +
1723 "\", \"content\": " + content_.form() + params +
1724 ", \"form_key\": \"" + form_key.str() +
"\" }";
1737 std::string parameters_;
1757 template <
typename BUILDER>
1798 parameters_ = parameter;
1806 content_.set_id(
id);
1818 return content_.length();
1824 return content_.is_valid(error);
1832 content_.buffer_nbytes(names_nbytes);
1841 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1842 content_.to_buffers(buffers);
1851 content_.to_char_buffers(buffers);
1858 std::stringstream form_key;
1859 form_key <<
"node" << id_;
1860 std::string params(
"");
1861 if (parameters_ ==
"") {
1863 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1865 return "{ \"class\": \"UnmaskedArray\", \"content\": " +
1866 content_.form() + params +
", \"form_key\": \"" +
1867 form_key.str() +
"\" }";
1875 std::string parameters_;
1897 template <
bool VALID_WHEN,
typename BUILDER>
1936 mask_.
append(valid_when_);
1947 for (
size_t i = 0; i < size; i++) {
1948 mask_.
append(valid_when_);
1958 mask_.
append(!valid_when_);
1969 for (
size_t i = 0; i < size; i++) {
1970 mask_.
append(!valid_when_);
1984 parameters_ = parameter;
1992 content_.set_id(
id);
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()
2017 error.append(out.str());
2021 return content_.is_valid(error);
2030 names_nbytes[
"node" + std::to_string(id_) +
"-mask"] = mask_.
nbytes();
2031 content_.buffer_nbytes(names_nbytes);
2040 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
2042 buffers[
"node" + std::to_string(id_) +
"-mask"]));
2043 content_.to_buffers(buffers);
2053 buffers[
"node" + std::to_string(id_) +
"-mask"]));
2054 content_.to_char_buffers(buffers);
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_ ==
"") {
2067 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
2069 return "{ \"class\": \"ByteMaskedArray\", \"mask\": \"i8\", "
2071 content_.form() +
", \"valid_when\": " + form_valid_when.str() +
2072 params +
", \"form_key\": \"" + form_key.str() +
"\" }";
2085 std::string parameters_;
2091 bool valid_when_ = VALID_WHEN;
2110 template <
bool VALID_WHEN,
bool LSB_ORDER,
typename BUILDER>
2117 current_byte_(uint8_t(0)),
2118 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
2123 for (
size_t i = 0; i < 8; i++) {
2127 for (
size_t i = 0; i < 8; i++) {
2128 cast_[i] = 128 >> i;
2140 current_byte_(uint8_t(0)),
2141 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
2146 for (
size_t i = 0; i < 8; i++) {
2150 for (
size_t i = 0; i < 8; i++) {
2151 cast_[i] = 128 >> i;
2182 current_byte_ |= cast_[current_index_];
2195 for (
size_t i = 0; i < size; i++) {
2218 for (
size_t i = 0; i < size; i++) {
2233 parameters_ = parameter;
2241 content_.set_id(
id);
2255 return (mask_.
length() - 1) * 8 + current_index_;
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()
2266 error.append(out.str());
2270 return content_.is_valid(error);
2279 names_nbytes[
"node" + std::to_string(id_) +
"-mask"] = mask_.
nbytes();
2280 content_.buffer_nbytes(names_nbytes);
2289 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
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);
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);
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_ ==
"") {
2321 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
2323 return "{ \"class\": \"BitMaskedArray\", \"mask\": \"u8\", "
2325 content_.form() +
", \"valid_when\": " + form_valid_when.str() +
2326 ", \"lsb_order\": " + form_lsb_order.str() + params +
2327 ", \"form_key\": \"" + form_key.str() +
"\" }";
2336 if (current_index_ == 8) {
2338 current_byte_ = uint8_t(0);
2350 current_index_ += 1;
2352 current_byte_ref_ = current_byte_;
2354 current_byte_ref_ = ~current_byte_;
2361 GrowableBuffer<uint8_t> mask_;
2367 std::string parameters_;
2373 uint8_t current_byte_;
2376 uint8_t& current_byte_ref_;
2379 size_t current_index_;
2385 bool valid_when_ = VALID_WHEN;
2389 bool lsb_order_ = LSB_ORDER;
2407 template <
typename TAGS,
typename INDEX,
typename... BUILDERS>
2412 template <std::
size_t I>
2422 for (
size_t i = 0; i < contents_count_; i++)
2423 last_valid_index_[i] = -1;
2436 for (
size_t i = 0; i < contents_count_; i++)
2437 last_valid_index_[i] = -1;
2440 template <std::
size_t I>
2443 return std::get<I>(contents_);
2448 template <std::
size_t TAG>
2451 auto& which_content = std::get<TAG>(contents_);
2452 INDEX next_index = which_content.length();
2454 TAGS tag = (TAGS)TAG;
2455 last_valid_index_[tag] = next_index;
2457 index_.
append(next_index);
2459 return which_content;
2471 parameters_ = parameter;
2479 auto contents_id = [&id](
auto&
content) {
2482 for (
size_t i = 0; i < contents_count_; i++)
2483 visit_at(contents_, i, contents_id);
2492 for (
size_t i = 0; i < contents_count_; i++)
2493 last_valid_index_[i] = -1;
2496 auto clear_contents = [](
auto&
content) {
2499 for (
size_t i = 0; i < contents_count_; i++)
2500 visit_at(contents_, i, clear_contents);
2512 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
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());
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>());
2538 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2540 names_nbytes[
"node" + std::to_string(id_) +
"-tags"] = tags_.
nbytes();
2541 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.
nbytes();
2543 for (
size_t i = 0; i < contents_count_; i++)
2545 content.buffer_nbytes(names_nbytes);
2555 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
2556 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2559 buffers[
"node" + std::to_string(id_) +
"-tags"]));
2561 buffers[
"node" + std::to_string(id_) +
"-index"]));
2563 for (
size_t i = 0; i < contents_count_; i++)
2575 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2578 buffers[
"node" + std::to_string(id_) +
"-tags"]));
2580 buffers[
"node" + std::to_string(id_) +
"-index"]));
2582 for (
size_t i = 0; i < contents_count_; i++)
2584 content.to_char_buffers(buffers);
2592 std::stringstream form_key;
2593 form_key <<
"node" << id_;
2594 std::string params(
"");
2595 if (parameters_ ==
"") {
2597 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
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++) {
2607 auto contents_form = [&](
auto&
content) {
2610 visit_at(contents_, i, contents_form);
2613 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
2620 template <std::size_t... S>
2622 content_lengths(std::index_sequence<S...>)
const {
2623 return std::vector<size_t>({std::get<S>(contents_).length()...});
2627 template <std::size_t... S>
2629 content_is_valid(std::index_sequence<S...>, std::string& error)
const {
2630 return std::vector<bool>({std::get<S>(contents_).is_valid(error)...});
2636 GrowableBuffer<TAGS> tags_;
2641 GrowableBuffer<INDEX> index_;
2647 std::string parameters_;
2653 size_t last_valid_index_[
sizeof...(BUILDERS)];
2656 static constexpr size_t contents_count_ =
sizeof...(BUILDERS);
Discontiguous, one-dimensional buffer (which consists of multiple contiguous, one-dimensional panels)...
Definition: GrowableBuffer.h:217
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:484
size_t nbytes() const
Currently used number of bytes.
Definition: GrowableBuffer.h:423
void concatenate(PRIMITIVE *external_pointer) const noexcept
Copies and concatenates all accumulated data from multiple panels to one contiguously allocated exter...
Definition: GrowableBuffer.h:475
PRIMITIVE & append_and_get_ref(PRIMITIVE datum)
Like append, but the type signature returns the reference to PRIMITIVE.
Definition: GrowableBuffer.h:467
size_t length() const
Currently used number of elements.
Definition: GrowableBuffer.h:392
void append(PRIMITIVE datum)
Inserts one datum into the panel, possibly triggering allocation of a new panel.
Definition: GrowableBuffer.h:433
void clear()
Discards accumulated data, the #reserved returns to options.initial(), and a new #ptr is allocated.
Definition: GrowableBuffer.h:405
Builds a BitMaskedArray in which mask values are packed into a bitmap.
Definition: LayoutBuilder.h:2111
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition: LayoutBuilder.h:2164
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition: LayoutBuilder.h:2247
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
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
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
BUILDER & extend_null(size_t size) noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition: LayoutBuilder.h:2217
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:2226
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:2232
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:2158
size_t length() const noexcept
Current length of the mask buffer.
Definition: LayoutBuilder.h:2254
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
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:2238
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:2260
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
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
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
BitMasked()
Creates a new BitMasked layout builder by allocating a new mask buffer, using default_options for ini...
Definition: LayoutBuilder.h:2115
BUILDER & append_null() noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition: LayoutBuilder.h:2205
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
Builds a ByteMaskedArray using a mask which is an array of booleans that determines whether the corre...
Definition: LayoutBuilder.h:1898
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition: LayoutBuilder.h:1927
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition: LayoutBuilder.h:1998
BUILDER & extend_valid(size_t size) noexcept
Inserts size number of valid_when in the mask.
Definition: LayoutBuilder.h:1946
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
BUILDER & extend_null(size_t size) noexcept
Inserts size number of !valid_when in the mask.
Definition: LayoutBuilder.h:1968
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:1977
ByteMasked()
Creates a new ByteMasked layout builder by allocating a new mask buffer, using default_options for in...
Definition: LayoutBuilder.h:1902
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:1983
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:1921
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
size_t length() const noexcept
Current length of the mask buffer.
Definition: LayoutBuilder.h:2005
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
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:1989
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:2011
BUILDER & append_valid() noexcept
Inserts valid_when in the mask.
Definition: LayoutBuilder.h:1935
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
BUILDER & append_null() noexcept
Inserts !valid_when in the mask.
Definition: LayoutBuilder.h:1957
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
Builds an Empty RecordArray which has has zero contents. It still represents a non-empty array....
Definition: LayoutBuilder.h:648
void clear() noexcept
Clears the builder contents, the length returns to zero.
Definition: LayoutBuilder.h:691
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:703
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
void to_buffers(std::map< std::string, void * > &) const noexcept
Definition: LayoutBuilder.h:712
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:672
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:678
void append() noexcept
Inserts an empty record.
Definition: LayoutBuilder.h:658
size_t length() const noexcept
Current number of records.
Definition: LayoutBuilder.h:697
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
void buffer_nbytes(std::map< std::string, size_t > &) const noexcept
Definition: LayoutBuilder.h:708
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:684
void extend(size_t size) noexcept
Inserts size number of empty records.
Definition: LayoutBuilder.h:666
EmptyRecord()
Creates a new EmptyRecord layout builder.
Definition: LayoutBuilder.h:651
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
void clear() noexcept
Definition: LayoutBuilder.h:591
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:601
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
void to_buffers(std::map< std::string, void * > &) const noexcept
Definition: LayoutBuilder.h:610
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:577
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:583
Empty()
Creates a new Empty layout builder.
Definition: LayoutBuilder.h:570
void set_id(size_t &) noexcept
Definition: LayoutBuilder.h:588
size_t length() const noexcept
Current length of the content.
Definition: LayoutBuilder.h:595
void buffer_nbytes(std::map< std::string, size_t > &) const noexcept
Definition: LayoutBuilder.h:606
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:617
Helper class for sending a pair of field names (as enum) and field type as template parameters in Rec...
Definition: LayoutBuilder.h:31
std::string index_as_field() const
Converts index as field string.
Definition: LayoutBuilder.h:37
BUILDER Builder
Definition: LayoutBuilder.h:33
const std::size_t index
The index of a Record field.
Definition: LayoutBuilder.h:42
Builder builder
The content type of field in a Record.
Definition: LayoutBuilder.h:44
Builds an IndexedOptionArray which consists of an index buffer. The negative values in the index are ...
Definition: LayoutBuilder.h:1557
void clear() noexcept
Discards the accumulated index and clears the content of the builder. Also, last valid returns to -1.
Definition: LayoutBuilder.h:1650
void extend_null(size_t size) noexcept
Inserts -1 in the index buffer size number of times.
Definition: LayoutBuilder.h:1621
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
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:1629
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
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:1635
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
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:1583
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
size_t length() const noexcept
Current length of the index buffer.
Definition: LayoutBuilder.h:1658
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
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:1641
void append_null() noexcept
Inserts -1 in the index buffer.
Definition: LayoutBuilder.h:1613
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:1664
IndexedOption()
Creates a new IndexedOption layout builder by allocating a new index buffer, using default_options fo...
Definition: LayoutBuilder.h:1561
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
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
Builds an IndexedArray which consists of an index buffer. It is a general-purpose tool for changing t...
Definition: LayoutBuilder.h:1365
void clear() noexcept
Discards the accumulated index and clears the content of the builder. Also, last valid returns to -1.
Definition: LayoutBuilder.h:1442
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
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
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:1421
Indexed()
Creates a new Indexed layout builder by allocating a new index buffer, using default_options for init...
Definition: LayoutBuilder.h:1369
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
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:1427
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:1391
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
size_t length() const noexcept
Current length of the content and the index buffer.
Definition: LayoutBuilder.h:1450
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
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:1433
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:1456
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
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
Builds a ListOffsetArray which describes unequal-length lists (often called a "jagged" or "ragged" ar...
Definition: LayoutBuilder.h:209
void clear() noexcept
Discards the accumulated offsets and clears the builder content.
Definition: LayoutBuilder.h:274
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the builder content.
Definition: LayoutBuilder.h:241
ListOffset()
Creates a new ListOffset layout builder by allocating a new offset buffer, using default_options for ...
Definition: LayoutBuilder.h:213
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
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:254
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:260
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:235
size_t length() const noexcept
Current length of the content.
Definition: LayoutBuilder.h:282
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
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:266
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:288
void end_list() noexcept
Ends a list and appends the current length of the list contents in the offsets buffer.
Definition: LayoutBuilder.h:248
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
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
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
Builds a ListArray which generalizes ListOffsetArray. Instead of a single offsets array,...
Definition: LayoutBuilder.h:381
void clear() noexcept
Discards the accumulated starts and stops, and clears the builder content.
Definition: LayoutBuilder.h:451
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
List()
Creates a new List layout builder by allocating new starts and stops buffer, using default_options fo...
Definition: LayoutBuilder.h:385
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
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:430
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:436
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:408
size_t length() const noexcept
Current length of the content and starts buffer.
Definition: LayoutBuilder.h:459
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
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:442
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:465
void end_list() noexcept
Ends a list and appends the current length of the list contents in the stops buffer.
Definition: LayoutBuilder.h:424
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
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
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
Builds a NumpyArray which describes multi-dimensional data of PRIMITIVE type.
Definition: LayoutBuilder.h:54
void clear() noexcept
Discards the accumulated data in the builder.
Definition: LayoutBuilder.h:111
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:123
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
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:92
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:98
size_t length() const noexcept
Current length of the data.
Definition: LayoutBuilder.h:117
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
void append(PRIMITIVE x) noexcept
Inserts a PRIMITIVE type data.
Definition: LayoutBuilder.h:78
Numpy()
Creates a new Numpy layout builder by allocating a new buffer, using default_options for initializing...
Definition: LayoutBuilder.h:58
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:104
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
void extend(PRIMITIVE *ptr, size_t size) noexcept
Inserts an entire array of PRIMITIVE type data.
Definition: LayoutBuilder.h:86
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
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
Builds a RecordArray which represents an array of records, which can be of same or different types....
Definition: LayoutBuilder.h:770
void clear() noexcept
Clears the builder contents.
Definition: LayoutBuilder.h:857
Record()
Creates a new Record layout builder.
Definition: LayoutBuilder.h:779
MAP UserDefinedMap
Definition: LayoutBuilder.h:773
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
std::tuple_element_t< INDEX, RecordContents > RecordFieldType
Definition: LayoutBuilder.h:776
const std::vector< std::string > field_names() const noexcept
Returns a vector of strings sontaining all the field names.
Definition: LayoutBuilder.h:800
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
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:830
typename std::tuple< BUILDERS... > RecordContents
Definition: LayoutBuilder.h:772
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:836
void set_field_names(MAP user_defined_field_id_to_name_map) noexcept
Sets the field names.
Definition: LayoutBuilder.h:817
size_t length() const noexcept
Current number of records in first field.
Definition: LayoutBuilder.h:866
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
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:842
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:872
RecordFieldType< INDEX >::Builder & field() noexcept
Returns the reference to the builder contents at INDEX.
Definition: LayoutBuilder.h:824
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
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
RecordContents contents
The contents of the RecordArray.
Definition: LayoutBuilder.h:966
Builds a RegularArray that describes lists that have the same length, a single integer size....
Definition: LayoutBuilder.h:1218
void clear() noexcept
Clears the builder content.
Definition: LayoutBuilder.h:1267
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the content of the builder.
Definition: LayoutBuilder.h:1235
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
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:1247
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:1253
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:1228
size_t length() const noexcept
Current number of lists of length SIZE.
Definition: LayoutBuilder.h:1274
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
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:1259
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:1280
void end_list() noexcept
Ends a list and increments the number of lists.
Definition: LayoutBuilder.h:1241
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
Regular()
Creates a new Regular layout builder.
Definition: LayoutBuilder.h:1221
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
Builds a RecordArray which represents an array of tuples which can be of same or different types with...
Definition: LayoutBuilder.h:1018
void clear() noexcept
Clears the builder contents.
Definition: LayoutBuilder.h:1066
TupleContents contents
The contents of the RecordArray without fields.
Definition: LayoutBuilder.h:1172
TupleContentType< INDEX > & index() noexcept
Returns the reference to the builder contents at INDEX.
Definition: LayoutBuilder.h:1034
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
Tuple()
Creates a new Tuple layout builder.
Definition: LayoutBuilder.h:1026
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:1040
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:1046
size_t length() const noexcept
Current number of records in the first index of the tuple.
Definition: LayoutBuilder.h:1075
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
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:1052
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:1081
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
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
Builds a UnionArray which represents data drawn from an ordered list of contents, which can have diff...
Definition: LayoutBuilder.h:2408
void clear() noexcept
Discards the accumulated tags and index, and clears the builder contents.
Definition: LayoutBuilder.h:2491
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
typename std::tuple< BUILDERS... > Contents
Definition: LayoutBuilder.h:2410
std::tuple_element_t< I, Contents > ContentType
Definition: LayoutBuilder.h:2413
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
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:2464
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:2470
size_t length() const noexcept
Current length of the tags buffer.
Definition: LayoutBuilder.h:2505
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
Union()
Creates a new Union layout builder by allocating new tags and index buffers, using default_options fo...
Definition: LayoutBuilder.h:2417
ContentType< I > & content() noexcept
Definition: LayoutBuilder.h:2442
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:2476
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:2511
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
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
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
Builds an UnmaskedArray which the values are never, in fact, missing. It exists to satisfy systems th...
Definition: LayoutBuilder.h:1758
void clear() noexcept
Clears the builder content.
Definition: LayoutBuilder.h:1811
Unmasked()
Creates a new Unmasked layout builder.
Definition: LayoutBuilder.h:1761
BUILDER & extend_valid(size_t size) noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:1785
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
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition: LayoutBuilder.h:1791
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition: LayoutBuilder.h:1797
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:1768
size_t length() const noexcept
Current length of the content.
Definition: LayoutBuilder.h:1817
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
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition: LayoutBuilder.h:1803
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition: LayoutBuilder.h:1823
BUILDER & append_valid() noexcept
Returns the reference to the builder content.
Definition: LayoutBuilder.h:1776
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
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::BuilderOptions default_options(1024, 1)
Object of BuilderOptions which sets the values of the default options.
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:306
Container for all configuration options needed by ArrayBuilder, GrowableBuffer, LayoutBuilder and the...
Definition: BuilderOptions.h:20