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_) {
1231 size_t start = content_.length();
1232 size_t stop = start + size;
1233 if (stop - 1 > max_index_) {
1234 max_index_ = stop - 1;
1236 for (
size_t i = start; i < stop; i++) {
1251 parameters_ = parameter;
1259 content_.set_id(
id);
1274 return index_.length();
1282 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
1283 content_.buffer_nbytes(names_nbytes);
1290 if (max_index_ == UINTMAX_MAX) {
1291 std::stringstream out;
1292 out <<
"Indexed node" << id_ <<
" has a negative index\n";
1293 error.append(out.str());
1295 }
else if ((content_.length() == 0) && (max_index_ == 0)) {
1296 }
else if (max_index_ >= content_.length()) {
1297 std::stringstream out;
1298 out <<
"Indexed node" << id_ <<
" has index " << max_index_
1299 <<
" but content has length "
1300 << content_.length() <<
"\n";
1301 error.append(out.str());
1304 return content_.is_valid(error);
1313 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1314 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1315 buffers[
"node" + std::to_string(id_) +
"-index"]));
1316 content_.to_buffers(buffers);
1325 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-index")) {
1326 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
1328 content_.to_buffer(buffer, name);
1337 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1338 buffers[
"node" + std::to_string(id_) +
"-index"]));
1339 content_.to_char_buffers(buffers);
1346 std::stringstream form_key;
1347 form_key <<
"node" << id_;
1348 std::string params(
"");
1349 if (parameters_ ==
"") {
1351 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1353 return "{ \"class\": \"IndexedArray\", \"index\": \"" +
1355 "\", \"content\": " + content_.form() + params +
1356 ", \"form_key\": \"" + form_key.str() +
"\" }";
1369 std::string parameters_;
1388 template <
typename PRIMITIVE,
typename BUILDER>
1431 if (i > max_index_) {
1446 size_t start = content_.length();
1447 size_t stop = start + size;
1448 size_t last_valid = stop - 1;
1449 if (last_valid > max_index_) {
1450 max_index_ = last_valid;
1452 for (
size_t i = start; i < stop; i++) {
1469 for (
size_t i = 0; i < size; i++) {
1483 parameters_ = parameter;
1491 content_.set_id(
id);
1505 return index_.length();
1511 if ((content_.length() == 0) && (max_index_ == 0)) {
1512 }
else if (max_index_ >= content_.length()) {
1513 std::stringstream out;
1514 out <<
"IndexedOption node" << id_ <<
" has index " << max_index_
1515 <<
" but content has length "
1516 << content_.length() <<
"\n";
1517 error.append(out.str());
1521 return content_.is_valid(error);
1529 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
1530 content_.buffer_nbytes(names_nbytes);
1539 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1540 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1541 buffers[
"node" + std::to_string(id_) +
"-index"]));
1542 content_.to_buffers(buffers);
1551 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-index")) {
1552 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
1554 content_.to_buffer(buffer, name);
1563 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1564 buffers[
"node" + std::to_string(id_) +
"-index"]));
1565 content_.to_char_buffers(buffers);
1572 std::stringstream form_key;
1573 form_key <<
"node" << id_;
1574 std::string params(
"");
1575 if (parameters_ ==
"") {
1577 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1579 return "{ \"class\": \"IndexedOptionArray\", \"index\": \"" +
1581 "\", \"content\": " + content_.form() + params +
1582 ", \"form_key\": \"" + form_key.str() +
"\" }";
1595 std::string parameters_;
1615 template <
typename BUILDER>
1639 parameters_ = parameter;
1647 content_.set_id(
id);
1659 return content_.length();
1665 return content_.is_valid(error);
1673 content_.buffer_nbytes(names_nbytes);
1682 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1683 content_.to_buffers(buffers);
1691 content_.to_buffer(buffer, name);
1700 content_.to_char_buffers(buffers);
1707 std::stringstream form_key;
1708 form_key <<
"node" << id_;
1709 std::string params(
"");
1710 if (parameters_ ==
"") {
1712 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1714 return "{ \"class\": \"UnmaskedArray\", \"content\": " +
1715 content_.form() + params +
", \"form_key\": \"" +
1716 form_key.str() +
"\" }";
1724 std::string parameters_;
1746 template <
bool VALID_WHEN,
typename BUILDER>
1785 mask_.append(valid_when_);
1796 for (
size_t i = 0; i < size; i++) {
1797 mask_.append(valid_when_);
1807 mask_.append(!valid_when_);
1818 for (
size_t i = 0; i < size; i++) {
1819 mask_.append(!valid_when_);
1833 parameters_ = parameter;
1841 content_.set_id(
id);
1855 return mask_.length();
1861 if (content_.length() != mask_.length()) {
1862 std::stringstream out;
1863 out <<
"ByteMasked node" << id_ <<
"has content length "
1864 << content_.length() <<
"but mask length " << mask_.length()
1866 error.append(out.str());
1870 return content_.is_valid(error);
1879 names_nbytes[
"node" + std::to_string(id_) +
"-mask"] = mask_.nbytes();
1880 content_.buffer_nbytes(names_nbytes);
1889 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1890 mask_.concatenate(
reinterpret_cast<int8_t*
>(
1891 buffers[
"node" + std::to_string(id_) +
"-mask"]));
1892 content_.to_buffers(buffers);
1901 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-mask")) {
1902 mask_.concatenate(
reinterpret_cast<int8_t*
>(buffer));
1904 content_.to_buffer(buffer, name);
1913 mask_.concatenate(
reinterpret_cast<int8_t*
>(
1914 buffers[
"node" + std::to_string(id_) +
"-mask"]));
1915 content_.to_char_buffers(buffers);
1922 std::stringstream form_key, form_valid_when;
1923 form_key <<
"node" << id_;
1924 form_valid_when << std::boolalpha << valid_when_;
1925 std::string params(
"");
1926 if (parameters_ ==
"") {
1928 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1930 return "{ \"class\": \"ByteMaskedArray\", \"mask\": \"i8\", "
1932 content_.form() +
", \"valid_when\": " + form_valid_when.str() +
1933 params +
", \"form_key\": \"" + form_key.str() +
"\" }";
1946 std::string parameters_;
1952 bool valid_when_ = VALID_WHEN;
1971 template <
bool VALID_WHEN,
bool LSB_ORDER,
typename BUILDER>
1978 current_byte_(uint8_t(0)),
1983 for (
size_t i = 0; i < 8; i++) {
1987 for (
size_t i = 0; i < 8; i++) {
1988 cast_[i] = 128 >> i;
2000 current_byte_(uint8_t(0)),
2005 for (
size_t i = 0; i < 8; i++) {
2009 for (
size_t i = 0; i < 8; i++) {
2010 cast_[i] = 128 >> i;
2041 current_byte_ |= cast_[current_index_];
2054 for (
size_t i = 0; i < size; i++) {
2077 for (
size_t i = 0; i < size; i++) {
2092 parameters_ = parameter;
2100 content_.set_id(
id);
2119 return mask_.length() * 8 + current_index_;
2125 return mask_.length() + (current_index_ > 0 ? 1 : 0);
2131 if (content_.length() !=
length()) {
2132 std::stringstream out;
2133 out <<
"BitMasked node" << id_ <<
"has content length "
2134 << content_.length() <<
"but bit mask length " << mask_.length()
2136 error.append(out.str());
2140 return content_.is_valid(error);
2149 names_nbytes[
"node" + std::to_string(id_) +
"-mask"] =
mask_nbytes();
2150 content_.buffer_nbytes(names_nbytes);
2159 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
2160 write_mask(
reinterpret_cast<uint8_t*
>(
2161 buffers[
"node" + std::to_string(id_) +
"-mask"]));
2162 content_.to_buffers(buffers);
2171 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-mask")) {
2172 write_mask(
reinterpret_cast<uint8_t*
>(buffer));
2174 content_.to_buffer(buffer, name);
2183 write_mask(
reinterpret_cast<uint8_t*
>(
2184 buffers[
"node" + std::to_string(id_) +
"-mask"]));
2185 content_.to_char_buffers(buffers);
2192 std::stringstream form_key, form_valid_when, form_lsb_order;
2193 form_key <<
"node" << id_;
2194 form_valid_when << std::boolalpha << valid_when_;
2195 form_lsb_order << std::boolalpha << lsb_order_;
2196 std::string params(
"");
2197 if (parameters_ ==
"") {
2199 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
2201 return "{ \"class\": \"BitMaskedArray\", \"mask\": \"u8\", "
2203 content_.form() +
", \"valid_when\": " + form_valid_when.str() +
2204 ", \"lsb_order\": " + form_lsb_order.str() + params +
2205 ", \"form_key\": \"" + form_key.str() +
"\" }";
2222 current_index_ += 1;
2223 if (current_index_ == 8) {
2224 mask_.
append(valid_when_ ? current_byte_ : (uint8_t)(~current_byte_));
2225 current_byte_ = uint8_t(0);
2235 write_mask(uint8_t* buffer)
const noexcept {
2236 if (buffer ==
nullptr) {
2239 if (mask_.length() > 0) {
2240 mask_.concatenate(buffer);
2242 if (current_index_ > 0) {
2243 buffer[mask_.length()] =
2244 valid_when_ ? current_byte_ : (uint8_t)(~current_byte_);
2251 GrowableBuffer<uint8_t> mask_;
2257 std::string parameters_;
2263 uint8_t current_byte_;
2266 size_t current_index_;
2272 bool valid_when_ = VALID_WHEN;
2276 bool lsb_order_ = LSB_ORDER;
2294 template <
typename TAGS,
typename INDEX,
typename... BUILDERS>
2299 template <std::
size_t I>
2323 template <std::
size_t I>
2326 return std::get<I>(contents_);
2331 template <std::
size_t TAG>
2334 auto& which_content = std::get<TAG>(contents_);
2335 INDEX next_index = which_content.length();
2337 TAGS tag = (TAGS)TAG;
2339 index_.append(next_index);
2341 return which_content;
2353 parameters_ = parameter;
2361 for (
size_t i = 0; i < contents_count_; i++) {
2376 for (
size_t i = 0; i < contents_count_; i++) {
2387 return tags_.length();
2393 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2395 std::vector<size_t> lengths = content_lengths(index_sequence);
2396 std::unique_ptr<INDEX[]> index_ptr(
new INDEX[index_.length()]);
2397 index_.concatenate(index_ptr.get());
2398 std::unique_ptr<TAGS[]> tags_ptr(
new TAGS[tags_.length()]);
2399 tags_.concatenate(tags_ptr.get());
2400 for (
size_t i = 0; i < index_.length(); i++) {
2401 if (index_ptr.get()[i] < 0 || index_ptr.get()[i] >= lengths[tags_ptr.get()[i]]) {
2402 std::stringstream out;
2403 out <<
"Union node" << id_ <<
" has index " << index_ptr.get()[i]
2404 <<
" at position " << i <<
" but content has length "
2405 << lengths[tags_ptr.get()[i]] <<
"\n";
2406 error.append(out.str());
2412 std::vector<bool> valid_contents =
2413 content_is_valid(index_sequence, error);
2414 return std::none_of(std::cbegin(valid_contents),
2415 std::cend(valid_contents),
2416 std::logical_not<bool>());
2424 names_nbytes[
"node" + std::to_string(id_) +
"-tags"] = tags_.nbytes();
2425 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
2427 for (
size_t i = 0; i < contents_count_; i++) {
2429 content.buffer_nbytes(names_nbytes);
2441 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
2443 tags_.concatenate(
reinterpret_cast<TAGS*
>(
2444 buffers[
"node" + std::to_string(id_) +
"-tags"]));
2445 index_.concatenate(
reinterpret_cast<INDEX*
>(
2446 buffers[
"node" + std::to_string(id_) +
"-index"]));
2448 for (
size_t i = 0; i < contents_count_; i++) {
2462 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-tags")) {
2463 tags_.concatenate(
reinterpret_cast<TAGS*
>(buffer));
2465 else if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-index")) {
2466 index_.concatenate(
reinterpret_cast<INDEX*
>(buffer));
2469 for (
size_t i = 0; i < contents_count_; i++) {
2471 content.to_buffer(buffer, name);
2484 tags_.concatenate(
reinterpret_cast<TAGS*
>(
2485 buffers[
"node" + std::to_string(id_) +
"-tags"]));
2486 index_.concatenate(
reinterpret_cast<INDEX*
>(
2487 buffers[
"node" + std::to_string(id_) +
"-index"]));
2489 for (
size_t i = 0; i < contents_count_; i++) {
2491 content.to_char_buffers(buffers);
2505 template <
class CONTENT>
2511 std::stringstream& out_;
2517 std::stringstream form_key;
2518 form_key <<
"node" << id_;
2519 std::string params(
"");
2520 if (!parameters_.empty()) {
2521 params =
"\"parameters\": { " + parameters_ +
" }, ";
2523 std::stringstream out;
2524 out <<
"{ \"class\": \"UnionArray\", \"tags\": \"" +
2527 for (
size_t i = 0; i < contents_count_; i++) {
2531 ContentsFormFunctor contentsFormFunctor(out);
2532 visit_at(contents_, i, contentsFormFunctor);
2535 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
2543 template <std::size_t... S>
2545 content_lengths(std::index_sequence<S...>)
const {
2546 return std::vector<size_t>({std::get<S>(contents_).length()...});
2550 template <std::size_t... S>
2552 content_is_valid(std::index_sequence<S...>, std::string& error)
const {
2553 return std::vector<bool>({std::get<S>(contents_).is_valid(error)...});
2559 GrowableBuffer<TAGS> tags_;
2564 GrowableBuffer<INDEX> index_;
2570 std::string parameters_;
2576 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
void append(PRIMITIVE datum)
Inserts one datum into the panel, possibly triggering allocation of a new panel.
Definition GrowableBuffer.h:472
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition LayoutBuilder.h:2023
size_t mask_nbytes() const noexcept
Number of bytes the mask occupies.
Definition LayoutBuilder.h:2124
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:2106
bool lsb_order() const noexcept
Determines whether the position of each bit is in Least-Significant Bit order (LSB) or not.
Definition LayoutBuilder.h:2030
BUILDER & append_invalid() noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:2064
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:2053
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:2191
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:2085
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:2091
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:2017
size_t length() const noexcept
Current number of elements (bits) accumulated in the mask.
Definition LayoutBuilder.h:2118
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:2182
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:2097
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2130
BitMasked(const awkward::BuilderOptions &options)
Creates a new BitMasked layout builder by allocating a new mask buffer, taking options from BuilderOp...
Definition LayoutBuilder.h:1998
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:2039
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:2147
BUILDER & extend_invalid(size_t size) noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:2076
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:2170
BitMasked()
Creates a new BitMasked layout builder by allocating a new mask buffer, using AWKWARD_LAYOUTBUILDER_D...
Definition LayoutBuilder.h:1976
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:2159
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:1776
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:1847
BUILDER & append_invalid() noexcept
Inserts !valid_when in the mask.
Definition LayoutBuilder.h:1806
BUILDER & extend_valid(size_t size) noexcept
Inserts size number of valid_when in the mask.
Definition LayoutBuilder.h:1795
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:1921
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1826
ByteMasked()
Creates a new ByteMasked layout builder by allocating a new mask buffer, using AWKWARD_LAYOUTBUILDER_...
Definition LayoutBuilder.h:1751
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1832
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1770
ByteMasked(const awkward::BuilderOptions &options)
Creates a new ByteMasked layout builder by allocating a new mask buffer, taking options from BuilderO...
Definition LayoutBuilder.h:1762
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:1854
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:1912
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1838
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1860
BUILDER & append_valid() noexcept
Inserts valid_when in the mask.
Definition LayoutBuilder.h:1784
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:1877
BUILDER & extend_invalid(size_t size) noexcept
Inserts size number of !valid_when in the mask.
Definition LayoutBuilder.h:1817
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:1900
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:1889
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:1497
void extend_invalid(size_t size) noexcept
Inserts -1 in the index buffer size number of times.
Definition LayoutBuilder.h:1468
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:1442
std::string form() const noexcept
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition LayoutBuilder.h:1571
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1476
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1482
IndexedOption(const awkward::BuilderOptions &options)
Creates a new IndexedOption layout builder by allocating a new index buffer, taking options from Buil...
Definition LayoutBuilder.h:1406
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1415
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:1429
size_t length() const noexcept
Current length of the index buffer.
Definition LayoutBuilder.h:1504
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:1562
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1488
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1510
IndexedOption()
Creates a new IndexedOption layout builder by allocating a new index buffer, using AWKWARD_LAYOUTBUIL...
Definition LayoutBuilder.h:1393
BUILDER & append_valid() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1422
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:1527
void append_invalid() noexcept
Inserts -1 in the index buffer.
Definition LayoutBuilder.h:1460
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:1550
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:1539
void clear() noexcept
Discards the accumulated index and clears the content of the builder.
Definition LayoutBuilder.h:1265
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:1345
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:1244
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:1250
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:1227
size_t length() const noexcept
Current length of the index buffer.
Definition LayoutBuilder.h:1273
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:1336
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1256
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1288
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:1280
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:1324
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:1313
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:2506
ContentsFormFunctor(std::stringstream &out)
Definition LayoutBuilder.h:2501
void clear() noexcept
Discards the accumulated tags and index, and clears the builder contents.
Definition LayoutBuilder.h:2372
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:2316
typename std::tuple< BUILDERS... > Contents
Definition LayoutBuilder.h:2297
std::tuple_element_t< I, Contents > ContentType
Definition LayoutBuilder.h:2300
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:2333
std::string form() const noexcept
Definition LayoutBuilder.h:2516
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:2346
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:2352
size_t length() const noexcept
Current length of the tags buffer.
Definition LayoutBuilder.h:2386
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:2482
Union()
Creates a new Union layout builder by allocating new tags and index buffers, using AWKWARD_LAYOUTBUIL...
Definition LayoutBuilder.h:2304
ContentType< I > & content() noexcept
Definition LayoutBuilder.h:2325
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:2358
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2392
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:2422
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:2461
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:2441
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:1652
Unmasked()
Creates a new Unmasked layout builder.
Definition LayoutBuilder.h:1619
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:1706
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1632
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1638
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1626
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:1658
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition LayoutBuilder.h:1699
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1644
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1664
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:1671
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:1690
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:1682
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