15#include <arrow/compute/api_aggregate.h>
16#include <arrow/compute/kernel.h>
17#include <arrow/table.h>
24 auto locate = std::find_if(
list.begin(),
list.end(), [&binding, &
key](
auto const&
entry) { return (entry.binding == binding) && (entry.key == key); });
25 if (locate ==
list.end()) {
27 }
else if (!locate->enabled &&
enabled) {
28 locate->enabled =
true;
50 return {(*groups)[
value].data(), (*groups)[
value].size()};
65 bindingsKeysUnsorted{bsksUnsorted}
92 if (table->num_rows() == 0) {
93 return arrow::Status::OK();
97 throw runtime_error_f(
"Disabled cache %s/%s update requested",
b.c_str(), k.c_str());
102 auto column = table->GetColumnByName(k);
105 for (
auto iChunk = column->num_chunks() - 1; iChunk >= 0; --iChunk) {
106 auto chunk =
static_cast<arrow::NumericArray<arrow::Int32Type>
>(column->chunk(iChunk)->data());
107 for (
auto iElement = chunk.length() - 1; iElement >= 0; --iElement) {
108 auto value = chunk.Value(iElement);
125 int lastValue = std::numeric_limits<int>::max();
127 for (
auto iChunk = 0; iChunk < column->num_chunks(); ++iChunk) {
128 auto chunk =
static_cast<arrow::NumericArray<arrow::Int32Type>
>(column->chunk(iChunk)->data());
129 for (
auto iElement = 0; iElement < chunk.length(); ++iElement) {
130 auto v = chunk.Value(iElement);
132 if (
v == lastValue) {
144 return arrow::Status::OK();
151 if (table->num_rows() == 0) {
152 return arrow::Status::OK();
156 throw runtime_error_f(
"Disabled unsorted cache %s/%s update requested",
b.c_str(), k.c_str());
158 auto column = table->GetColumnByName(k);
160 for (
auto iChunk = 0; iChunk < column->num_chunks(); ++iChunk) {
161 auto chunk =
static_cast<arrow::NumericArray<arrow::Int32Type>
>(column->chunk(iChunk)->data());
162 for (
auto iElement = 0; iElement < chunk.length(); ++iElement) {
163 auto v = chunk.Value(iElement);
177 return arrow::Status::OK();
190 throw runtime_error_f(
"%s/%s not found neither in sorted or unsorted cache", bindingKey.
binding.c_str(), bindingKey.
key.c_str());
195 auto locate = std::find_if(
bindingsKeys.begin(),
bindingsKeys.end(), [&](
Entry const& bk) { return (bindingKey.binding == bk.binding) && (bindingKey.key == bk.key); });
255 auto column = input->GetColumnByName(
key);
256 auto array0 =
static_cast<arrow::NumericArray<arrow::Int32Type>
>(column->chunk(0)->data());
258 int32_t cur = array0.Value(0);
259 int32_t lastNeg = cur < 0 ? cur : 0;
260 int32_t lastPos = cur < 0 ? -1 : cur;
261 for (
auto i = 0;
i < column->num_chunks(); ++
i) {
262 auto array =
static_cast<arrow::NumericArray<arrow::Int32Type>
>(column->chunk(
i)->data());
263 for (
auto e = 0; e <
array.length(); ++e) {
270 cur =
array.Value(e);
273 throw runtime_error_f(
"Table %s index %s is not sorted: next value %d < previous value %d!",
target.c_str(),
key.c_str(), cur, lastPos);
275 if (lastPos == cur && prev < 0) {
276 throw runtime_error_f(
"Table %s index %s has a group with index %d that is split by %d",
target.c_str(),
key.c_str(), cur, prev);
280 throw runtime_error_f(
"Table %s index %s is not sorted: next negative value %d > previous negative value %d!",
target.c_str(),
key.c_str(), cur, lastNeg);
282 if (lastNeg == cur && prev >= 0) {
283 throw runtime_error_f(
"Table %s index %s has a group with index %d that is split by %d",
target.c_str(),
key.c_str(), cur, prev);
GLuint GLsizei const GLuint const GLintptr * offsets
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * value
GLenum GLsizei GLsizei GLint * values
Defining PrimaryVertex explicitly as messageable.
std::vector< Entry > Cache
void updatePairList(Cache &list, std::string const &binding, std::string const &key, bool enabled)
RuntimeErrorRef runtime_error_f(const char *,...)
void setCachesUnsorted(Cache &&bsks)
void setCaches(Cache &&bsks)
Cache bindingsKeysUnsorted
SliceInfoPtr getCacheForPos(int pos) const
SliceInfoUnsortedPtr getCacheUnsortedFor(Entry const &bindingKey) const
arrow::Status updateCacheEntryUnsorted(int pos, std::shared_ptr< arrow::Table > const &table)
int getCachePosSortedFor(Entry const &bindingKey) const
arrow::Status updateCacheEntry(int pos, std::shared_ptr< arrow::Table > const &table)
std::pair< int, bool > getCachePos(Entry const &bindingKey) const
SliceInfoPtr getCacheFor(Entry const &bindingKey) const
void setCaches(Cache &&bsks, Cache &&bsksUnsorted={})
ArrowTableSlicingCache(Cache &&bsks, Cache &&bsksUnsorted={})
Cache bindingsKeysUnsorted
SliceInfoUnsortedPtr getCacheUnsortedForPos(int pos) const
int getCachePosUnsortedFor(Entry const &bindingKey) const
std::vector< std::vector< int > > valuesUnsorted
static void validateOrder(Entry const &bindingKey, std::shared_ptr< arrow::Table > const &input)
std::pair< int64_t, int64_t > getSliceFor(int value) const
std::span< int64_t const > getSliceFor(int value) const