Project
Loading...
Searching...
No Matches
ArrowTableSlicingCache.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef ARROWTABLESLICINGCACHE_H
13#define ARROWTABLESLICINGCACHE_H
14
16#include <arrow/array.h>
17#include <gsl/span>
18
19namespace o2::framework
20{
21using ListVector = std::vector<std::vector<int64_t>>;
22
24 gsl::span<int const> values;
25 gsl::span<int64_t const> counts;
26
27 std::pair<int64_t, int64_t> getSliceFor(int value) const;
28};
29
31 gsl::span<int const> values;
33
34 gsl::span<int64_t const> getSliceFor(int value) const;
35};
36
37struct Entry {
38 std::string binding;
39 std::string key;
40 bool enabled;
41
42 Entry(std::string b, std::string k, bool e = true)
43 : binding{b},
44 key{k},
45 enabled{e}
46 {
47 }
48};
49
50using Cache = std::vector<Entry>;
51
52void updatePairList(Cache& list, std::string const& binding, std::string const& key, bool enabled);
53
62
65
67 std::vector<std::shared_ptr<arrow::NumericArray<arrow::Int32Type>>> values;
68 std::vector<std::shared_ptr<arrow::NumericArray<arrow::Int64Type>>> counts;
69
71 std::vector<std::vector<int>> valuesUnsorted;
72 std::vector<ListVector> groups;
73
74 ArrowTableSlicingCache(Cache&& bsks, Cache&& bsksUnsorted = {});
75
76 // set caching information externally
77 void setCaches(Cache&& bsks, Cache&& bsksUnsorted = {});
78
79 // update slicing info cache entry (assumes it is already present)
80 arrow::Status updateCacheEntry(int pos, std::shared_ptr<arrow::Table> const& table);
81 arrow::Status updateCacheEntryUnsorted(int pos, std::shared_ptr<arrow::Table> const& table);
82
83 // helper to locate cache position
84 std::pair<int, bool> getCachePos(Entry const& bindingKey) const;
85 int getCachePosSortedFor(Entry const& bindingKey) const;
86 int getCachePosUnsortedFor(Entry const& bindingKey) const;
87
88 // get slice from cache for a given value
89 SliceInfoPtr getCacheFor(Entry const& bindingKey) const;
90 SliceInfoUnsortedPtr getCacheUnsortedFor(Entry const& bindingKey) const;
93
94 static void validateOrder(Entry const& bindingKey, std::shared_ptr<arrow::Table> const& input);
95};
96} // namespace o2::framework
97
98#endif // ARROWTABLESLICINGCACHE_H
uint16_t pos
Definition RawData.h:3
StringRef key
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition glcorearb.h:2513
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLsizei const GLfloat * value
Definition glcorearb.h:819
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
ServiceKind
The kind of service we are asking for.
std::vector< Entry > Cache
void updatePairList(Cache &list, std::string const &binding, std::string const &key, bool enabled)
std::vector< std::vector< int64_t > > ListVector
Definition list.h:40
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
std::vector< std::shared_ptr< arrow::NumericArray< arrow::Int32Type > > > values
void setCaches(Cache &&bsks, Cache &&bsksUnsorted={})
static constexpr ServiceKind service_kind
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::vector< std::shared_ptr< arrow::NumericArray< arrow::Int64Type > > > counts
Entry(std::string b, std::string k, bool e=true)
gsl::span< int64_t const > counts
std::pair< int64_t, int64_t > getSliceFor(int value) const
gsl::span< int64_t const > getSliceFor(int value) const