15#include <arrow/util/key_value_metadata.h>
16#include <arrow/util/config.h>
26 throw o2::framework::runtime_error_f(
"Trying to dereference index with a wrong type in %s_as<T> for base target \"%s\". Note that if you have several compatible index targets in your process() signature, the last one will be the one actually bound.", getter,
target);
46 rows.resize(sel->GetNumSlots());
47 for (
auto i = 0;
i < sel->GetNumSlots(); ++
i) {
48 rows[
i] = sel->GetIndex(
i);
57 auto start_iterator = std::lower_bound(mSelectedRows.begin(), mSelectedRows.end(),
start);
58 auto stop_iterator = std::lower_bound(start_iterator, mSelectedRows.end(),
end);
60 std::transform(slicedSelection.begin(), slicedSelection.end(), slicedSelection.begin(),
61 [&
start](int64_t idx) {
62 return idx - static_cast<int64_t>(start);
64 return slicedSelection;
69 if (tables.size() == 1) {
72 for (
auto i = 0U;
i < tables.size() - 1; ++
i) {
73 if (tables[
i]->num_rows() != tables[
i + 1]->num_rows()) {
75 tables[
i]->schema()->metadata()->Get(
"label").ValueOrDie().c_str(),
76 tables[
i + 1]->schema()->metadata()->Get(
"label").ValueOrDie().c_str(),
77 tables[
i]->num_rows(),
78 tables[
i + 1]->num_rows());
81 std::vector<std::shared_ptr<arrow::Field>> fields;
82 std::vector<std::shared_ptr<arrow::ChunkedArray>> columns;
84 for (
auto& t : tables) {
85 auto tf = t->fields();
86 std::copy(
tf.begin(),
tf.end(), std::back_inserter(fields));
89 auto schema = std::make_shared<arrow::Schema>(fields);
91 if (tables[0]->num_rows() != 0) {
92 for (
auto& t : tables) {
93 auto tc = t->columns();
94 std::copy(tc.begin(), tc.end(), std::back_inserter(columns));
97 return arrow::Table::Make(schema, columns);
102 if (tables.size() == 1) {
105 std::vector<std::shared_ptr<arrow::ChunkedArray>> columns;
106 assert(tables.size() > 1);
107 std::vector<std::shared_ptr<arrow::Field>> resultFields = tables[0]->schema()->fields();
108 auto compareFields = [](std::shared_ptr<arrow::Field>
const& f1, std::shared_ptr<arrow::Field>
const& f2) {
110 return (!f1->Equals(f2)) && (f1->name() < f2->name());
112 for (
size_t i = 1;
i < tables.size(); ++
i) {
113 auto& fields = tables[
i]->schema()->fields();
114 std::vector<std::shared_ptr<arrow::Field>> intersection;
116 std::set_intersection(resultFields.begin(), resultFields.end(),
117 fields.begin(), fields.end(),
118 std::back_inserter(intersection), compareFields);
119 resultFields.swap(intersection);
122 for (
auto& field : resultFields) {
123 arrow::ArrayVector chunks;
124 for (
auto& table : tables) {
125 auto ci = table->schema()->GetFieldIndex(field->name());
127 throw std::runtime_error(
"Unable to find field " + field->name());
129 auto column = table->column(ci);
130 auto otherChunks = column->chunks();
131 chunks.insert(chunks.end(), otherChunks.begin(), otherChunks.end());
133 columns.push_back(std::make_shared<arrow::ChunkedArray>(chunks));
136 auto result = arrow::Table::Make(std::make_shared<arrow::Schema>(resultFields), columns);
142 auto field = std::find_if(table->schema()->fields().begin(), table->schema()->fields().end(), [&](std::shared_ptr<arrow::Field>
const&
f) {
143 auto caseInsensitiveCompare = [](const std::string_view& str1, const std::string& str2) {
144 return std::ranges::equal(
146 [](char c1, char c2) {
147 return std::tolower(static_cast<unsigned char>(c1)) ==
148 std::tolower(static_cast<unsigned char>(c2));
152 return caseInsensitiveCompare(
label,
f->name());
154 if (field == table->schema()->fields().end()) {
157 auto index = std::distance(table->schema()->fields().begin(), field);
158 return table->column(
index).get();
183 if (
pos != std::string::npos) {
191 std::transform(
str.begin(),
str.end(),
str.begin(), [](
unsigned char c) { return std::toupper(c); });
219 offset =
static_cast<int64_t
>(offset_);
GLsizei const GLfloat * value
GLuint GLsizei const GLchar * label
std::shared_ptr< gandiva::SelectionVector > Selection
Defining PrimaryVertex explicitly as messageable.
RuntimeErrorRef runtime_error(const char *)
void throw_error(RuntimeErrorRef)
std::pair< std::string, std::string > StringPair
std::string strToUpper(std::string &&str)
RuntimeErrorRef runtime_error_f(const char *,...)
std::string cutString(std::string &&str)
SelectionVector selectionToVector(gandiva::Selection const &sel)
SelectionVector sliceSelection(gsl::span< int64_t const > const &mSelectedRows, int64_t nrows, uint64_t offset)
void notBoundTable(const char *tableName)
std::vector< int64_t > SelectionVector
void missingFilterDeclaration(int hash, int ai)
void accessingInvalidIndexFor(const char *getter)
void dereferenceWithWrongType(const char *getter, const char *target)
void getterNotFound(const char *targetColumnLabel)
void missingOptionalPreslice(const char *label, const char *key)
arrow::ChunkedArray * getIndexFromLabel(arrow::Table *table, std::string_view label)
void notFoundColumn(const char *label, const char *key)
std::unique_ptr< GPUReconstructionTimeframe > tf
StringPair const & getBindingKey() const
const std::string binding
SliceInfoUnsortedPtr sliceInfo
gsl::span< const int64_t > getSliceFor(int value) const
void updateSliceInfo(SliceInfoUnsortedPtr &&si)
void updateSliceInfo(SliceInfoPtr &&si)
std::shared_ptr< arrow::Table > getSliceFor(int value, std::shared_ptr< arrow::Table > const &input, uint64_t &offset) const
std::pair< int64_t, int64_t > getSliceFor(int value) const
gsl::span< int64_t const > getSliceFor(int value) const
static std::shared_ptr< arrow::Table > joinTables(std::vector< std::shared_ptr< arrow::Table > > &&tables)
static std::shared_ptr< arrow::Table > concatTables(std::vector< std::shared_ptr< arrow::Table > > &&tables)
std::vector< ReadoutWindowData > rows