diff options
author | Arne Juul <arnej@verizonmedia.com> | 2020-11-06 14:32:44 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2020-11-06 14:57:44 +0000 |
commit | 6d1552839a5d44294da227f18a88e188411c699e (patch) | |
tree | c9d317deee020d25dbf933618ae48350d8953670 /eval | |
parent | 42c7b83b98622e7af61adae806c7df53cc01b568 (diff) |
just reorder so optimized join implementations are together
Diffstat (limited to 'eval')
-rw-r--r-- | eval/src/vespa/eval/eval/fast_value.hpp | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/eval/src/vespa/eval/eval/fast_value.hpp b/eval/src/vespa/eval/eval/fast_value.hpp index 559f2e0a7f6..2b7f36cec33 100644 --- a/eval/src/vespa/eval/eval/fast_value.hpp +++ b/eval/src/vespa/eval/eval/fast_value.hpp @@ -155,17 +155,17 @@ struct FastValueIndex final : Value::Index { ConstArrayRef<LCT> lhs_cells, ConstArrayRef<RCT> rhs_cells, Stash &stash); template <typename LCT, typename RCT, typename OCT, typename Fun> - static const Value &sparse_only_merge(const ValueType &res_type, const Fun &fun, - const FastValueIndex &lhs, const FastValueIndex &rhs, - ConstArrayRef<LCT> lhs_cells, ConstArrayRef<RCT> rhs_cells, - Stash &stash) __attribute((noinline)); - - template <typename LCT, typename RCT, typename OCT, typename Fun> static const Value &sparse_no_overlap_join(const ValueType &res_type, const Fun &fun, const FastValueIndex &lhs, const FastValueIndex &rhs, const std::vector<JoinAddrSource> &addr_sources, ConstArrayRef<LCT> lhs_cells, ConstArrayRef<RCT> rhs_cells, Stash &stash); + template <typename LCT, typename RCT, typename OCT, typename Fun> + static const Value &sparse_only_merge(const ValueType &res_type, const Fun &fun, + const FastValueIndex &lhs, const FastValueIndex &rhs, + ConstArrayRef<LCT> lhs_cells, ConstArrayRef<RCT> rhs_cells, + Stash &stash) __attribute((noinline)); + size_t size() const override { return map.size(); } std::unique_ptr<View> create_view(const std::vector<size_t> &dims) const override; }; @@ -333,42 +333,6 @@ FastValueIndex::sparse_full_overlap_join(const ValueType &res_type, const Fun &f template <typename LCT, typename RCT, typename OCT, typename Fun> const Value & -FastValueIndex::sparse_only_merge(const ValueType &res_type, const Fun &fun, - const FastValueIndex &lhs, const FastValueIndex &rhs, - ConstArrayRef<LCT> lhs_cells, ConstArrayRef<RCT> rhs_cells, Stash &stash) -{ - auto &result = stash.create<FastValue<OCT>>(res_type, lhs.map.num_dims(), 1, lhs.map.size()+rhs.map.size()); - lhs.map.each_map_entry([&](auto lhs_subspace, auto hash) - { - auto idx = result.my_index.map.add_mapping(lhs.map.make_addr(lhs_subspace), hash); - if (__builtin_expect((idx == result.my_cells.size), true)) { - auto rhs_subspace = rhs.map.lookup(hash); - if (rhs_subspace != FastSparseMap::npos()) { - auto cell_value = fun(lhs_cells[lhs_subspace], rhs_cells[rhs_subspace]); - result.my_cells.push_back_fast(cell_value); - } else { - result.my_cells.push_back_fast(lhs_cells[lhs_subspace]); - } - } - }); - rhs.map.each_map_entry([&](auto rhs_subspace, auto hash) - { - auto lhs_subspace = lhs.map.lookup(hash); - if (lhs_subspace == FastSparseMap::npos()) { - auto idx = result.my_index.map.add_mapping(rhs.map.make_addr(rhs_subspace), hash); - if (__builtin_expect((idx == result.my_cells.size), true)) { - result.my_cells.push_back_fast(rhs_cells[rhs_subspace]); - } - } - }); - - return result; -} - -//----------------------------------------------------------------------------- - -template <typename LCT, typename RCT, typename OCT, typename Fun> -const Value & FastValueIndex::sparse_no_overlap_join(const ValueType &res_type, const Fun &fun, const FastValueIndex &lhs, const FastValueIndex &rhs, const std::vector<JoinAddrSource> &addr_sources, @@ -408,4 +372,40 @@ FastValueIndex::sparse_no_overlap_join(const ValueType &res_type, const Fun &fun return result; } +//----------------------------------------------------------------------------- + +template <typename LCT, typename RCT, typename OCT, typename Fun> +const Value & +FastValueIndex::sparse_only_merge(const ValueType &res_type, const Fun &fun, + const FastValueIndex &lhs, const FastValueIndex &rhs, + ConstArrayRef<LCT> lhs_cells, ConstArrayRef<RCT> rhs_cells, Stash &stash) +{ + auto &result = stash.create<FastValue<OCT>>(res_type, lhs.map.num_dims(), 1, lhs.map.size()+rhs.map.size()); + lhs.map.each_map_entry([&](auto lhs_subspace, auto hash) + { + auto idx = result.my_index.map.add_mapping(lhs.map.make_addr(lhs_subspace), hash); + if (__builtin_expect((idx == result.my_cells.size), true)) { + auto rhs_subspace = rhs.map.lookup(hash); + if (rhs_subspace != FastSparseMap::npos()) { + auto cell_value = fun(lhs_cells[lhs_subspace], rhs_cells[rhs_subspace]); + result.my_cells.push_back_fast(cell_value); + } else { + result.my_cells.push_back_fast(lhs_cells[lhs_subspace]); + } + } + }); + rhs.map.each_map_entry([&](auto rhs_subspace, auto hash) + { + auto lhs_subspace = lhs.map.lookup(hash); + if (lhs_subspace == FastSparseMap::npos()) { + auto idx = result.my_index.map.add_mapping(rhs.map.make_addr(rhs_subspace), hash); + if (__builtin_expect((idx == result.my_cells.size), true)) { + result.my_cells.push_back_fast(rhs_cells[rhs_subspace]); + } + } + }); + + return result; +} + } |