diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2019-12-08 18:11:26 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2020-01-02 12:13:57 +0100 |
commit | f37bf6bfb9cc557fccd32c7b2d022dd57dd9373b (patch) | |
tree | eb0db7dd60acf6af9ee8d0dc14ea25ccc1d52504 /searchcore | |
parent | 6d7909e022817be11b5f088cbd1e537d9b71919d (diff) |
Remove unused class search::grouping::MergingManager.
Diffstat (limited to 'searchcore')
3 files changed, 0 insertions, 271 deletions
diff --git a/searchcore/src/vespa/searchcore/grouping/CMakeLists.txt b/searchcore/src/vespa/searchcore/grouping/CMakeLists.txt index be61cfced93..95de834e72b 100644 --- a/searchcore/src/vespa/searchcore/grouping/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/grouping/CMakeLists.txt @@ -4,6 +4,5 @@ vespa_add_library(searchcore_grouping STATIC groupingcontext.cpp groupingmanager.cpp groupingsession.cpp - mergingmanager.cpp DEPENDS ) diff --git a/searchcore/src/vespa/searchcore/grouping/mergingmanager.cpp b/searchcore/src/vespa/searchcore/grouping/mergingmanager.cpp deleted file mode 100644 index 1fcb8a56acb..00000000000 --- a/searchcore/src/vespa/searchcore/grouping/mergingmanager.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "mergingmanager.h" -#include <map> -#include <vespa/searchlib/aggregation/grouping.h> -#include <vespa/searchlib/aggregation/fs4hit.h> -#include <vespa/vespalib/objects/objectpredicate.h> -#include <vespa/vespalib/objects/objectoperation.h> -#include <vespa/vespalib/objects/nbostream.h> - -namespace search { -namespace grouping { - -namespace { - -class PathMangler : public vespalib::ObjectPredicate, - public vespalib::ObjectOperation -{ -private: - uint32_t _partBits; - uint32_t _rowBits; - uint32_t _partId; - uint32_t _rowId; - -public: - typedef search::aggregation::FS4Hit FS4Hit; - PathMangler(uint32_t partBits, uint32_t rowBits, uint32_t partId, uint32_t rowId) - : _partBits(partBits), _rowBits(rowBits), _partId(partId), _rowId(rowId) {} - bool check(const vespalib::Identifiable &obj) const override; - void execute(vespalib::Identifiable &obj) override __attribute__((noinline)); - uint32_t computeNewPath(uint32_t path) const { - path += _partId; - if (_rowBits > 0) { - path = (path << _rowBits) + _rowId; - } - return path; - } -}; - -bool PathMangler::check(const vespalib::Identifiable &obj) const { - return (obj.getClass().id() == FS4Hit::classId); -} - -void PathMangler::execute(vespalib::Identifiable &obj) { - FS4Hit &hit = static_cast<search::aggregation::FS4Hit&>(obj); - hit.setPath(computeNewPath(hit.getPath())); -} - -} // namespace search::grouping::<unnamed> - -using search::aggregation::Grouping; - -//----------------------------------------------------------------------------- - -MergingManager::MergingManager(uint32_t partBits, uint32_t rowBits) - : _partBits(partBits), - _rowBits(rowBits), - _input(), - _result(0), - _resultLen(0) -{ -} - -MergingManager::~MergingManager() -{ - free(_result); -} - -void -MergingManager::addResult(uint32_t partId, uint32_t rowId, - const char *groupResult, size_t groupResultLen) -{ - _input.push_back(Entry(partId, rowId, groupResult, groupResultLen)); -} - -bool MergingManager::needMerge() const -{ - if (_input.size() == 1) { - PathMangler pathMangler(_partBits, _rowBits, _input[0].partId, _input[0].rowId); - if (pathMangler.computeNewPath(0) == 0) { - return false; - } - } - return true; -} - -void -MergingManager::merge() -{ - if (needMerge()) { - fullMerge(); - } else { - _resultLen = _input[0].length; - _result = (char *) malloc(_resultLen); - memcpy(_result, _input[0].data, _resultLen); - } -} - -typedef std::unique_ptr<Grouping> UP; -typedef std::map<uint32_t, UP> MAP; -typedef MAP::iterator ITR; - -namespace { - -void mergeOne(MAP & map, const MergingManager::Entry & input, uint32_t partBits, uint32_t rowBits) __attribute__((noinline)); - -void mergeOne(MAP & map, const MergingManager::Entry & input, uint32_t partBits, uint32_t rowBits) { - PathMangler pathMangler(partBits, rowBits, input.partId, input.rowId); - vespalib::nbostream is(input.data, input.length); - vespalib::NBOSerializer nis(is); - uint32_t cnt = 0; - nis >> cnt; - for (uint32_t j = 0; j < cnt; ++j) { - UP g(new Grouping()); - g->deserialize(nis); - g->select(pathMangler, pathMangler); - ITR pos = map.find(g->getId()); - if (pos == map.end()) { - map[g->getId()] = std::move(g); - } else { - pos->second->merge(*g); - } - } -} - -} - -void -MergingManager::fullMerge() -{ - MAP map; - for (size_t i = 0; i < _input.size(); ++i) { - if ((_input[i].data != NULL) && (_input[i].length > 0)) { - mergeOne(map, _input[i], _partBits, _rowBits); - } - } - vespalib::nbostream os; - vespalib::NBOSerializer nos(os); - nos << (uint32_t)map.size(); - for (auto & entry : map) { - entry.second->postMerge(); - entry.second->sortById(); - entry.second->serialize(nos); - } - _resultLen = os.size(); - _result = (char *) malloc(os.size()); - memcpy(_result, os.c_str(), os.size()); -} - -size_t -MergingManager::getGroupResultLen() const -{ - return _resultLen; -} - -const char * -MergingManager::getGroupResult() const -{ - return _result; -} - -char * -MergingManager::stealGroupResult() -{ - char *tmp = _result; - _result = 0; - return tmp; -} - -//----------------------------------------------------------------------------- - -} // namespace search::grouping -} // namespace search diff --git a/searchcore/src/vespa/searchcore/grouping/mergingmanager.h b/searchcore/src/vespa/searchcore/grouping/mergingmanager.h deleted file mode 100644 index 08349e8629a..00000000000 --- a/searchcore/src/vespa/searchcore/grouping/mergingmanager.h +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -#include <memory> -#include <vector> - -namespace search::grouping { - -/** - * Wrapper class used to handle merging of grouping results. All input - * data is assumed to be kept alive by the user. - **/ -class MergingManager -{ -public: - /** - * Simple wrapper for all the grouping results from a single - * search node. - **/ - struct Entry { - uint32_t partId; - uint32_t rowId; - const char *data; - size_t length; - - Entry(uint32_t part, uint32_t row, const char *pt, size_t len) - : partId(part), rowId(row), data(pt), length(len) {} - }; - -private: - MergingManager(const MergingManager &); - MergingManager &operator=(const MergingManager &); - void fullMerge(); - bool needMerge() const; - - uint32_t _partBits; - uint32_t _rowBits; - std::vector<Entry> _input; - char *_result; - size_t _resultLen; - -public: - /** - * Create a new merging manager. - * - * @param partBits how many bits to be used to encode partId into path - * @param rowBits how many bits to be used to encode rowId into path - **/ - MergingManager(uint32_t partBits, uint32_t rowBits); - - /** - * Release resources - **/ - ~MergingManager(); - - /** - * Register an additional grouping result that should be part of - * the upcoming merge operation. - * - * @param partId which partition these results came from - * @param rowId which row these results came from - * @param groupSpec group spec - * @param groupSpecLen length of the group spec - **/ - void addResult(uint32_t partId, uint32_t rowId, - const char *groupResult, size_t groupResultLen); - - /** - * Perform actual merging of all the registered grouping results. - **/ - void merge(); - - /** - * Obtain the size of the grouping result - * - * @return grouping result size - **/ - size_t getGroupResultLen() const; - - /** - * Obtain the grouping result. - * - * @return grouping result - **/ - const char *getGroupResult() const; - - /** - * Steal the grouping result. Invoking this method will take - * overship of the grouping result blob returned by this - * method. Use 'free' to release the memory when you are done with - * it. - * - * @return grouping result that have just been stolen - **/ - char *stealGroupResult(); -}; - -} |