Skip to content

Commit 2275e38

Browse files
committed
Describe slice-info tables as DPL inputs
Add inputForEntry and matcherForEntry, which makes the InputSpec of the slice-info table for a slicing cache entry
1 parent 86faed3 commit 2275e38

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

‎Framework/Core/include/Framework/ArrowTableSlicingCache.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
#define ARROWTABLESLICINGCACHE_H
1414

1515
#include "Framework/ConcreteDataMatcher.h"
16+
#include "Framework/DataSpecUtils.h"
17+
#include "Framework/InputSpec.h"
1618
#include "Framework/ServiceHandle.h"
19+
#include "Framework/StringHelpers.h"
1720
#include <arrow/array.h>
21+
#include <fmt/format.h>
1822
#include <gsl/span>
1923

2024
namespace o2::framework
@@ -55,6 +59,10 @@ struct Entry {
5559
}
5660
};
5761

62+
InputSpec inputForEntry(Entry const& entry, bool sorted);
63+
ConcreteDataMatcher matcherForEntry(Entry const& entry);
64+
ConcreteDataMatcher matcherForMatcherAndKey(ConcreteDataMatcher const& matcher, std::string const& key);
65+
5866
/// Layout of the slice-info tables produced by the internal slicer device.
5967
/// Row v describes the group with index value v, for v in [0, max index value];
6068
/// rows with negative index values do not belong to any group.

‎Framework/Core/src/ArrowTableSlicingCache.cxx‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,48 @@ void fillSorted(arrow::ChunkedArray* column, std::vector<int64_t>& offsets, std:
9393
}
9494
} // namespace
9595

96+
InputSpec inputForEntry(Entry const& entry, bool sorted)
97+
{
98+
// the slice info table inherits the sliced table binding and origin, while using hash
99+
// of original description and normalized column name as a new description
100+
auto& [origin, description, version] = entry.matcher;
101+
auto newdescription = std::string{description.str} + "/" + entry.key;
102+
auto hash = runtime_hash(newdescription.c_str());
103+
auto d = header::DataDescription{"initial"};
104+
d.runtimeInit(std::to_string(hash).c_str());
105+
InputSpec result{entry.binding + "_Slice", origin, d, version};
106+
// add metadata to retrieve the original table
107+
result.metadata.emplace_back(
108+
o2::framework::ConfigParamSpec{fmt::format("slice-source:{}", entry.binding),
109+
framework::VariantType::String,
110+
fmt::format("{}/{}/{}/{}", entry.binding, origin.as<std::string>(), description.as<std::string>(), version),
111+
{"\"\""}}
112+
);
113+
result.metadata.emplace_back(
114+
o2::framework::ConfigParamSpec{"slice-key", framework::VariantType::String, entry.key, {"\"\""}}
115+
);
116+
result.metadata.emplace_back(
117+
o2::framework::ConfigParamSpec{"sorted", framework::VariantType::Bool, sorted, {"\"\""}}
118+
);
119+
120+
return result;
121+
}
122+
123+
ConcreteDataMatcher matcherForEntry(Entry const& entry)
124+
{
125+
return matcherForMatcherAndKey(entry.matcher, entry.key);
126+
}
127+
128+
ConcreteDataMatcher matcherForMatcherAndKey(ConcreteDataMatcher const& matcher, std::string const& key)
129+
{
130+
auto& [origin, description, version] = matcher;
131+
auto newdescription = std::string{description.str} + "/" + key;
132+
auto hash = runtime_hash(newdescription.c_str());
133+
auto d = header::DataDescription{"initial"};
134+
d.runtimeInit(std::to_string(hash).c_str());
135+
return {origin, d, version};
136+
}
137+
96138
void updatePairList(Cache& list, Entry& entry)
97139
{
98140
auto locate = std::find(list.begin(), list.end(), entry);

0 commit comments

Comments
 (0)