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
37using StringPair = std::pair<std::string, std::string>;
38
39void updatePairList(std::vector<StringPair>& list, std::string const& binding, std::string const& key);
40
43 std::vector<StringPair> bindingsKeys;
44 std::vector<StringPair> bindingsKeysUnsorted;
45
46 void setCaches(std::vector<StringPair>&& bsks);
47 void setCachesUnsorted(std::vector<StringPair>&& bsks);
48};
49
52
53 std::vector<StringPair> bindingsKeys;
54 std::vector<std::shared_ptr<arrow::NumericArray<arrow::Int32Type>>> values;
55 std::vector<std::shared_ptr<arrow::NumericArray<arrow::Int64Type>>> counts;
56
57 std::vector<StringPair> bindingsKeysUnsorted;
58 std::vector<std::vector<int>> valuesUnsorted;
59 std::vector<ListVector> groups;
60
61 ArrowTableSlicingCache(std::vector<StringPair>&& bsks, std::vector<StringPair>&& bsksUnsorted = {});
62
63 // set caching information externally
64 void setCaches(std::vector<StringPair>&& bsks, std::vector<StringPair>&& bsksUnsorted = {});
65
66 // update slicing info cache entry (assumes it is already present)
67 arrow::Status updateCacheEntry(int pos, std::shared_ptr<arrow::Table> const& table);
68 arrow::Status updateCacheEntryUnsorted(int pos, std::shared_ptr<arrow::Table> const& table);
69
70 // helper to locate cache position
71 std::pair<int, bool> getCachePos(StringPair const& bindingKey) const;
72 int getCachePosSortedFor(StringPair const& bindingKey) const;
73 int getCachePosUnsortedFor(StringPair const& bindingKey) const;
74
75 // get slice from cache for a given value
76 SliceInfoPtr getCacheFor(StringPair const& bindingKey) const;
80
81 static void validateOrder(StringPair const& bindingKey, std::shared_ptr<arrow::Table> const& input);
82};
83} // namespace o2::framework
84
85#endif // ARROWTABLESLICINGCACHE_H
uint16_t pos
Definition RawData.h:3
StringRef key
GLsizei const GLfloat * value
Definition glcorearb.h:819
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
void updatePairList(std::vector< StringPair > &list, std::string const &binding, std::string const &key)
ServiceKind
The kind of service we are asking for.
std::pair< std::string, std::string > StringPair
std::vector< std::vector< int64_t > > ListVector
Definition list.h:40
void setCaches(std::vector< StringPair > &&bsks)
void setCachesUnsorted(std::vector< StringPair > &&bsks)
std::pair< int, bool > getCachePos(StringPair const &bindingKey) const
arrow::Status updateCacheEntryUnsorted(int pos, std::shared_ptr< arrow::Table > const &table)
void setCaches(std::vector< StringPair > &&bsks, std::vector< StringPair > &&bsksUnsorted={})
arrow::Status updateCacheEntry(int pos, std::shared_ptr< arrow::Table > const &table)
int getCachePosSortedFor(StringPair const &bindingKey) const
std::vector< std::shared_ptr< arrow::NumericArray< arrow::Int32Type > > > values
int getCachePosUnsortedFor(StringPair const &bindingKey) const
static constexpr ServiceKind service_kind
SliceInfoPtr getCacheFor(StringPair const &bindingKey) const
SliceInfoUnsortedPtr getCacheUnsortedFor(StringPair const &bindingKey) const
SliceInfoUnsortedPtr getCacheUnsortedForPos(int pos) const
static void validateOrder(StringPair const &bindingKey, std::shared_ptr< arrow::Table > const &input)
std::vector< std::vector< int > > valuesUnsorted
std::vector< std::shared_ptr< arrow::NumericArray< arrow::Int64Type > > > counts
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