3#ifndef AWKWARD_LAYOUTBUILDER_H_
4#define AWKWARD_LAYOUTBUILDER_H_
18 namespace LayoutBuilder {
31 template <std::
size_t ENUM,
typename BUILDER>
39 return std::to_string(
index);
54 template <
typename PRIMITIVE>
87 extend(PRIMITIVE* ptr,
size_t size)
noexcept {
88 data_.extend(ptr, size);
100 parameters_ = parameter;
119 return data_.length();
132 names_nbytes[
"node" + std::to_string(id_) +
"-data"] = data_.nbytes();
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"]));
152 data_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
153 buffers[
"node" + std::to_string(id_) +
"-data"]));
160 std::stringstream form_key;
161 form_key <<
"node" << id_;
163 std::string params(
"");
164 if (parameters_ ==
"") {
166 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
169 if (std::is_arithmetic<PRIMITIVE>::value) {
170 return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
171 type_to_name<PRIMITIVE>() +
"\"" + params +
172 ", \"form_key\": \"" + form_key.str() +
"\" }";
174 return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
175 type_to_name<PRIMITIVE>() +
"\"" + params +
176 ", \"form_key\": \"" + form_key.str() +
"\" }";
178 throw std::runtime_error(
"type " +
179 std::string(
typeid(PRIMITIVE).name()) +
189 std::string parameters_;
209 template <
typename PRIMITIVE,
typename BUILDER>
250 offsets_.append(content_.length());
262 parameters_ = parameter;
284 return offsets_.length() - 1;
290 if ((int64_t)content_.length() != (int64_t)offsets_.last()) {
291 std::stringstream out;
292 out <<
"ListOffset node" << id_ <<
"has content length "
293 << content_.length() <<
"but last offset " << offsets_.last()
295 error.append(out.str());
299 return content_.is_valid(error);
308 names_nbytes[
"node" + std::to_string(id_) +
"-offsets"] =
310 content_.buffer_nbytes(names_nbytes);
319 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
320 offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
321 buffers[
"node" + std::to_string(id_) +
"-offsets"]));
322 content_.to_buffers(buffers);
331 offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
332 buffers[
"node" + std::to_string(id_) +
"-offsets"]));
333 content_.to_char_buffers(buffers);
340 std::stringstream form_key;
341 form_key <<
"node" << id_;
342 std::string params(
"");
343 if (parameters_ ==
"") {
345 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
347 return "{ \"class\": \"ListOffsetArray\", \"offsets\": \"" +
348 type_to_numpy_like<PRIMITIVE>() +
349 "\", \"content\": " + content_.form() + params +
350 ", \"form_key\": \"" + form_key.str() +
"\" }";
363 std::string parameters_;
381 template <
typename PRIMITIVE,
typename BUILDER>
418 starts_.append(content_.length());
426 stops_.append(content_.length());
438 parameters_ = parameter;
461 return starts_.length();
467 if (starts_.length() != stops_.length()) {
468 std::stringstream out;
469 out <<
"List node" << id_ <<
" has starts length " << starts_.length()
470 <<
" but stops length " << stops_.length() <<
"\n";
471 error.append(out.str());
474 }
else if (stops_.length() > 0 && content_.length() != stops_.last()) {
475 std::stringstream out;
476 out <<
"List node" << id_ <<
" has content length "
477 << content_.length() <<
" but last stops " << stops_.last()
479 error.append(out.str());
483 return content_.is_valid(error);
492 names_nbytes[
"node" + std::to_string(id_) +
"-starts"] =
494 names_nbytes[
"node" + std::to_string(id_) +
"-stops"] = stops_.nbytes();
495 content_.buffer_nbytes(names_nbytes);
504 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
505 starts_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
506 buffers[
"node" + std::to_string(id_) +
"-starts"]));
507 stops_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
508 buffers[
"node" + std::to_string(id_) +
"-stops"]));
509 content_.to_buffers(buffers);
518 starts_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
519 buffers[
"node" + std::to_string(id_) +
"-starts"]));
520 stops_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
521 buffers[
"node" + std::to_string(id_) +
"-stops"]));
522 content_.to_char_buffers(buffers);
529 std::stringstream form_key;
530 form_key <<
"node" << id_;
531 std::string params(
"");
532 if (parameters_ ==
"") {
534 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
536 return "{ \"class\": \"ListArray\", \"starts\": \"" +
537 type_to_numpy_like<PRIMITIVE>() +
"\", \"stops\": \"" +
538 type_to_numpy_like<PRIMITIVE>() +
539 "\", \"content\": " + content_.form() + params +
540 ", \"form_key\": \"" + form_key.str() +
"\" }";
558 std::string parameters_;
585 parameters_ = parameter;
624 std::string params(
"");
625 if (parameters_ ==
"") {
627 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
629 return "{ \"class\": \"EmptyArray\"" + params +
" }";
634 std::string parameters_;
648 template <
bool IS_TUPLE>
680 parameters_ = parameter;
726 std::stringstream form_key;
727 form_key <<
"node" << id_;
728 std::string params(
"");
729 if (parameters_ ==
"") {
731 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
735 return "{ \"class\": \"RecordArray\", \"contents\": []" + params +
736 ", \"form_key\": \"" + form_key.str() +
"\" }";
738 return "{ \"class\": \"RecordArray\", \"contents\": {}" + params +
739 ", \"form_key\": \"" + form_key.str() +
"\" }";
745 std::string parameters_;
757 bool is_tuple_ = IS_TUPLE;
769 template <
class MAP = std::map<std::
size_t, std::
string>,
770 typename... BUILDERS>
776 template <std::
size_t INDEX>
783 map_fields(std::index_sequence_for<BUILDERS...>());
793 : content_names_(user_defined_field_id_to_name_map) {
794 assert(content_names_.size() == fields_count_);
800 const std::vector<std::string>
802 if (content_names_.empty()) {
805 std::vector<std::string> result;
806 for (
auto it : content_names_) {
807 result.emplace_back(it.second);
819 content_names_ = user_defined_field_id_to_name_map;
823 template <std::
size_t INDEX>
824 typename RecordFieldType<INDEX>::Builder&
826 return std::get<INDEX>(
contents).builder;
838 parameters_ = parameter;
846 for (
size_t i = 0; i < fields_count_; i++) {
848 content.builder.set_id(
id);
859 for (
size_t i = 0; i < fields_count_; i++)
861 content.builder.clear();
868 return (std::get<0>(
contents).builder.length());
874 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
877 std::vector<size_t> lengths = field_lengths(index_sequence);
878 for (
size_t i = 0; i < lengths.size(); i++) {
882 else if (
length != (int64_t)lengths[i]) {
883 std::stringstream out;
884 out <<
"Record node" << id_ <<
" has field \""
885 <<
field_names().at(i) <<
"\" length " << lengths[i]
886 <<
" that differs from the first length " <<
length <<
"\n";
887 error.append(out.str());
893 std::vector<bool> valid_fields = field_is_valid(index_sequence, error);
894 return std::none_of(std::cbegin(valid_fields),
895 std::cend(valid_fields),
896 std::logical_not<bool>());
904 for (
size_t i = 0; i < fields_count_; i++)
906 content.builder.buffer_nbytes(names_nbytes);
916 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
917 for (
size_t i = 0; i < fields_count_; i++)
919 content.builder.to_buffers(buffers);
929 for (
size_t i = 0; i < fields_count_; i++)
931 content.builder.to_char_buffers(buffers);
939 std::stringstream form_key;
940 form_key <<
"node" << id_;
941 std::string params(
"");
942 if (parameters_ ==
"") {
944 params = std::string(
"\"parameters\": { " + parameters_ +
" }, ");
946 std::stringstream out;
947 out <<
"{ \"class\": \"RecordArray\", \"contents\": { ";
948 for (
size_t i = 0; i < fields_count_; i++) {
952 auto contents_form = [&](
auto& content) {
954 << (!content_names_.empty() ? content_names_.at(content.index)
955 : content.index_as_field())
957 out << content.builder.form();
962 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
972 template <std::size_t... S>
974 map_fields(std::index_sequence<S...>)
noexcept {
975 field_names_ = std::vector<std::string>(
976 {std::string(std::get<S>(
contents).index_as_field())...});
981 template <std::size_t... S>
983 field_lengths(std::index_sequence<S...>)
const noexcept {
984 return std::vector<size_t>({std::get<S>(
contents).builder.length()...});
988 template <std::size_t... S>
990 field_is_valid(std::index_sequence<S...>, std::string& error)
const
992 return std::vector<bool>(
993 {std::get<S>(
contents).builder.is_valid(error)...});
997 std::vector<std::string> field_names_;
1003 std::string parameters_;
1009 static constexpr size_t fields_count_ =
sizeof...(BUILDERS);
1018 template <
typename... BUILDERS>
1020 using TupleContents =
typename std::tuple<BUILDERS...>;
1022 template <std::
size_t INDEX>
1023 using TupleContentType = std::tuple_element_t<INDEX, TupleContents>;
1033 template <std::
size_t INDEX>
1034 TupleContentType<INDEX>&
1048 parameters_ = parameter;
1056 for (
size_t i = 0; i < fields_count_; i++) {
1068 for (
size_t i = 0; i < fields_count_; i++)
1083 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
1086 std::vector<size_t> lengths = content_lengths(index_sequence);
1087 for (
size_t i = 0; i < lengths.size(); i++) {
1089 length = (int64_t)lengths[i];
1091 else if (
length != (int64_t)lengths[i]) {
1092 std::stringstream out;
1093 out <<
"Record node" << id_ <<
" has index \"" << i <<
"\" length "
1094 << lengths[i] <<
" that differs from the first length "
1096 error.append(out.str());
1102 std::vector<bool> valid_fields =
1103 content_is_valid(index_sequence, error);
1104 return std::none_of(std::cbegin(valid_fields),
1105 std::cend(valid_fields),
1106 std::logical_not<bool>());
1114 for (
size_t i = 0; i < fields_count_; i++)
1116 content.buffer_nbytes(names_nbytes);
1126 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1127 for (
size_t i = 0; i < fields_count_; i++)
1129 content.to_buffers(buffers);
1139 for (
size_t i = 0; i < fields_count_; i++)
1141 content.to_char_buffers(buffers);
1149 std::stringstream form_key;
1150 form_key <<
"node" << id_;
1151 std::string params(
"");
1152 if (parameters_ ==
"") {
1154 params = std::string(
"\"parameters\": { " + parameters_ +
" }, ");
1156 std::stringstream out;
1157 out <<
"{ \"class\": \"RecordArray\", \"contents\": [";
1158 for (
size_t i = 0; i < fields_count_; i++) {
1162 auto contents_form = [&out](
auto& content) {
1163 out << content.form();
1168 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
1178 template <std::size_t... S>
1180 content_lengths(std::index_sequence<S...>)
const noexcept {
1181 return std::vector<size_t>({std::get<S>(
contents).length()...});
1185 template <std::size_t... S>
1187 content_is_valid(std::index_sequence<S...>, std::string& error)
const
1189 return std::vector<bool>({std::get<S>(
contents).is_valid(error)...});
1193 std::vector<int64_t> field_index_;
1196 std::string parameters_;
1202 static constexpr size_t fields_count_ =
sizeof...(BUILDERS);
1218 template <
unsigned SIZE,
typename BUILDER>
1255 parameters_ = parameter;
1263 content_.set_id(
id);
1282 if (content_.length() != length_ * size_) {
1283 std::stringstream out;
1284 out <<
"Regular node" << id_ <<
"has content length "
1285 << content_.length() <<
", but length " << length_ <<
" and size "
1287 error.append(out.str());
1291 return content_.is_valid(error);
1300 content_.buffer_nbytes(names_nbytes);
1309 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1310 content_.to_buffers(buffers);
1319 content_.to_char_buffers(buffers);
1326 std::stringstream form_key;
1327 form_key <<
"node" << id_;
1328 std::string params(
"");
1329 if (parameters_ ==
"") {
1331 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1333 return "{ \"class\": \"RegularArray\", \"content\": " +
1334 content_.form() +
", \"size\": " + std::to_string(size_) +
1335 params +
", \"form_key\": \"" + form_key.str() +
"\" }";
1343 std::string parameters_;
1352 size_t size_ = SIZE;
1365 template <
typename PRIMITIVE,
typename BUILDER>
1400 last_valid_ = content_.length();
1401 index_.append(last_valid_);
1411 size_t start = content_.length();
1412 size_t stop = start + size;
1413 last_valid_ = stop - 1;
1414 for (
size_t i = start; i < stop; i++) {
1429 parameters_ = parameter;
1437 content_.set_id(
id);
1452 return index_.length();
1458 if (content_.length() != index_.length()) {
1459 std::stringstream out;
1460 out <<
"Indexed node" << id_ <<
" has content length "
1461 << content_.length() <<
" but index length " << index_.length()
1463 error.append(out.str());
1466 }
else if (content_.length() != last_valid_ + 1) {
1467 std::stringstream out;
1468 out <<
"Indexed node" << id_ <<
" has content length "
1469 << content_.length() <<
" but last valid index is " << last_valid_
1471 error.append(out.str());
1475 return content_.is_valid(error);
1484 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
1485 content_.buffer_nbytes(names_nbytes);
1494 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1495 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1496 buffers[
"node" + std::to_string(id_) +
"-index"]));
1497 content_.to_buffers(buffers);
1506 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1507 buffers[
"node" + std::to_string(id_) +
"-index"]));
1508 content_.to_char_buffers(buffers);
1515 std::stringstream form_key;
1516 form_key <<
"node" << id_;
1517 std::string params(
"");
1518 if (parameters_ ==
"") {
1520 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1522 return "{ \"class\": \"IndexedArray\", \"index\": \"" +
1523 type_to_numpy_like<PRIMITIVE>() +
1524 "\", \"content\": " + content_.form() + params +
1525 ", \"form_key\": \"" + form_key.str() +
"\" }";
1538 std::string parameters_;
1557 template <
typename PRIMITIVE,
typename BUILDER>
1592 last_valid_ = content_.length();
1593 index_.append(last_valid_);
1603 size_t start = content_.length();
1604 size_t stop = start + size;
1605 last_valid_ = stop - 1;
1606 for (
size_t i = start; i < stop; i++) {
1623 for (
size_t i = 0; i < size; i++) {
1637 parameters_ = parameter;
1645 content_.set_id(
id);
1660 return index_.length();
1666 if (content_.length() != last_valid_ + 1) {
1667 std::stringstream out;
1668 out <<
"IndexedOption node" << id_ <<
" has content length "
1669 << content_.length() <<
" but last valid index is " << last_valid_
1671 error.append(out.str());
1675 return content_.is_valid(error);
1684 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
1685 content_.buffer_nbytes(names_nbytes);
1694 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1695 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1696 buffers[
"node" + std::to_string(id_) +
"-index"]));
1697 content_.to_buffers(buffers);
1706 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1707 buffers[
"node" + std::to_string(id_) +
"-index"]));
1708 content_.to_char_buffers(buffers);
1715 std::stringstream form_key;
1716 form_key <<
"node" << id_;
1717 std::string params(
"");
1718 if (parameters_ ==
"") {
1720 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1722 return "{ \"class\": \"IndexedOptionArray\", \"index\": \"" +
1723 type_to_numpy_like<PRIMITIVE>() +
1724 "\", \"content\": " + content_.form() + params +
1725 ", \"form_key\": \"" + form_key.str() +
"\" }";
1738 std::string parameters_;
1758 template <
typename BUILDER>
1799 parameters_ = parameter;
1807 content_.set_id(
id);
1819 return content_.length();
1825 return content_.is_valid(error);
1833 content_.buffer_nbytes(names_nbytes);
1842 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1843 content_.to_buffers(buffers);
1852 content_.to_char_buffers(buffers);
1859 std::stringstream form_key;
1860 form_key <<
"node" << id_;
1861 std::string params(
"");
1862 if (parameters_ ==
"") {
1864 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1866 return "{ \"class\": \"UnmaskedArray\", \"content\": " +
1867 content_.form() + params +
", \"form_key\": \"" +
1868 form_key.str() +
"\" }";
1876 std::string parameters_;
1898 template <
bool VALID_WHEN,
typename BUILDER>
1937 mask_.
append(valid_when_);
1948 for (
size_t i = 0; i < size; i++) {
1949 mask_.
append(valid_when_);
1959 mask_.
append(!valid_when_);
1970 for (
size_t i = 0; i < size; i++) {
1971 mask_.
append(!valid_when_);
1985 parameters_ = parameter;
1993 content_.set_id(
id);
2013 if (content_.length() != mask_.
length()) {
2014 std::stringstream out;
2015 out <<
"ByteMasked node" << id_ <<
"has content length "
2016 << content_.length() <<
"but mask length " << mask_.
length()
2018 error.append(out.str());
2022 return content_.is_valid(error);
2031 names_nbytes[
"node" + std::to_string(id_) +
"-mask"] = mask_.
nbytes();
2032 content_.buffer_nbytes(names_nbytes);
2041 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
2043 buffers[
"node" + std::to_string(id_) +
"-mask"]));
2044 content_.to_buffers(buffers);
2054 buffers[
"node" + std::to_string(id_) +
"-mask"]));
2055 content_.to_char_buffers(buffers);
2062 std::stringstream form_key, form_valid_when;
2063 form_key <<
"node" << id_;
2064 form_valid_when << std::boolalpha << valid_when_;
2065 std::string params(
"");
2066 if (parameters_ ==
"") {
2068 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
2070 return "{ \"class\": \"ByteMaskedArray\", \"mask\": \"i8\", "
2072 content_.form() +
", \"valid_when\": " + form_valid_when.str() +
2073 params +
", \"form_key\": \"" + form_key.str() +
"\" }";
2086 std::string parameters_;
2092 bool valid_when_ = VALID_WHEN;
2111 template <
bool VALID_WHEN,
bool LSB_ORDER,
typename BUILDER>
2118 current_byte_(uint8_t(0)),
2119 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
2124 for (
size_t i = 0; i < 8; i++) {
2128 for (
size_t i = 0; i < 8; i++) {
2129 cast_[i] = 128 >> i;
2141 current_byte_(uint8_t(0)),
2142 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
2147 for (
size_t i = 0; i < 8; i++) {
2151 for (
size_t i = 0; i < 8; i++) {
2152 cast_[i] = 128 >> i;
2183 current_byte_ |= cast_[current_index_];
2196 for (
size_t i = 0; i < size; i++) {
2219 for (
size_t i = 0; i < size; i++) {
2234 parameters_ = parameter;
2242 content_.set_id(
id);
2259 return mask_.
length() > 0 ?
2260 (mask_.
length() - 1) * 8 + current_index_ : current_index_;
2266 if (content_.length() !=
length()) {
2267 std::stringstream out;
2268 out <<
"BitMasked node" << id_ <<
"has content length "
2269 << content_.length() <<
"but bit mask length " << mask_.
length()
2271 error.append(out.str());
2275 return content_.is_valid(error);
2284 names_nbytes[
"node" + std::to_string(id_) +
"-mask"] = mask_.
nbytes();
2285 content_.buffer_nbytes(names_nbytes);
2294 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
2296 buffers[
"node" + std::to_string(id_) +
"-mask"]), 0, 1);
2297 mask_.
append(
reinterpret_cast<uint8_t*
>(
2298 buffers[
"node" + std::to_string(id_) +
"-mask"]), mask_.
length() - 1, 0, 1);
2299 content_.to_buffers(buffers);
2309 buffers[
"node" + std::to_string(id_) +
"-mask"]), 0, 1);
2310 mask_.
append(
reinterpret_cast<uint8_t*
>(
2311 buffers[
"node" + std::to_string(id_) +
"-mask"]), mask_.
length() - 1, 0, 1);
2312 content_.to_char_buffers(buffers);
2319 std::stringstream form_key, form_valid_when, form_lsb_order;
2320 form_key <<
"node" << id_;
2321 form_valid_when << std::boolalpha << valid_when_;
2322 form_lsb_order << std::boolalpha << lsb_order_;
2323 std::string params(
"");
2324 if (parameters_ ==
"") {
2326 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
2328 return "{ \"class\": \"BitMaskedArray\", \"mask\": \"u8\", "
2330 content_.form() +
", \"valid_when\": " + form_valid_when.str() +
2331 ", \"lsb_order\": " + form_lsb_order.str() + params +
2332 ", \"form_key\": \"" + form_key.str() +
"\" }";
2341 if (current_index_ == 8) {
2343 current_byte_ = uint8_t(0);
2355 current_index_ += 1;
2357 current_byte_ref_ = current_byte_;
2359 current_byte_ref_ = ~current_byte_;
2366 GrowableBuffer<uint8_t> mask_;
2372 std::string parameters_;
2378 uint8_t current_byte_;
2381 uint8_t& current_byte_ref_;
2384 size_t current_index_;
2390 bool valid_when_ = VALID_WHEN;
2394 bool lsb_order_ = LSB_ORDER;
2412 template <
typename TAGS,
typename INDEX,
typename... BUILDERS>
2417 template <std::
size_t I>
2427 for (
size_t i = 0; i < contents_count_; i++)
2428 last_valid_index_[i] = -1;
2441 for (
size_t i = 0; i < contents_count_; i++)
2442 last_valid_index_[i] = -1;
2445 template <std::
size_t I>
2448 return std::get<I>(contents_);
2453 template <std::
size_t TAG>
2456 auto& which_content = std::get<TAG>(contents_);
2457 INDEX next_index = which_content.length();
2459 TAGS tag = (TAGS)TAG;
2460 last_valid_index_[tag] = next_index;
2462 index_.
append(next_index);
2464 return which_content;
2476 parameters_ = parameter;
2484 auto contents_id = [&id](
auto&
content) {
2487 for (
size_t i = 0; i < contents_count_; i++)
2488 visit_at(contents_, i, contents_id);
2497 for (
size_t i = 0; i < contents_count_; i++)
2498 last_valid_index_[i] = -1;
2501 auto clear_contents = [](
auto&
content) {
2504 for (
size_t i = 0; i < contents_count_; i++)
2505 visit_at(contents_, i, clear_contents);
2517 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2519 std::vector<size_t> lengths = content_lengths(index_sequence);
2520 for (
size_t tag = 0; tag < contents_count_; tag++) {
2521 if (lengths[tag] != last_valid_index_[tag] + 1) {
2522 std::stringstream out;
2523 out <<
"Union node" << id_ <<
" has content length " << lengths[tag]
2524 <<
" but index length " << last_valid_index_[tag] <<
"\n";
2525 error.append(out.str());
2531 std::vector<bool> valid_contents =
2532 content_is_valid(index_sequence, error);
2533 return std::none_of(std::cbegin(valid_contents),
2534 std::cend(valid_contents),
2535 std::logical_not<bool>());
2543 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2545 names_nbytes[
"node" + std::to_string(id_) +
"-tags"] = tags_.
nbytes();
2546 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.
nbytes();
2548 for (
size_t i = 0; i < contents_count_; i++)
2550 content.buffer_nbytes(names_nbytes);
2560 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
2561 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2564 buffers[
"node" + std::to_string(id_) +
"-tags"]));
2566 buffers[
"node" + std::to_string(id_) +
"-index"]));
2568 for (
size_t i = 0; i < contents_count_; i++)
2580 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2583 buffers[
"node" + std::to_string(id_) +
"-tags"]));
2585 buffers[
"node" + std::to_string(id_) +
"-index"]));
2587 for (
size_t i = 0; i < contents_count_; i++)
2589 content.to_char_buffers(buffers);
2597 std::stringstream form_key;
2598 form_key <<
"node" << id_;
2599 std::string params(
"");
2600 if (parameters_ ==
"") {
2602 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
2604 std::stringstream out;
2605 out <<
"{ \"class\": \"UnionArray\", \"tags\": \"" +
2606 type_to_numpy_like<TAGS>() +
"\", \"index\": \"" +
2607 type_to_numpy_like<INDEX>() +
"\", \"contents\": [";
2608 for (
size_t i = 0; i < contents_count_; i++) {
2612 auto contents_form = [&](
auto&
content) {
2615 visit_at(contents_, i, contents_form);
2618 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
2625 template <std::size_t... S>
2627 content_lengths(std::index_sequence<S...>)
const {
2628 return std::vector<size_t>({std::get<S>(contents_).length()...});
2632 template <std::size_t... S>
2634 content_is_valid(std::index_sequence<S...>, std::string& error)
const {
2635 return std::vector<bool>({std::get<S>(contents_).is_valid(error)...});
2641 GrowableBuffer<TAGS> tags_;
2646 GrowableBuffer<INDEX> index_;
2652 std::string parameters_;
2658 size_t last_valid_index_[
sizeof...(BUILDERS)];
2661 static constexpr size_t contents_count_ =
sizeof...(BUILDERS);
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:2112
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition LayoutBuilder.h:2165
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:2248
bool lsb_order() const noexcept
Determines whether the position of each bit is in Least-Significant Bit order (LSB) or not.
Definition LayoutBuilder.h:2172
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:2195
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:2318
BUILDER & extend_null(size_t size) noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:2218
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:2227
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:2233
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:2159
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:2258
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:2307
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:2239
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2265
BitMasked(const awkward::BuilderOptions &options)
Creates a new BitMasked layout builder by allocating a new mask buffer, taking options from BuilderOp...
Definition LayoutBuilder.h:2139
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:2181
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:2282
BitMasked()
Creates a new BitMasked layout builder by allocating a new mask buffer, using default_options for ini...
Definition LayoutBuilder.h:2116
BUILDER & append_null() noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:2206
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:2294
Builds a ByteMaskedArray using a mask which is an array of booleans that determines whether the corre...
Definition LayoutBuilder.h:1899
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition LayoutBuilder.h:1928
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:1999
BUILDER & extend_valid(size_t size) noexcept
Inserts size number of valid_when in the mask.
Definition LayoutBuilder.h:1947
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:2061
BUILDER & extend_null(size_t size) noexcept
Inserts size number of !valid_when in the mask.
Definition LayoutBuilder.h:1969
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1978
ByteMasked()
Creates a new ByteMasked layout builder by allocating a new mask buffer, using default_options for in...
Definition LayoutBuilder.h:1903
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1984
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1922
ByteMasked(const awkward::BuilderOptions &options)
Creates a new ByteMasked layout builder by allocating a new mask buffer, taking options from BuilderO...
Definition LayoutBuilder.h:1914
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:2006
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:2052
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1990
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2012
BUILDER & append_valid() noexcept
Inserts valid_when in the mask.
Definition LayoutBuilder.h:1936
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:2029
BUILDER & append_null() noexcept
Inserts !valid_when in the mask.
Definition LayoutBuilder.h:1958
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:2041
Builds an Empty RecordArray which has has zero contents. It still represents a non-empty array....
Definition LayoutBuilder.h:649
void clear() noexcept
Clears the builder contents, the length returns to zero.
Definition LayoutBuilder.h:692
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:704
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:725
void to_buffers(std::map< std::string, void * > &) const noexcept
Definition LayoutBuilder.h:713
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:673
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:679
void append() noexcept
Inserts an empty record.
Definition LayoutBuilder.h:659
size_t length() const noexcept
Current number of records.
Definition LayoutBuilder.h:698
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:720
void buffer_nbytes(std::map< std::string, size_t > &) const noexcept
Definition LayoutBuilder.h:709
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:685
void extend(size_t size) noexcept
Inserts size number of empty records.
Definition LayoutBuilder.h:667
EmptyRecord()
Creates a new EmptyRecord layout builder.
Definition LayoutBuilder.h:652
Builds an EmptyArray which has no content in it. It is used whenever an array's type is not known bec...
Definition LayoutBuilder.h:568
void clear() noexcept
Definition LayoutBuilder.h:592
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:602
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:623
void to_buffers(std::map< std::string, void * > &) const noexcept
Definition LayoutBuilder.h:611
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:578
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:584
Empty()
Creates a new Empty layout builder.
Definition LayoutBuilder.h:571
void set_id(size_t &) noexcept
Definition LayoutBuilder.h:589
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:596
void buffer_nbytes(std::map< std::string, size_t > &) const noexcept
Definition LayoutBuilder.h:607
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:618
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:1558
void clear() noexcept
Discards the accumulated index and clears the content of the builder. Also, last valid returns to -1.
Definition LayoutBuilder.h:1651
void extend_null(size_t size) noexcept
Inserts -1 in the index buffer size number of times.
Definition LayoutBuilder.h:1622
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:1714
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1630
BUILDER & append_index() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1591
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1636
IndexedOption(const awkward::BuilderOptions &options)
Creates a new IndexedOption layout builder by allocating a new index buffer, taking options from Buil...
Definition LayoutBuilder.h:1575
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1584
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:1602
size_t length() const noexcept
Current length of the index buffer.
Definition LayoutBuilder.h:1659
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:1705
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1642
void append_null() noexcept
Inserts -1 in the index buffer.
Definition LayoutBuilder.h:1614
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1665
IndexedOption()
Creates a new IndexedOption layout builder by allocating a new index buffer, using default_options fo...
Definition LayoutBuilder.h:1562
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:1682
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:1694
Builds an IndexedArray which consists of an index buffer. It is a general-purpose tool for changing t...
Definition LayoutBuilder.h:1366
void clear() noexcept
Discards the accumulated index and clears the content of the builder. Also, last valid returns to -1.
Definition LayoutBuilder.h:1443
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:1514
Indexed(const awkward::BuilderOptions &options)
Creates a new Indexed layout builder by allocating a new index buffer, taking options from BuilderOpt...
Definition LayoutBuilder.h:1383
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1422
Indexed()
Creates a new Indexed layout builder by allocating a new index buffer, using default_options for init...
Definition LayoutBuilder.h:1370
BUILDER & append_index() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1399
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1428
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1392
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:1410
size_t length() const noexcept
Current length of the content and the index buffer.
Definition LayoutBuilder.h:1451
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:1505
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1434
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1457
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:1482
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:1494
Builds a ListOffsetArray which describes unequal-length lists (often called a "jagged" or "ragged" ar...
Definition LayoutBuilder.h:210
void clear() noexcept
Discards the accumulated offsets and clears the builder content.
Definition LayoutBuilder.h:275
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the builder content.
Definition LayoutBuilder.h:242
ListOffset()
Creates a new ListOffset layout builder by allocating a new offset buffer, using default_options for ...
Definition LayoutBuilder.h:214
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:339
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:255
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:261
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:236
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:283
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:330
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:267
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:289
void end_list() noexcept
Ends a list and appends the current length of the list contents in the offsets buffer.
Definition LayoutBuilder.h:249
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:306
ListOffset(const awkward::BuilderOptions &options)
Creates a new ListOffset layout builder by allocating a new offset buffer, taking options from Builde...
Definition LayoutBuilder.h:227
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:319
Builds a ListArray which generalizes ListOffsetArray. Instead of a single offsets array,...
Definition LayoutBuilder.h:382
void clear() noexcept
Discards the accumulated starts and stops, and clears the builder content.
Definition LayoutBuilder.h:452
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:417
List()
Creates a new List layout builder by allocating new starts and stops buffer, using default_options fo...
Definition LayoutBuilder.h:386
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:528
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:431
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:437
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:409
size_t length() const noexcept
Current length of the content and starts buffer.
Definition LayoutBuilder.h:460
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:517
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:443
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:466
void end_list() noexcept
Ends a list and appends the current length of the list contents in the stops buffer.
Definition LayoutBuilder.h:425
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:490
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:400
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:504
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:151
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 default_options for initializing...
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_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:159
Builds a RecordArray which represents an array of records, which can be of same or different types....
Definition LayoutBuilder.h:771
void clear() noexcept
Clears the builder contents.
Definition LayoutBuilder.h:858
Record()
Creates a new Record layout builder.
Definition LayoutBuilder.h:780
MAP UserDefinedMap
Definition LayoutBuilder.h:774
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:938
std::tuple_element_t< INDEX, RecordContents > RecordFieldType
Definition LayoutBuilder.h:777
const std::vector< std::string > field_names() const noexcept
Returns a vector of strings sontaining all the field names.
Definition LayoutBuilder.h:801
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:792
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:831
typename std::tuple< BUILDERS... > RecordContents
Definition LayoutBuilder.h:773
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:837
void set_field_names(MAP user_defined_field_id_to_name_map) noexcept
Sets the field names.
Definition LayoutBuilder.h:818
size_t length() const noexcept
Current number of records in first field.
Definition LayoutBuilder.h:867
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:928
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:843
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:873
RecordFieldType< INDEX >::Builder & field() noexcept
Returns the reference to the builder contents at INDEX.
Definition LayoutBuilder.h:825
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:902
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:916
RecordContents contents
The contents of the RecordArray.
Definition LayoutBuilder.h:967
Builds a RegularArray that describes lists that have the same length, a single integer size....
Definition LayoutBuilder.h:1219
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:1268
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the content of the builder.
Definition LayoutBuilder.h:1236
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:1325
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1248
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1254
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1229
size_t length() const noexcept
Current number of lists of length SIZE.
Definition LayoutBuilder.h:1275
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:1318
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1260
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1281
void end_list() noexcept
Ends a list and increments the number of lists.
Definition LayoutBuilder.h:1242
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:1298
Regular()
Creates a new Regular layout builder.
Definition LayoutBuilder.h:1222
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:1309
Builds a RecordArray which represents an array of tuples which can be of same or different types with...
Definition LayoutBuilder.h:1019
void clear() noexcept
Clears the builder contents.
Definition LayoutBuilder.h:1067
TupleContents contents
The contents of the RecordArray without fields.
Definition LayoutBuilder.h:1173
TupleContentType< INDEX > & index() noexcept
Returns the reference to the builder contents at INDEX.
Definition LayoutBuilder.h:1035
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:1148
Tuple()
Creates a new Tuple layout builder.
Definition LayoutBuilder.h:1027
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1041
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1047
size_t length() const noexcept
Current number of records in the first index of the tuple.
Definition LayoutBuilder.h:1076
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:1138
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1053
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1082
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:1112
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:1126
Builds a UnionArray which represents data drawn from an ordered list of contents, which can have diff...
Definition LayoutBuilder.h:2413
void clear() noexcept
Discards the accumulated tags and index, and clears the builder contents.
Definition LayoutBuilder.h:2496
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:2436
typename std::tuple< BUILDERS... > Contents
Definition LayoutBuilder.h:2415
std::tuple_element_t< I, Contents > ContentType
Definition LayoutBuilder.h:2418
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:2596
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:2469
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:2475
size_t length() const noexcept
Current length of the tags buffer.
Definition LayoutBuilder.h:2510
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:2579
Union()
Creates a new Union layout builder by allocating new tags and index buffers, using default_options fo...
Definition LayoutBuilder.h:2422
ContentType< I > & content() noexcept
Definition LayoutBuilder.h:2447
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:2481
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2516
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:2541
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:2455
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:2560
Builds an UnmaskedArray which the values are never, in fact, missing. It exists to satisfy systems th...
Definition LayoutBuilder.h:1759
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:1812
Unmasked()
Creates a new Unmasked layout builder.
Definition LayoutBuilder.h:1762
BUILDER & extend_valid(size_t size) noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1786
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:1858
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1792
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1798
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1769
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:1818
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:1851
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1804
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1824
BUILDER & append_valid() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1777
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:1831
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:1842
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:262
Container for all configuration options needed by ArrayBuilder, GrowableBuffer, LayoutBuilder and the...
Definition BuilderOptions.h:20
std::map< std::size_t, std::string > UserDefinedMap
Definition test_1494-layout-builder.cpp:39