| 927 | } |
| 928 | |
| 929 | void AppendRowGroups(FileMetaDataImpl* other) { |
| 930 | std::ostringstream diff_output; |
| 931 | if (!schema()->Equals(*other->schema(), &diff_output)) { |
| 932 | auto msg = "AppendRowGroups requires equal schemas.\n" + diff_output.str(); |
| 933 | throw ParquetException(msg); |
| 934 | } |
| 935 | |
| 936 | // ARROW-13654: `other` may point to self, be careful not to enter an infinite loop |
| 937 | const int n = other->num_row_groups(); |
| 938 | // ARROW-16613: do not use reserve() as that may suppress overallocation |
| 939 | // and incur O(n²) behavior on repeated calls to AppendRowGroups(). |
| 940 | // (see https://en.cppreference.com/w/cpp/container/vector/reserve |
| 941 | // about inappropriate uses of reserve()). |
| 942 | const auto start = metadata_->row_groups.size(); |
| 943 | metadata_->row_groups.resize(start + n); |
| 944 | for (int i = 0; i < n; i++) { |
| 945 | metadata_->row_groups[start + i] = other->row_group(i); |
| 946 | metadata_->num_rows += metadata_->row_groups[start + i].num_rows; |
| 947 | } |
| 948 | } |
| 949 | |
| 950 | std::shared_ptr<FileMetaData> Subset(const std::vector<int>& row_groups) { |
| 951 | for (int i : row_groups) { |
nothing calls this directly
no test coverage detected