3#ifndef AWKWARD_LAYOUTBUILDER_H_
4#define AWKWARD_LAYOUTBUILDER_H_
18#define AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS awkward::BuilderOptions(1024, 1)
22 namespace LayoutBuilder {
31 template <std::
size_t ENUM,
typename BUILDER>
39 return std::to_string(
index);
54 template <
typename PRIMITIVE>
87 extend(PRIMITIVE* ptr,
size_t size)
noexcept {
88 data_.extend(ptr, size);
87 extend(PRIMITIVE* ptr,
size_t size)
noexcept {
…}
100 parameters_ = parameter;
119 return data_.length();
132 names_nbytes[
"node" + std::to_string(id_) +
"-data"] = data_.nbytes();
141 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
142 data_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
143 buffers[
"node" + std::to_string(id_) +
"-data"]));
141 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
…}
150 to_buffer(
void* buffer,
const char* name)
const noexcept {
151 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-data")) {
152 data_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
162 data_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
163 buffers[
"node" + std::to_string(id_) +
"-data"]));
170 std::stringstream form_key;
171 form_key <<
"node" << id_;
173 std::string params(
"");
174 if (parameters_ ==
"") {
176 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
179 if (std::is_arithmetic<PRIMITIVE>::value) {
180 return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
181 type_to_name<PRIMITIVE>() +
"\"" + params +
182 ", \"form_key\": \"" + form_key.str() +
"\" }";
184 return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
185 type_to_name<PRIMITIVE>() +
"\"" + params +
186 ", \"form_key\": \"" + form_key.str() +
"\" }";
188 throw std::runtime_error(
"type " +
189 std::string(
typeid(PRIMITIVE).name()) +
199 std::string parameters_;
219 template <
typename PRIMITIVE,
typename BUILDER>
260 offsets_.append(content_.length());
272 parameters_ = parameter;
294 return offsets_.length() - 1;
300 if ((int64_t)content_.length() != (int64_t)offsets_.last()) {
301 std::stringstream out;
302 out <<
"ListOffset node" << id_ <<
"has content length "
303 << content_.length() <<
"but last offset " << offsets_.last()
305 error.append(out.str());
309 return content_.is_valid(error);
318 names_nbytes[
"node" + std::to_string(id_) +
"-offsets"] =
320 content_.buffer_nbytes(names_nbytes);
329 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
330 offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
331 buffers[
"node" + std::to_string(id_) +
"-offsets"]));
332 content_.to_buffers(buffers);
329 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
…}
340 to_buffer(
void* buffer,
const char* name)
const noexcept {
341 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-offsets")) {
342 offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
344 content_.to_buffer(buffer, name);
353 offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
354 buffers[
"node" + std::to_string(id_) +
"-offsets"]));
355 content_.to_char_buffers(buffers);
362 std::stringstream form_key;
363 form_key <<
"node" << id_;
364 std::string params(
"");
365 if (parameters_ ==
"") {
367 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
369 return "{ \"class\": \"ListOffsetArray\", \"offsets\": \"" +
370 type_to_numpy_like<PRIMITIVE>() +
371 "\", \"content\": " + content_.form() + params +
372 ", \"form_key\": \"" + form_key.str() +
"\" }";
385 std::string parameters_;
443 return "{ \"class\": \"EmptyArray\" }";
461 template <
class MAP = std::map<std::
size_t, std::
string>,
462 typename... BUILDERS>
468 template <std::
size_t INDEX>
475 map_fields(std::index_sequence_for<BUILDERS...>());
485 : content_names_(user_defined_field_id_to_name_map) {
486 assert(content_names_.size() == fields_count_);
492 const std::vector<std::string>
494 if (content_names_.empty()) {
497 std::vector<std::string> result;
498 for (
auto it : content_names_) {
499 result.emplace_back(it.second);
511 content_names_ = user_defined_field_id_to_name_map;
515 template <std::
size_t INDEX>
516 typename RecordFieldType<INDEX>::Builder&
518 return std::get<INDEX>(
contents).builder;
530 parameters_ = parameter;
538 for (
size_t i = 0; i < fields_count_; i++) {
551 for (
size_t i = 0; i < fields_count_; i++) {
561 return (std::get<0>(
contents).builder.length());
567 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
570 std::vector<size_t> lengths = field_lengths(index_sequence);
571 for (
size_t i = 0; i < lengths.size(); i++) {
575 else if (
length != (int64_t)lengths[i]) {
576 std::stringstream out;
577 out <<
"Record node" << id_ <<
" has field \""
578 <<
fields().at(i) <<
"\" length " << lengths[i]
579 <<
" that differs from the first length " <<
length <<
"\n";
580 error.append(out.str());
586 std::vector<bool> valid_fields = field_is_valid(index_sequence, error);
587 return std::none_of(std::cbegin(valid_fields),
588 std::cend(valid_fields),
589 std::logical_not<bool>());
597 for (
size_t i = 0; i < fields_count_; i++) {
599 content.builder.buffer_nbytes(names_nbytes);
610 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
611 for (
size_t i = 0; i < fields_count_; i++) {
610 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
…}
622 to_buffer(
void* buffer,
const char* name)
const noexcept {
623 for (
size_t i = 0; i < fields_count_; i++) {
625 content.builder.to_buffer(buffer, name);
636 for (
size_t i = 0; i < fields_count_; i++) {
638 content.builder.to_char_buffers(buffers);
647 std::stringstream form_key;
648 form_key <<
"node" << id_;
649 std::string params(
"");
650 if (parameters_ ==
"") {
652 params = std::string(
"\"parameters\": { " + parameters_ +
" }, ");
654 std::stringstream out;
655 out <<
"{ \"class\": \"RecordArray\", \"contents\": { ";
656 for (
size_t i = 0; i < fields_count_; i++) {
660 auto contents_form = [&](
auto&
content) {
662 << (!content_names_.empty() ? content_names_.at(
content.
index)
670 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
680 template <std::size_t... S>
682 map_fields(std::index_sequence<S...>)
noexcept {
683 fields_ = std::vector<std::string>(
684 {std::string(std::get<S>(
contents).index_as_field())...});
689 template <std::size_t... S>
691 field_lengths(std::index_sequence<S...>)
const noexcept {
692 return std::vector<size_t>({std::get<S>(
contents).builder.length()...});
696 template <std::size_t... S>
698 field_is_valid(std::index_sequence<S...>, std::string& error)
const
700 return std::vector<bool>(
701 {std::get<S>(
contents).builder.is_valid(error)...});
705 std::vector<std::string> fields_;
711 std::string parameters_;
717 static constexpr size_t fields_count_ =
sizeof...(BUILDERS);
726 template <
typename... BUILDERS>
728 using TupleContents =
typename std::tuple<BUILDERS...>;
730 template <std::
size_t INDEX>
731 using TupleContentType = std::tuple_element_t<INDEX, TupleContents>;
741 template <std::
size_t INDEX>
742 TupleContentType<INDEX>&
756 parameters_ = parameter;
764 for (
size_t i = 0; i < fields_count_; i++) {
776 for (
size_t i = 0; i < fields_count_; i++) {
792 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
795 std::vector<size_t> lengths = content_lengths(index_sequence);
796 for (
size_t i = 0; i < lengths.size(); i++) {
798 length = (int64_t)lengths[i];
800 else if (
length != (int64_t)lengths[i]) {
801 std::stringstream out;
802 out <<
"Record node" << id_ <<
" has index \"" << i <<
"\" length "
803 << lengths[i] <<
" that differs from the first length "
805 error.append(out.str());
811 std::vector<bool> valid_fields =
812 content_is_valid(index_sequence, error);
813 return std::none_of(std::cbegin(valid_fields),
814 std::cend(valid_fields),
815 std::logical_not<bool>());
823 for (
size_t i = 0; i < fields_count_; i++) {
825 content.buffer_nbytes(names_nbytes);
836 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
837 for (
size_t i = 0; i < fields_count_; i++) {
836 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
…}
848 to_buffer(
void* buffer,
const char* name)
const noexcept {
849 for (
size_t i = 0; i < fields_count_; i++) {
851 content.to_buffer(buffer, name);
862 for (
size_t i = 0; i < fields_count_; i++) {
864 content.to_char_buffers(buffers);
873 std::stringstream form_key;
874 form_key <<
"node" << id_;
875 std::string params(
"");
876 if (parameters_ ==
"") {
878 params = std::string(
"\"parameters\": { " + parameters_ +
" }, ");
880 std::stringstream out;
881 out <<
"{ \"class\": \"RecordArray\", \"contents\": [";
882 for (
size_t i = 0; i < fields_count_; i++) {
886 auto contents_form = [&out](
auto&
content) {
892 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
902 template <std::size_t... S>
904 content_lengths(std::index_sequence<S...>)
const noexcept {
905 return std::vector<size_t>({std::get<S>(
contents).length()...});
909 template <std::size_t... S>
911 content_is_valid(std::index_sequence<S...>, std::string& error)
const
913 return std::vector<bool>({std::get<S>(
contents).is_valid(error)...});
917 std::vector<int64_t> field_index_;
920 std::string parameters_;
926 static constexpr size_t fields_count_ =
sizeof...(BUILDERS);
942 template <
unsigned SIZE,
typename BUILDER>
979 parameters_ = parameter;
1006 if (content_.length() != length_ * size_) {
1007 std::stringstream out;
1008 out <<
"Regular node" << id_ <<
"has content length "
1009 << content_.length() <<
", but length " << length_ <<
" and size "
1011 error.append(out.str());
1015 return content_.is_valid(error);
1024 content_.buffer_nbytes(names_nbytes);
1033 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1034 content_.to_buffers(buffers);
1042 content_.to_buffer(buffer, name);
1051 content_.to_char_buffers(buffers);
1058 std::stringstream form_key;
1059 form_key <<
"node" << id_;
1060 std::string params(
"");
1061 if (parameters_ ==
"") {
1063 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1065 return "{ \"class\": \"RegularArray\", \"content\": " +
1066 content_.form() +
", \"size\": " + std::to_string(size_) +
1067 params +
", \"form_key\": \"" + form_key.str() +
"\" }";
1075 std::string parameters_;
1084 size_t size_ = SIZE;
1097 template <
typename PRIMITIVE,
typename BUILDER>
1130 index_.append(content_.length());
1140 size_t start = content_.length();
1141 size_t stop = start + size;
1142 for (
size_t i = start; i < stop; i++) {
1157 parameters_ = parameter;
1165 content_.set_id(
id);
1179 return index_.length();
1187 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
1188 content_.buffer_nbytes(names_nbytes);
1194 if (content_.length() != index_.length()) {
1195 std::stringstream out;
1196 out <<
"Indexed node" << id_ <<
" has content length "
1197 << content_.length() <<
" but index has length " << index_.length()
1199 error.append(out.str());
1203 return content_.is_valid(error);
1213 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1214 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1215 buffers[
"node" + std::to_string(id_) +
"-index"]));
1216 content_.to_buffers(buffers);
1225 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-index")) {
1226 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
1228 content_.to_buffer(buffer, name);
1237 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1238 buffers[
"node" + std::to_string(id_) +
"-index"]));
1239 content_.to_char_buffers(buffers);
1246 std::stringstream form_key;
1247 form_key <<
"node" << id_;
1248 std::string params(
"");
1249 if (parameters_ ==
"") {
1251 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1253 return "{ \"class\": \"IndexedArray\", \"index\": \"" +
1254 type_to_numpy_like<PRIMITIVE>() +
1255 "\", \"content\": " + content_.form() + params +
1256 ", \"form_key\": \"" + form_key.str() +
"\" }";
1269 std::string parameters_;
1285 template <
typename PRIMITIVE,
typename BUILDER>
1320 last_valid_ = content_.length();
1321 index_.append(last_valid_);
1331 size_t start = content_.length();
1332 size_t stop = start + size;
1333 last_valid_ = stop - 1;
1334 for (
size_t i = start; i < stop; i++) {
1351 for (
size_t i = 0; i < size; i++) {
1365 parameters_ = parameter;
1373 content_.set_id(
id);
1388 return index_.length();
1394 if (content_.length() != last_valid_ + 1) {
1395 std::stringstream out;
1396 out <<
"IndexedOption node" << id_ <<
" has content length "
1397 << content_.length() <<
" but last valid index is " << last_valid_
1399 error.append(out.str());
1403 return content_.is_valid(error);
1412 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
1413 content_.buffer_nbytes(names_nbytes);
1422 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1423 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1424 buffers[
"node" + std::to_string(id_) +
"-index"]));
1425 content_.to_buffers(buffers);
1434 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-index")) {
1435 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
1437 content_.to_buffer(buffer, name);
1446 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1447 buffers[
"node" + std::to_string(id_) +
"-index"]));
1448 content_.to_char_buffers(buffers);
1455 std::stringstream form_key;
1456 form_key <<
"node" << id_;
1457 std::string params(
"");
1458 if (parameters_ ==
"") {
1460 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1462 return "{ \"class\": \"IndexedOptionArray\", \"index\": \"" +
1463 type_to_numpy_like<PRIMITIVE>() +
1464 "\", \"content\": " + content_.form() + params +
1465 ", \"form_key\": \"" + form_key.str() +
"\" }";
1478 std::string parameters_;
1498 template <
typename BUILDER>
1522 parameters_ = parameter;
1530 content_.set_id(
id);
1542 return content_.length();
1548 return content_.is_valid(error);
1556 content_.buffer_nbytes(names_nbytes);
1565 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1566 content_.to_buffers(buffers);
1574 content_.to_buffer(buffer, name);
1583 content_.to_char_buffers(buffers);
1590 std::stringstream form_key;
1591 form_key <<
"node" << id_;
1592 std::string params(
"");
1593 if (parameters_ ==
"") {
1595 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1597 return "{ \"class\": \"UnmaskedArray\", \"content\": " +
1598 content_.form() + params +
", \"form_key\": \"" +
1599 form_key.str() +
"\" }";
1607 std::string parameters_;
1629 template <
bool VALID_WHEN,
typename BUILDER>
1668 mask_.
append(valid_when_);
1679 for (
size_t i = 0; i < size; i++) {
1680 mask_.
append(valid_when_);
1690 mask_.
append(!valid_when_);
1701 for (
size_t i = 0; i < size; i++) {
1702 mask_.
append(!valid_when_);
1716 parameters_ = parameter;
1724 content_.set_id(
id);
1744 if (content_.length() != mask_.
length()) {
1745 std::stringstream out;
1746 out <<
"ByteMasked node" << id_ <<
"has content length "
1747 << content_.length() <<
"but mask length " << mask_.
length()
1749 error.append(out.str());
1753 return content_.is_valid(error);
1762 names_nbytes[
"node" + std::to_string(id_) +
"-mask"] = mask_.
nbytes();
1763 content_.buffer_nbytes(names_nbytes);
1772 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1774 buffers[
"node" + std::to_string(id_) +
"-mask"]));
1775 content_.to_buffers(buffers);
1784 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-mask")) {
1785 mask_.
concatenate(
reinterpret_cast<int8_t*
>(buffer));
1787 content_.to_buffer(buffer, name);
1797 buffers[
"node" + std::to_string(id_) +
"-mask"]));
1798 content_.to_char_buffers(buffers);
1805 std::stringstream form_key, form_valid_when;
1806 form_key <<
"node" << id_;
1807 form_valid_when << std::boolalpha << valid_when_;
1808 std::string params(
"");
1809 if (parameters_ ==
"") {
1811 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1813 return "{ \"class\": \"ByteMaskedArray\", \"mask\": \"i8\", "
1815 content_.form() +
", \"valid_when\": " + form_valid_when.str() +
1816 params +
", \"form_key\": \"" + form_key.str() +
"\" }";
1829 std::string parameters_;
1835 bool valid_when_ = VALID_WHEN;
1854 template <
bool VALID_WHEN,
bool LSB_ORDER,
typename BUILDER>
1861 current_byte_(uint8_t(0)),
1862 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
1867 for (
size_t i = 0; i < 8; i++) {
1871 for (
size_t i = 0; i < 8; i++) {
1872 cast_[i] = 128 >> i;
1884 current_byte_(uint8_t(0)),
1885 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
1890 for (
size_t i = 0; i < 8; i++) {
1894 for (
size_t i = 0; i < 8; i++) {
1895 cast_[i] = 128 >> i;
1926 current_byte_ |= cast_[current_index_];
1939 for (
size_t i = 0; i < size; i++) {
1962 for (
size_t i = 0; i < size; i++) {
1977 parameters_ = parameter;
1985 content_.set_id(
id);
2002 return mask_.
length() > 0 ?
2003 (mask_.
length() - 1) * 8 + current_index_ : current_index_;
2009 if (content_.length() !=
length()) {
2010 std::stringstream out;
2011 out <<
"BitMasked node" << id_ <<
"has content length "
2012 << content_.length() <<
"but bit mask length " << mask_.
length()
2014 error.append(out.str());
2018 return content_.is_valid(error);
2027 names_nbytes[
"node" + std::to_string(id_) +
"-mask"] = mask_.
nbytes();
2028 content_.buffer_nbytes(names_nbytes);
2037 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
2039 buffers[
"node" + std::to_string(id_) +
"-mask"]), 0, 1);
2040 mask_.
append(
reinterpret_cast<uint8_t*
>(
2041 buffers[
"node" + std::to_string(id_) +
"-mask"]), mask_.
length() - 1, 0, 1);
2042 content_.to_buffers(buffers);
2051 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-mask")) {
2053 mask_.
append(
reinterpret_cast<uint8_t*
>(buffer), mask_.
length() - 1, 0, 1);
2055 content_.to_buffer(buffer, name);
2065 buffers[
"node" + std::to_string(id_) +
"-mask"]), 0, 1);
2066 mask_.
append(
reinterpret_cast<uint8_t*
>(
2067 buffers[
"node" + std::to_string(id_) +
"-mask"]), mask_.
length() - 1, 0, 1);
2068 content_.to_char_buffers(buffers);
2075 std::stringstream form_key, form_valid_when, form_lsb_order;
2076 form_key <<
"node" << id_;
2077 form_valid_when << std::boolalpha << valid_when_;
2078 form_lsb_order << std::boolalpha << lsb_order_;
2079 std::string params(
"");
2080 if (parameters_ ==
"") {
2082 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
2084 return "{ \"class\": \"BitMaskedArray\", \"mask\": \"u8\", "
2086 content_.form() +
", \"valid_when\": " + form_valid_when.str() +
2087 ", \"lsb_order\": " + form_lsb_order.str() + params +
2088 ", \"form_key\": \"" + form_key.str() +
"\" }";
2097 if (current_index_ == 8) {
2099 current_byte_ = uint8_t(0);
2111 current_index_ += 1;
2113 current_byte_ref_ = current_byte_;
2115 current_byte_ref_ = ~current_byte_;
2122 GrowableBuffer<uint8_t> mask_;
2128 std::string parameters_;
2134 uint8_t current_byte_;
2137 uint8_t& current_byte_ref_;
2140 size_t current_index_;
2146 bool valid_when_ = VALID_WHEN;
2150 bool lsb_order_ = LSB_ORDER;
2168 template <
typename TAGS,
typename INDEX,
typename... BUILDERS>
2173 template <std::
size_t I>
2183 for (
size_t i = 0; i < contents_count_; i++) {
2184 last_valid_index_[i] = -1;
2198 for (
size_t i = 0; i < contents_count_; i++) {
2199 last_valid_index_[i] = -1;
2203 template <std::
size_t I>
2206 return std::get<I>(contents_);
2211 template <std::
size_t TAG>
2214 auto& which_content = std::get<TAG>(contents_);
2215 INDEX next_index = which_content.length();
2217 TAGS tag = (TAGS)TAG;
2218 last_valid_index_[tag] = next_index;
2220 index_.
append(next_index);
2222 return which_content;
2234 parameters_ = parameter;
2242 auto contents_id = [&id](
auto&
content) {
2245 for (
size_t i = 0; i < contents_count_; i++) {
2246 visit_at(contents_, i, contents_id);
2256 for (
size_t i = 0; i < contents_count_; i++) {
2257 last_valid_index_[i] = -1;
2261 auto clear_contents = [](
auto&
content) {
2264 for (
size_t i = 0; i < contents_count_; i++) {
2265 visit_at(contents_, i, clear_contents);
2278 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2280 std::vector<size_t> lengths = content_lengths(index_sequence);
2281 for (
size_t tag = 0; tag < contents_count_; tag++) {
2282 if (lengths[tag] != last_valid_index_[tag] + 1) {
2283 std::stringstream out;
2284 out <<
"Union node" << id_ <<
" has content length " << lengths[tag]
2285 <<
" but index length " << last_valid_index_[tag] <<
"\n";
2286 error.append(out.str());
2292 std::vector<bool> valid_contents =
2293 content_is_valid(index_sequence, error);
2294 return std::none_of(std::cbegin(valid_contents),
2295 std::cend(valid_contents),
2296 std::logical_not<bool>());
2304 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2306 names_nbytes[
"node" + std::to_string(id_) +
"-tags"] = tags_.
nbytes();
2307 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.
nbytes();
2309 for (
size_t i = 0; i < contents_count_; i++) {
2311 content.buffer_nbytes(names_nbytes);
2322 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
2323 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2326 buffers[
"node" + std::to_string(id_) +
"-tags"]));
2328 buffers[
"node" + std::to_string(id_) +
"-index"]));
2330 for (
size_t i = 0; i < contents_count_; i++) {
2343 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2345 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-tags")) {
2346 tags_.
concatenate(
reinterpret_cast<TAGS*
>(buffer));
2348 else if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-index")) {
2349 index_.
concatenate(
reinterpret_cast<INDEX*
>(buffer));
2352 for (
size_t i = 0; i < contents_count_; i++) {
2354 content.to_buffer(buffer, name);
2365 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2368 buffers[
"node" + std::to_string(id_) +
"-tags"]));
2370 buffers[
"node" + std::to_string(id_) +
"-index"]));
2372 for (
size_t i = 0; i < contents_count_; i++) {
2374 content.to_char_buffers(buffers);
2383 std::stringstream form_key;
2384 form_key <<
"node" << id_;
2385 std::string params(
"");
2386 if (parameters_ ==
"") {
2388 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
2390 std::stringstream out;
2391 out <<
"{ \"class\": \"UnionArray\", \"tags\": \"" +
2392 type_to_numpy_like<TAGS>() +
"\", \"index\": \"" +
2393 type_to_numpy_like<INDEX>() +
"\", \"contents\": [";
2394 for (
size_t i = 0; i < contents_count_; i++) {
2398 auto contents_form = [&](
auto&
content) {
2401 visit_at(contents_, i, contents_form);
2404 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
2411 template <std::size_t... S>
2413 content_lengths(std::index_sequence<S...>)
const {
2414 return std::vector<size_t>({std::get<S>(contents_).length()...});
2418 template <std::size_t... S>
2420 content_is_valid(std::index_sequence<S...>, std::string& error)
const {
2421 return std::vector<bool>({std::get<S>(contents_).is_valid(error)...});
2427 GrowableBuffer<TAGS> tags_;
2432 GrowableBuffer<INDEX> index_;
2438 std::string parameters_;
2444 size_t last_valid_index_[
sizeof...(BUILDERS)];
2447 static constexpr size_t contents_count_ =
sizeof...(BUILDERS);
22 namespace LayoutBuilder {
…}
#define AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS
Object of BuilderOptions which sets the values of the default options.
Definition LayoutBuilder.h:18
virtual const std::string to_buffers(BuffersContainer &container, int64_t &form_key_id) const =0
Copy the current snapshot into the BuffersContainer and return a Form as a std::string (JSON).
virtual void clear()=0
Removes all accumulated data without resetting the type knowledge.
virtual const BuilderPtr index(int64_t index)=0
Sets the pointer to a given tuple field index; the next command will fill that slot.
Discontiguous, one-dimensional buffer (which consists of multiple contiguous, one-dimensional panels)...
Definition GrowableBuffer.h:233
void concatenate_from(PRIMITIVE *external_pointer, size_t to, size_t from) const noexcept
Copies and concatenates all accumulated data from multiple panels to one contiguously allocated exter...
Definition GrowableBuffer.h:517
size_t nbytes() const
Currently used number of bytes.
Definition GrowableBuffer.h:440
void concatenate(PRIMITIVE *external_pointer) const noexcept
Copies and concatenates all accumulated data from multiple panels to one contiguously allocated exter...
Definition GrowableBuffer.h:492
PRIMITIVE & append_and_get_ref(PRIMITIVE datum)
Like append, but the type signature returns the reference to PRIMITIVE.
Definition GrowableBuffer.h:484
size_t length() const
Currently used number of elements.
Definition GrowableBuffer.h:408
void append(PRIMITIVE datum)
Inserts one datum into the panel, possibly triggering allocation of a new panel.
Definition GrowableBuffer.h:450
void clear()
Discards accumulated data, the #reserved returns to options.initial(), and a new #ptr is allocated.
Definition GrowableBuffer.h:421
Builds a BitMaskedArray in which mask values are packed into a bitmap.
Definition LayoutBuilder.h:1855
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition LayoutBuilder.h:1908
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:1991
bool lsb_order() const noexcept
Determines whether the position of each bit is in Least-Significant Bit order (LSB) or not.
Definition LayoutBuilder.h:1915
BUILDER & append_invalid() noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:1949
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:1938
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:2074
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1970
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1976
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1902
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:2001
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:2063
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1982
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2008
BitMasked(const awkward::BuilderOptions &options)
Creates a new BitMasked layout builder by allocating a new mask buffer, taking options from BuilderOp...
Definition LayoutBuilder.h:1882
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:1924
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:2025
BUILDER & extend_invalid(size_t size) noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:1961
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:2050
BitMasked()
Creates a new BitMasked layout builder by allocating a new mask buffer, using AWKWARD_LAYOUTBUILDER_D...
Definition LayoutBuilder.h:1859
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:2037
Builds a ByteMaskedArray using a mask which is an array of booleans that determines whether the corre...
Definition LayoutBuilder.h:1630
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition LayoutBuilder.h:1659
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:1730
BUILDER & append_invalid() noexcept
Inserts !valid_when in the mask.
Definition LayoutBuilder.h:1689
BUILDER & extend_valid(size_t size) noexcept
Inserts size number of valid_when in the mask.
Definition LayoutBuilder.h:1678
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:1804
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1709
ByteMasked()
Creates a new ByteMasked layout builder by allocating a new mask buffer, using AWKWARD_LAYOUTBUILDER_...
Definition LayoutBuilder.h:1634
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1715
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1653
ByteMasked(const awkward::BuilderOptions &options)
Creates a new ByteMasked layout builder by allocating a new mask buffer, taking options from BuilderO...
Definition LayoutBuilder.h:1645
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:1737
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:1795
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1721
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1743
BUILDER & append_valid() noexcept
Inserts valid_when in the mask.
Definition LayoutBuilder.h:1667
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:1760
BUILDER & extend_invalid(size_t size) noexcept
Inserts size number of !valid_when in the mask.
Definition LayoutBuilder.h:1700
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:1783
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:1772
Builds an EmptyArray which has no content in it. It is used whenever an array's type is not known bec...
Definition LayoutBuilder.h:396
void clear() noexcept
Definition LayoutBuilder.h:408
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:418
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:442
void to_buffers(std::map< std::string, void * > &) const noexcept
Definition LayoutBuilder.h:427
void to_buffer(void *, const char *) const noexcept
Definition LayoutBuilder.h:430
Empty()
Creates a new Empty layout builder.
Definition LayoutBuilder.h:399
void set_id(size_t &) noexcept
Definition LayoutBuilder.h:405
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:412
void buffer_nbytes(std::map< std::string, size_t > &) const noexcept
Definition LayoutBuilder.h:423
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:437
Helper class for sending a pair of field names (as enum) and field type as template parameters in Rec...
Definition LayoutBuilder.h:32
std::string index_as_field() const
Converts index as field string.
Definition LayoutBuilder.h:38
BUILDER Builder
Definition LayoutBuilder.h:34
const std::size_t index
The index of a Record field.
Definition LayoutBuilder.h:43
Builder builder
The content type of field in a Record.
Definition LayoutBuilder.h:45
Builds an IndexedOptionArray which consists of an index buffer. The negative values in the index are ...
Definition LayoutBuilder.h:1286
void clear() noexcept
Discards the accumulated index and clears the content of the builder. Also, last valid returns to -1.
Definition LayoutBuilder.h:1379
void extend_invalid(size_t size) noexcept
Inserts -1 in the index buffer size number of times.
Definition LayoutBuilder.h:1350
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:1330
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:1454
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1358
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1364
IndexedOption(const awkward::BuilderOptions &options)
Creates a new IndexedOption layout builder by allocating a new index buffer, taking options from Buil...
Definition LayoutBuilder.h:1303
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1312
size_t length() const noexcept
Current length of the index buffer.
Definition LayoutBuilder.h:1387
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:1445
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1370
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1393
IndexedOption()
Creates a new IndexedOption layout builder by allocating a new index buffer, using AWKWARD_LAYOUTBUIL...
Definition LayoutBuilder.h:1290
BUILDER & append_valid() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1319
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:1410
void append_invalid() noexcept
Inserts -1 in the index buffer.
Definition LayoutBuilder.h:1342
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:1433
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:1422
Builds an IndexedArray which consists of an index buffer.
Definition LayoutBuilder.h:1098
void clear() noexcept
Discards the accumulated index and clears the content of the builder.
Definition LayoutBuilder.h:1171
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:1245
Indexed(const awkward::BuilderOptions &options)
Creates a new Indexed layout builder by allocating a new index buffer, taking options from BuilderOpt...
Definition LayoutBuilder.h:1114
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1150
Indexed()
Creates a new Indexed layout builder by allocating a new index buffer, using AWKWARD_LAYOUTBUILDER_DE...
Definition LayoutBuilder.h:1102
BUILDER & append_index() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1129
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1156
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1122
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:1139
size_t length() const noexcept
Current length of the index buffer.
Definition LayoutBuilder.h:1178
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:1236
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1162
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1193
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:1185
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:1224
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:1213
Builds a ListOffsetArray which describes unequal-length lists (often called a "jagged" or "ragged" ar...
Definition LayoutBuilder.h:220
void clear() noexcept
Discards the accumulated offsets and clears the builder content.
Definition LayoutBuilder.h:285
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the builder content.
Definition LayoutBuilder.h:252
ListOffset()
Creates a new ListOffset layout builder by allocating a new offset buffer, using AWKWARD_LAYOUTBUILDE...
Definition LayoutBuilder.h:224
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:361
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:265
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:271
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:246
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:293
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:352
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:277
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:299
void end_list() noexcept
Ends a list and appends the current length of the list contents in the offsets buffer.
Definition LayoutBuilder.h:259
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:316
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:340
ListOffset(const awkward::BuilderOptions &options)
Creates a new ListOffset layout builder by allocating a new offset buffer, taking options from Builde...
Definition LayoutBuilder.h:237
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:329
Builds a NumpyArray which describes multi-dimensional data of PRIMITIVE type.
Definition LayoutBuilder.h:55
void clear() noexcept
Discards the accumulated data in the builder.
Definition LayoutBuilder.h:112
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:124
Numpy(const awkward::BuilderOptions &options)
Creates a new Numpy layout builder by allocating a new buffer, taking options from BuilderOptions for...
Definition LayoutBuilder.h:71
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:93
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:99
size_t length() const noexcept
Current length of the data.
Definition LayoutBuilder.h:118
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition LayoutBuilder.h:161
void append(PRIMITIVE x) noexcept
Inserts a PRIMITIVE type data.
Definition LayoutBuilder.h:79
Numpy()
Creates a new Numpy layout builder by allocating a new buffer, using AWKWARD_LAYOUTBUILDER_DEFAULT_OP...
Definition LayoutBuilder.h:59
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:105
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Retrieves the name and size (in bytes) of the buffer.
Definition LayoutBuilder.h:130
void extend(PRIMITIVE *ptr, size_t size) noexcept
Inserts an entire array of PRIMITIVE type data.
Definition LayoutBuilder.h:87
void to_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:150
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a user-defined pointer.
Definition LayoutBuilder.h:141
std::string form() const
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition LayoutBuilder.h:169
Builds a RecordArray which represents an array of records, which can be of same or different types....
Definition LayoutBuilder.h:463
void clear() noexcept
Clears the builder contents.
Definition LayoutBuilder.h:550
Record()
Creates a new Record layout builder.
Definition LayoutBuilder.h:472
MAP UserDefinedMap
Definition LayoutBuilder.h:466
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:646
RecordFieldType< INDEX >::Builder & content() noexcept
Returns the reference to the builder contents at INDEX.
Definition LayoutBuilder.h:517
std::tuple_element_t< INDEX, RecordContents > RecordFieldType
Definition LayoutBuilder.h:469
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:484
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:523
typename std::tuple< BUILDERS... > RecordContents
Definition LayoutBuilder.h:465
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:529
size_t length() const noexcept
Current number of records in first field.
Definition LayoutBuilder.h:560
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:635
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:535
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:566
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:595
void set_fields(MAP user_defined_field_id_to_name_map) noexcept
Sets the field names.
Definition LayoutBuilder.h:510
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:622
const std::vector< std::string > fields() const noexcept
Returns a vector of strings sontaining all the field names.
Definition LayoutBuilder.h:493
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:610
RecordContents contents
The contents of the RecordArray.
Definition LayoutBuilder.h:675
Builds a RegularArray that describes lists that have the same length, a single integer size....
Definition LayoutBuilder.h:943
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:992
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the content of the builder.
Definition LayoutBuilder.h:960
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:1057
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:972
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:978
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:953
size_t length() const noexcept
Current number of lists of length SIZE.
Definition LayoutBuilder.h:999
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:1050
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:984
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1005
void end_list() noexcept
Ends a list and increments the number of lists.
Definition LayoutBuilder.h:966
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:1022
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:1041
Regular()
Creates a new Regular layout builder.
Definition LayoutBuilder.h:946
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:1033
Builds a RecordArray which represents an array of tuples which can be of same or different types with...
Definition LayoutBuilder.h:727
void clear() noexcept
Clears the builder contents.
Definition LayoutBuilder.h:775
TupleContents contents
The contents of the RecordArray without fields.
Definition LayoutBuilder.h:897
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:872
Tuple()
Creates a new Tuple layout builder.
Definition LayoutBuilder.h:735
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:749
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:755
size_t length() const noexcept
Current number of records in the first index of the tuple.
Definition LayoutBuilder.h:785
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:861
TupleContentType< INDEX > & content() noexcept
Returns the reference to the builder contents at INDEX.
Definition LayoutBuilder.h:743
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:761
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:791
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:821
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:848
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:836
Builds a UnionArray which represents data drawn from an ordered list of contents, which can have diff...
Definition LayoutBuilder.h:2169
void clear() noexcept
Discards the accumulated tags and index, and clears the builder contents.
Definition LayoutBuilder.h:2255
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:2193
typename std::tuple< BUILDERS... > Contents
Definition LayoutBuilder.h:2171
std::tuple_element_t< I, Contents > ContentType
Definition LayoutBuilder.h:2174
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:2213
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:2382
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:2227
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:2233
size_t length() const noexcept
Current length of the tags buffer.
Definition LayoutBuilder.h:2271
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:2364
Union()
Creates a new Union layout builder by allocating new tags and index buffers, using AWKWARD_LAYOUTBUIL...
Definition LayoutBuilder.h:2178
ContentType< I > & content() noexcept
Definition LayoutBuilder.h:2205
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:2239
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2277
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:2302
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:2342
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:2322
Builds an UnmaskedArray which the values are never, in fact, missing. It exists to satisfy systems th...
Definition LayoutBuilder.h:1499
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:1535
Unmasked()
Creates a new Unmasked layout builder.
Definition LayoutBuilder.h:1502
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:1589
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1515
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1521
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1509
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:1541
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:1582
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1527
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1547
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:1554
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:1573
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:1565
Definition ArrayBuilder.h:14
void visit_at(std::tuple< CONTENTs... > const &contents, size_t index, FUNCTION fun)
Visits the tuple contents at index.
Definition utils.h:263
Container for all configuration options needed by ArrayBuilder, GrowableBuffer, LayoutBuilder and the...
Definition BuilderOptions.h:20
std::map< std::size_t, std::string > UserDefinedMap
Definition test_1494-layout-builder.cpp:39