3#ifndef AWKWARD_LAYOUTBUILDER_H_
4#define AWKWARD_LAYOUTBUILDER_H_
19#define AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS awkward::BuilderOptions(1024, 1)
32 template <
class CONTENT>
34 content.builder.set_id(id_);
48 template <std::
size_t ENUM,
typename BUILDER>
56 return std::to_string(
index);
71 template <
typename PRIMITIVE>
104 extend(PRIMITIVE* ptr,
size_t size)
noexcept {
105 data_.extend(ptr, size);
117 parameters_ = parameter;
136 return data_.length();
149 names_nbytes[
"node" + std::to_string(id_) +
"-data"] = data_.nbytes();
158 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
159 data_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
160 buffers[
"node" + std::to_string(id_) +
"-data"]));
167 to_buffer(
void* buffer,
const char* name)
const noexcept {
168 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-data")) {
169 data_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
179 data_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
180 buffers[
"node" + std::to_string(id_) +
"-data"]));
187 std::stringstream form_key;
188 form_key <<
"node" << id_;
190 std::string params(
"");
191 if (parameters_ ==
"") {
193 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
196 if (std::is_arithmetic<PRIMITIVE>::value) {
197 return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
199 ", \"form_key\": \"" + form_key.str() +
"\" }";
201 return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
203 ", \"form_key\": \"" + form_key.str() +
"\" }";
205 throw std::runtime_error(
"type " +
206 std::string(
typeid(PRIMITIVE).name()) +
216 std::string parameters_;
236 template <
typename PRIMITIVE,
typename BUILDER>
277 offsets_.append(content_.length());
289 parameters_ = parameter;
311 return offsets_.length() - 1;
317 if ((int64_t)content_.length() != (int64_t)offsets_.last()) {
318 std::stringstream out;
319 out <<
"ListOffset node" << id_ <<
"has content length "
320 << content_.length() <<
"but last offset " << offsets_.last()
322 error.append(out.str());
326 return content_.is_valid(error);
335 names_nbytes[
"node" + std::to_string(id_) +
"-offsets"] =
337 content_.buffer_nbytes(names_nbytes);
346 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
347 offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
348 buffers[
"node" + std::to_string(id_) +
"-offsets"]));
349 content_.to_buffers(buffers);
357 to_buffer(
void* buffer,
const char* name)
const noexcept {
358 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-offsets")) {
359 offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
361 content_.to_buffer(buffer, name);
370 offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
371 buffers[
"node" + std::to_string(id_) +
"-offsets"]));
372 content_.to_char_buffers(buffers);
379 std::stringstream form_key;
380 form_key <<
"node" << id_;
381 std::string params(
"");
382 if (parameters_ ==
"") {
384 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
386 return "{ \"class\": \"ListOffsetArray\", \"offsets\": \"" +
388 "\", \"content\": " + content_.form() + params +
389 ", \"form_key\": \"" + form_key.str() +
"\" }";
402 std::string parameters_;
412 template<
class PRIMITIVE>
422 for (
const auto& c: value) {
480 return "{ \"class\": \"EmptyArray\" }";
494 template <
class MAP = std::map<std::
size_t, std::
string>,
495 typename... BUILDERS>
501 template <std::
size_t INDEX>
508 map_fields(std::index_sequence_for<BUILDERS...>());
518 : content_names_(user_defined_field_id_to_name_map) {
519 assert(content_names_.size() == fields_count_);
525 const std::vector<std::string>
527 if (content_names_.empty()) {
530 std::vector<std::string> result;
531 for (
auto it : content_names_) {
532 result.emplace_back(it.second);
544 content_names_ = user_defined_field_id_to_name_map;
548 template <std::
size_t INDEX>
549 typename RecordFieldType<INDEX>::Builder&
551 return std::get<INDEX>(
contents).builder;
563 parameters_ = parameter;
573 for (
size_t i = 0; i < fields_count_; i++) {
585 template <
class CONTENT>
593 ClearBuilder clearBuilder;
594 for (
size_t i = 0; i < fields_count_; i++) {
601 return (std::get<0>(
contents).builder.length());
607 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
610 std::vector<size_t> lengths = field_lengths(index_sequence);
611 for (
size_t i = 0; i < lengths.size(); i++) {
615 else if (
length != (int64_t)lengths[i]) {
616 std::stringstream out;
617 out <<
"Record node" << id_ <<
" has field \""
618 <<
fields().at(i) <<
"\" length " << lengths[i]
619 <<
" that differs from the first length " <<
length <<
"\n";
620 error.append(out.str());
626 std::vector<bool> valid_fields = field_is_valid(index_sequence, error);
627 return std::none_of(std::cbegin(valid_fields),
628 std::cend(valid_fields),
629 std::logical_not<bool>());
636 for (
size_t i = 0; i < fields_count_; i++) {
638 content.builder.buffer_nbytes(names_nbytes);
649 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
650 for (
size_t i = 0; i < fields_count_; i++) {
652 content.builder.to_buffers(buffers);
660 to_buffer(
void* buffer,
const char* name)
const noexcept {
661 for (
size_t i = 0; i < fields_count_; i++) {
663 content.builder.to_buffer(buffer, name);
675 for (
size_t i = 0; i < fields_count_; i++) {
677 content.builder.to_char_buffers(buffers);
689 : out_(out), content_names_(content_names) {}
692 template <
class CONTENT>
695 auto it = content_names_.find(index);
697 if (it != content_names_.end()) {
698 out_ <<
"\"" << it->second <<
"\": ";
700 out_ <<
"\"" << index <<
"\": ";
703 out_ <<
content.builder.form();
707 std::stringstream& out_;
712 std::string
form() const noexcept {
713 std::stringstream form_key;
714 form_key <<
"node" << id_;
716 std::string params(
"");
717 if (!parameters_.empty()) {
718 params =
"\"parameters\": { " + parameters_ +
" }, ";
721 std::stringstream out;
722 out <<
"{ \"class\": \"RecordArray\", \"contents\": { ";
724 for (
size_t i = 0; i < fields_count_; i++) {
728 ContentsFormFunctor contentsFormFunctor(out, content_names_);
733 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
743 template <std::size_t... S>
745 map_fields(std::index_sequence<S...>)
noexcept {
746 fields_ = std::vector<std::string>(
747 {std::string(std::get<S>(
contents).index_as_field())...});
752 template <std::size_t... S>
754 field_lengths(std::index_sequence<S...>)
const noexcept {
755 return std::vector<size_t>({std::get<S>(
contents).builder.length()...});
759 template <std::size_t... S>
761 field_is_valid(std::index_sequence<S...>, std::string& error)
const
763 return std::vector<bool>(
764 {std::get<S>(
contents).builder.is_valid(error)...});
768 std::vector<std::string> fields_;
774 std::string parameters_;
780 static constexpr size_t fields_count_ =
sizeof...(BUILDERS);
789 template <
typename... BUILDERS>
791 using TupleContents =
typename std::tuple<BUILDERS...>;
793 template <std::
size_t INDEX>
794 using TupleContentType = std::tuple_element_t<INDEX, TupleContents>;
804 template <std::
size_t INDEX>
805 TupleContentType<INDEX>&
819 parameters_ = parameter;
827 for (
size_t i = 0; i < fields_count_; i++) {
840 for (
size_t i = 0; i < fields_count_; i++) {
856 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
859 std::vector<size_t> lengths = content_lengths(index_sequence);
860 for (
size_t i = 0; i < lengths.size(); i++) {
862 length = (int64_t)lengths[i];
864 else if (
length != (int64_t)lengths[i]) {
865 std::stringstream out;
866 out <<
"Record node" << id_ <<
" has index \"" << i <<
"\" length "
867 << lengths[i] <<
" that differs from the first length "
869 error.append(out.str());
875 std::vector<bool> valid_fields =
876 content_is_valid(index_sequence, error);
877 return std::none_of(std::cbegin(valid_fields),
878 std::cend(valid_fields),
879 std::logical_not<bool>());
886 for (
size_t i = 0; i < fields_count_; i++) {
888 content.buffer_nbytes(names_nbytes);
900 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
901 for (
size_t i = 0; i < fields_count_; i++) {
913 to_buffer(
void* buffer,
const char* name)
const noexcept {
914 for (
size_t i = 0; i < fields_count_; i++) {
916 content.to_buffer(buffer, name);
928 for (
size_t i = 0; i < fields_count_; i++) {
930 content.to_char_buffers(buffers);
943 template <
class CONTENT>
949 std::stringstream& out_;
955 std::stringstream form_key;
956 form_key <<
"node" << id_;
957 std::string params(
"");
958 if (!parameters_.empty()) {
959 params =
"\"parameters\": { " + parameters_ +
" }, ";
961 std::stringstream out;
962 out <<
"{ \"class\": \"RecordArray\", \"contents\": [";
963 for (
size_t i = 0; i < fields_count_; i++) {
967 ContentsFormFunctor contentsFormFunctor(out);
971 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
981 template <std::size_t... S>
983 content_lengths(std::index_sequence<S...>)
const noexcept {
984 return std::vector<size_t>({std::get<S>(
contents).length()...});
988 template <std::size_t... S>
990 content_is_valid(std::index_sequence<S...>, std::string& error)
const
992 return std::vector<bool>({std::get<S>(
contents).is_valid(error)...});
996 std::string parameters_;
1002 static constexpr size_t fields_count_ =
sizeof...(BUILDERS);
1018 template <
unsigned SIZE,
typename BUILDER>
1055 parameters_ = parameter;
1063 content_.set_id(
id);
1082 if (content_.length() != length_ * size_) {
1083 std::stringstream out;
1084 out <<
"Regular node" << id_ <<
"has content length "
1085 << content_.length() <<
", but length " << length_ <<
" and size "
1087 error.append(out.str());
1091 return content_.is_valid(error);
1100 content_.buffer_nbytes(names_nbytes);
1109 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1110 content_.to_buffers(buffers);
1118 content_.to_buffer(buffer, name);
1127 content_.to_char_buffers(buffers);
1134 std::stringstream form_key;
1135 form_key <<
"node" << id_;
1136 std::string params(
"");
1137 if (parameters_ ==
"") {
1139 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1141 return "{ \"class\": \"RegularArray\", \"content\": " +
1142 content_.form() +
", \"size\": " + std::to_string(size_) +
1143 params +
", \"form_key\": \"" + form_key.str() +
"\" }";
1151 std::string parameters_;
1160 size_t size_ = SIZE;
1173 template <
typename PRIMITIVE,
typename BUILDER>
1216 if (i > max_index_) {
1219 max_index_ = UINTMAX_MAX;
1230 size_t start = content_.length();
1231 size_t stop = start + size;
1232 if (stop - 1 > max_index_) {
1233 max_index_ = stop - 1;
1235 for (
size_t i = start; i < stop; i++) {
1250 parameters_ = parameter;
1258 content_.set_id(
id);
1273 return index_.length();
1281 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
1282 content_.buffer_nbytes(names_nbytes);
1289 if (max_index_ == UINTMAX_MAX) {
1290 std::stringstream out;
1291 out <<
"Indexed node" << id_ <<
" has a negative index\n";
1292 error.append(out.str());
1294 }
else if ((content_.length() == 0) && (max_index_ == 0)) {
1295 }
else if (max_index_ >= content_.length()) {
1296 std::stringstream out;
1297 out <<
"Indexed node" << id_ <<
" has index " << max_index_
1298 <<
" but content has length "
1299 << content_.length() <<
"\n";
1300 error.append(out.str());
1303 return content_.is_valid(error);
1312 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1313 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1314 buffers[
"node" + std::to_string(id_) +
"-index"]));
1315 content_.to_buffers(buffers);
1324 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-index")) {
1325 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
1327 content_.to_buffer(buffer, name);
1336 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1337 buffers[
"node" + std::to_string(id_) +
"-index"]));
1338 content_.to_char_buffers(buffers);
1345 std::stringstream form_key;
1346 form_key <<
"node" << id_;
1347 std::string params(
"");
1348 if (parameters_ ==
"") {
1350 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1352 return "{ \"class\": \"IndexedArray\", \"index\": \"" +
1354 "\", \"content\": " + content_.form() + params +
1355 ", \"form_key\": \"" + form_key.str() +
"\" }";
1368 std::string parameters_;
1387 template <
typename PRIMITIVE,
typename BUILDER>
1430 if (i > max_index_) {
1442 size_t start = content_.length();
1443 size_t stop = start + size;
1444 size_t last_valid = stop - 1;
1445 if (last_valid > max_index_) {
1446 max_index_ = last_valid;
1448 for (
size_t i = start; i < stop; i++) {
1465 for (
size_t i = 0; i < size; i++) {
1479 parameters_ = parameter;
1487 content_.set_id(
id);
1501 return index_.length();
1507 if ((content_.length() == 0) && (max_index_ == 0)) {
1508 }
else if (max_index_ >= content_.length()) {
1509 std::stringstream out;
1510 out <<
"IndexedOption node" << id_ <<
" has index " << max_index_
1511 <<
" but content has length "
1512 << content_.length() <<
"\n";
1513 error.append(out.str());
1517 return content_.is_valid(error);
1525 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
1526 content_.buffer_nbytes(names_nbytes);
1535 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1536 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1537 buffers[
"node" + std::to_string(id_) +
"-index"]));
1538 content_.to_buffers(buffers);
1547 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-index")) {
1548 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
1550 content_.to_buffer(buffer, name);
1559 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1560 buffers[
"node" + std::to_string(id_) +
"-index"]));
1561 content_.to_char_buffers(buffers);
1568 std::stringstream form_key;
1569 form_key <<
"node" << id_;
1570 std::string params(
"");
1571 if (parameters_ ==
"") {
1573 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1575 return "{ \"class\": \"IndexedOptionArray\", \"index\": \"" +
1577 "\", \"content\": " + content_.form() + params +
1578 ", \"form_key\": \"" + form_key.str() +
"\" }";
1591 std::string parameters_;
1611 template <
typename BUILDER>
1635 parameters_ = parameter;
1643 content_.set_id(
id);
1655 return content_.length();
1661 return content_.is_valid(error);
1669 content_.buffer_nbytes(names_nbytes);
1678 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1679 content_.to_buffers(buffers);
1687 content_.to_buffer(buffer, name);
1696 content_.to_char_buffers(buffers);
1703 std::stringstream form_key;
1704 form_key <<
"node" << id_;
1705 std::string params(
"");
1706 if (parameters_ ==
"") {
1708 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1710 return "{ \"class\": \"UnmaskedArray\", \"content\": " +
1711 content_.form() + params +
", \"form_key\": \"" +
1712 form_key.str() +
"\" }";
1720 std::string parameters_;
1742 template <
bool VALID_WHEN,
typename BUILDER>
1781 mask_.append(valid_when_);
1792 for (
size_t i = 0; i < size; i++) {
1793 mask_.append(valid_when_);
1803 mask_.append(!valid_when_);
1814 for (
size_t i = 0; i < size; i++) {
1815 mask_.append(!valid_when_);
1829 parameters_ = parameter;
1837 content_.set_id(
id);
1851 return mask_.length();
1857 if (content_.length() != mask_.length()) {
1858 std::stringstream out;
1859 out <<
"ByteMasked node" << id_ <<
"has content length "
1860 << content_.length() <<
"but mask length " << mask_.length()
1862 error.append(out.str());
1866 return content_.is_valid(error);
1875 names_nbytes[
"node" + std::to_string(id_) +
"-mask"] = mask_.nbytes();
1876 content_.buffer_nbytes(names_nbytes);
1885 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1886 mask_.concatenate(
reinterpret_cast<int8_t*
>(
1887 buffers[
"node" + std::to_string(id_) +
"-mask"]));
1888 content_.to_buffers(buffers);
1897 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-mask")) {
1898 mask_.concatenate(
reinterpret_cast<int8_t*
>(buffer));
1900 content_.to_buffer(buffer, name);
1909 mask_.concatenate(
reinterpret_cast<int8_t*
>(
1910 buffers[
"node" + std::to_string(id_) +
"-mask"]));
1911 content_.to_char_buffers(buffers);
1918 std::stringstream form_key, form_valid_when;
1919 form_key <<
"node" << id_;
1920 form_valid_when << std::boolalpha << valid_when_;
1921 std::string params(
"");
1922 if (parameters_ ==
"") {
1924 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1926 return "{ \"class\": \"ByteMaskedArray\", \"mask\": \"i8\", "
1928 content_.form() +
", \"valid_when\": " + form_valid_when.str() +
1929 params +
", \"form_key\": \"" + form_key.str() +
"\" }";
1942 std::string parameters_;
1948 bool valid_when_ = VALID_WHEN;
1967 template <
bool VALID_WHEN,
bool LSB_ORDER,
typename BUILDER>
1974 current_byte_(uint8_t(0)),
1975 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
1980 for (
size_t i = 0; i < 8; i++) {
1984 for (
size_t i = 0; i < 8; i++) {
1985 cast_[i] = 128 >> i;
1997 current_byte_(uint8_t(0)),
1998 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
2003 for (
size_t i = 0; i < 8; i++) {
2007 for (
size_t i = 0; i < 8; i++) {
2008 cast_[i] = 128 >> i;
2039 current_byte_ |= cast_[current_index_];
2052 for (
size_t i = 0; i < size; i++) {
2075 for (
size_t i = 0; i < size; i++) {
2090 parameters_ = parameter;
2098 content_.set_id(
id);
2108 current_byte_ref_ = mask_.append_and_get_ref(current_byte_);
2115 return mask_.length() > 0 ?
2116 (mask_.length() - 1) * 8 + current_index_ : current_index_;
2122 if (content_.length() !=
length()) {
2123 std::stringstream out;
2124 out <<
"BitMasked node" << id_ <<
"has content length "
2125 << content_.length() <<
"but bit mask length " << mask_.length()
2127 error.append(out.str());
2131 return content_.is_valid(error);
2140 names_nbytes[
"node" + std::to_string(id_) +
"-mask"] = mask_.nbytes();
2141 content_.buffer_nbytes(names_nbytes);
2150 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
2151 mask_.concatenate_from(
reinterpret_cast<uint8_t*
>(
2152 buffers[
"node" + std::to_string(id_) +
"-mask"]), 0, 1);
2153 mask_.append(
reinterpret_cast<uint8_t*
>(
2154 buffers[
"node" + std::to_string(id_) +
"-mask"]), mask_.length() - 1, 0, 1);
2155 content_.to_buffers(buffers);
2164 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-mask")) {
2165 mask_.concatenate_from(
reinterpret_cast<uint8_t*
>(buffer), 0, 1);
2166 mask_.append(
reinterpret_cast<uint8_t*
>(buffer), mask_.length() - 1, 0, 1);
2168 content_.to_buffer(buffer, name);
2177 mask_.concatenate_from(
reinterpret_cast<uint8_t*
>(
2178 buffers[
"node" + std::to_string(id_) +
"-mask"]), 0, 1);
2179 mask_.append(
reinterpret_cast<uint8_t*
>(
2180 buffers[
"node" + std::to_string(id_) +
"-mask"]), mask_.length() - 1, 0, 1);
2181 content_.to_char_buffers(buffers);
2188 std::stringstream form_key, form_valid_when, form_lsb_order;
2189 form_key <<
"node" << id_;
2190 form_valid_when << std::boolalpha << valid_when_;
2191 form_lsb_order << std::boolalpha << lsb_order_;
2192 std::string params(
"");
2193 if (parameters_ ==
"") {
2195 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
2197 return "{ \"class\": \"BitMaskedArray\", \"mask\": \"u8\", "
2199 content_.form() +
", \"valid_when\": " + form_valid_when.str() +
2200 ", \"lsb_order\": " + form_lsb_order.str() + params +
2201 ", \"form_key\": \"" + form_key.str() +
"\" }";
2210 if (current_index_ == 8) {
2212 current_byte_ = uint8_t(0);
2224 current_index_ += 1;
2226 current_byte_ref_ = current_byte_;
2228 current_byte_ref_ = ~current_byte_;
2235 GrowableBuffer<uint8_t> mask_;
2241 std::string parameters_;
2247 uint8_t current_byte_;
2250 uint8_t& current_byte_ref_;
2253 size_t current_index_;
2259 bool valid_when_ = VALID_WHEN;
2263 bool lsb_order_ = LSB_ORDER;
2281 template <
typename TAGS,
typename INDEX,
typename... BUILDERS>
2286 template <std::
size_t I>
2310 template <std::
size_t I>
2313 return std::get<I>(contents_);
2318 template <std::
size_t TAG>
2321 auto& which_content = std::get<TAG>(contents_);
2322 INDEX next_index = which_content.length();
2324 TAGS tag = (TAGS)TAG;
2326 index_.append(next_index);
2328 return which_content;
2340 parameters_ = parameter;
2348 for (
size_t i = 0; i < contents_count_; i++) {
2363 for (
size_t i = 0; i < contents_count_; i++) {
2374 return tags_.length();
2380 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2382 std::vector<size_t> lengths = content_lengths(index_sequence);
2383 std::unique_ptr<INDEX[]> index_ptr(
new INDEX[index_.length()]);
2384 index_.concatenate(index_ptr.get());
2385 std::unique_ptr<TAGS[]> tags_ptr(
new TAGS[tags_.length()]);
2386 tags_.concatenate(tags_ptr.get());
2387 for (
size_t i = 0; i < index_.length(); i++) {
2388 if (index_ptr.get()[i] < 0 || index_ptr.get()[i] >= lengths[tags_ptr.get()[i]]) {
2389 std::stringstream out;
2390 out <<
"Union node" << id_ <<
" has index " << index_ptr.get()[i]
2391 <<
" at position " << i <<
" but content has length "
2392 << lengths[tags_ptr.get()[i]] <<
"\n";
2393 error.append(out.str());
2399 std::vector<bool> valid_contents =
2400 content_is_valid(index_sequence, error);
2401 return std::none_of(std::cbegin(valid_contents),
2402 std::cend(valid_contents),
2403 std::logical_not<bool>());
2411 names_nbytes[
"node" + std::to_string(id_) +
"-tags"] = tags_.nbytes();
2412 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
2414 for (
size_t i = 0; i < contents_count_; i++) {
2416 content.buffer_nbytes(names_nbytes);
2428 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
2430 tags_.concatenate(
reinterpret_cast<TAGS*
>(
2431 buffers[
"node" + std::to_string(id_) +
"-tags"]));
2432 index_.concatenate(
reinterpret_cast<INDEX*
>(
2433 buffers[
"node" + std::to_string(id_) +
"-index"]));
2435 for (
size_t i = 0; i < contents_count_; i++) {
2449 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-tags")) {
2450 tags_.concatenate(
reinterpret_cast<TAGS*
>(buffer));
2452 else if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-index")) {
2453 index_.concatenate(
reinterpret_cast<INDEX*
>(buffer));
2456 for (
size_t i = 0; i < contents_count_; i++) {
2458 content.to_buffer(buffer, name);
2471 tags_.concatenate(
reinterpret_cast<TAGS*
>(
2472 buffers[
"node" + std::to_string(id_) +
"-tags"]));
2473 index_.concatenate(
reinterpret_cast<INDEX*
>(
2474 buffers[
"node" + std::to_string(id_) +
"-index"]));
2476 for (
size_t i = 0; i < contents_count_; i++) {
2478 content.to_char_buffers(buffers);
2492 template <
class CONTENT>
2498 std::stringstream& out_;
2504 std::stringstream form_key;
2505 form_key <<
"node" << id_;
2506 std::string params(
"");
2507 if (!parameters_.empty()) {
2508 params =
"\"parameters\": { " + parameters_ +
" }, ";
2510 std::stringstream out;
2511 out <<
"{ \"class\": \"UnionArray\", \"tags\": \"" +
2514 for (
size_t i = 0; i < contents_count_; i++) {
2518 ContentsFormFunctor contentsFormFunctor(out);
2519 visit_at(contents_, i, contentsFormFunctor);
2522 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
2530 template <std::size_t... S>
2532 content_lengths(std::index_sequence<S...>)
const {
2533 return std::vector<size_t>({std::get<S>(contents_).length()...});
2537 template <std::size_t... S>
2539 content_is_valid(std::index_sequence<S...>, std::string& error)
const {
2540 return std::vector<bool>({std::get<S>(contents_).is_valid(error)...});
2546 GrowableBuffer<TAGS> tags_;
2551 GrowableBuffer<INDEX> index_;
2557 std::string parameters_;
2563 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:19
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:2021
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:2104
bool lsb_order() const noexcept
Determines whether the position of each bit is in Least-Significant Bit order (LSB) or not.
Definition LayoutBuilder.h:2028
BUILDER & append_invalid() noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:2062
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:2051
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:2187
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:2083
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:2089
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:2015
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:2114
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:2176
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:2095
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2121
BitMasked(const awkward::BuilderOptions &options)
Creates a new BitMasked layout builder by allocating a new mask buffer, taking options from BuilderOp...
Definition LayoutBuilder.h:1995
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:2037
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:2138
BUILDER & extend_invalid(size_t size) noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:2074
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:2163
BitMasked()
Creates a new BitMasked layout builder by allocating a new mask buffer, using AWKWARD_LAYOUTBUILDER_D...
Definition LayoutBuilder.h:1972
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:2150
Functor for setting the ids of all nodes in a layout tree.
Definition LayoutBuilder.h:28
BuilderSetId(size_t &id)
Definition LayoutBuilder.h:30
void operator()(CONTENT &content)
Definition LayoutBuilder.h:33
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition LayoutBuilder.h:1772
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:1843
BUILDER & append_invalid() noexcept
Inserts !valid_when in the mask.
Definition LayoutBuilder.h:1802
BUILDER & extend_valid(size_t size) noexcept
Inserts size number of valid_when in the mask.
Definition LayoutBuilder.h:1791
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:1917
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1822
ByteMasked()
Creates a new ByteMasked layout builder by allocating a new mask buffer, using AWKWARD_LAYOUTBUILDER_...
Definition LayoutBuilder.h:1747
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1828
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1766
ByteMasked(const awkward::BuilderOptions &options)
Creates a new ByteMasked layout builder by allocating a new mask buffer, taking options from BuilderO...
Definition LayoutBuilder.h:1758
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:1850
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:1908
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1834
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1856
BUILDER & append_valid() noexcept
Inserts valid_when in the mask.
Definition LayoutBuilder.h:1780
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:1873
BUILDER & extend_invalid(size_t size) noexcept
Inserts size number of !valid_when in the mask.
Definition LayoutBuilder.h:1813
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:1896
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:1885
void clear() noexcept
Definition LayoutBuilder.h:445
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:455
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:479
void to_buffers(std::map< std::string, void * > &) const noexcept
Definition LayoutBuilder.h:464
void to_buffer(void *, const char *) const noexcept
Definition LayoutBuilder.h:467
Empty()
Creates a new Empty layout builder.
Definition LayoutBuilder.h:436
void set_id(size_t &) noexcept
Definition LayoutBuilder.h:442
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:449
void buffer_nbytes(std::map< std::string, size_t > &) const noexcept
Definition LayoutBuilder.h:460
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:474
Helper class for sending a pair of field names (as enum) and field type as template parameters in Rec...
Definition LayoutBuilder.h:49
std::string index_as_field() const
Converts index as field string.
Definition LayoutBuilder.h:55
BUILDER Builder
Definition LayoutBuilder.h:51
const std::size_t index
Definition LayoutBuilder.h:60
Builder builder
Definition LayoutBuilder.h:62
void clear() noexcept
Discards the accumulated index and clears the content of the builder.
Definition LayoutBuilder.h:1493
void extend_invalid(size_t size) noexcept
Inserts -1 in the index buffer size number of times.
Definition LayoutBuilder.h:1464
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:1441
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:1567
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1472
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1478
IndexedOption(const awkward::BuilderOptions &options)
Creates a new IndexedOption layout builder by allocating a new index buffer, taking options from Buil...
Definition LayoutBuilder.h:1405
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1414
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:1428
size_t length() const noexcept
Current length of the index buffer.
Definition LayoutBuilder.h:1500
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:1558
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1484
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1506
IndexedOption()
Creates a new IndexedOption layout builder by allocating a new index buffer, using AWKWARD_LAYOUTBUIL...
Definition LayoutBuilder.h:1392
BUILDER & append_valid() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1421
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:1523
void append_invalid() noexcept
Inserts -1 in the index buffer.
Definition LayoutBuilder.h:1456
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:1546
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:1535
void clear() noexcept
Discards the accumulated index and clears the content of the builder.
Definition LayoutBuilder.h:1264
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:1344
Indexed(const awkward::BuilderOptions &options)
Creates a new Indexed layout builder by allocating a new index buffer, taking options from BuilderOpt...
Definition LayoutBuilder.h:1191
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1243
Indexed()
Creates a new Indexed layout builder by allocating a new index buffer, using AWKWARD_LAYOUTBUILDER_DE...
Definition LayoutBuilder.h:1178
BUILDER & append_index() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1207
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1249
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1200
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:1229
size_t length() const noexcept
Current length of the index buffer.
Definition LayoutBuilder.h:1272
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:1335
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1255
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1287
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:1279
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:1323
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:1312
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:1214
void clear() noexcept
Discards the accumulated offsets and clears the builder content.
Definition LayoutBuilder.h:302
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the builder content.
Definition LayoutBuilder.h:269
ListOffset()
Creates a new ListOffset layout builder by allocating a new offset buffer, using AWKWARD_LAYOUTBUILDE...
Definition LayoutBuilder.h:241
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:378
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:282
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:288
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:263
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:310
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:369
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:294
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:316
void end_list() noexcept
Ends a list and appends the current length of the list contents in the offsets buffer.
Definition LayoutBuilder.h:276
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:333
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:357
ListOffset(const awkward::BuilderOptions &options)
Creates a new ListOffset layout builder by allocating a new offset buffer, taking options from Builde...
Definition LayoutBuilder.h:254
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:346
Builds a NumpyArray which describes multi-dimensional data of PRIMITIVE type.
Definition LayoutBuilder.h:72
void clear() noexcept
Discards the accumulated data in the builder.
Definition LayoutBuilder.h:129
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:141
Numpy(const awkward::BuilderOptions &options)
Creates a new Numpy layout builder by allocating a new buffer, taking options from BuilderOptions for...
Definition LayoutBuilder.h:88
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:110
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:116
size_t length() const noexcept
Current length of the data.
Definition LayoutBuilder.h:135
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:178
void append(PRIMITIVE x) noexcept
Inserts a PRIMITIVE type data.
Definition LayoutBuilder.h:96
Numpy()
Creates a new Numpy layout builder by allocating a new buffer, using AWKWARD_LAYOUTBUILDER_DEFAULT_OP...
Definition LayoutBuilder.h:76
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:122
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:147
void extend(PRIMITIVE *ptr, size_t size) noexcept
Inserts an entire array of PRIMITIVE type data.
Definition LayoutBuilder.h:104
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:167
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:158
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:186
Clears the builder contents.
Definition LayoutBuilder.h:583
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:586
ContentsFormFunctor(std::stringstream &out, const UserDefinedMap &content_names)
Definition LayoutBuilder.h:688
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:693
void clear() noexcept
Definition LayoutBuilder.h:592
Record()
Creates a new Record layout builder.
Definition LayoutBuilder.h:505
MAP UserDefinedMap
Definition LayoutBuilder.h:499
std::string form() const noexcept
Definition LayoutBuilder.h:712
RecordFieldType< INDEX >::Builder & content() noexcept
Returns the reference to the builder contents at INDEX.
Definition LayoutBuilder.h:550
std::tuple_element_t< INDEX, RecordContents > RecordFieldType
Definition LayoutBuilder.h:502
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:517
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:556
typename std::tuple< BUILDERS... > RecordContents
Definition LayoutBuilder.h:498
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:562
size_t length() const noexcept
Current number of records in first field.
Definition LayoutBuilder.h:600
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:674
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:567
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:606
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:635
void set_fields(MAP user_defined_field_id_to_name_map) noexcept
Sets the field names.
Definition LayoutBuilder.h:543
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:660
const std::vector< std::string > fields() const noexcept
Returns a vector of strings sontaining all the field names.
Definition LayoutBuilder.h:526
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:649
RecordContents contents
Definition LayoutBuilder.h:738
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:1068
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the content of the builder.
Definition LayoutBuilder.h:1036
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:1133
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1048
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1054
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1029
size_t length() const noexcept
Current number of lists of length SIZE.
Definition LayoutBuilder.h:1075
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition LayoutBuilder.h:1126
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1060
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1081
void end_list() noexcept
Ends a list and increments the number of lists.
Definition LayoutBuilder.h:1042
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:1098
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:1117
Regular()
Creates a new Regular layout builder.
Definition LayoutBuilder.h:1022
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:1109
void append(const std::string &value)
Definition LayoutBuilder.h:420
String()
Definition LayoutBuilder.h:415
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:944
ContentsFormFunctor(std::stringstream &out)
Definition LayoutBuilder.h:939
void clear() noexcept
Clears the builder contents.
Definition LayoutBuilder.h:839
TupleContents contents
Definition LayoutBuilder.h:976
std::string form() const noexcept
Definition LayoutBuilder.h:954
Tuple()
Creates a new Tuple layout builder.
Definition LayoutBuilder.h:798
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:812
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:818
size_t length() const noexcept
Current number of records in the first index of the tuple.
Definition LayoutBuilder.h:849
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition LayoutBuilder.h:927
TupleContentType< INDEX > & content() noexcept
Returns the reference to the builder contents at INDEX.
Definition LayoutBuilder.h:806
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:824
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:855
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:885
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:913
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:900
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:2493
ContentsFormFunctor(std::stringstream &out)
Definition LayoutBuilder.h:2488
void clear() noexcept
Discards the accumulated tags and index, and clears the builder contents.
Definition LayoutBuilder.h:2359
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:2303
typename std::tuple< BUILDERS... > Contents
Definition LayoutBuilder.h:2284
std::tuple_element_t< I, Contents > ContentType
Definition LayoutBuilder.h:2287
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:2320
std::string form() const noexcept
Definition LayoutBuilder.h:2503
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:2333
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:2339
size_t length() const noexcept
Current length of the tags buffer.
Definition LayoutBuilder.h:2373
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:2469
Union()
Creates a new Union layout builder by allocating new tags and index buffers, using AWKWARD_LAYOUTBUIL...
Definition LayoutBuilder.h:2291
ContentType< I > & content() noexcept
Definition LayoutBuilder.h:2312
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:2345
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2379
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:2409
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:2448
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:2428
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:1648
Unmasked()
Creates a new Unmasked layout builder.
Definition LayoutBuilder.h:1615
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:1702
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1628
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1634
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1622
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:1654
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:1695
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1640
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1660
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:1667
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:1686
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:1678
Definition LayoutBuilder.h:23
Definition ArrayBuilder.h:14
const std::string type_to_numpy_like()
Returns char string when the primitive type is a character.
Definition utils.h:94
void visit_at(std::tuple< CONTENTs... > const &contents, size_t index, FUNCTION fun)
Visits the tuple contents at index.
Definition utils.h:242
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:24