3#ifndef AWKWARD_LAYOUTBUILDER_H_
4#define AWKWARD_LAYOUTBUILDER_H_
18#define AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS awkward::BuilderOptions(1024, 1)
31 template <
class CONTENT>
33 content.builder.set_id(id_);
47 template <std::
size_t ENUM,
typename BUILDER>
55 return std::to_string(
index);
70 template <
typename PRIMITIVE>
103 extend(PRIMITIVE* ptr,
size_t size)
noexcept {
104 data_.extend(ptr, size);
116 parameters_ = parameter;
135 return data_.length();
148 names_nbytes[
"node" + std::to_string(id_) +
"-data"] = data_.nbytes();
157 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
158 data_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
159 buffers[
"node" + std::to_string(id_) +
"-data"]));
166 to_buffer(
void* buffer,
const char* name)
const noexcept {
167 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-data")) {
168 data_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
178 data_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
179 buffers[
"node" + std::to_string(id_) +
"-data"]));
186 std::stringstream form_key;
187 form_key <<
"node" << id_;
189 std::string params(
"");
190 if (parameters_ ==
"") {
192 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
195 if (std::is_arithmetic<PRIMITIVE>::value) {
196 return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
198 ", \"form_key\": \"" + form_key.str() +
"\" }";
200 return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
202 ", \"form_key\": \"" + form_key.str() +
"\" }";
204 throw std::runtime_error(
"type " +
205 std::string(
typeid(PRIMITIVE).name()) +
215 std::string parameters_;
235 template <
typename PRIMITIVE,
typename BUILDER>
276 offsets_.append(content_.length());
288 parameters_ = parameter;
310 return offsets_.length() - 1;
316 if ((int64_t)content_.length() != (int64_t)offsets_.last()) {
317 std::stringstream out;
318 out <<
"ListOffset node" << id_ <<
"has content length "
319 << content_.length() <<
"but last offset " << offsets_.last()
321 error.append(out.str());
325 return content_.is_valid(error);
334 names_nbytes[
"node" + std::to_string(id_) +
"-offsets"] =
336 content_.buffer_nbytes(names_nbytes);
345 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
346 offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
347 buffers[
"node" + std::to_string(id_) +
"-offsets"]));
348 content_.to_buffers(buffers);
356 to_buffer(
void* buffer,
const char* name)
const noexcept {
357 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-offsets")) {
358 offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
360 content_.to_buffer(buffer, name);
369 offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
370 buffers[
"node" + std::to_string(id_) +
"-offsets"]));
371 content_.to_char_buffers(buffers);
378 std::stringstream form_key;
379 form_key <<
"node" << id_;
380 std::string params(
"");
381 if (parameters_ ==
"") {
383 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
385 return "{ \"class\": \"ListOffsetArray\", \"offsets\": \"" +
387 "\", \"content\": " + content_.form() + params +
388 ", \"form_key\": \"" + form_key.str() +
"\" }";
401 std::string parameters_;
411 template<
class PRIMITIVE>
421 for (
const auto& c: value) {
479 return "{ \"class\": \"EmptyArray\" }";
493 template <
class MAP = std::map<std::
size_t, std::
string>,
494 typename... BUILDERS>
500 template <std::
size_t INDEX>
507 map_fields(std::index_sequence_for<BUILDERS...>());
517 : content_names_(user_defined_field_id_to_name_map) {
518 assert(content_names_.size() == fields_count_);
524 const std::vector<std::string>
526 if (content_names_.empty()) {
529 std::vector<std::string> result;
530 for (
auto it : content_names_) {
531 result.emplace_back(it.second);
543 content_names_ = user_defined_field_id_to_name_map;
547 template <std::
size_t INDEX>
548 typename RecordFieldType<INDEX>::Builder&
550 return std::get<INDEX>(
contents).builder;
562 parameters_ = parameter;
572 for (
size_t i = 0; i < fields_count_; i++) {
584 template <
class CONTENT>
592 ClearBuilder clearBuilder;
593 for (
size_t i = 0; i < fields_count_; i++) {
600 return (std::get<0>(
contents).builder.length());
606 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
609 std::vector<size_t> lengths = field_lengths(index_sequence);
610 for (
size_t i = 0; i < lengths.size(); i++) {
614 else if (
length != (int64_t)lengths[i]) {
615 std::stringstream out;
616 out <<
"Record node" << id_ <<
" has field \""
617 <<
fields().at(i) <<
"\" length " << lengths[i]
618 <<
" that differs from the first length " <<
length <<
"\n";
619 error.append(out.str());
625 std::vector<bool> valid_fields = field_is_valid(index_sequence, error);
626 return std::none_of(std::cbegin(valid_fields),
627 std::cend(valid_fields),
628 std::logical_not<bool>());
635 for (
size_t i = 0; i < fields_count_; i++) {
637 content.builder.buffer_nbytes(names_nbytes);
648 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
649 for (
size_t i = 0; i < fields_count_; i++) {
651 content.builder.to_buffers(buffers);
659 to_buffer(
void* buffer,
const char* name)
const noexcept {
660 for (
size_t i = 0; i < fields_count_; i++) {
662 content.builder.to_buffer(buffer, name);
674 for (
size_t i = 0; i < fields_count_; i++) {
676 content.builder.to_char_buffers(buffers);
688 : out_(out), content_names_(content_names) {}
691 template <
class CONTENT>
694 auto it = content_names_.find(index);
696 if (it != content_names_.end()) {
697 out_ <<
"\"" << it->second <<
"\": ";
699 out_ <<
"\"" << index <<
"\": ";
702 out_ <<
content.builder.form();
706 std::stringstream& out_;
707 const std::map<size_t, std::string>& content_names_;
711 std::string
form() const noexcept {
712 std::stringstream form_key;
713 form_key <<
"node" << id_;
715 std::string params(
"");
716 if (!parameters_.empty()) {
717 params =
"\"parameters\": { " + parameters_ +
" }, ";
720 std::stringstream out;
721 out <<
"{ \"class\": \"RecordArray\", \"contents\": { ";
723 for (
size_t i = 0; i < fields_count_; i++) {
727 ContentsFormFunctor contentsFormFunctor(out, content_names_);
732 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
742 template <std::size_t... S>
744 map_fields(std::index_sequence<S...>)
noexcept {
745 fields_ = std::vector<std::string>(
746 {std::string(std::get<S>(
contents).index_as_field())...});
751 template <std::size_t... S>
753 field_lengths(std::index_sequence<S...>)
const noexcept {
754 return std::vector<size_t>({std::get<S>(
contents).builder.length()...});
758 template <std::size_t... S>
760 field_is_valid(std::index_sequence<S...>, std::string& error)
const
762 return std::vector<bool>(
763 {std::get<S>(
contents).builder.is_valid(error)...});
767 std::vector<std::string> fields_;
773 std::string parameters_;
779 static constexpr size_t fields_count_ =
sizeof...(BUILDERS);
788 template <
typename... BUILDERS>
790 using TupleContents =
typename std::tuple<BUILDERS...>;
792 template <std::
size_t INDEX>
793 using TupleContentType = std::tuple_element_t<INDEX, TupleContents>;
803 template <std::
size_t INDEX>
804 TupleContentType<INDEX>&
818 parameters_ = parameter;
826 for (
size_t i = 0; i < fields_count_; i++) {
839 for (
size_t i = 0; i < fields_count_; i++) {
855 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
858 std::vector<size_t> lengths = content_lengths(index_sequence);
859 for (
size_t i = 0; i < lengths.size(); i++) {
861 length = (int64_t)lengths[i];
863 else if (
length != (int64_t)lengths[i]) {
864 std::stringstream out;
865 out <<
"Record node" << id_ <<
" has index \"" << i <<
"\" length "
866 << lengths[i] <<
" that differs from the first length "
868 error.append(out.str());
874 std::vector<bool> valid_fields =
875 content_is_valid(index_sequence, error);
876 return std::none_of(std::cbegin(valid_fields),
877 std::cend(valid_fields),
878 std::logical_not<bool>());
885 for (
size_t i = 0; i < fields_count_; i++) {
887 content.buffer_nbytes(names_nbytes);
899 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
900 for (
size_t i = 0; i < fields_count_; i++) {
912 to_buffer(
void* buffer,
const char* name)
const noexcept {
913 for (
size_t i = 0; i < fields_count_; i++) {
915 content.to_buffer(buffer, name);
927 for (
size_t i = 0; i < fields_count_; i++) {
929 content.to_char_buffers(buffers);
942 template <
class CONTENT>
948 std::stringstream& out_;
954 std::stringstream form_key;
955 form_key <<
"node" << id_;
956 std::string params(
"");
957 if (!parameters_.empty()) {
958 params =
"\"parameters\": { " + parameters_ +
" }, ";
960 std::stringstream out;
961 out <<
"{ \"class\": \"RecordArray\", \"contents\": [";
962 for (
size_t i = 0; i < fields_count_; i++) {
966 ContentsFormFunctor contentsFormFunctor(out);
970 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
980 template <std::size_t... S>
982 content_lengths(std::index_sequence<S...>)
const noexcept {
983 return std::vector<size_t>({std::get<S>(
contents).length()...});
987 template <std::size_t... S>
989 content_is_valid(std::index_sequence<S...>, std::string& error)
const
991 return std::vector<bool>({std::get<S>(
contents).is_valid(error)...});
995 std::string parameters_;
1001 static constexpr size_t fields_count_ =
sizeof...(BUILDERS);
1017 template <
unsigned SIZE,
typename BUILDER>
1054 parameters_ = parameter;
1062 content_.set_id(
id);
1081 if (content_.length() != length_ * size_) {
1082 std::stringstream out;
1083 out <<
"Regular node" << id_ <<
"has content length "
1084 << content_.length() <<
", but length " << length_ <<
" and size "
1086 error.append(out.str());
1090 return content_.is_valid(error);
1099 content_.buffer_nbytes(names_nbytes);
1108 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1109 content_.to_buffers(buffers);
1117 content_.to_buffer(buffer, name);
1126 content_.to_char_buffers(buffers);
1133 std::stringstream form_key;
1134 form_key <<
"node" << id_;
1135 std::string params(
"");
1136 if (parameters_ ==
"") {
1138 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1140 return "{ \"class\": \"RegularArray\", \"content\": " +
1141 content_.form() +
", \"size\": " + std::to_string(size_) +
1142 params +
", \"form_key\": \"" + form_key.str() +
"\" }";
1150 std::string parameters_;
1159 size_t size_ = SIZE;
1172 template <
typename PRIMITIVE,
typename BUILDER>
1215 if (i > max_index_) {
1218 max_index_ = UINTMAX_MAX;
1229 size_t start = content_.length();
1230 size_t stop = start + size;
1231 if (stop - 1 > max_index_) {
1232 max_index_ = stop - 1;
1234 for (
size_t i = start; i < stop; i++) {
1249 parameters_ = parameter;
1257 content_.set_id(
id);
1272 return index_.length();
1280 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
1281 content_.buffer_nbytes(names_nbytes);
1288 if (max_index_ == UINTMAX_MAX) {
1289 std::stringstream out;
1290 out <<
"Indexed node" << id_ <<
" has a negative index\n";
1291 error.append(out.str());
1293 }
else if ((content_.length() == 0) && (max_index_ == 0)) {
1294 }
else if (max_index_ >= content_.length()) {
1295 std::stringstream out;
1296 out <<
"Indexed node" << id_ <<
" has index " << max_index_
1297 <<
" but content has length "
1298 << content_.length() <<
"\n";
1299 error.append(out.str());
1302 return content_.is_valid(error);
1311 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1312 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1313 buffers[
"node" + std::to_string(id_) +
"-index"]));
1314 content_.to_buffers(buffers);
1323 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-index")) {
1324 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
1326 content_.to_buffer(buffer, name);
1335 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1336 buffers[
"node" + std::to_string(id_) +
"-index"]));
1337 content_.to_char_buffers(buffers);
1344 std::stringstream form_key;
1345 form_key <<
"node" << id_;
1346 std::string params(
"");
1347 if (parameters_ ==
"") {
1349 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1351 return "{ \"class\": \"IndexedArray\", \"index\": \"" +
1353 "\", \"content\": " + content_.form() + params +
1354 ", \"form_key\": \"" + form_key.str() +
"\" }";
1367 std::string parameters_;
1386 template <
typename PRIMITIVE,
typename BUILDER>
1429 if (i > max_index_) {
1441 size_t start = content_.length();
1442 size_t stop = start + size;
1443 size_t last_valid = stop - 1;
1444 if (last_valid > max_index_) {
1445 max_index_ = last_valid;
1447 for (
size_t i = start; i < stop; i++) {
1464 for (
size_t i = 0; i < size; i++) {
1478 parameters_ = parameter;
1486 content_.set_id(
id);
1500 return index_.length();
1506 if ((content_.length() == 0) && (max_index_ == 0)) {
1507 }
else if (max_index_ >= content_.length()) {
1508 std::stringstream out;
1509 out <<
"IndexedOption node" << id_ <<
" has index " << max_index_
1510 <<
" but content has length "
1511 << content_.length() <<
"\n";
1512 error.append(out.str());
1516 return content_.is_valid(error);
1524 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
1525 content_.buffer_nbytes(names_nbytes);
1534 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1535 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1536 buffers[
"node" + std::to_string(id_) +
"-index"]));
1537 content_.to_buffers(buffers);
1546 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-index")) {
1547 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
1549 content_.to_buffer(buffer, name);
1558 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1559 buffers[
"node" + std::to_string(id_) +
"-index"]));
1560 content_.to_char_buffers(buffers);
1567 std::stringstream form_key;
1568 form_key <<
"node" << id_;
1569 std::string params(
"");
1570 if (parameters_ ==
"") {
1572 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1574 return "{ \"class\": \"IndexedOptionArray\", \"index\": \"" +
1576 "\", \"content\": " + content_.form() + params +
1577 ", \"form_key\": \"" + form_key.str() +
"\" }";
1590 std::string parameters_;
1610 template <
typename BUILDER>
1634 parameters_ = parameter;
1642 content_.set_id(
id);
1654 return content_.length();
1660 return content_.is_valid(error);
1668 content_.buffer_nbytes(names_nbytes);
1677 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1678 content_.to_buffers(buffers);
1686 content_.to_buffer(buffer, name);
1695 content_.to_char_buffers(buffers);
1702 std::stringstream form_key;
1703 form_key <<
"node" << id_;
1704 std::string params(
"");
1705 if (parameters_ ==
"") {
1707 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1709 return "{ \"class\": \"UnmaskedArray\", \"content\": " +
1710 content_.form() + params +
", \"form_key\": \"" +
1711 form_key.str() +
"\" }";
1719 std::string parameters_;
1741 template <
bool VALID_WHEN,
typename BUILDER>
1780 mask_.append(valid_when_);
1791 for (
size_t i = 0; i < size; i++) {
1792 mask_.append(valid_when_);
1802 mask_.append(!valid_when_);
1813 for (
size_t i = 0; i < size; i++) {
1814 mask_.append(!valid_when_);
1828 parameters_ = parameter;
1836 content_.set_id(
id);
1850 return mask_.length();
1856 if (content_.length() != mask_.length()) {
1857 std::stringstream out;
1858 out <<
"ByteMasked node" << id_ <<
"has content length "
1859 << content_.length() <<
"but mask length " << mask_.length()
1861 error.append(out.str());
1865 return content_.is_valid(error);
1874 names_nbytes[
"node" + std::to_string(id_) +
"-mask"] = mask_.nbytes();
1875 content_.buffer_nbytes(names_nbytes);
1884 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1885 mask_.concatenate(
reinterpret_cast<int8_t*
>(
1886 buffers[
"node" + std::to_string(id_) +
"-mask"]));
1887 content_.to_buffers(buffers);
1896 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-mask")) {
1897 mask_.concatenate(
reinterpret_cast<int8_t*
>(buffer));
1899 content_.to_buffer(buffer, name);
1908 mask_.concatenate(
reinterpret_cast<int8_t*
>(
1909 buffers[
"node" + std::to_string(id_) +
"-mask"]));
1910 content_.to_char_buffers(buffers);
1917 std::stringstream form_key, form_valid_when;
1918 form_key <<
"node" << id_;
1919 form_valid_when << std::boolalpha << valid_when_;
1920 std::string params(
"");
1921 if (parameters_ ==
"") {
1923 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1925 return "{ \"class\": \"ByteMaskedArray\", \"mask\": \"i8\", "
1927 content_.form() +
", \"valid_when\": " + form_valid_when.str() +
1928 params +
", \"form_key\": \"" + form_key.str() +
"\" }";
1941 std::string parameters_;
1947 bool valid_when_ = VALID_WHEN;
1966 template <
bool VALID_WHEN,
bool LSB_ORDER,
typename BUILDER>
1973 current_byte_(uint8_t(0)),
1974 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
1979 for (
size_t i = 0; i < 8; i++) {
1983 for (
size_t i = 0; i < 8; i++) {
1984 cast_[i] = 128 >> i;
1996 current_byte_(uint8_t(0)),
1997 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
2002 for (
size_t i = 0; i < 8; i++) {
2006 for (
size_t i = 0; i < 8; i++) {
2007 cast_[i] = 128 >> i;
2038 current_byte_ |= cast_[current_index_];
2051 for (
size_t i = 0; i < size; i++) {
2074 for (
size_t i = 0; i < size; i++) {
2089 parameters_ = parameter;
2097 content_.set_id(
id);
2107 current_byte_ref_ = mask_.append_and_get_ref(current_byte_);
2114 return mask_.length() > 0 ?
2115 (mask_.length() - 1) * 8 + current_index_ : current_index_;
2121 if (content_.length() !=
length()) {
2122 std::stringstream out;
2123 out <<
"BitMasked node" << id_ <<
"has content length "
2124 << content_.length() <<
"but bit mask length " << mask_.length()
2126 error.append(out.str());
2130 return content_.is_valid(error);
2139 names_nbytes[
"node" + std::to_string(id_) +
"-mask"] = mask_.nbytes();
2140 content_.buffer_nbytes(names_nbytes);
2149 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
2150 mask_.concatenate_from(
reinterpret_cast<uint8_t*
>(
2151 buffers[
"node" + std::to_string(id_) +
"-mask"]), 0, 1);
2152 mask_.append(
reinterpret_cast<uint8_t*
>(
2153 buffers[
"node" + std::to_string(id_) +
"-mask"]), mask_.length() - 1, 0, 1);
2154 content_.to_buffers(buffers);
2163 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-mask")) {
2164 mask_.concatenate_from(
reinterpret_cast<uint8_t*
>(buffer), 0, 1);
2165 mask_.append(
reinterpret_cast<uint8_t*
>(buffer), mask_.length() - 1, 0, 1);
2167 content_.to_buffer(buffer, name);
2176 mask_.concatenate_from(
reinterpret_cast<uint8_t*
>(
2177 buffers[
"node" + std::to_string(id_) +
"-mask"]), 0, 1);
2178 mask_.append(
reinterpret_cast<uint8_t*
>(
2179 buffers[
"node" + std::to_string(id_) +
"-mask"]), mask_.length() - 1, 0, 1);
2180 content_.to_char_buffers(buffers);
2187 std::stringstream form_key, form_valid_when, form_lsb_order;
2188 form_key <<
"node" << id_;
2189 form_valid_when << std::boolalpha << valid_when_;
2190 form_lsb_order << std::boolalpha << lsb_order_;
2191 std::string params(
"");
2192 if (parameters_ ==
"") {
2194 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
2196 return "{ \"class\": \"BitMaskedArray\", \"mask\": \"u8\", "
2198 content_.form() +
", \"valid_when\": " + form_valid_when.str() +
2199 ", \"lsb_order\": " + form_lsb_order.str() + params +
2200 ", \"form_key\": \"" + form_key.str() +
"\" }";
2209 if (current_index_ == 8) {
2211 current_byte_ = uint8_t(0);
2223 current_index_ += 1;
2225 current_byte_ref_ = current_byte_;
2227 current_byte_ref_ = ~current_byte_;
2234 GrowableBuffer<uint8_t> mask_;
2240 std::string parameters_;
2246 uint8_t current_byte_;
2249 uint8_t& current_byte_ref_;
2252 size_t current_index_;
2258 bool valid_when_ = VALID_WHEN;
2262 bool lsb_order_ = LSB_ORDER;
2280 template <
typename TAGS,
typename INDEX,
typename... BUILDERS>
2285 template <std::
size_t I>
2309 template <std::
size_t I>
2312 return std::get<I>(contents_);
2317 template <std::
size_t TAG>
2320 auto& which_content = std::get<TAG>(contents_);
2321 INDEX next_index = which_content.length();
2323 TAGS tag = (TAGS)TAG;
2325 index_.append(next_index);
2327 return which_content;
2339 parameters_ = parameter;
2347 for (
size_t i = 0; i < contents_count_; i++) {
2362 for (
size_t i = 0; i < contents_count_; i++) {
2373 return tags_.length();
2379 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2381 std::vector<size_t> lengths = content_lengths(index_sequence);
2382 std::unique_ptr<INDEX[]> index_ptr(
new INDEX[index_.length()]);
2383 index_.concatenate(index_ptr.get());
2384 std::unique_ptr<TAGS[]> tags_ptr(
new TAGS[tags_.length()]);
2385 tags_.concatenate(tags_ptr.get());
2386 for (
size_t i = 0; i < index_.length(); i++) {
2387 if (index_ptr.get()[i] < 0 || index_ptr.get()[i] >= lengths[tags_ptr.get()[i]]) {
2388 std::stringstream out;
2389 out <<
"Union node" << id_ <<
" has index " << index_ptr.get()[i]
2390 <<
" at position " << i <<
" but content has length "
2391 << lengths[tags_ptr.get()[i]] <<
"\n";
2392 error.append(out.str());
2398 std::vector<bool> valid_contents =
2399 content_is_valid(index_sequence, error);
2400 return std::none_of(std::cbegin(valid_contents),
2401 std::cend(valid_contents),
2402 std::logical_not<bool>());
2410 names_nbytes[
"node" + std::to_string(id_) +
"-tags"] = tags_.nbytes();
2411 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
2413 for (
size_t i = 0; i < contents_count_; i++) {
2415 content.buffer_nbytes(names_nbytes);
2427 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
2429 tags_.concatenate(
reinterpret_cast<TAGS*
>(
2430 buffers[
"node" + std::to_string(id_) +
"-tags"]));
2431 index_.concatenate(
reinterpret_cast<INDEX*
>(
2432 buffers[
"node" + std::to_string(id_) +
"-index"]));
2434 for (
size_t i = 0; i < contents_count_; i++) {
2448 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-tags")) {
2449 tags_.concatenate(
reinterpret_cast<TAGS*
>(buffer));
2451 else if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-index")) {
2452 index_.concatenate(
reinterpret_cast<INDEX*
>(buffer));
2455 for (
size_t i = 0; i < contents_count_; i++) {
2457 content.to_buffer(buffer, name);
2470 tags_.concatenate(
reinterpret_cast<TAGS*
>(
2471 buffers[
"node" + std::to_string(id_) +
"-tags"]));
2472 index_.concatenate(
reinterpret_cast<INDEX*
>(
2473 buffers[
"node" + std::to_string(id_) +
"-index"]));
2475 for (
size_t i = 0; i < contents_count_; i++) {
2477 content.to_char_buffers(buffers);
2491 template <
class CONTENT>
2497 std::stringstream& out_;
2503 std::stringstream form_key;
2504 form_key <<
"node" << id_;
2505 std::string params(
"");
2506 if (!parameters_.empty()) {
2507 params =
", \"parameters\": { " + parameters_ +
" }";
2509 std::stringstream out;
2510 out <<
"{ \"class\": \"UnionArray\", \"tags\": \"" +
2513 for (
size_t i = 0; i < contents_count_; i++) {
2517 ContentsFormFunctor contentsFormFunctor(out);
2518 visit_at(contents_, i, contentsFormFunctor);
2521 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
2529 template <std::size_t... S>
2531 content_lengths(std::index_sequence<S...>)
const {
2532 return std::vector<size_t>({std::get<S>(contents_).length()...});
2536 template <std::size_t... S>
2538 content_is_valid(std::index_sequence<S...>, std::string& error)
const {
2539 return std::vector<bool>({std::get<S>(contents_).is_valid(error)...});
2545 GrowableBuffer<TAGS> tags_;
2550 GrowableBuffer<INDEX> index_;
2556 std::string parameters_;
2562 static constexpr size_t contents_count_ =
sizeof...(BUILDERS);
#define AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS
Object of BuilderOptions which sets the values of the default options.
Definition LayoutBuilder.h:18
Discontiguous, one-dimensional buffer (which consists of multiple contiguous, one-dimensional panels)...
Definition GrowableBuffer.h:250
PRIMITIVE & append_and_get_ref(PRIMITIVE datum)
Like append, but the type signature returns the reference to PRIMITIVE.
Definition GrowableBuffer.h:500
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition LayoutBuilder.h:2020
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:2103
bool lsb_order() const noexcept
Determines whether the position of each bit is in Least-Significant Bit order (LSB) or not.
Definition LayoutBuilder.h:2027
BUILDER & append_invalid() noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:2061
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:2050
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:2186
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:2082
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:2088
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:2014
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:2113
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:2175
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:2094
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2120
BitMasked(const awkward::BuilderOptions &options)
Creates a new BitMasked layout builder by allocating a new mask buffer, taking options from BuilderOp...
Definition LayoutBuilder.h:1994
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:2036
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:2137
BUILDER & extend_invalid(size_t size) noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:2073
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the builder buffer to a user-defined pointer if the g...
Definition LayoutBuilder.h:2162
BitMasked()
Creates a new BitMasked layout builder by allocating a new mask buffer, using AWKWARD_LAYOUTBUILDER_D...
Definition LayoutBuilder.h:1971
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:2149
Functor for setting the ids of all nodes in a layout tree.
Definition LayoutBuilder.h:27
BuilderSetId(size_t &id)
Definition LayoutBuilder.h:29
void operator()(CONTENT &content)
Definition LayoutBuilder.h:32
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition LayoutBuilder.h:1771
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:1842
BUILDER & append_invalid() noexcept
Inserts !valid_when in the mask.
Definition LayoutBuilder.h:1801
BUILDER & extend_valid(size_t size) noexcept
Inserts size number of valid_when in the mask.
Definition LayoutBuilder.h:1790
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:1916
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1821
ByteMasked()
Creates a new ByteMasked layout builder by allocating a new mask buffer, using AWKWARD_LAYOUTBUILDER_...
Definition LayoutBuilder.h:1746
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1827
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1765
ByteMasked(const awkward::BuilderOptions &options)
Creates a new ByteMasked layout builder by allocating a new mask buffer, taking options from BuilderO...
Definition LayoutBuilder.h:1757
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:1849
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:1907
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1833
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1855
BUILDER & append_valid() noexcept
Inserts valid_when in the mask.
Definition LayoutBuilder.h:1779
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:1872
BUILDER & extend_invalid(size_t size) noexcept
Inserts size number of !valid_when in the mask.
Definition LayoutBuilder.h:1812
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the builder buffer to a user-defined pointer if the g...
Definition LayoutBuilder.h:1895
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:1884
void clear() noexcept
Definition LayoutBuilder.h:444
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:454
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:478
void to_buffers(std::map< std::string, void * > &) const noexcept
Definition LayoutBuilder.h:463
void to_buffer(void *, const char *) const noexcept
Definition LayoutBuilder.h:466
Empty()
Creates a new Empty layout builder.
Definition LayoutBuilder.h:435
void set_id(size_t &) noexcept
Definition LayoutBuilder.h:441
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:448
void buffer_nbytes(std::map< std::string, size_t > &) const noexcept
Definition LayoutBuilder.h:459
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:473
Helper class for sending a pair of field names (as enum) and field type as template parameters in Rec...
Definition LayoutBuilder.h:48
std::string index_as_field() const
Converts index as field string.
Definition LayoutBuilder.h:54
BUILDER Builder
Definition LayoutBuilder.h:50
const std::size_t index
Definition LayoutBuilder.h:59
Builder builder
Definition LayoutBuilder.h:61
void clear() noexcept
Discards the accumulated index and clears the content of the builder.
Definition LayoutBuilder.h:1492
void extend_invalid(size_t size) noexcept
Inserts -1 in the index buffer size number of times.
Definition LayoutBuilder.h:1463
BUILDER & extend_valid(size_t size) noexcept
Inserts size number of valid index in the index buffer and returns the reference to the builder conte...
Definition LayoutBuilder.h:1440
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:1566
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1471
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1477
IndexedOption(const awkward::BuilderOptions &options)
Creates a new IndexedOption layout builder by allocating a new index buffer, taking options from Buil...
Definition LayoutBuilder.h:1404
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1413
BUILDER & append_valid(size_t i) noexcept
Inserts an explicit value in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1427
size_t length() const noexcept
Current length of the index buffer.
Definition LayoutBuilder.h:1499
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:1557
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1483
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1505
IndexedOption()
Creates a new IndexedOption layout builder by allocating a new index buffer, using AWKWARD_LAYOUTBUIL...
Definition LayoutBuilder.h:1391
BUILDER & append_valid() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1420
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:1522
void append_invalid() noexcept
Inserts -1 in the index buffer.
Definition LayoutBuilder.h:1455
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the builder buffer to a user-defined pointer if the g...
Definition LayoutBuilder.h:1545
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:1534
void clear() noexcept
Discards the accumulated index and clears the content of the builder.
Definition LayoutBuilder.h:1263
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:1343
Indexed(const awkward::BuilderOptions &options)
Creates a new Indexed layout builder by allocating a new index buffer, taking options from BuilderOpt...
Definition LayoutBuilder.h:1190
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1242
Indexed()
Creates a new Indexed layout builder by allocating a new index buffer, using AWKWARD_LAYOUTBUILDER_DE...
Definition LayoutBuilder.h:1177
BUILDER & append_index() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1206
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1248
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1199
BUILDER & extend_index(size_t size) noexcept
Inserts size number indices in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1228
size_t length() const noexcept
Current length of the index buffer.
Definition LayoutBuilder.h:1271
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:1334
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1254
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1286
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:1278
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the builder buffer to a user-defined pointer if the g...
Definition LayoutBuilder.h:1322
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:1311
BUILDER & append_index(size_t i) noexcept
Inserts an explicit value in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1213
void clear() noexcept
Discards the accumulated offsets and clears the builder content.
Definition LayoutBuilder.h:301
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the builder content.
Definition LayoutBuilder.h:268
ListOffset()
Creates a new ListOffset layout builder by allocating a new offset buffer, using AWKWARD_LAYOUTBUILDE...
Definition LayoutBuilder.h:240
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:377
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:281
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:287
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:262
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:309
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:368
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:293
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:315
void end_list() noexcept
Ends a list and appends the current length of the list contents in the offsets buffer.
Definition LayoutBuilder.h:275
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:332
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the builder buffer to a user-defined pointer if the g...
Definition LayoutBuilder.h:356
ListOffset(const awkward::BuilderOptions &options)
Creates a new ListOffset layout builder by allocating a new offset buffer, taking options from Builde...
Definition LayoutBuilder.h:253
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:345
Builds a NumpyArray which describes multi-dimensional data of PRIMITIVE type.
Definition LayoutBuilder.h:71
void clear() noexcept
Discards the accumulated data in the builder.
Definition LayoutBuilder.h:128
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:140
Numpy(const awkward::BuilderOptions &options)
Creates a new Numpy layout builder by allocating a new buffer, taking options from BuilderOptions for...
Definition LayoutBuilder.h:87
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:109
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:115
size_t length() const noexcept
Current length of the data.
Definition LayoutBuilder.h:134
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:177
void append(PRIMITIVE x) noexcept
Inserts a PRIMITIVE type data.
Definition LayoutBuilder.h:95
Numpy()
Creates a new Numpy layout builder by allocating a new buffer, using AWKWARD_LAYOUTBUILDER_DEFAULT_OP...
Definition LayoutBuilder.h:75
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:121
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:146
void extend(PRIMITIVE *ptr, size_t size) noexcept
Inserts an entire array of PRIMITIVE type data.
Definition LayoutBuilder.h:103
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the builder buffer to a user-defined pointer if the g...
Definition LayoutBuilder.h:166
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:157
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:185
Clears the builder contents.
Definition LayoutBuilder.h:582
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:585
ContentsFormFunctor(std::stringstream &out, const std::map< size_t, std::string > &content_names)
Definition LayoutBuilder.h:687
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:692
void clear() noexcept
Definition LayoutBuilder.h:591
Record()
Creates a new Record layout builder.
Definition LayoutBuilder.h:504
MAP UserDefinedMap
Definition LayoutBuilder.h:498
std::string form() const noexcept
Definition LayoutBuilder.h:711
RecordFieldType< INDEX >::Builder & content() noexcept
Returns the reference to the builder contents at INDEX.
Definition LayoutBuilder.h:549
std::tuple_element_t< INDEX, RecordContents > RecordFieldType
Definition LayoutBuilder.h:501
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:516
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:555
typename std::tuple< BUILDERS... > RecordContents
Definition LayoutBuilder.h:497
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:561
size_t length() const noexcept
Current number of records in first field.
Definition LayoutBuilder.h:599
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:673
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:566
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:605
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:634
void set_fields(MAP user_defined_field_id_to_name_map) noexcept
Sets the field names.
Definition LayoutBuilder.h:542
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the buffers of the builder contents to user-defined p...
Definition LayoutBuilder.h:659
const std::vector< std::string > fields() const noexcept
Returns a vector of strings sontaining all the field names.
Definition LayoutBuilder.h:525
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:648
RecordContents contents
Definition LayoutBuilder.h:737
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:1067
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the content of the builder.
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:1132
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1047
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1053
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1028
size_t length() const noexcept
Current number of lists of length SIZE.
Definition LayoutBuilder.h:1074
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:1125
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1059
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1080
void end_list() noexcept
Ends a list and increments the number of lists.
Definition LayoutBuilder.h:1041
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:1097
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the buffers of the builder content to user-defined po...
Definition LayoutBuilder.h:1116
Regular()
Creates a new Regular layout builder.
Definition LayoutBuilder.h:1021
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:1108
void append(const std::string &value)
Definition LayoutBuilder.h:419
String()
Definition LayoutBuilder.h:414
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:943
ContentsFormFunctor(std::stringstream &out)
Definition LayoutBuilder.h:938
void clear() noexcept
Clears the builder contents.
Definition LayoutBuilder.h:838
TupleContents contents
Definition LayoutBuilder.h:975
std::string form() const noexcept
Definition LayoutBuilder.h:953
Tuple()
Creates a new Tuple layout builder.
Definition LayoutBuilder.h:797
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:811
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:817
size_t length() const noexcept
Current number of records in the first index of the tuple.
Definition LayoutBuilder.h:848
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:926
TupleContentType< INDEX > & content() noexcept
Returns the reference to the builder contents at INDEX.
Definition LayoutBuilder.h:805
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:823
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:854
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:884
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the buffers of the builder contents to user-defined p...
Definition LayoutBuilder.h:912
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:899
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:2492
ContentsFormFunctor(std::stringstream &out)
Definition LayoutBuilder.h:2487
void clear() noexcept
Discards the accumulated tags and index, and clears the builder contents.
Definition LayoutBuilder.h:2358
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:2302
typename std::tuple< BUILDERS... > Contents
Definition LayoutBuilder.h:2283
std::tuple_element_t< I, Contents > ContentType
Definition LayoutBuilder.h:2286
ContentType< TAG > & append_content() noexcept
Inserts the current tag in the tags buffer and the next index in the index buffer and returns the ref...
Definition LayoutBuilder.h:2319
std::string form() const noexcept
Definition LayoutBuilder.h:2502
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:2332
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:2338
size_t length() const noexcept
Current length of the tags buffer.
Definition LayoutBuilder.h:2372
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:2468
Union()
Creates a new Union layout builder by allocating new tags and index buffers, using AWKWARD_LAYOUTBUIL...
Definition LayoutBuilder.h:2290
ContentType< I > & content() noexcept
Definition LayoutBuilder.h:2311
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:2344
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2378
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:2408
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the builder buffers to user-defined pointers if the g...
Definition LayoutBuilder.h:2447
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:2427
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:1647
Unmasked()
Creates a new Unmasked layout builder.
Definition LayoutBuilder.h:1614
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:1701
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1627
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1633
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1621
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:1653
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:1694
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1639
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1659
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:1666
void to_buffer(void *buffer, const char *name) const noexcept
Copies and concatenates the accumulated data in the buffers of the builder content to user-defined po...
Definition LayoutBuilder.h:1685
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:1677
Definition LayoutBuilder.h:22
Definition ArrayBuilder.h:14
const std::string type_to_numpy_like()
Returns char string when the primitive type is a character.
Definition utils.h:93
void visit_at(std::tuple< CONTENTs... > const &contents, size_t index, FUNCTION fun)
Visits the tuple contents at index.
Definition utils.h:241
Options< int64_t, double > BuilderOptions
Definition BuilderOptions.h:56
const std::string type_to_name()
Returns the name of a primitive type as a string.
Definition utils.h:23