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
17#include <arrow/array.h>
18#include <gsl/span>
19
20namespace o2::framework
21{
22using ListVector = std::vector<std::vector<int64_t>>;
23
25 gsl::span<int64_t const> offsets;
26 gsl::span<int64_t const> sizes;
27
28 std::pair<int64_t, int64_t> getSliceFor(int value) const;
29};
30
32 std::span<int const> values;
34
35 std::span<int64_t const> getSliceFor(int value) const;
36};
37
38struct Entry {
39 std::string binding;
41 std::string key;
42 bool enabled;
43
44 Entry(std::string b, ConcreteDataMatcher m, std::string k, bool e = true)
45 : binding{b},
46 matcher{m},
47 key{k},
48 enabled{e}
49 {
50 }
51
52 friend bool operator==(Entry const& lhs, Entry const& rhs)
53 {
54 return (lhs.matcher == rhs.matcher) &&
55 (lhs.key == rhs.key);
56 }
57};
58
59using Cache = std::vector<Entry>;
60
62
71
74
76 std::vector<std::vector<int64_t>> offsets;
77 std::vector<std::vector<int64_t>> sizes;
78
80 std::vector<std::vector<int>> valuesUnsorted;
81 std::vector<ListVector> groups;
82
83 ArrowTableSlicingCache(Cache&& bsks, Cache&& bsksUnsorted = {});
84
85 // set caching information externally
86 void setCaches(Cache&& bsks, Cache&& bsksUnsorted = {});
87
88 // update slicing info cache entry (assumes it is already present)
89 arrow::Status updateCacheEntry(int pos, std::shared_ptr<arrow::Table> const& table);
90 arrow::Status updateCacheEntryUnsorted(int pos, std::shared_ptr<arrow::Table> const& table);
91
92 // helper to locate cache position
93 std::pair<int, bool> getCachePos(Entry const& bindingKey) const;
94 int getCachePosSortedFor(Entry const& bindingKey) const;
95 int getCachePosUnsortedFor(Entry const& bindingKey) const;
96
97 // get slice from cache for a given value
98 SliceInfoPtr getCacheFor(Entry const& bindingKey) const;
99 SliceInfoUnsortedPtr getCacheUnsortedFor(Entry const& bindingKey) const;
102
103 static void validateOrder(Entry const& bindingKey, std::shared_ptr<arrow::Table> const& input);
104};
105} // namespace o2::framework
106
107#endif // ARROWTABLESLICINGCACHE_H
uint16_t pos
Definition RawData.h:3
const GLfloat * m
Definition glcorearb.h:4066
GLuint entry
Definition glcorearb.h:5735
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.
void updatePairList(Cache &list, Entry &entry)
ServiceKind
The kind of service we are asking for.
std::vector< Entry > Cache
std::vector< std::vector< int64_t > > ListVector
Definition list.h:40
std::vector< std::vector< int64_t > > offsets
SliceInfoUnsortedPtr getCacheUnsortedFor(Entry const &bindingKey) const
arrow::Status updateCacheEntryUnsorted(int pos, std::shared_ptr< arrow::Table > const &table)
int getCachePosSortedFor(Entry const &bindingKey) const
std::vector< std::vector< int64_t > > sizes
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={})
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)
ConcreteDataMatcher matcher
friend bool operator==(Entry const &lhs, Entry const &rhs)
Entry(std::string b, ConcreteDataMatcher m, std::string k, bool e=true)
gsl::span< int64_t const > sizes
gsl::span< int64_t const > offsets
std::pair< int64_t, int64_t > getSliceFor(int value) const
std::span< int64_t const > getSliceFor(int value) const