3#ifndef AWKWARD_LAYOUTBUILDER_H_ 
    4#define AWKWARD_LAYOUTBUILDER_H_ 
   18#define AWKWARD_LAYOUTBUILDER_DEFAULT_OPTIONS awkward::BuilderOptions(1024, 1) 
   31        template <
class CONTENT>
 
   33            content.builder.set_id(id_);
 
 
 
   47    template <std::
size_t ENUM, 
typename BUILDER>
 
   55        return std::to_string(
index);
 
 
 
   70    template <
typename PRIMITIVE>
 
  103      extend(PRIMITIVE* ptr, 
size_t size) 
noexcept {
 
  104        data_.extend(ptr, size);
 
 
  116        parameters_ = parameter;
 
 
  135        return data_.length();
 
 
  148        names_nbytes[
"node" + std::to_string(id_) + 
"-data"] = data_.nbytes();
 
 
  157      to_buffers(std::map<std::string, void*>& buffers) 
const noexcept {
 
  158        data_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
 
  159            buffers[
"node" + std::to_string(id_) + 
"-data"]));
 
 
  166      to_buffer(
void* buffer, 
const char* name) 
const noexcept {
 
  167        if (std::string(name) == std::string(
"node" + std::to_string(id_) + 
"-data")) {
 
  168          data_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
 
 
  178        data_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
 
  179          buffers[
"node" + std::to_string(id_) + 
"-data"]));
 
 
  186        std::stringstream form_key;
 
  187        form_key << 
