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"]));
152 data_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
153 buffers[
"node" + std::to_string(id_) +
"-data"]));
160 std::stringstream form_key;
161 form_key <<
"node" << id_;
163 std::string params(
"");
164 if (parameters_ ==
"") {
166 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
169 if (std::is_arithmetic<PRIMITIVE>::value) {
170 return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
171 type_to_name<PRIMITIVE>() +
"\"" + params +
172 ", \"form_key\": \"" + form_key.str() +
"\" }";
174 return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
175 type_to_name<PRIMITIVE>() +
"\"" + params +
176 ", \"form_key\": \"" + form_key.str() +
"\" }";
178 throw std::runtime_error(
"type " +
179 std::string(
typeid(PRIMITIVE).name()) +
189 std::string parameters_;
209 template <
typename PRIMITIVE,
typename BUILDER>
250 offsets_.append(content_.length());
262 parameters_ = parameter;
284 return offsets_.length() - 1;
290 if ((int64_t)content_.length() != (int64_t)offsets_.last()) {
291 std::stringstream out;
292 out <<
"ListOffset node" << id_ <<
"has content length "
293 << content_.length() <<
"but last offset " << offsets_.last()
295 error.append(out.str());
299 return content_.is_valid(error);
308 names_nbytes[
"node" + std::to_string(id_) +
"-offsets"] =
310 content_.buffer_nbytes(names_nbytes);
319 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
320 offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
321 buffers[
"node" + std::to_string(id_) +
"-offsets"]));
322 content_.to_buffers(buffers);
331 offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
332 buffers[
"node" + std::to_string(id_) +
"-offsets"]));
333 content_.to_char_buffers(buffers);
340 std::stringstream form_key;
341 form_key <<
"node" << id_;
342 std::string params(
"");
343 if (parameters_ ==
"") {
345 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
347 return "{ \"class\": \"ListOffsetArray\", \"offsets\": \"" +
348 type_to_numpy_like<PRIMITIVE>() +
349 "\", \"content\": " + content_.form() + params +
350 ", \"form_key\": \"" + form_key.str() +
"\" }";
363 std::string parameters_;
418 return "{ \"class\": \"EmptyArray\" }";
436 template <
class MAP = std::map<std::
size_t, std::
string>,
437 typename... BUILDERS>
443 template <std::
size_t INDEX>
450 map_fields(std::index_sequence_for<BUILDERS...>());
460 : content_names_(user_defined_field_id_to_name_map) {
461 assert(content_names_.size() == fields_count_);
467 const std::vector<std::string>
469 if (content_names_.empty()) {
472 std::vector<std::string> result;
473 for (
auto it : content_names_) {
474 result.emplace_back(it.second);
486 content_names_ = user_defined_field_id_to_name_map;
490 template <std::
size_t INDEX>
491 typename RecordFieldType<INDEX>::Builder&
493 return std::get<INDEX>(
contents).builder;
505 parameters_ = parameter;
513 for (
size_t i = 0; i < fields_count_; i++) {
526 for (
size_t i = 0; i < fields_count_; i++)
535 return (std::get<0>(
contents).builder.length());
541 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
544 std::vector<size_t> lengths = field_lengths(index_sequence);
545 for (
size_t i = 0; i < lengths.size(); i++) {
549 else if (
length != (int64_t)lengths[i]) {
550 std::stringstream out;
551 out <<
"Record node" << id_ <<
" has field \""
552 <<
fields().at(i) <<
"\" length " << lengths[i]
553 <<
" that differs from the first length " <<
length <<
"\n";
554 error.append(out.str());
560 std::vector<bool> valid_fields = field_is_valid(index_sequence, error);
561 return std::none_of(std::cbegin(valid_fields),
562 std::cend(valid_fields),
563 std::logical_not<bool>());
571 for (
size_t i = 0; i < fields_count_; i++)
573 content.builder.buffer_nbytes(names_nbytes);
583 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
584 for (
size_t i = 0; i < fields_count_; i++)
596 for (
size_t i = 0; i < fields_count_; i++)
598 content.builder.to_char_buffers(buffers);
606 std::stringstream form_key;
607 form_key <<
"node" << id_;
608 std::string params(
"");
609 if (parameters_ ==
"") {
611 params = std::string(
"\"parameters\": { " + parameters_ +
" }, ");
613 std::stringstream out;
614 out <<
"{ \"class\": \"RecordArray\", \"contents\": { ";
615 for (
size_t i = 0; i < fields_count_; i++) {
619 auto contents_form = [&](
auto&
content) {
621 << (!content_names_.empty() ? content_names_.at(
content.
index)
629 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
639 template <std::size_t... S>
641 map_fields(std::index_sequence<S...>)
noexcept {
642 fields_ = std::vector<std::string>(
643 {std::string(std::get<S>(
contents).index_as_field())...});
648 template <std::size_t... S>
650 field_lengths(std::index_sequence<S...>)
const noexcept {
651 return std::vector<size_t>({std::get<S>(
contents).builder.length()...});
655 template <std::size_t... S>
657 field_is_valid(std::index_sequence<S...>, std::string& error)
const
659 return std::vector<bool>(
660 {std::get<S>(
contents).builder.is_valid(error)...});
664 std::vector<std::string> fields_;
670 std::string parameters_;
676 static constexpr size_t fields_count_ =
sizeof...(BUILDERS);
685 template <
typename... BUILDERS>
687 using TupleContents =
typename std::tuple<BUILDERS...>;
689 template <std::
size_t INDEX>
690 using TupleContentType = std::tuple_element_t<INDEX, TupleContents>;
700 template <std::
size_t INDEX>
701 TupleContentType<INDEX>&
715 parameters_ = parameter;
723 for (
size_t i = 0; i < fields_count_; i++) {
735 for (
size_t i = 0; i < fields_count_; i++)
750 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
753 std::vector<size_t> lengths = content_lengths(index_sequence);
754 for (
size_t i = 0; i < lengths.size(); i++) {
756 length = (int64_t)lengths[i];
758 else if (
length != (int64_t)lengths[i]) {
759 std::stringstream out;
760 out <<
"Record node" << id_ <<
" has index \"" << i <<
"\" length "
761 << lengths[i] <<
" that differs from the first length "
763 error.append(out.str());
769 std::vector<bool> valid_fields =
770 content_is_valid(index_sequence, error);
771 return std::none_of(std::cbegin(valid_fields),
772 std::cend(valid_fields),
773 std::logical_not<bool>());
781 for (
size_t i = 0; i < fields_count_; i++)
783 content.buffer_nbytes(names_nbytes);
793 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
794 for (
size_t i = 0; i < fields_count_; i++)
806 for (
size_t i = 0; i < fields_count_; i++)
808 content.to_char_buffers(buffers);
816 std::stringstream form_key;
817 form_key <<
"node" << id_;
818 std::string params(
"");
819 if (parameters_ ==
"") {
821 params = std::string(
"\"parameters\": { " + parameters_ +
" }, ");
823 std::stringstream out;
824 out <<
"{ \"class\": \"RecordArray\", \"contents\": [";
825 for (
size_t i = 0; i < fields_count_; i++) {
829 auto contents_form = [&out](
auto&
content) {
835 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
845 template <std::size_t... S>
847 content_lengths(std::index_sequence<S...>)
const noexcept {
848 return std::vector<size_t>({std::get<S>(
contents).length()...});
852 template <std::size_t... S>
854 content_is_valid(std::index_sequence<S...>, std::string& error)
const
856 return std::vector<bool>({std::get<S>(
contents).is_valid(error)...});
860 std::vector<int64_t> field_index_;
863 std::string parameters_;
869 static constexpr size_t fields_count_ =
sizeof...(BUILDERS);
885 template <
unsigned SIZE,
typename BUILDER>
922 parameters_ = parameter;
949 if (content_.length() != length_ * size_) {
950 std::stringstream out;
951 out <<
"Regular node" << id_ <<
"has content length "
952 << content_.length() <<
", but length " << length_ <<
" and size "
954 error.append(out.str());
958 return content_.is_valid(error);
967 content_.buffer_nbytes(names_nbytes);
976 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
977 content_.to_buffers(buffers);
986 content_.to_char_buffers(buffers);
993 std::stringstream form_key;
994 form_key <<
"node" << id_;
995 std::string params(
"");
996 if (parameters_ ==
"") {
998 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1000 return "{ \"class\": \"RegularArray\", \"content\": " +
1001 content_.form() +
", \"size\": " + std::to_string(size_) +
1002 params +
", \"form_key\": \"" + form_key.str() +
"\" }";
1010 std::string parameters_;
1019 size_t size_ = SIZE;
1033 template <
typename PRIMITIVE,
typename BUILDER>
1068 last_valid_ = content_.length();
1069 index_.append(last_valid_);
1079 size_t start = content_.length();
1080 size_t stop = start + size;
1081 last_valid_ = stop - 1;
1082 for (
size_t i = start; i < stop; i++) {
1099 for (
size_t i = 0; i < size; i++) {
1113 parameters_ = parameter;
1121 content_.set_id(
id);
1136 return index_.length();
1142 if (content_.length() != last_valid_ + 1) {
1143 std::stringstream out;
1144 out <<
"IndexedOption node" << id_ <<
" has content length "
1145 << content_.length() <<
" but last valid index is " << last_valid_
1147 error.append(out.str());
1151 return content_.is_valid(error);
1160 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.nbytes();
1161 content_.buffer_nbytes(names_nbytes);
1170 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1171 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1172 buffers[
"node" + std::to_string(id_) +
"-index"]));
1173 content_.to_buffers(buffers);
1182 index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
1183 buffers[
"node" + std::to_string(id_) +
"-index"]));
1184 content_.to_char_buffers(buffers);
1191 std::stringstream form_key;
1192 form_key <<
"node" << id_;
1193 std::string params(
"");
1194 if (parameters_ ==
"") {
1196 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1198 return "{ \"class\": \"IndexedOptionArray\", \"index\": \"" +
1199 type_to_numpy_like<PRIMITIVE>() +
1200 "\", \"content\": " + content_.form() + params +
1201 ", \"form_key\": \"" + form_key.str() +
"\" }";
1214 std::string parameters_;
1234 template <
typename BUILDER>
1258 parameters_ = parameter;
1266 content_.set_id(
id);
1278 return content_.length();
1284 return content_.is_valid(error);
1292 content_.buffer_nbytes(names_nbytes);
1301 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1302 content_.to_buffers(buffers);
1311 content_.to_char_buffers(buffers);
1318 std::stringstream form_key;
1319 form_key <<
"node" << id_;
1320 std::string params(
"");
1321 if (parameters_ ==
"") {
1323 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1325 return "{ \"class\": \"UnmaskedArray\", \"content\": " +
1326 content_.form() + params +
", \"form_key\": \"" +
1327 form_key.str() +
"\" }";
1335 std::string parameters_;
1357 template <
bool VALID_WHEN,
typename BUILDER>
1396 mask_.
append(valid_when_);
1407 for (
size_t i = 0; i < size; i++) {
1408 mask_.
append(valid_when_);
1418 mask_.
append(!valid_when_);
1429 for (
size_t i = 0; i < size; i++) {
1430 mask_.
append(!valid_when_);
1444 parameters_ = parameter;
1452 content_.set_id(
id);
1472 if (content_.length() != mask_.
length()) {
1473 std::stringstream out;
1474 out <<
"ByteMasked node" << id_ <<
"has content length "
1475 << content_.length() <<
"but mask length " << mask_.
length()
1477 error.append(out.str());
1481 return content_.is_valid(error);
1490 names_nbytes[
"node" + std::to_string(id_) +
"-mask"] = mask_.
nbytes();
1491 content_.buffer_nbytes(names_nbytes);
1500 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1502 buffers[
"node" + std::to_string(id_) +
"-mask"]));
1503 content_.to_buffers(buffers);
1513 buffers[
"node" + std::to_string(id_) +
"-mask"]));
1514 content_.to_char_buffers(buffers);
1521 std::stringstream form_key, form_valid_when;
1522 form_key <<
"node" << id_;
1523 form_valid_when << std::boolalpha << valid_when_;
1524 std::string params(
"");
1525 if (parameters_ ==
"") {
1527 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1529 return "{ \"class\": \"ByteMaskedArray\", \"mask\": \"i8\", "
1531 content_.form() +
", \"valid_when\": " + form_valid_when.str() +
1532 params +
", \"form_key\": \"" + form_key.str() +
"\" }";
1545 std::string parameters_;
1551 bool valid_when_ = VALID_WHEN;
1570 template <
bool VALID_WHEN,
bool LSB_ORDER,
typename BUILDER>
1577 current_byte_(uint8_t(0)),
1578 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
1583 for (
size_t i = 0; i < 8; i++) {
1587 for (
size_t i = 0; i < 8; i++) {
1588 cast_[i] = 128 >> i;
1600 current_byte_(uint8_t(0)),
1601 current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
1606 for (
size_t i = 0; i < 8; i++) {
1610 for (
size_t i = 0; i < 8; i++) {
1611 cast_[i] = 128 >> i;
1642 current_byte_ |= cast_[current_index_];
1655 for (
size_t i = 0; i < size; i++) {
1678 for (
size_t i = 0; i < size; i++) {
1693 parameters_ = parameter;
1701 content_.set_id(
id);
1718 return mask_.
length() > 0 ?
1719 (mask_.
length() - 1) * 8 + current_index_ : current_index_;
1725 if (content_.length() !=
length()) {
1726 std::stringstream out;
1727 out <<
"BitMasked node" << id_ <<
"has content length "
1728 << content_.length() <<
"but bit mask length " << mask_.
length()
1730 error.append(out.str());
1734 return content_.is_valid(error);
1743 names_nbytes[
"node" + std::to_string(id_) +
"-mask"] = mask_.
nbytes();
1744 content_.buffer_nbytes(names_nbytes);
1753 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
1755 buffers[
"node" + std::to_string(id_) +
"-mask"]), 0, 1);
1756 mask_.
append(
reinterpret_cast<uint8_t*
>(
1757 buffers[
"node" + std::to_string(id_) +
"-mask"]), mask_.
length() - 1, 0, 1);
1758 content_.to_buffers(buffers);
1768 buffers[
"node" + std::to_string(id_) +
"-mask"]), 0, 1);
1769 mask_.
append(
reinterpret_cast<uint8_t*
>(
1770 buffers[
"node" + std::to_string(id_) +
"-mask"]), mask_.
length() - 1, 0, 1);
1771 content_.to_char_buffers(buffers);
1778 std::stringstream form_key, form_valid_when, form_lsb_order;
1779 form_key <<
"node" << id_;
1780 form_valid_when << std::boolalpha << valid_when_;
1781 form_lsb_order << std::boolalpha << lsb_order_;
1782 std::string params(
"");
1783 if (parameters_ ==
"") {
1785 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
1787 return "{ \"class\": \"BitMaskedArray\", \"mask\": \"u8\", "
1789 content_.form() +
", \"valid_when\": " + form_valid_when.str() +
1790 ", \"lsb_order\": " + form_lsb_order.str() + params +
1791 ", \"form_key\": \"" + form_key.str() +
"\" }";
1800 if (current_index_ == 8) {
1802 current_byte_ = uint8_t(0);
1814 current_index_ += 1;
1816 current_byte_ref_ = current_byte_;
1818 current_byte_ref_ = ~current_byte_;
1825 GrowableBuffer<uint8_t> mask_;
1831 std::string parameters_;
1837 uint8_t current_byte_;
1840 uint8_t& current_byte_ref_;
1843 size_t current_index_;
1849 bool valid_when_ = VALID_WHEN;
1853 bool lsb_order_ = LSB_ORDER;
1871 template <
typename TAGS,
typename INDEX,
typename... BUILDERS>
1876 template <std::
size_t I>
1886 for (
size_t i = 0; i < contents_count_; i++)
1887 last_valid_index_[i] = -1;
1900 for (
size_t i = 0; i < contents_count_; i++)
1901 last_valid_index_[i] = -1;
1904 template <std::
size_t I>
1907 return std::get<I>(contents_);
1912 template <std::
size_t TAG>
1915 auto& which_content = std::get<TAG>(contents_);
1916 INDEX next_index = which_content.length();
1918 TAGS tag = (TAGS)TAG;
1919 last_valid_index_[tag] = next_index;
1921 index_.
append(next_index);
1923 return which_content;
1935 parameters_ = parameter;
1943 auto contents_id = [&id](
auto&
content) {
1946 for (
size_t i = 0; i < contents_count_; i++)
1947 visit_at(contents_, i, contents_id);
1956 for (
size_t i = 0; i < contents_count_; i++)
1957 last_valid_index_[i] = -1;
1960 auto clear_contents = [](
auto&
content) {
1963 for (
size_t i = 0; i < contents_count_; i++)
1964 visit_at(contents_, i, clear_contents);
1976 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
1978 std::vector<size_t> lengths = content_lengths(index_sequence);
1979 for (
size_t tag = 0; tag < contents_count_; tag++) {
1980 if (lengths[tag] != last_valid_index_[tag] + 1) {
1981 std::stringstream out;
1982 out <<
"Union node" << id_ <<
" has content length " << lengths[tag]
1983 <<
" but index length " << last_valid_index_[tag] <<
"\n";
1984 error.append(out.str());
1990 std::vector<bool> valid_contents =
1991 content_is_valid(index_sequence, error);
1992 return std::none_of(std::cbegin(valid_contents),
1993 std::cend(valid_contents),
1994 std::logical_not<bool>());
2002 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2004 names_nbytes[
"node" + std::to_string(id_) +
"-tags"] = tags_.
nbytes();
2005 names_nbytes[
"node" + std::to_string(id_) +
"-index"] = index_.
nbytes();
2007 for (
size_t i = 0; i < contents_count_; i++)
2009 content.buffer_nbytes(names_nbytes);
2019 to_buffers(std::map<std::string, void*>& buffers)
const noexcept {
2020 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2023 buffers[
"node" + std::to_string(id_) +
"-tags"]));
2025 buffers[
"node" + std::to_string(id_) +
"-index"]));
2027 for (
size_t i = 0; i < contents_count_; i++)
2039 auto index_sequence((std::index_sequence_for<BUILDERS...>()));
2042 buffers[
"node" + std::to_string(id_) +
"-tags"]));
2044 buffers[
"node" + std::to_string(id_) +
"-index"]));
2046 for (
size_t i = 0; i < contents_count_; i++)
2048 content.to_char_buffers(buffers);
2056 std::stringstream form_key;
2057 form_key <<
"node" << id_;
2058 std::string params(
"");
2059 if (parameters_ ==
"") {
2061 params = std::string(
", \"parameters\": { " + parameters_ +
" }");
2063 std::stringstream out;
2064 out <<
"{ \"class\": \"UnionArray\", \"tags\": \"" +
2065 type_to_numpy_like<TAGS>() +
"\", \"index\": \"" +
2066 type_to_numpy_like<INDEX>() +
"\", \"contents\": [";
2067 for (
size_t i = 0; i < contents_count_; i++) {
2071 auto contents_form = [&](
auto&
content) {
2074 visit_at(contents_, i, contents_form);
2077 out << params <<
"\"form_key\": \"" << form_key.str() <<
"\" }";
2084 template <std::size_t... S>
2086 content_lengths(std::index_sequence<S...>)
const {
2087 return std::vector<size_t>({std::get<S>(contents_).length()...});
2091 template <std::size_t... S>
2093 content_is_valid(std::index_sequence<S...>, std::string& error)
const {
2094 return std::vector<bool>({std::get<S>(contents_).is_valid(error)...});
2100 GrowableBuffer<TAGS> tags_;
2105 GrowableBuffer<INDEX> index_;
2111 std::string parameters_;
2117 size_t last_valid_index_[
sizeof...(BUILDERS)];
2120 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:1571
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition LayoutBuilder.h:1624
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:1707
bool lsb_order() const noexcept
Determines whether the position of each bit is in Least-Significant Bit order (LSB) or not.
Definition LayoutBuilder.h:1631
BUILDER & append_invalid() noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:1665
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:1654
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:1777
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1686
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1692
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1618
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:1717
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:1766
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1698
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1724
BitMasked(const awkward::BuilderOptions &options)
Creates a new BitMasked layout builder by allocating a new mask buffer, taking options from BuilderOp...
Definition LayoutBuilder.h:1598
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:1640
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:1741
BUILDER & extend_invalid(size_t size) noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:1677
BitMasked()
Creates a new BitMasked layout builder by allocating a new mask buffer, using AWKWARD_LAYOUTBUILDER_D...
Definition LayoutBuilder.h:1575
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:1753
Builds a ByteMaskedArray using a mask which is an array of booleans that determines whether the corre...
Definition LayoutBuilder.h:1358
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition LayoutBuilder.h:1387
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:1458
BUILDER & append_invalid() noexcept
Inserts !valid_when in the mask.
Definition LayoutBuilder.h:1417
BUILDER & extend_valid(size_t size) noexcept
Inserts size number of valid_when in the mask.
Definition LayoutBuilder.h:1406
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:1520
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1437
ByteMasked()
Creates a new ByteMasked layout builder by allocating a new mask buffer, using AWKWARD_LAYOUTBUILDER_...
Definition LayoutBuilder.h:1362
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1443
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1381
ByteMasked(const awkward::BuilderOptions &options)
Creates a new ByteMasked layout builder by allocating a new mask buffer, taking options from BuilderO...
Definition LayoutBuilder.h:1373
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:1465
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:1511
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1449
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1471
BUILDER & append_valid() noexcept
Inserts valid_when in the mask.
Definition LayoutBuilder.h:1395
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:1488
BUILDER & extend_invalid(size_t size) noexcept
Inserts size number of !valid_when in the mask.
Definition LayoutBuilder.h:1428
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:1500
Builds an EmptyArray which has no content in it. It is used whenever an array's type is not known bec...
Definition LayoutBuilder.h:374
void clear() noexcept
Definition LayoutBuilder.h:386
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:396
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:417
void to_buffers(std::map< std::string, void * > &) const noexcept
Definition LayoutBuilder.h:405
Empty()
Creates a new Empty layout builder.
Definition LayoutBuilder.h:377
void set_id(size_t &) noexcept
Definition LayoutBuilder.h:383
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:390
void buffer_nbytes(std::map< std::string, size_t > &) const noexcept
Definition LayoutBuilder.h:401
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:412
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:1034
void clear() noexcept
Discards the accumulated index and clears the content of the builder. Also, last valid returns to -1.
Definition LayoutBuilder.h:1127
void extend_invalid(size_t size) noexcept
Inserts -1 in the index buffer size number of times.
Definition LayoutBuilder.h:1098
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:1078
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:1190
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1106
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1112
IndexedOption(const awkward::BuilderOptions &options)
Creates a new IndexedOption layout builder by allocating a new index buffer, taking options from Buil...
Definition LayoutBuilder.h:1051
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1060
size_t length() const noexcept
Current length of the index buffer.
Definition LayoutBuilder.h:1135
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:1181
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1118
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1141
IndexedOption()
Creates a new IndexedOption layout builder by allocating a new index buffer, using AWKWARD_LAYOUTBUIL...
Definition LayoutBuilder.h:1038
BUILDER & append_valid() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1067
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:1158
void append_invalid() noexcept
Inserts -1 in the index buffer.
Definition LayoutBuilder.h:1090
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:1170
Builds a ListOffsetArray which describes unequal-length lists (often called a "jagged" or "ragged" ar...
Definition LayoutBuilder.h:210
void clear() noexcept
Discards the accumulated offsets and clears the builder content.
Definition LayoutBuilder.h:275
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the builder content.
Definition LayoutBuilder.h:242
ListOffset()
Creates a new ListOffset layout builder by allocating a new offset buffer, using AWKWARD_LAYOUTBUILDE...
Definition LayoutBuilder.h:214
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:339
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:255
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:261
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:236
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:283
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:330
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:267
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:289
void end_list() noexcept
Ends a list and appends the current length of the list contents in the offsets buffer.
Definition LayoutBuilder.h:249
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:306
ListOffset(const awkward::BuilderOptions &options)
Creates a new ListOffset layout builder by allocating a new offset buffer, taking options from Builde...
Definition LayoutBuilder.h:227
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:319
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:151
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_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:159
Builds a RecordArray which represents an array of records, which can be of same or different types....
Definition LayoutBuilder.h:438
void clear() noexcept
Clears the builder contents.
Definition LayoutBuilder.h:525
Record()
Creates a new Record layout builder.
Definition LayoutBuilder.h:447
MAP UserDefinedMap
Definition LayoutBuilder.h:441
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:605
RecordFieldType< INDEX >::Builder & content() noexcept
Returns the reference to the builder contents at INDEX.
Definition LayoutBuilder.h:492
std::tuple_element_t< INDEX, RecordContents > RecordFieldType
Definition LayoutBuilder.h:444
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:459
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:498
typename std::tuple< BUILDERS... > RecordContents
Definition LayoutBuilder.h:440
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:504
size_t length() const noexcept
Current number of records in first field.
Definition LayoutBuilder.h:534
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:595
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:510
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:540
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:569
void set_fields(MAP user_defined_field_id_to_name_map) noexcept
Sets the field names.
Definition LayoutBuilder.h:485
const std::vector< std::string > fields() const noexcept
Returns a vector of strings sontaining all the field names.
Definition LayoutBuilder.h:468
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:583
RecordContents contents
The contents of the RecordArray.
Definition LayoutBuilder.h:634
Builds a RegularArray that describes lists that have the same length, a single integer size....
Definition LayoutBuilder.h:886
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:935
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the content of the builder.
Definition LayoutBuilder.h:903
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:992
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:915
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:921
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:896
size_t length() const noexcept
Current number of lists of length SIZE.
Definition LayoutBuilder.h:942
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:985
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:927
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:948
void end_list() noexcept
Ends a list and increments the number of lists.
Definition LayoutBuilder.h:909
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:965
Regular()
Creates a new Regular layout builder.
Definition LayoutBuilder.h:889
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:976
Builds a RecordArray which represents an array of tuples which can be of same or different types with...
Definition LayoutBuilder.h:686
void clear() noexcept
Clears the builder contents.
Definition LayoutBuilder.h:734
TupleContents contents
The contents of the RecordArray without fields.
Definition LayoutBuilder.h:840
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:815
Tuple()
Creates a new Tuple layout builder.
Definition LayoutBuilder.h:694
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:708
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:714
size_t length() const noexcept
Current number of records in the first index of the tuple.
Definition LayoutBuilder.h:743
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:805
TupleContentType< INDEX > & content() noexcept
Returns the reference to the builder contents at INDEX.
Definition LayoutBuilder.h:702
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:720
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:749
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:779
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:793
Builds a UnionArray which represents data drawn from an ordered list of contents, which can have diff...
Definition LayoutBuilder.h:1872
void clear() noexcept
Discards the accumulated tags and index, and clears the builder contents.
Definition LayoutBuilder.h:1955
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:1895
typename std::tuple< BUILDERS... > Contents
Definition LayoutBuilder.h:1874
std::tuple_element_t< I, Contents > ContentType
Definition LayoutBuilder.h:1877
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:1914
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:2055
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1928
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1934
size_t length() const noexcept
Current length of the tags buffer.
Definition LayoutBuilder.h:1969
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:2038
Union()
Creates a new Union layout builder by allocating new tags and index buffers, using AWKWARD_LAYOUTBUIL...
Definition LayoutBuilder.h:1881
ContentType< I > & content() noexcept
Definition LayoutBuilder.h:1906
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1940
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1975
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:2000
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:2019
Builds an UnmaskedArray which the values are never, in fact, missing. It exists to satisfy systems th...
Definition LayoutBuilder.h:1235
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:1271
Unmasked()
Creates a new Unmasked layout builder.
Definition LayoutBuilder.h:1238
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:1317
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1251
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1257
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1245
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:1277
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:1310
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1263
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1283
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:1290
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:1301
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:262
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