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);
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"]));
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);
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_;
395 template<
class PRIMITIVE>
405 for (
const auto& c: value) {
463 return "{ \"class\": \"EmptyArray\" }";
481 template <
class MAP = std::map<std::
size_t, std::
string>,
482 typename... BUILDERS>
488 template <std::
size_t INDEX>
495 map_fields(std::index_sequence_for<BUILDERS...>());
505 : content_names_(user_defined_field_id_to_name_map) {
506 assert(content_names_.size() == fields_count_);
512 const std::vector<std::string>
514 if (content_names_.empty()) {
517 std::vector<std::string> result;
518 for (
auto it : content_names_) {
519 result.emplace_back(it.second);
531 content_names_ = user_defined_field_id_to_name_map;
535 template <std::
size_t INDEX>
536 typename RecordFieldType<INDEX>::Builder&
538 return std::get<INDEX>(
contents).builder;
550 parameters_ = parameter;
558 for (
size_t i = 0; i < fields_count_; i++) {
571 for (
size_t i = 0; i < fields_count_; i++) {
581 return (std::get<0>(
contents).builder.length());
587 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
590 std::vector<size_t> lengths = field_lengths(index_sequence);
591 for (
size_t i = 0; i < lengths.size(); i++) {
595 else if (
length != (int64_t)lengths[i]) {
596 std::stringstream out;
597 out <<
"Record node" << id_ <<
" has field \""
598 <<
fields().at(i) <<
"\" length " << lengths[i]
599 <<
" that differs from the first length " <<
length <<
"\n";
600 error.append(out.str());
606 std::vector<bool> valid_fields = field_is_valid(index_sequence, error);
607 return std::none_of(std::cbegin(valid_fields),
608 std::cend(valid_fields),
609 std::logical_not<bool>());
617 for (
size_t i = 0; i < fields_count_; i++) {
619 content.builder.buffer_nbytes(names_nbytes);
630 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
631 for (
size_t i = 0; i < fields_count_; i++) {
642 to_buffer(
void* buffer,
const char* name)
const noexcept {
643 for (
size_t i = 0; i < fields_count_; i++) {
645 content.builder.to_buffer(buffer, name);
656 for (
size_t i = 0; i < fields_count_; i++) {
658 content.builder.to_char_buffers(buffers);
667 std::stringstream form_key;
668 form_key <<
"node" << id_;
669 std::string params(
"");
670 if (parameters_ ==
"") {
672 params = std::string(
"\"parameters\": { " + parameters_ +
" }, ");
674 std::stringstream out;
675 out <<
"{ \"class\": \"RecordArray\", \"contents\": { ";
676 for (
size_t i = 0; i < fields_count_; i++) {
680 auto contents_form = [&](
auto&
content) {
682 << (!content_names_.empty() ? content_names_.at(
content.
index)
690 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
700 template <std::size_t... S>
702 map_fields(std::index_sequence<S...>)
noexcept {
703 fields_ = std::vector<std::string>(
704 {std::string(std::get<S>(
contents).index_as_field())...});
709 template <std::size_t... S>
711 field_lengths(std::index_sequence<S...>)
const noexcept {
712 return std::vector<size_t>({std::get<S>(
contents).builder.length()...});
716 template <std::size_t... S>
718 field_is_valid(std::index_sequence<S...>, std::string& error)
const
720 return std::vector<bool>(
721 {std::get<S>(
contents).builder.is_valid(error)...});
725 std::vector<std::string> fields_;
731 std::string parameters_;
737 static constexpr size_t fields_count_ =
sizeof...(BUILDERS);
746 template <
typename... BUILDERS>
748 using TupleContents =
typename std::tuple<BUILDERS...>;
750 template <std::
size_t INDEX>
751 using TupleContentType = std::tuple_element_t<INDEX, TupleContents>;
761 template <std::
size_t INDEX>
762 TupleContentType<INDEX>&
776 parameters_ = parameter;
784 for (
size_t i = 0; i < fields_count_; i++) {
796 for (
size_t i = 0; i < fields_count_; i++) {
812 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
815 std::vector<size_t> lengths = content_lengths(index_sequence);
816 for (
size_t i = 0; i < lengths.size(); i++) {
818 length = (int64_t)lengths[i];
820 else if (
length != (int64_t)lengths[i]) {
821 std::stringstream out;
822 out <<
"Record node" << id_ <<
" has index \"" << i <<
"\" length "
823 << lengths[i] <<
" that differs from the first length "
825 error.append(out.str());
831 std::vector<bool> valid_fields =
832 content_is_valid(index_sequence, error);
833 return std::none_of(std::cbegin(valid_fields),
834 std::cend(valid_fields),
835 std::logical_not<bool>());
843 for (
size_t i = 0; i < fields_count_; i++) {
845 content.buffer_nbytes(names_nbytes);
856 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
857 for (
size_t i = 0; i < fields_count_; i++) {
868 to_buffer(
void* buffer,
const char* name)
const noexcept {
869 for (
size_t i = 0; i < fields_count_; i++) {
871 content.to_buffer(buffer, name);
882 for (
size_t i = 0; i < fields_count_; i++) {
884 content.to_char_buffers(buffers);
893 std::stringstream form_key;
894 form_key <<
"node" << id_;
895 std::string params(
"");
896 if (parameters_ ==
"") {
898 params = std::string(
"\"parameters\": { " + parameters_ +
" }, ");
900 std::stringstream out;
901 out <<
"{ \"class\": \"RecordArray\", \"contents\": [";
902 for (
size_t i = 0; i < fields_count_; i++) {
906 auto contents_form = [&out](
auto&
content) {
912 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
922 template <std::size_t... S>
924 content_lengths(std::index_sequence<S...>)
const noexcept {
925 return std::vector<size_t>({std::get<S>(
contents).length()...});
929 template <std::size_t... S>
931 content_is_valid(std::index_sequence<S...>, std::string& error)
const
933 return std::vector<bool>({std::get<S>(
contents).is_valid(error)...});
937 std::vector<int64_t> field_index_;
940 std::string parameters_;
946 static constexpr size_t fields_count_ =
sizeof...(BUILDERS);
962 template <
unsigned SIZE,
typename BUILDER>
999 parameters_ = parameter;
1007 content_.set_id(
id);
1026 if (content_.length() != length_ * size_) {
1027 std::stringstream out;
1028 out <<
"Regular node" << id_ <<
"has content length "
1029 << content_.length() <<
", but length " << length_ <<
" and size "
1031 error.append(out.str());
1035 return content_.is_valid(error);
1044 content_.buffer_nbytes(names_nbytes);
1053 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1054 content_.to_buffers(buffers);
1062 content_.to_buffer(buffer, name);
1071 content_.to_char_buffers(buffers);
1078 std::stringstream form_key;
1079 form_key <<
"node" << id_;
1080 std::string params(
"");
1081 if (parameters_ ==
"") {
1083 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1085 return "{ \"class\": \"RegularArray\", \"content\": " +
1086 content_.form() +
", \"size\": " + std::to_string(size_) +
1087 params +
", \"form_key\": \"" + form_key.str() +
"\" }";
1095 std::string parameters_;
1104 size_t size_ = SIZE;
1117 template <
typename PRIMITIVE,
typename BUILDER>
1160 if (i > max_index_) {
1163 max_index_ = UINTMAX_MAX;
1174 size_t start = content_.length();
1175 size_t stop = start + size;
1176 if (stop - 1 > max_index_) {
1177 max_index_ = stop - 1;
1179 for (
size_t i = start; i < stop; i++) {
1194 parameters_ = parameter;
1202 content_.set_id(
id);
1217 return index_.length();
1225 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
1226 content_.buffer_nbytes(names_nbytes);
1233 if (max_index_ == UINTMAX_MAX) {
1234 std::stringstream out;
1235 out <<
"Indexed node" << id_ <<
" has a negative index\n";
1236 error.append(out.str());
1238 }
else if ((content_.length() == 0) && (max_index_ == 0)) {
1239 }
else if (max_index_ >= content_.length()) {
1240 std::stringstream out;
1241 out <<
"Indexed node" << id_ <<
" has index " << max_index_
1242 <<
" but content has length "
1243 << content_.length() <<
"\n";
1244 error.append(out.str());
1247 return content_.is_valid(error);
1256 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1257 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1258 buffers[
"node" + std::to_string(id_) +
"-index"]));
1259 content_.to_buffers(buffers);
1268 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-index")) {
1269 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
1271 content_.to_buffer(buffer, name);
1280 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1281 buffers[
"node" + std::to_string(id_) +
"-index"]));
1282 content_.to_char_buffers(buffers);
1289 std::stringstream form_key;
1290 form_key <<
"node" << id_;
1291 std::string params(
"");
1292 if (parameters_ ==
"") {
1294 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1296 return "{ \"class\": \"IndexedArray\", \"index\": \"" +
1297 type_to_numpy_like<PRIMITIVE>() +
1298 "\", \"content\": " + content_.form() + params +
1299 ", \"form_key\": \"" + form_key.str() +
"\" }";
1312 std::string parameters_;
1331 template <
typename PRIMITIVE,
typename BUILDER>
1368 last_valid_ = content_.length();
1376 last_valid_ = content_.length();
1378 if (i > max_index_) {
1390 size_t start = content_.length();
1391 size_t stop = start + size;
1392 last_valid_ = stop - 1;
1393 if (last_valid_ > max_index_) {
1394 max_index_ = last_valid_;
1396 for (
size_t i = start; i < stop; i++) {
1413 for (
size_t i = 0; i < size; i++) {
1427 parameters_ = parameter;
1435 content_.set_id(
id);
1450 return index_.length();
1456 if ((content_.length() == 0) && (max_index_ == 0)) {
1457 }
else if (max_index_ >= content_.length()) {
1458 std::stringstream out;
1459 out <<
"IndexedOption node" << id_ <<
" has index " << max_index_
1460 <<
" but content has length "
1461 << content_.length() <<
"\n";
1462 error.append(out.str());
1466 return content_.is_valid(error);
1474 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
1475 content_.buffer_nbytes(names_nbytes);
1484 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1485 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1486 buffers[
"node" + std::to_string(id_) +
"-index"]));
1487 content_.to_buffers(buffers);
1496 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-index")) {
1497 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
1499 content_.to_buffer(buffer, name);
1508 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1509 buffers[
"node" + std::to_string(id_) +
"-index"]));
1510 content_.to_char_buffers(buffers);
1517 std::stringstream form_key;
1518 form_key <<
"node" << id_;
1519 std::string params(
"");
1520 if (parameters_ ==
"") {
1522 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1524 return "{ \"class\": \"IndexedOptionArray\", \"index\": \"" +
1525 type_to_numpy_like<PRIMITIVE>() +
1526 "\", \"content\": " + content_.form() + params +
1527 ", \"form_key\": \"" + form_key.str() +
"\" }";
1540 std::string parameters_;
1563 template <
typename BUILDER>
1587 parameters_ = parameter;
1595 content_.set_id(
id);
1607 return content_.length();
1613 return content_.is_valid(error);
1621 content_.buffer_nbytes(names_nbytes);
1630 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1631 content_.to_buffers(buffers);
1639 content_.to_buffer(buffer, name);
1648 content_.to_char_buffers(buffers);
1655 std::stringstream form_key;
1656 form_key <<
"node" << id_;
1657 std::string params(
"");
1658 if (parameters_ ==
"") {
1660 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1662 return "{ \"class\": \"UnmaskedArray\", \"content\": " +
1663 content_.form() + params +
", \"form_key\": \"" +
1664 form_key.str() +
"\" }";
1672 std::string parameters_;
1694 template <
bool VALID_WHEN,
typename BUILDER>
1733 mask_.
append(valid_when_);
1744 for (
size_t i = 0; i < size; i++) {
1745 mask_.
append(valid_when_);
1755 mask_.
append(!valid_when_);
1766 for (
size_t i = 0; i < size; i++) {
1767 mask_.
append(!valid_when_);
1781 parameters_ = parameter;
1789 content_.set_id(
id);
1809 if (content_.length() != mask_.
length()) {
1810 std::stringstream out;
1811 out <<
"ByteMasked node" << id_ <<
"has content length "
1812 << content_.length() <<
"but mask length " << mask_.
length()
1814 error.append(out.str());
1818 return content_.is_valid(error);
1827 names_nbytes[
"node" + std::to_string(id_) +
"-mask"] = mask_.
nbytes();
1828 content_.buffer_nbytes(names_nbytes);
1837 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1839 buffers[
"node" + std::to_string(id_) +
"-mask"]));
1840 content_.to_buffers(buffers);
1849 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-mask")) {
1850 mask_.
concatenate(
reinterpret_cast<int8_t*
>(buffer));
1852 content_.to_buffer(buffer, name);
1862 buffers[
"node" + std::to_string(id_) +
"-mask"]));
1863 content_.to_char_buffers(buffers);
1870 std::stringstream form_key, form_valid_when;
1871 form_key <<
"node" << id_;
1872 form_valid_when << std::boolalpha << valid_when_;
1873 std::string params(
"");
1874 if (parameters_ ==
"") {
1876 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1878 return "{ \"class\": \"ByteMaskedArray\", \"mask\": \"i8\", "
1880 content_.form() +
", \"valid_when\": " + form_valid_when.str() +
1881 params +
", \"form_key\": \"" + form_key.str() +
"\" }";
1894 std::string parameters_;
1900 bool valid_when_ = VALID_WHEN;
1919 template <
bool VALID_WHEN,
bool LSB_ORDER,
typename BUILDER>
1926 current_byte_(uint8_t(0)),
1927 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
1932 for (
size_t i = 0; i < 8; i++) {
1936 for (
size_t i = 0; i < 8; i++) {
1937 cast_[i] = 128 >> i;
1949 current_byte_(uint8_t(0)),
1950 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
1955 for (
size_t i = 0; i < 8; i++) {
1959 for (
size_t i = 0; i < 8; i++) {
1960 cast_[i] = 128 >> i;
1991 current_byte_ |= cast_[current_index_];
2004 for (
size_t i = 0; i < size; i++) {
2027 for (
size_t i = 0; i < size; i++) {
2042 parameters_ = parameter;
2050 content_.set_id(
id);
2067 return mask_.
length() > 0 ?
2068 (mask_.
length() - 1) * 8 + current_index_ : current_index_;
2074 if (content_.length() !=
length()) {
2075 std::stringstream out;
2076 out <<
"BitMasked node" << id_ <<
"has content length "
2077 << content_.length() <<
"but bit mask length " << mask_.
length()
2079 error.append(out.str());
2083 return content_.is_valid(error);
2092 names_nbytes[
"node" + std::to_string(id_) +
"-mask"] = mask_.
nbytes();
2093 content_.buffer_nbytes(names_nbytes);
2102 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
2104 buffers[
"node" + std::to_string(id_) +
"-mask"]), 0, 1);
2105 mask_.
append(
reinterpret_cast<uint8_t*
>(
2106 buffers[
"node" + std::to_string(id_) +
"-mask"]), mask_.
length() - 1, 0, 1);
2107 content_.to_buffers(buffers);
2116 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-mask")) {
2118 mask_.
append(
reinterpret_cast<uint8_t*
>(buffer), mask_.
length() - 1, 0, 1);
2120 content_.to_buffer(buffer, name);
2130 buffers[
"node" + std::to_string(id_) +
"-mask"]), 0, 1);
2131 mask_.
append(
reinterpret_cast<uint8_t*
>(
2132 buffers[
"node" + std::to_string(id_) +
"-mask"]), mask_.
length() - 1, 0, 1);
2133 content_.to_char_buffers(buffers);
2140 std::stringstream form_key, form_valid_when, form_lsb_order;
2141 form_key <<
"node" << id_;
2142 form_valid_when << std::boolalpha << valid_when_;
2143 form_lsb_order << std::boolalpha << lsb_order_;
2144 std::string params(
"");
2145 if (parameters_ ==
"") {
2147 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
2149 return "{ \"class\": \"BitMaskedArray\", \"mask\": \"u8\", "
2151 content_.form() +
", \"valid_when\": " + form_valid_when.str() +
2152 ", \"lsb_order\": " + form_lsb_order.str() + params +
2153 ", \"form_key\": \"" + form_key.str() +
"\" }";
2162 if (current_index_ == 8) {
2164 current_byte_ = uint8_t(0);
2176 current_index_ += 1;
2178 current_byte_ref_ = current_byte_;
2180 current_byte_ref_ = ~current_byte_;
2187 GrowableBuffer<uint8_t> mask_;
2193 std::string parameters_;
2199 uint8_t current_byte_;
2202 uint8_t& current_byte_ref_;
2205 size_t current_index_;
2211 bool valid_when_ = VALID_WHEN;
2215 bool lsb_order_ = LSB_ORDER;
2233 template <
typename TAGS,
typename INDEX,
typename... BUILDERS>
2238 template <std::
size_t I>
2248 for (
size_t i = 0; i < contents_count_; i++) {
2249 last_valid_index_[i] = -1;
2263 for (
size_t i = 0; i < contents_count_; i++) {
2264 last_valid_index_[i] = -1;
2268 template <std::
size_t I>
2271 return std::get<I>(contents_);
2276 template <std::
size_t TAG>
2279 auto& which_content = std::get<TAG>(contents_);
2280 INDEX next_index = which_content.length();
2282 TAGS tag = (TAGS)TAG;
2283 last_valid_index_[tag] = next_index;
2285 index_.
append(next_index);
2287 return which_content;
2299 parameters_ = parameter;
2307 auto contents_id = [&id](
auto&
content) {
2310 for (
size_t i = 0; i < contents_count_; i++) {
2311 visit_at(contents_, i, contents_id);
2321 for (
size_t i = 0; i < contents_count_; i++) {
2322 last_valid_index_[i] = -1;
2326 auto clear_contents = [](
auto&
content) {
2329 for (
size_t i = 0; i < contents_count_; i++) {
2330 visit_at(contents_, i, clear_contents);
2343 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2345 std::vector<size_t> lengths = content_lengths(index_sequence);
2346 std::unique_ptr<INDEX[]> index_ptr(
new INDEX[index_.
length()]);
2348 std::unique_ptr<TAGS[]> tags_ptr(
new TAGS[tags_.
length()]);
2350 for (
size_t i = 0; i < index_.
length(); i++) {
2351 if (index_ptr.get()[i] < 0 || index_ptr.get()[i] >= lengths[tags_ptr.get()[i]]) {
2352 std::stringstream out;
2353 out <<
"Union node" << id_ <<
" has index " << index_ptr.get()[i]
2354 <<
" at position " << i <<
" but content has length "
2355 << lengths[tags_ptr.get()[i]] <<
"\n";
2356 error.append(out.str());
2362 std::vector<bool> valid_contents =
2363 content_is_valid(index_sequence, error);
2364 return std::none_of(std::cbegin(valid_contents),
2365 std::cend(valid_contents),
2366 std::logical_not<bool>());
2374 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2376 names_nbytes[
"node" + std::to_string(id_) +
"-tags"] = tags_.
nbytes();
2377 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.
nbytes();
2379 for (
size_t i = 0; i < contents_count_; i++) {
2381 content.buffer_nbytes(names_nbytes);
2392 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
2393 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2396 buffers[
"node" + std::to_string(id_) +
"-tags"]));
2398 buffers[
"node" + std::to_string(id_) +
"-index"]));
2400 for (
size_t i = 0; i < contents_count_; i++) {
2413 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2415 if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-tags")) {
2416 tags_.
concatenate(
reinterpret_cast<TAGS*
>(buffer));
2418 else if (std::string(name) == std::string(
"node" + std::to_string(id_) +
"-index")) {
2419 index_.
concatenate(
reinterpret_cast<INDEX*
>(buffer));
2422 for (
size_t i = 0; i < contents_count_; i++) {
2424 content.to_buffer(buffer, name);
2435 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2438 buffers[
"node" + std::to_string(id_) +
"-tags"]));
2440 buffers[
"node" + std::to_string(id_) +
"-index"]));
2442 for (
size_t i = 0; i < contents_count_; i++) {
2444 content.to_char_buffers(buffers);
2453 std::stringstream form_key;
2454 form_key <<
"node" << id_;
2455 std::string params(
"");
2456 if (parameters_ ==
"") {
2458 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
2460 std::stringstream out;
2461 out <<
"{ \"class\": \"UnionArray\", \"tags\": \"" +
2462 type_to_numpy_like<TAGS>() +
"\", \"index\": \"" +
2463 type_to_numpy_like<INDEX>() +
"\", \"contents\": [";
2464 for (
size_t i = 0; i < contents_count_; i++) {
2468 auto contents_form = [&](
auto&
content) {
2471 visit_at(contents_, i, contents_form);
2474 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
2481 template <std::size_t... S>
2483 content_lengths(std::index_sequence<S...>)
const {
2484 return std::vector<size_t>({std::get<S>(contents_).length()...});
2488 template <std::size_t... S>
2490 content_is_valid(std::index_sequence<S...>, std::string& error)
const {
2491 return std::vector<bool>({std::get<S>(contents_).is_valid(error)...});
2497 GrowableBuffer<TAGS> tags_;
2502 GrowableBuffer<INDEX> index_;
2508 std::string parameters_;
2514 size_t last_valid_index_[
sizeof...(BUILDERS)];
2517 static constexpr size_t contents_count_ =
sizeof...(BUILDERS);
#define AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS
Object of BuilderOptions which sets the values of the default options.
Definition LayoutBuilder.h:18
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:1920
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition LayoutBuilder.h:1973
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:2056
bool lsb_order() const noexcept
Determines whether the position of each bit is in Least-Significant Bit order (LSB) or not.
Definition LayoutBuilder.h:1980
BUILDER & append_invalid() noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:2014
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:2003
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:2139
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:2035
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:2041
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1967
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:2066
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:2128
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:2047
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2073
BitMasked(const awkward::BuilderOptions &options)
Creates a new BitMasked layout builder by allocating a new mask buffer, taking options from BuilderOp...
Definition LayoutBuilder.h:1947
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:1989
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:2090
BUILDER & extend_invalid(size_t size) noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:2026
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:2115
BitMasked()
Creates a new BitMasked layout builder by allocating a new mask buffer, using AWKWARD_LAYOUTBUILDER_D...
Definition LayoutBuilder.h:1924
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:2102
Builds a ByteMaskedArray using a mask which is an array of booleans that determines whether the corre...
Definition LayoutBuilder.h:1695
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition LayoutBuilder.h:1724
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:1795
BUILDER & append_invalid() noexcept
Inserts !valid_when in the mask.
Definition LayoutBuilder.h:1754
BUILDER & extend_valid(size_t size) noexcept
Inserts size number of valid_when in the mask.
Definition LayoutBuilder.h:1743
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:1869
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1774
ByteMasked()
Creates a new ByteMasked layout builder by allocating a new mask buffer, using AWKWARD_LAYOUTBUILDER_...
Definition LayoutBuilder.h:1699
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1780
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1718
ByteMasked(const awkward::BuilderOptions &options)
Creates a new ByteMasked layout builder by allocating a new mask buffer, taking options from BuilderO...
Definition LayoutBuilder.h:1710
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:1802
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:1860
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1786
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1808
BUILDER & append_valid() noexcept
Inserts valid_when in the mask.
Definition LayoutBuilder.h:1732
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:1825
BUILDER & extend_invalid(size_t size) noexcept
Inserts size number of !valid_when in the mask.
Definition LayoutBuilder.h:1765
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:1848
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:1837
Builds an EmptyArray which has no content in it. It is used whenever an array's type is not known bec...
Definition LayoutBuilder.h:416
void clear() noexcept
Definition LayoutBuilder.h:428
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:438
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:462
void to_buffers(std::map< std::string, void * > &) const noexcept
Definition LayoutBuilder.h:447
void to_buffer(void *, const char *) const noexcept
Definition LayoutBuilder.h:450
Empty()
Creates a new Empty layout builder.
Definition LayoutBuilder.h:419
void set_id(size_t &) noexcept
Definition LayoutBuilder.h:425
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:432
void buffer_nbytes(std::map< std::string, size_t > &) const noexcept
Definition LayoutBuilder.h:443
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:457
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:1332
void clear() noexcept
Discards the accumulated index and clears the content of the builder. Also, last valid returns to -1.
Definition LayoutBuilder.h:1441
void extend_invalid(size_t size) noexcept
Inserts -1 in the index buffer size number of times.
Definition LayoutBuilder.h:1412
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:1389
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:1516
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1420
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1426
IndexedOption(const awkward::BuilderOptions &options)
Creates a new IndexedOption layout builder by allocating a new index buffer, taking options from Buil...
Definition LayoutBuilder.h:1350
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1360
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:1375
size_t length() const noexcept
Current length of the index buffer.
Definition LayoutBuilder.h:1449
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:1507
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1432
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1455
IndexedOption()
Creates a new IndexedOption layout builder by allocating a new index buffer, using AWKWARD_LAYOUTBUIL...
Definition LayoutBuilder.h:1336
BUILDER & append_valid() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1367
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:1472
void append_invalid() noexcept
Inserts -1 in the index buffer.
Definition LayoutBuilder.h:1404
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:1495
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:1484
Builds an IndexedArray which consists of an index buffer.
Definition LayoutBuilder.h:1118
void clear() noexcept
Discards the accumulated index and clears the content of the builder.
Definition LayoutBuilder.h:1208
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:1288
Indexed(const awkward::BuilderOptions &options)
Creates a new Indexed layout builder by allocating a new index buffer, taking options from BuilderOpt...
Definition LayoutBuilder.h:1135
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1187
Indexed()
Creates a new Indexed layout builder by allocating a new index buffer, using AWKWARD_LAYOUTBUILDER_DE...
Definition LayoutBuilder.h:1122
BUILDER & append_index() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1151
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1193
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1144
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:1173
size_t length() const noexcept
Current length of the index buffer.
Definition LayoutBuilder.h:1216
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:1279
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1199
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1231
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:1223
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:1267
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:1256
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:1158
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:483
void clear() noexcept
Clears the builder contents.
Definition LayoutBuilder.h:570
Record()
Creates a new Record layout builder.
Definition LayoutBuilder.h:492
MAP UserDefinedMap
Definition LayoutBuilder.h:486
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:666
RecordFieldType< INDEX >::Builder & content() noexcept
Returns the reference to the builder contents at INDEX.
Definition LayoutBuilder.h:537
std::tuple_element_t< INDEX, RecordContents > RecordFieldType
Definition LayoutBuilder.h:489
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:504
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:543
typename std::tuple< BUILDERS... > RecordContents
Definition LayoutBuilder.h:485
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:549
size_t length() const noexcept
Current number of records in first field.
Definition LayoutBuilder.h:580
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:655
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:555
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:586
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:615
void set_fields(MAP user_defined_field_id_to_name_map) noexcept
Sets the field names.
Definition LayoutBuilder.h:530
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:642
const std::vector< std::string > fields() const noexcept
Returns a vector of strings sontaining all the field names.
Definition LayoutBuilder.h:513
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:630
RecordContents contents
The contents of the RecordArray.
Definition LayoutBuilder.h:695
Builds a RegularArray that describes lists that have the same length, a single integer size....
Definition LayoutBuilder.h:963
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:1012
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the content of the builder.
Definition LayoutBuilder.h:980
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:1077
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:992
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:998
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:973
size_t length() const noexcept
Current number of lists of length SIZE.
Definition LayoutBuilder.h:1019
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:1070
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1004
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1025
void end_list() noexcept
Ends a list and increments the number of lists.
Definition LayoutBuilder.h:986
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:1042
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:1061
Regular()
Creates a new Regular layout builder.
Definition LayoutBuilder.h:966
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:1053
Helper for building an array of strings with a similar API as a Numpy builder.
Definition LayoutBuilder.h:396
void append(const std::string &value)
Definition LayoutBuilder.h:403
String()
Definition LayoutBuilder.h:398
Builds a RecordArray which represents an array of tuples which can be of same or different types with...
Definition LayoutBuilder.h:747
void clear() noexcept
Clears the builder contents.
Definition LayoutBuilder.h:795
TupleContents contents
The contents of the RecordArray without fields.
Definition LayoutBuilder.h:917
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:892
Tuple()
Creates a new Tuple layout builder.
Definition LayoutBuilder.h:755
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:769
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:775
size_t length() const noexcept
Current number of records in the first index of the tuple.
Definition LayoutBuilder.h:805
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:881
TupleContentType< INDEX > & content() noexcept
Returns the reference to the builder contents at INDEX.
Definition LayoutBuilder.h:763
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:781
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:811
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:841
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:868
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:856
Builds a UnionArray which represents data drawn from an ordered list of contents, which can have diff...
Definition LayoutBuilder.h:2234
void clear() noexcept
Discards the accumulated tags and index, and clears the builder contents.
Definition LayoutBuilder.h:2320
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:2258
typename std::tuple< BUILDERS... > Contents
Definition LayoutBuilder.h:2236
std::tuple_element_t< I, Contents > ContentType
Definition LayoutBuilder.h:2239
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:2278
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:2452
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:2292
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:2298
size_t length() const noexcept
Current length of the tags buffer.
Definition LayoutBuilder.h:2336
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:2434
Union()
Creates a new Union layout builder by allocating new tags and index buffers, using AWKWARD_LAYOUTBUIL...
Definition LayoutBuilder.h:2243
ContentType< I > & content() noexcept
Definition LayoutBuilder.h:2270
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:2304
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2342
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:2372
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:2412
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:2392
Builds an UnmaskedArray which the values are never, in fact, missing. It exists to satisfy systems th...
Definition LayoutBuilder.h:1564
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:1600
Unmasked()
Creates a new Unmasked layout builder.
Definition LayoutBuilder.h:1567
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:1654
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1580
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1586
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1574
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:1606
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:1647
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1592
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1612
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:1619
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:1638
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:1630
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