"node" << id_;
 
  189        std::string params(
"");
 
  190        if (parameters_ == 
"") {
 
  192          params = std::string(
", \"parameters\": { " + parameters_ + 
" }");
 
  195        if (std::is_arithmetic<PRIMITIVE>::value) {
 
  196          return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
 
  198                 ", \"form_key\": \"" + form_key.str() + 
"\" }";
 
  200          return "{ \"class\": \"NumpyArray\", \"primitive\": \"" +
 
  202                 ", \"form_key\": \"" + form_key.str() + 
"\" }";
 
  204          throw std::runtime_error(
"type " +
 
  205                                   std::string(
typeid(PRIMITIVE).name()) +
 
 
  215      std::string parameters_;
 
 
  235    template <
typename PRIMITIVE, 
typename BUILDER>
 
  276        offsets_.append(content_.length());
 
 
  288        parameters_ = parameter;
 
 
  310        return offsets_.length() - 1;
 
 
  316        if ((int64_t)content_.length() != (int64_t)offsets_.last()) {
 
  317          std::stringstream out;
 
  318          out << 
"ListOffset node" << id_ << 
"has content length " 
  319              << content_.length() << 
"but last offset " << offsets_.last()
 
  321          error.append(out.str());
 
  325          return content_.is_valid(error);
 
 
  334        names_nbytes[
"node" + std::to_string(id_) + 
"-offsets"] =
 
  336        content_.buffer_nbytes(names_nbytes);
 
 
  345      to_buffers(std::map<std::string, void*>& buffers) 
const noexcept {
 
  346        offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
 
  347            buffers[
"node" + std::to_string(id_) + 
"-offsets"]));
 
  348        content_.to_buffers(buffers);
 
 
  356      to_buffer(
void* buffer, 
const char* name) 
const noexcept {
 
  357        if (std::string(name) == std::string(
"node" + std::to_string(id_) + 
"-offsets")) {
 
  358          offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
 
  360        content_.to_buffer(buffer, name);
 
 
  369        offsets_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
 
  370            buffers[
"node" + std::to_string(id_) + 
"-offsets"]));
 
  371        content_.to_char_buffers(buffers);
 
 
  378        std::stringstream form_key;
 
  379        form_key << 
"node" << id_;
 
  380        std::string params(
"");
 
  381        if (parameters_ == 
"") {
 
  383          params = std::string(
", \"parameters\": { " + parameters_ + 
" }");
 
  385        return "{ \"class\": \"ListOffsetArray\", \"offsets\": \"" +
 
  387               "\", \"content\": " + content_.form() + params +
 
  388               ", \"form_key\": \"" + form_key.str() + 
"\" }";
 
 
  401      std::string parameters_;
 
 
  411    template<
class PRIMITIVE>
 
  421          for (
const auto& c: value) {
 
 
 
  479        return "{ \"class\": \"EmptyArray\" }";
 
 
 
  497    template <
class MAP = std::map<std::
size_t, std::
string>,
 
  498              typename... BUILDERS>
 
  504      template <std::
size_t INDEX>
 
  511        map_fields(std::index_sequence_for<BUILDERS...>());
 
 
  521          : content_names_(user_defined_field_id_to_name_map) {
 
  522        assert(content_names_.size() == fields_count_);
 
 
  528      const std::vector<std::string>
 
  530        if (content_names_.empty()) {
 
  533          std::vector<std::string> result;
 
  534          for (
auto it : content_names_) {
 
  535            result.emplace_back(it.second);
 
 
  547        content_names_ = user_defined_field_id_to_name_map;
 
 
  551      template <std::
size_t INDEX>
 
  552      typename RecordFieldType<INDEX>::Builder&
 
  554        return std::get<INDEX>(
contents).builder;
 
 
  566        parameters_ = parameter;
 
 
  576          for (
size_t i = 0; i < fields_count_; i++) {
 
 
  588          template <
class CONTENT>
 
 
  596          ClearBuilder clearBuilder; 
 
  597          for (
size_t i = 0; i < fields_count_; i++) {
 
 
  604        return (std::get<0>(
contents).builder.length());
 
 
  610        auto index_sequence((std::index_sequence_for<BUILDERS...>()));
 
  613        std::vector<size_t> lengths = field_lengths(index_sequence);
 
  614        for (
size_t i = 0; i < lengths.size(); i++) {
 
  618          else if (
length != (int64_t)lengths[i]) {
 
  619            std::stringstream out;
 
  620            out << 
"Record node" << id_ << 
" has field \"" 
  621                << 
fields().at(i) << 
"\" length " << lengths[i]
 
  622                << 
" that differs from the first length " << 
length << 
"\n";
 
  623            error.append(out.str());
 
  629        std::vector<bool> valid_fields = field_is_valid(index_sequence, error);
 
  630        return std::none_of(std::cbegin(valid_fields),
 
  631                            std::cend(valid_fields),
 
  632                            std::logical_not<bool>());
 
 
  641              : names_nbytes_(names_nbytes) { }
 
 
  644          template <
class CONTENT>
 
  646              content.builder.buffer_nbytes(names_nbytes_);
 
 
  650          std::map<std::string, size_t>& names_nbytes_;  
 
 
  655          BufferNBytesFunctor bufferNBytesFunctor(names_nbytes); 
 
  656          for (
size_t i = 0; i < fields_count_; i++) {
 
 
  670              : buffers_(buffers) { }
 
 
  673          template <
class CONTENT>
 
  675              content.builder.to_buffers(buffers_);
 
 
  679          std::map<std::string, void*>& buffers_;  
 
 
  683      to_buffers(std::map<std::string, void*>& buffers) 
const noexcept {
 
  684          ToBuffersFunctor toBuffersFunctor(buffers); 
 
  685          for (
size_t i = 0; i < fields_count_; i++) {
 
 
  696              : buffer_(buffer), name_(name) { }
 
 
  699          template <
class CONTENT>
 
  701              content.builder.to_buffer(buffer_, name_);
 
 
 
  710      to_buffer(
void* buffer, 
const char* name) 
const noexcept {
 
  711          ToBufferFunctor toBufferFunctor(buffer, name); 
 
  712          for (
size_t i = 0; i < fields_count_; i++) {
 
 
  726              : buffers_(buffers) { }
 
 
  729          template <
class CONTENT>
 
  731              content.builder.to_char_buffers(buffers_);
 
 
  735          std::map<std::string, uint8_t*>& buffers_;  
 
 
  740          ToCharBuffersFunctor toCharBuffersFunctor(buffers); 
 
  741          for (
size_t i = 0; i < fields_count_; i++) {
 
 
  753              : out_(out), content_names_(content_names) {}
 
 
  756          template <
class CONTENT>
 
  759              auto it = content_names_.find(index); 
 
  761              if (it != content_names_.end()) {
 
  762                  out_ << 
"\"" << it->second << 
"\": ";
 
  764                  out_ << 
"\"" << index << 
"\": "; 
 
  767              out_ << 
content.builder.form();
 
 
  771          std::stringstream& out_;
 
  772          const std::map<size_t, std::string>& content_names_;  
 
 
  776      std::string 
form() const noexcept {
 
  777          std::stringstream form_key;
 
  778          form_key << 
"node" << id_;
 
  780          std::string params(
"");
 
  781          if (!parameters_.empty()) {
 
  782              params = 
"\"parameters\": { " + parameters_ + 
" }, ";
 
  785          std::stringstream out;
 
  786          out << 
"{ \"class\": \"RecordArray\", \"contents\": { ";
 
  788          for (
size_t i = 0; i < fields_count_; i++) {
 
  792              ContentsFormFunctor contentsFormFunctor(out, content_names_);
 
  797          out << params << 
"\"form_key\": \"" << form_key.str() << 
"\" }";
 
 
  807      template <std::size_t... S>
 
  809      map_fields(std::index_sequence<S...>) 
noexcept {
 
  810        fields_ = std::vector<std::string>(
 
  811            {std::string(std::get<S>(
contents).index_as_field())...});
 
  816      template <std::size_t... S>
 
  818      field_lengths(std::index_sequence<S...>) 
const noexcept {
 
  819        return std::vector<size_t>({std::get<S>(
contents).builder.length()...});
 
  823      template <std::size_t... S>
 
  825      field_is_valid(std::index_sequence<S...>, std::string& error) 
const 
  827        return std::vector<bool>(
 
  828            {std::get<S>(
contents).builder.is_valid(error)...});
 
  832      std::vector<std::string> fields_;
 
  838      std::string parameters_;
 
  844      static constexpr size_t fields_count_ = 
sizeof...(BUILDERS);
 
 
  853    template <
typename... BUILDERS>
 
  855      using TupleContents = 
typename std::tuple<BUILDERS...>;
 
  857      template <std::
size_t INDEX>
 
  858      using TupleContentType = std::tuple_element_t<INDEX, TupleContents>;
 
  868      template <std::
size_t INDEX>
 
  869      TupleContentType<INDEX>&
 
  883        parameters_ = parameter;
 
 
  893          template <
class CONTENT>
 
 
  906          SetIdFunctor setIdFunctor(
id);  
 
  907          for (
size_t i = 0; i < fields_count_; i++) {
 
 
  919          template <
class CONTENT>
 
 
  926          ClearFunctor clearFunctor;  
 
  927          for (
size_t i = 0; i < fields_count_; i++) {
 
 
  941        auto index_sequence((std::index_sequence_for<BUILDERS...>()));
 
  944        std::vector<size_t> lengths = content_lengths(index_sequence);
 
  945        for (
size_t i = 0; i < lengths.size(); i++) {
 
  947            length = (int64_t)lengths[i];
 
  949          else if (
length != (int64_t)lengths[i]) {
 
  950            std::stringstream out;
 
  951            out << 
"Record node" << id_ << 
" has index \"" << i << 
"\" length " 
  952                << lengths[i] << 
" that differs from the first length " 
  954            error.append(out.str());
 
  960        std::vector<bool> valid_fields =
 
  961            content_is_valid(index_sequence, error);
 
  962        return std::none_of(std::cbegin(valid_fields),
 
  963                            std::cend(valid_fields),
 
  964                            std::logical_not<bool>());
 
 
  973              : names_nbytes_(names_nbytes) { }
 
 
  976          template <
class CONTENT>
 
  978              content.buffer_nbytes(names_nbytes_);
 
 
  982          std::map<std::string, size_t>& names_nbytes_;  
 
 
  987          BufferNBytesFunctor bufferNBytesFunctor(names_nbytes);  
 
  988          for (
size_t i = 0; i < fields_count_; i++) {
 
 
 1003              : buffers_(buffers) { }
 
 
 1006          template <
class CONTENT>
 
 1012          std::map<std::string, void*>& buffers_;  
 
 
 1016      to_buffers(std::map<std::string, void*>& buffers) 
const noexcept {
 
 1017          ToBuffersFunctor toBuffersFunctor(buffers);  
 
 1018          for (
size_t i = 0; i < fields_count_; i++) {
 
 
 1031              : buffer_(buffer), name_(name) { }
 
 
 1034          template <
class CONTENT>
 
 1036              content.to_buffer(buffer_, name_);
 
 
 
 1046          ToBufferFunctor toBufferFunctor(buffer, name);  
 
 1047          for (
size_t i = 0; i < fields_count_; i++) {
 
 
 1061              : buffers_(buffers) { }
 
 
 1064          template <
class CONTENT>
 
 1066              content.to_char_buffers(buffers_);
 
 
 1070          std::map<std::string, uint8_t*>& buffers_;  
 
 
 1075          ToCharBuffersFunctor toCharBuffersFunctor(buffers);  
 
 1076          for (
size_t i = 0; i < fields_count_; i++) {
 
 
 1089          template <
class CONTENT>
 
 1095          std::stringstream& out_;  
 
 
 1101          std::stringstream form_key;
 
 1102          form_key << 
"node" << id_;
 
 1103          std::string params(
"");
 
 1104          if (!parameters_.empty()) {
 
 1105              params = 
"\"parameters\": { " + parameters_ + 
" }, ";
 
 1107          std::stringstream out;
 
 1108          out << 
"{ \"class\": \"RecordArray\", \"contents\": [";
 
 1109          for (
size_t i = 0; i < fields_count_; i++) {
 
 1113              ContentsFormFunctor contentsFormFunctor(out);
 
 1117          out << params << 
"\"form_key\": \"" << form_key.str() << 
"\" }";
 
 
 1127      template <std::size_t... S>
 
 1129      content_lengths(std::index_sequence<S...>) 
const noexcept {
 
 1130        return std::vector<size_t>({std::get<S>(
contents).length()...});
 
 1134      template <std::size_t... S>
 
 1136      content_is_valid(std::index_sequence<S...>, std::string& error) 
const 
 1138        return std::vector<bool>({std::get<S>(
contents).is_valid(error)...});
 
 1142      std::vector<int64_t> field_index_;
 
 1145      std::string parameters_;
 
 1151      static constexpr size_t fields_count_ = 
sizeof...(BUILDERS);
 
 
 1167    template <
unsigned SIZE, 
typename BUILDER>
 
 1204        parameters_ = parameter;
 
 
 1212        content_.set_id(
id);
 
 
 1231        if (content_.length() != length_ * size_) {
 
 1232          std::stringstream out;
 
 1233          out << 
"Regular node" << id_ << 
"has content length " 
 1234              << content_.length() << 
", but length " << length_ << 
" and size " 
 1236          error.append(out.str());
 
 1240          return content_.is_valid(error);
 
 
 1249        content_.buffer_nbytes(names_nbytes);
 
 
 1258      to_buffers(std::map<std::string, void*>& buffers) 
const noexcept {
 
 1259        content_.to_buffers(buffers);
 
 
 1267        content_.to_buffer(buffer, name);
 
 
 1276        content_.to_char_buffers(buffers);
 
 
 1283        std::stringstream form_key;
 
 1284        form_key << 
"node" << id_;
 
 1285        std::string params(
"");
 
 1286        if (parameters_ == 
"") {
 
 1288          params = std::string(
", \"parameters\": { " + parameters_ + 
" }");
 
 1290        return "{ \"class\": \"RegularArray\", \"content\": " +
 
 1291               content_.form() + 
", \"size\": " + std::to_string(size_) +
 
 1292               params + 
", \"form_key\": \"" + form_key.str() + 
"\" }";
 
 
 1300      std::string parameters_;
 
 1309      size_t size_ = SIZE;
 
 
 1322    template <
typename PRIMITIVE, 
typename BUILDER>
 
 1365        if (i > max_index_) {
 
 1368          max_index_ = UINTMAX_MAX;
 
 
 1379        size_t start = content_.length();
 
 1380        size_t stop = start + size;
 
 1381        if (stop - 1 > max_index_) {
 
 1382          max_index_ = stop - 1;
 
 1384        for (
size_t i = start; i < stop; i++) {
 
 
 1399        parameters_ = parameter;
 
 
 1407        content_.set_id(
id);
 
 
 1422        return index_.length();
 
 
 1430        names_nbytes[
"node" + std::to_string(id_) + 
"-index"] = index_.nbytes();
 
 1431        content_.buffer_nbytes(names_nbytes);
 
 
 1438        if (max_index_ == UINTMAX_MAX) {
 
 1439          std::stringstream out;
 
 1440          out << 
"Indexed node" << id_ << 
" has a negative index\n";
 
 1441          error.append(out.str());
 
 1443        } 
else if ((content_.length() == 0) && (max_index_ == 0)) { 
 
 1444        } 
else if (max_index_ >= content_.length()) {
 
 1445          std::stringstream out;
 
 1446          out << 
"Indexed node" << id_ << 
" has index " << max_index_
 
 1447              << 
" but content has length " 
 1448              << content_.length() << 
"\n";
 
 1449          error.append(out.str());
 
 1452        return content_.is_valid(error);
 
 
 1461      to_buffers(std::map<std::string, void*>& buffers) 
const noexcept {
 
 1462        index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
 
 1463            buffers[
"node" + std::to_string(id_) + 
"-index"]));
 
 1464        content_.to_buffers(buffers);
 
 
 1473        if (std::string(name) == std::string(
"node" + std::to_string(id_) + 
"-index")) {
 
 1474          index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
 
 1476        content_.to_buffer(buffer, name);
 
 
 1485        index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
 
 1486            buffers[
"node" + std::to_string(id_) + 
"-index"]));
 
 1487        content_.to_char_buffers(buffers);
 
 
 1494        std::stringstream form_key;
 
 1495        form_key << 
"node" << id_;
 
 1496        std::string params(
"");
 
 1497        if (parameters_ == 
"") {
 
 1499          params = std::string(
", \"parameters\": { " + parameters_ + 
" }");
 
 1501        return "{ \"class\": \"IndexedArray\", \"index\": \"" +
 
 1503               "\", \"content\": " + content_.form() + params +
 
 1504               ", \"form_key\": \"" + form_key.str() + 
"\" }";
 
 
 1517      std::string parameters_;
 
 
 1536    template <
typename PRIMITIVE, 
typename BUILDER>
 
 1573        last_valid_ = content_.length();
 
 
 1581        last_valid_ = content_.length();
 
 1583        if (i > max_index_) {
 
 
 1595        size_t start = content_.length();
 
 1596        size_t stop = start + size;
 
 1597        last_valid_ = stop - 1;
 
 1598        if (last_valid_ > max_index_) {
 
 1599          max_index_ = last_valid_;
 
 1601        for (
size_t i = start; i < stop; i++) {
 
 
 1618        for (
size_t i = 0; i < size; i++) {
 
 
 1632        parameters_ = parameter;
 
 
 1640        content_.set_id(
id);
 
 
 1655        return index_.length();
 
 
 1661        if ((content_.length() == 0) && (max_index_ == 0)) { 
 
 1662        } 
else if (max_index_ >= content_.length()) {
 
 1663          std::stringstream out;
 
 1664          out << 
"IndexedOption node" << id_ << 
" has index " << max_index_
 
 1665              << 
" but content has length " 
 1666              << content_.length() << 
"\n";
 
 1667          error.append(out.str());
 
 1671        return content_.is_valid(error);
 
 
 1679        names_nbytes[
"node" + std::to_string(id_) + 
"-index"] = index_.nbytes();
 
 1680        content_.buffer_nbytes(names_nbytes);
 
 
 1689      to_buffers(std::map<std::string, void*>& buffers) 
const noexcept {
 
 1690        index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
 
 1691            buffers[
"node" + std::to_string(id_) + 
"-index"]));
 
 1692        content_.to_buffers(buffers);
 
 
 1701        if (std::string(name) == std::string(
"node" + std::to_string(id_) + 
"-index")) {
 
 1702          index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(buffer));
 
 1704        content_.to_buffer(buffer, name);
 
 
 1713        index_.concatenate(
reinterpret_cast<PRIMITIVE*
>(
 
 1714            buffers[
"node" + std::to_string(id_) + 
"-index"]));
 
 1715        content_.to_char_buffers(buffers);
 
 
 1722        std::stringstream form_key;
 
 1723        form_key << 
"node" << id_;
 
 1724        std::string params(
"");
 
 1725        if (parameters_ == 
"") {
 
 1727          params = std::string(
", \"parameters\": { " + parameters_ + 
" }");
 
 1729        return "{ \"class\": \"IndexedOptionArray\", \"index\": \"" +
 
 1731               "\", \"content\": " + content_.form() + params +
 
 1732               ", \"form_key\": \"" + form_key.str() + 
"\" }";
 
 
 1745      std::string parameters_;
 
 
 1768    template <
typename BUILDER>
 
 1792        parameters_ = parameter;
 
 
 1800        content_.set_id(
id);
 
 
 1812        return content_.length();
 
 
 1818        return content_.is_valid(error);
 
 
 1826        content_.buffer_nbytes(names_nbytes);
 
 
 1835      to_buffers(std::map<std::string, void*>& buffers) 
const noexcept {
 
 1836        content_.to_buffers(buffers);
 
 
 1844        content_.to_buffer(buffer, name);
 
 
 1853        content_.to_char_buffers(buffers);
 
 
 1860        std::stringstream form_key;
 
 1861        form_key << 
"node" << id_;
 
 1862        std::string params(
"");
 
 1863        if (parameters_ == 
"") {
 
 1865          params = std::string(
", \"parameters\": { " + parameters_ + 
" }");
 
 1867        return "{ \"class\": \"UnmaskedArray\", \"content\": " +
 
 1868               content_.form() + params + 
", \"form_key\": \"" +
 
 1869               form_key.str() + 
"\" }";
 
 
 1877      std::string parameters_;
 
 
 1899    template <
bool VALID_WHEN, 
typename BUILDER>
 
 1938        mask_.append(valid_when_);
 
 
 1949        for (
size_t i = 0; i < size; i++) {
 
 1950          mask_.append(valid_when_);
 
 
 1960        mask_.append(!valid_when_);
 
 
 1971        for (
size_t i = 0; i < size; i++) {
 
 1972          mask_.append(!valid_when_);
 
 
 1986        parameters_ = parameter;
 
 
 1994        content_.set_id(
id);
 
 
 2008        return mask_.length();
 
 
 2014        if (content_.length() != mask_.length()) {
 
 2015          std::stringstream out;
 
 2016          out << 
"ByteMasked node" << id_ << 
"has content length " 
 2017              << content_.length() << 
"but mask length " << mask_.length()
 
 2019          error.append(out.str());
 
 2023          return content_.is_valid(error);
 
 
 2032        names_nbytes[
"node" + std::to_string(id_) + 
"-mask"] = mask_.nbytes();
 
 2033        content_.buffer_nbytes(names_nbytes);
 
 
 2042      to_buffers(std::map<std::string, void*>& buffers) 
const noexcept {
 
 2043        mask_.concatenate(
reinterpret_cast<int8_t*
>(
 
 2044            buffers[
"node" + std::to_string(id_) + 
"-mask"]));
 
 2045        content_.to_buffers(buffers);
 
 
 2054        if (std::string(name) == std::string(
"node" + std::to_string(id_) + 
"-mask")) {
 
 2055          mask_.concatenate(
reinterpret_cast<int8_t*
>(buffer));
 
 2057        content_.to_buffer(buffer, name);
 
 
 2066        mask_.concatenate(
reinterpret_cast<int8_t*
>(
 
 2067            buffers[
"node" + std::to_string(id_) + 
"-mask"]));
 
 2068        content_.to_char_buffers(buffers);
 
 
 2075        std::stringstream form_key, form_valid_when;
 
 2076        form_key << 
"node" << id_;
 
 2077        form_valid_when << std::boolalpha << valid_when_;
 
 2078        std::string params(
"");
 
 2079        if (parameters_ == 
"") {
 
 2081          params = std::string(
", \"parameters\": { " + parameters_ + 
" }");
 
 2083        return "{ \"class\": \"ByteMaskedArray\", \"mask\": \"i8\", " 
 2085               content_.form() + 
", \"valid_when\": " + form_valid_when.str() +
 
 2086               params + 
", \"form_key\": \"" + form_key.str() + 
"\" }";
 
 
 2099      std::string parameters_;
 
 2105      bool valid_when_ = VALID_WHEN;
 
 
 2124    template <
bool VALID_WHEN, 
bool LSB_ORDER, 
typename BUILDER>
 
 2131            current_byte_(uint8_t(0)),
 
 2132            current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
 
 2137          for (
size_t i = 0; i < 8; i++) {
 
 2141          for (
size_t i = 0; i < 8; i++) {
 
 2142            cast_[i] = 128 >> i;
 
 
 2154            current_byte_(uint8_t(0)),
 
 2155            current_byte_ref_(mask_.append_and_get_ref(current_byte_)),
 
 2160          for (
size_t i = 0; i < 8; i++) {
 
 2164          for (
size_t i = 0; i < 8; i++) {
 
 2165            cast_[i] = 128 >> i;
 
 
 2196        current_byte_ |= cast_[current_index_];
 
 
 2209        for (
size_t i = 0; i < size; i++) {
 
 
 2232        for (
size_t i = 0; i < size; i++) {
 
 
 2247        parameters_ = parameter;
 
 
 2255        content_.set_id(
id);
 
 
 2265        current_byte_ref_ = mask_.append_and_get_ref(current_byte_);
 
 
 2272        return mask_.length() > 0 ?
 
 2273          (mask_.length() - 1) * 8 + current_index_ : current_index_;
 
 
 2279        if (content_.length() != 
length()) {
 
 2280          std::stringstream out;
 
 2281          out << 
"BitMasked node" << id_ << 
"has content length " 
 2282              << content_.length() << 
"but bit mask length " << mask_.length()
 
 2284          error.append(out.str());
 
 2288          return content_.is_valid(error);
 
 
 2297        names_nbytes[
"node" + std::to_string(id_) + 
"-mask"] = mask_.nbytes();
 
 2298        content_.buffer_nbytes(names_nbytes);
 
 
 2307      to_buffers(std::map<std::string, void*>& buffers) 
const noexcept {
 
 2308        mask_.concatenate_from(
reinterpret_cast<uint8_t*
>(
 
 2309            buffers[
"node" + std::to_string(id_) + 
"-mask"]), 0, 1);
 
 2310        mask_.append(
reinterpret_cast<uint8_t*
>(
 
 2311            buffers[
"node" + std::to_string(id_) + 
"-mask"]), mask_.length() - 1, 0, 1);
 
 2312        content_.to_buffers(buffers);
 
 
 2321        if (std::string(name) == std::string(
"node" + std::to_string(id_) + 
"-mask")) {
 
 2322          mask_.concatenate_from(
reinterpret_cast<uint8_t*
>(buffer), 0, 1);
 
 2323          mask_.append(
reinterpret_cast<uint8_t*
>(buffer), mask_.length() - 1, 0, 1);
 
 2325        content_.to_buffer(buffer, name);
 
 
 2334        mask_.concatenate_from(
reinterpret_cast<uint8_t*
>(
 
 2335            buffers[
"node" + std::to_string(id_) + 
"-mask"]), 0, 1);
 
 2336        mask_.append(
reinterpret_cast<uint8_t*
>(
 
 2337            buffers[
"node" + std::to_string(id_) + 
"-mask"]), mask_.length() - 1, 0, 1);
 
 2338        content_.to_char_buffers(buffers);
 
 
 2345        std::stringstream form_key, form_valid_when, form_lsb_order;
 
 2346        form_key << 
"node" << id_;
 
 2347        form_valid_when << std::boolalpha << valid_when_;
 
 2348        form_lsb_order << std::boolalpha << lsb_order_;
 
 2349        std::string params(
"");
 
 2350        if (parameters_ == 
"") {
 
 2352          params = std::string(
", \"parameters\": { " + parameters_ + 
" }");
 
 2354        return "{ \"class\": \"BitMaskedArray\", \"mask\": \"u8\", " 
 2356               content_.form() + 
", \"valid_when\": " + form_valid_when.str() +
 
 2357               ", \"lsb_order\": " + form_lsb_order.str() + params +
 
 2358               ", \"form_key\": \"" + form_key.str() + 
"\" }";
 
 
 2367        if (current_index_ == 8) {
 
 2369          current_byte_ = uint8_t(0);
 
 2381        current_index_ += 1;
 
 2383          current_byte_ref_ = current_byte_;
 
 2385          current_byte_ref_ = ~current_byte_;
 
 2392      GrowableBuffer<uint8_t> mask_;
 
 2398      std::string parameters_;
 
 2404      uint8_t current_byte_;
 
 2407      uint8_t& current_byte_ref_;
 
 2410      size_t current_index_;
 
 2416      bool valid_when_ = VALID_WHEN;
 
 2420      bool lsb_order_ = LSB_ORDER;
 
 
 2438    template <
typename TAGS, 
typename INDEX, 
typename... BUILDERS>
 
 2443      template <std::
size_t I>
 
 2453        for (
size_t i = 0; i < contents_count_; i++) {
 
 2454          last_valid_index_[i] = -1;
 
 
 2468        for (
size_t i = 0; i < contents_count_; i++) {
 
 2469          last_valid_index_[i] = -1;
 
 
 2473      template <std::
size_t I>
 
 2476        return std::get<I>(contents_);
 
 
 2481      template <std::
size_t TAG>
 
 2484        auto& which_content = std::get<TAG>(contents_);
 
 2485        INDEX next_index = which_content.length();
 
 2487        TAGS tag = (TAGS)TAG;
 
 2488        last_valid_index_[tag] = next_index;
 
 2490        index_.append(next_index);
 
 2492        return which_content;
 
 
 2504        parameters_ = parameter;
 
 
 2514          template <
class CONTENT>
 
 
 2527          SetIdFunctor setIdFunctor(
id);  
 
 2528          for (
size_t i = 0; i < contents_count_; i++) {
 
 2529              visit_at(contents_, i, setIdFunctor);  
 
 
 2541          template <
class CONTENT>
 
 
 2549          for (
size_t i = 0; i < contents_count_; i++) {
 
 2550              last_valid_index_[i] = -1;
 
 2555          ClearContentsFunctor clearContentsFunctor;  
 
 2556          for (
size_t i = 0; i < contents_count_; i++) {
 
 2557              visit_at(contents_, i, clearContentsFunctor);  
 
 
 2565        return tags_.length();
 
 
 2571        auto index_sequence((std::index_sequence_for<BUILDERS...>()));
 
 2573        std::vector<size_t> lengths = content_lengths(index_sequence);
 
 2574        std::unique_ptr<INDEX[]> index_ptr(
new INDEX[index_.length()]);
 
 2575        index_.concatenate(index_ptr.get());
 
 2576        std::unique_ptr<TAGS[]> tags_ptr(
new TAGS[tags_.length()]);
 
 2577        tags_.concatenate(tags_ptr.get());
 
 2578        for (
size_t i = 0; i < index_.length(); i++) {
 
 2579          if (index_ptr.get()[i] < 0 || index_ptr.get()[i] >= lengths[tags_ptr.get()[i]]) {
 
 2580            std::stringstream out;
 
 2581            out << 
"Union node" << id_ << 
" has index " << index_ptr.get()[i]
 
 2582                << 
" at position " << i << 
" but content has length " 
 2583                << lengths[tags_ptr.get()[i]] << 
"\n";
 
 2584            error.append(out.str());
 
 2590        std::vector<bool> valid_contents =
 
 2591            content_is_valid(index_sequence, error);
 
 2592        return std::none_of(std::cbegin(valid_contents),
 
 2593                            std::cend(valid_contents),
 
 2594                            std::logical_not<bool>());
 
 
 2603              : names_nbytes_(names_nbytes) {}
 
 
 2606          template <
class CONTENT>
 
 2608              content.buffer_nbytes(names_nbytes_);
 
 
 2612          std::map<std::string, size_t>& names_nbytes_;  
 
 
 2617          auto index_sequence((std::index_sequence_for<BUILDERS...>()));
 
 2620          names_nbytes[
"node" + std::to_string(id_) + 
"-tags"] = tags_.nbytes();
 
 2621          names_nbytes[
"node" + std::to_string(id_) + 
"-index"] = index_.nbytes();
 
 2624          BufferNBytesFunctor bufferNBytesFunctor(names_nbytes);
 
 2626          for (
size_t i = 0; i < contents_count_; i++) {
 
 2627              visit_at(contents_, i, bufferNBytesFunctor);  
 
 
 2641              : buffers_(buffers) { }
 
 
 2644          template <
class CONTENT>
 
 2650          std::map<std::string, void*>& buffers_;  
 
 
 2654      to_buffers(std::map<std::string, void*>& buffers) 
const noexcept {
 
 2655          auto index_sequence((std::index_sequence_for<BUILDERS...>()));
 
 2658          tags_.concatenate(
reinterpret_cast<TAGS*
>(
 
 2659              buffers[
"node" + std::to_string(id_) + 
"-tags"]));
 
 2660          index_.concatenate(
reinterpret_cast<INDEX*
>(
 
 2661              buffers[
"node" + std::to_string(id_) + 
"-index"]));
 
 2664          ToBuffersFunctor toBuffersFunctor(buffers);
 
 2666          for (
size_t i = 0; i < contents_count_; i++) {
 
 2667              visit_at(contents_, i, toBuffersFunctor);  
 
 
 2680              : buffer_(buffer), name_(name) { }
 
 
 2683          template <
class CONTENT>
 
 2685              content.to_buffer(buffer_, name_);
 
 
 
 2695          auto index_sequence((std::index_sequence_for<BUILDERS...>()));
 
 2697          if (std::string(name) == std::string(
"node" + std::to_string(id_) + 
"-tags")) {
 
 2698              tags_.concatenate(
reinterpret_cast<TAGS*
>(buffer));
 
 2700          else if (std::string(name) == std::string(
"node" + std::to_string(id_) + 
"-index")) {
 
 2701              index_.concatenate(
reinterpret_cast<INDEX*
>(buffer));
 
 2705          ToBufferFunctor toBufferFunctor(buffer, name);
 
 2707          for (
size_t i = 0; i < contents_count_; i++) {
 
 2708              visit_at(contents_, i, toBufferFunctor);  
 
 
 2721              : buffers_(buffers) { }
 
 
 2724          template <
class CONTENT>
 
 2726              content.to_char_buffers(buffers_);
 
 
 2730          std::map<std::string, uint8_t*>& buffers_;  
 
 
 2735          auto index_sequence((std::index_sequence_for<BUILDERS...>()));
 
 2738          tags_.concatenate(
reinterpret_cast<TAGS*
>(
 
 2739              buffers[
"node" + std::to_string(id_) + 
"-tags"]));
 
 2740          index_.concatenate(
reinterpret_cast<INDEX*
>(
 
 2741              buffers[
"node" + std::to_string(id_) + 
"-index"]));
 
 2744          ToCharBuffersFunctor toCharBuffersFunctor(buffers);
 
 2746          for (
size_t i = 0; i < contents_count_; i++) {
 
 2747              visit_at(contents_, i, toCharBuffersFunctor);  
 
 
 2760          template <
class CONTENT>
 
 2766          std::stringstream& out_;  
 
 
 2772          std::stringstream form_key;
 
 2773          form_key << 
"node" << id_;
 
 2774          std::string params(
"");
 
 2775          if (!parameters_.empty()) {
 
 2776              params = 
", \"parameters\": { " + parameters_ + 
" }";
 
 2778          std::stringstream out;
 
 2779          out << 
"{ \"class\": \"UnionArray\", \"tags\": \"" +
 
 2782          for (
size_t i = 0; i < contents_count_; i++) {
 
 2786              ContentsFormFunctor contentsFormFunctor(out);
 
 2787              visit_at(contents_, i, contentsFormFunctor);
 
 2790          out << params << 
"\"form_key\": \"" << form_key.str() << 
"\" }";
 
 
 2798      template <std::size_t... S>
 
 2800      content_lengths(std::index_sequence<S...>)
 const {
 
 2801        return std::vector<size_t>({std::get<S>(contents_).length()...});
 
 2805      template <std::size_t... S>
 
 2807      content_is_valid(std::index_sequence<S...>, std::string& error)
 const {
 
 2808        return std::vector<bool>({std::get<S>(contents_).is_valid(error)...});
 
 2814      GrowableBuffer<TAGS> tags_;
 
 2819      GrowableBuffer<INDEX> index_;
 
 2825      std::string parameters_;
 
 2831      size_t last_valid_index_[
sizeof...(BUILDERS)];
 
 2834      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
 
Discontiguous, one-dimensional buffer (which consists of multiple contiguous, one-dimensional panels)...
Definition GrowableBuffer.h:233
 
PRIMITIVE & append_and_get_ref(PRIMITIVE datum)
Like append, but the type signature returns the reference to PRIMITIVE.
Definition GrowableBuffer.h:484
 
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition LayoutBuilder.h:2178
 
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:2261
 
bool lsb_order() const noexcept
Determines whether the position of each bit is in Least-Significant Bit order (LSB) or not.
Definition LayoutBuilder.h:2185
 
BUILDER & append_invalid() noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:2219
 
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:2208
 
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:2344
 
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:2240
 
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:2246
 
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:2172
 
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:2271
 
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition LayoutBuilder.h:2333
 
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:2252
 
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2278
 
BitMasked(const awkward::BuilderOptions &options)
Creates a new BitMasked layout builder by allocating a new mask buffer, taking options from BuilderOp...
Definition LayoutBuilder.h:2152
 
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:2194
 
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:2295
 
BUILDER & extend_invalid(size_t size) noexcept
Sets current_byte_ and cast_ default to null, no change in current_byte_.
Definition LayoutBuilder.h:2231
 
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:2320
 
BitMasked()
Creates a new BitMasked layout builder by allocating a new mask buffer, using AWKWARD_LAYOUTBUILDER_D...
Definition LayoutBuilder.h:2129
 
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:2307
 
Functor for setting the ids of all nodes in a layout tree.
Definition LayoutBuilder.h:27
 
BuilderSetId(size_t &id)
Definition LayoutBuilder.h:29
 
void operator()(CONTENT &content)
Definition LayoutBuilder.h:32
 
bool valid_when() const noexcept
Determines when the builder content are valid.
Definition LayoutBuilder.h:1929
 
void clear() noexcept
Discards the accumulated mask and clears the content of the builder.
Definition LayoutBuilder.h:2000
 
BUILDER & append_invalid() noexcept
Inserts !valid_when in the mask.
Definition LayoutBuilder.h:1959
 
BUILDER & extend_valid(size_t size) noexcept
Inserts size number of valid_when in the mask.
Definition LayoutBuilder.h:1948
 
std::string form() const noexcept
Generates a unique description of the builder and its contents in the form of a JSON-like string.
Definition LayoutBuilder.h:2074
 
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1979
 
ByteMasked()
Creates a new ByteMasked layout builder by allocating a new mask buffer, using AWKWARD_LAYOUTBUILDER_...
Definition LayoutBuilder.h:1904
 
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1985
 
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1923
 
ByteMasked(const awkward::BuilderOptions &options)
Creates a new ByteMasked layout builder by allocating a new mask buffer, taking options from BuilderO...
Definition LayoutBuilder.h:1915
 
size_t length() const noexcept
Current length of the mask buffer.
Definition LayoutBuilder.h:2007
 
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:2065
 
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1991
 
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2013
 
BUILDER & append_valid() noexcept
Inserts valid_when in the mask.
Definition LayoutBuilder.h:1937
 
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:2030
 
BUILDER & extend_invalid(size_t size) noexcept
Inserts size number of !valid_when in the mask.
Definition LayoutBuilder.h:1970
 
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:2053
 
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:2042
 
void clear() noexcept
Definition LayoutBuilder.h:444
 
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:454
 
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:478
 
void to_buffers(std::map< std::string, void * > &) const noexcept
Definition LayoutBuilder.h:463
 
void to_buffer(void *, const char *) const noexcept
Definition LayoutBuilder.h:466
 
Empty()
Creates a new Empty layout builder.
Definition LayoutBuilder.h:435
 
void set_id(size_t &) noexcept
Definition LayoutBuilder.h:441
 
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:448
 
void buffer_nbytes(std::map< std::string, size_t > &) const noexcept
Definition LayoutBuilder.h:459
 
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:473
 
Helper class for sending a pair of field names (as enum) and field type as template parameters in Rec...
Definition LayoutBuilder.h:48
 
std::string index_as_field() const
Converts index as field string.
Definition LayoutBuilder.h:54
 
BUILDER Builder
Definition LayoutBuilder.h:50
 
const std::size_t index
Definition LayoutBuilder.h:59
 
Builder builder
Definition LayoutBuilder.h:61
 
void clear() noexcept
Discards the accumulated index and clears the content of the builder. Also, last valid returns to -1.
Definition LayoutBuilder.h:1646
 
void extend_invalid(size_t size) noexcept
Inserts -1 in the index buffer size number of times.
Definition LayoutBuilder.h:1617
 
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:1594
 
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:1721
 
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1625
 
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1631
 
IndexedOption(const awkward::BuilderOptions &options)
Creates a new IndexedOption layout builder by allocating a new index buffer, taking options from Buil...
Definition LayoutBuilder.h:1555
 
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1565
 
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:1580
 
size_t length() const noexcept
Current length of the index buffer.
Definition LayoutBuilder.h:1654
 
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Copies and concatenates all the accumulated data in the builder to a map of user-allocated buffers.
Definition LayoutBuilder.h:1712
 
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1637
 
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1660
 
IndexedOption()
Creates a new IndexedOption layout builder by allocating a new index buffer, using AWKWARD_LAYOUTBUIL...
Definition LayoutBuilder.h:1541
 
BUILDER & append_valid() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1572
 
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:1677
 
void append_invalid() noexcept
Inserts -1 in the index buffer.
Definition LayoutBuilder.h:1609
 
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:1700
 
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:1689
 
void clear() noexcept
Discards the accumulated index and clears the content of the builder.
Definition LayoutBuilder.h:1413
 
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:1493
 
Indexed(const awkward::BuilderOptions &options)
Creates a new Indexed layout builder by allocating a new index buffer, taking options from BuilderOpt...
Definition LayoutBuilder.h:1340
 
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1392
 
Indexed()
Creates a new Indexed layout builder by allocating a new index buffer, using AWKWARD_LAYOUTBUILDER_DE...
Definition LayoutBuilder.h:1327
 
BUILDER & append_index() noexcept
Inserts the last valid index in the index buffer and returns the reference to the builder content.
Definition LayoutBuilder.h:1356
 
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1398
 
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1349
 
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:1378
 
size_t length() const noexcept
Current length of the index buffer.
Definition LayoutBuilder.h:1421
 
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:1484
 
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1404
 
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1436
 
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:1428
 
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:1472
 
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:1461
 
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:1363
 
void clear() noexcept
Discards the accumulated offsets and clears the builder content.
Definition LayoutBuilder.h:301
 
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the builder content.
Definition LayoutBuilder.h:268
 
ListOffset()
Creates a new ListOffset layout builder by allocating a new offset buffer, using AWKWARD_LAYOUTBUILDE...
Definition LayoutBuilder.h:240
 
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:377
 
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:281
 
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:287
 
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:262
 
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:309
 
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:368
 
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:293
 
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:315
 
void end_list() noexcept
Ends a list and appends the current length of the list contents in the offsets buffer.
Definition LayoutBuilder.h:275
 
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:332
 
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:356
 
ListOffset(const awkward::BuilderOptions &options)
Creates a new ListOffset layout builder by allocating a new offset buffer, taking options from Builde...
Definition LayoutBuilder.h:253
 
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:345
 
Builds a NumpyArray which describes multi-dimensional data of PRIMITIVE type.
Definition LayoutBuilder.h:71
 
void clear() noexcept
Discards the accumulated data in the builder.
Definition LayoutBuilder.h:128
 
bool is_valid(std::string &) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:140
 
Numpy(const awkward::BuilderOptions &options)
Creates a new Numpy layout builder by allocating a new buffer, taking options from BuilderOptions for...
Definition LayoutBuilder.h:87
 
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:109
 
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:115
 
size_t length() const noexcept
Current length of the data.
Definition LayoutBuilder.h:134
 
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:177
 
void append(PRIMITIVE x) noexcept
Inserts a PRIMITIVE type data.
Definition LayoutBuilder.h:95
 
Numpy()
Creates a new Numpy layout builder by allocating a new buffer, using AWKWARD_LAYOUTBUILDER_DEFAULT_OP...
Definition LayoutBuilder.h:75
 
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:121
 
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:146
 
void extend(PRIMITIVE *ptr, size_t size) noexcept
Inserts an entire array of PRIMITIVE type data.
Definition LayoutBuilder.h:103
 
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:166
 
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:157
 
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:185
 
BufferNBytesFunctor(std::map< std::string, size_t > &names_nbytes)
Definition LayoutBuilder.h:640
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:645
 
Clears the builder contents.
Definition LayoutBuilder.h:586
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:589
 
ContentsFormFunctor(std::stringstream &out, const std::map< size_t, std::string > &content_names)
Definition LayoutBuilder.h:752
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:757
 
ToBufferFunctor(void *buffer, const char *name)
Definition LayoutBuilder.h:695
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:700
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:674
 
ToBuffersFunctor(std::map< std::string, void * > &buffers)
Definition LayoutBuilder.h:669
 
ToCharBuffersFunctor(std::map< std::string, uint8_t * > &buffers)
Definition LayoutBuilder.h:725
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:730
 
void clear() noexcept
Definition LayoutBuilder.h:595
 
Record()
Creates a new Record layout builder.
Definition LayoutBuilder.h:508
 
MAP UserDefinedMap
Definition LayoutBuilder.h:502
 
std::string form() const noexcept
Definition LayoutBuilder.h:776
 
RecordFieldType< INDEX >::Builder & content() noexcept
Returns the reference to the builder contents at INDEX.
Definition LayoutBuilder.h:553
 
std::tuple_element_t< INDEX, RecordContents > RecordFieldType
Definition LayoutBuilder.h:505
 
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:520
 
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:559
 
typename std::tuple< BUILDERS... > RecordContents
Definition LayoutBuilder.h:501
 
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:565
 
size_t length() const noexcept
Current number of records in first field.
Definition LayoutBuilder.h:603
 
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Definition LayoutBuilder.h:739
 
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:570
 
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:609
 
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Definition LayoutBuilder.h:654
 
void set_fields(MAP user_defined_field_id_to_name_map) noexcept
Sets the field names.
Definition LayoutBuilder.h:546
 
void to_buffer(void *buffer, const char *name) const noexcept
Definition LayoutBuilder.h:710
 
const std::vector< std::string > fields() const noexcept
Returns a vector of strings sontaining all the field names.
Definition LayoutBuilder.h:529
 
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Definition LayoutBuilder.h:683
 
RecordContents contents
Definition LayoutBuilder.h:802
 
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:1217
 
BUILDER & begin_list() noexcept
Begins a list and returns the reference to the content of the builder.
Definition LayoutBuilder.h:1185
 
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:1282
 
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1197
 
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1203
 
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1178
 
size_t length() const noexcept
Current number of lists of length SIZE.
Definition LayoutBuilder.h:1224
 
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:1275
 
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1209
 
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1230
 
void end_list() noexcept
Ends a list and increments the number of lists.
Definition LayoutBuilder.h:1191
 
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:1247
 
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:1266
 
Regular()
Creates a new Regular layout builder.
Definition LayoutBuilder.h:1171
 
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:1258
 
void append(const std::string &value)
Definition LayoutBuilder.h:419
 
String()
Definition LayoutBuilder.h:414
 
BufferNBytesFunctor(std::map< std::string, size_t > &names_nbytes)
Definition LayoutBuilder.h:972
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:977
 
Clears the builder contents.
Definition LayoutBuilder.h:916
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:920
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:1090
 
ContentsFormFunctor(std::stringstream &out)
Definition LayoutBuilder.h:1085
 
SetIdFunctor(size_t &id)
Definition LayoutBuilder.h:890
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:894
 
ToBufferFunctor(void *buffer, const char *name)
Definition LayoutBuilder.h:1030
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:1035
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:1007
 
ToBuffersFunctor(std::map< std::string, void * > &buffers)
Definition LayoutBuilder.h:1002
 
ToCharBuffersFunctor(std::map< std::string, uint8_t * > &buffers)
Definition LayoutBuilder.h:1060
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:1065
 
void clear() noexcept
Definition LayoutBuilder.h:925
 
TupleContents contents
Definition LayoutBuilder.h:1122
 
std::string form() const noexcept
Definition LayoutBuilder.h:1100
 
Tuple()
Creates a new Tuple layout builder.
Definition LayoutBuilder.h:862
 
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:876
 
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:882
 
size_t length() const noexcept
Current number of records in the first index of the tuple.
Definition LayoutBuilder.h:934
 
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Definition LayoutBuilder.h:1074
 
TupleContentType< INDEX > & content() noexcept
Returns the reference to the builder contents at INDEX.
Definition LayoutBuilder.h:870
 
void set_id(size_t &id) noexcept
Definition LayoutBuilder.h:903
 
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:940
 
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Definition LayoutBuilder.h:986
 
void to_buffer(void *buffer, const char *name) const noexcept
Definition LayoutBuilder.h:1045
 
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Definition LayoutBuilder.h:1016
 
BufferNBytesFunctor(std::map< std::string, size_t > &names_nbytes)
Definition LayoutBuilder.h:2602
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:2607
 
Discards the accumulated tags and index, and clears the builder contents.
Definition LayoutBuilder.h:2538
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:2542
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:2761
 
ContentsFormFunctor(std::stringstream &out)
Definition LayoutBuilder.h:2756
 
SetIdFunctor(size_t &id)
Definition LayoutBuilder.h:2511
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:2515
 
ToBufferFunctor(void *buffer, const char *name)
Definition LayoutBuilder.h:2679
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:2684
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:2645
 
ToBuffersFunctor(std::map< std::string, void * > &buffers)
Definition LayoutBuilder.h:2640
 
ToCharBuffersFunctor(std::map< std::string, uint8_t * > &buffers)
Definition LayoutBuilder.h:2720
 
void operator()(CONTENT &content) const
Definition LayoutBuilder.h:2725
 
void clear() noexcept
Definition LayoutBuilder.h:2548
 
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:2463
 
typename std::tuple< BUILDERS... > Contents
Definition LayoutBuilder.h:2441
 
std::tuple_element_t< I, Contents > ContentType
Definition LayoutBuilder.h:2444
 
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:2483
 
std::string form() const noexcept
Definition LayoutBuilder.h:2771
 
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:2497
 
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:2503
 
size_t length() const noexcept
Current length of the tags buffer.
Definition LayoutBuilder.h:2564
 
void to_char_buffers(std::map< std::string, uint8_t * > &buffers) const noexcept
Definition LayoutBuilder.h:2734
 
Union()
Creates a new Union layout builder by allocating new tags and index buffers, using AWKWARD_LAYOUTBUIL...
Definition LayoutBuilder.h:2448
 
ContentType< I > & content() noexcept
Definition LayoutBuilder.h:2475
 
void set_id(size_t &id) noexcept
Definition LayoutBuilder.h:2524
 
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:2570
 
void buffer_nbytes(std::map< std::string, size_t > &names_nbytes) const noexcept
Definition LayoutBuilder.h:2616
 
void to_buffer(void *buffer, const char *name) const noexcept
Definition LayoutBuilder.h:2694
 
void to_buffers(std::map< std::string, void * > &buffers) const noexcept
Definition LayoutBuilder.h:2654
 
void clear() noexcept
Clears the builder content.
Definition LayoutBuilder.h:1805
 
Unmasked()
Creates a new Unmasked layout builder.
Definition LayoutBuilder.h:1772
 
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:1859
 
const std::string & parameters() const noexcept
Parameters for the builder form.
Definition LayoutBuilder.h:1785
 
void set_parameters(std::string parameter) noexcept
Sets the form parameters.
Definition LayoutBuilder.h:1791
 
BUILDER & content() noexcept
Returns the reference to the builder content.
Definition LayoutBuilder.h:1779
 
size_t length() const noexcept
Current length of the content.
Definition LayoutBuilder.h:1811
 
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:1852
 
void set_id(size_t &id) noexcept
Assigns a unique ID to each node.
Definition LayoutBuilder.h:1797
 
bool is_valid(std::string &error) const noexcept
Checks for validity and consistency.
Definition LayoutBuilder.h:1817
 
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:1824
 
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:1843
 
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:1835
 
Definition LayoutBuilder.h:22
 
Definition ArrayBuilder.h:14
 
const std::string type_to_numpy_like()
Returns char string when the primitive type is a character.
Definition utils.h:105
 
void visit_at(std::tuple< CONTENTs... > const &contents, size_t index, FUNCTION fun)
Visits the tuple contents at index.
Definition utils.h:263
 
Options< int64_t, double > BuilderOptions
Definition BuilderOptions.h:56
 
const std::string type_to_name()
Returns the name of a primitive type as a string.
Definition utils.h:35