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;
67std::shared_ptr<arrow::Table>
ArrowHelpers::joinTables(std::vector<std::shared_ptr<arrow::Table>>&& tables, std::span<const char* const> labels)
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 labels[
i], labels[
i + 1], tables[
i]->num_rows(), tables[
i + 1]->num_rows());
78 std::vector<std::shared_ptr<arrow::Field>> fields;
79 std::vector<std::shared_ptr<arrow::ChunkedArray>> columns;
81 for (
auto& t : tables) {
82 auto tf = t->fields();
83 std::copy(
tf.begin(),
tf.end(), std::back_inserter(fields));
86 auto schema = std::make_shared<arrow::Schema>(fields);
88 if (tables[0]->num_rows() != 0) {
89 for (
auto& t : tables) {
90 auto tc = t->columns();
91 std::copy(tc.begin(), tc.end(), std::back_inserter(columns));
94 return arrow::Table::Make(schema, columns);
99 if (tables.size() == 1) {
102 std::vector<std::shared_ptr<arrow::ChunkedArray>> columns;
103 assert(tables.size() > 1);
104 std::vector<std::shared_ptr<arrow::Field>> resultFields = tables[0]->schema()->fields();
105 auto compareFields = [](std::shared_ptr<arrow::Field>
const& f1, std::shared_ptr<arrow::Field>
const& f2) {
107 return (!f1->Equals(f2)) && (f1->name() < f2->name());
109 for (
size_t i = 1;
i < tables.size(); ++
i) {
110 auto& fields = tables[
i]->schema()->fields();
111 std::vector<std::shared_ptr<arrow::Field>> intersection;
113 std::set_intersection(resultFields.begin(), resultFields.end(),
114 fields.begin(), fields.end(),
115 std::back_inserter(intersection), compareFields);
116 resultFields.swap(intersection);
119 for (
auto& field : resultFields) {
120 arrow::ArrayVector chunks;
121 for (
auto& table : tables) {
122 auto ci = table->schema()->GetFieldIndex(field->name());
124 throw std::runtime_error(
"Unable to find field " + field->name());
126 auto column = table->column(ci);
127 auto otherChunks = column->chunks();
128 chunks.insert(chunks.end(), otherChunks.begin(), otherChunks.end());
130 columns.push_back(std::make_shared<arrow::ChunkedArray>(chunks));
133 auto result = arrow::Table::Make(std::make_shared<arrow::Schema>(resultFields), columns);
139 auto field = std::find_if(table->schema()->fields().begin(), table->schema()->fields().end(), [&](std::shared_ptr<arrow::Field>
const&
f) {
140 auto caseInsensitiveCompare = [](const std::string_view& str1, const std::string& str2) {
141 return std::ranges::equal(
143 [](char c1, char c2) {
144 return std::tolower(static_cast<unsigned char>(c1)) ==
145 std::tolower(static_cast<unsigned char>(c2));
149 return caseInsensitiveCompare(
label,
f->name());
151 if (field == table->schema()->fields().end()) {
154 auto index = std::distance(table->schema()->fields().begin(), field);
155 return table->column(
index).get();
180 if (
pos != std::string::npos) {
188 std::transform(
str.begin(),
str.end(),
str.begin(), [](
unsigned char c) { return std::toupper(c); });
216 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::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
const std::string binding
Entry const & getBindingKey() const
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, std::span< const char *const > labels)
static std::shared_ptr< arrow::Table > concatTables(std::vector< std::shared_ptr< arrow::Table > > &&tables)
std::vector< ReadoutWindowData > rows