aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/grouping/groupingengine.h
blob: 87c35382560a43afa73134b61b470a57c90c5d2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "groupengine.h"
#include <vespa/searchlib/aggregation/grouping.h>

namespace search::grouping {

class GroupingEngine
{
public:
    using GroupEngines = std::vector<GroupEngine *>;
public:
    GroupingEngine(const GroupingEngine &) = delete;
    GroupingEngine & operator = (const GroupingEngine &) = delete;
    GroupingEngine(aggregation::Grouping & request);
    GroupingEngine(vespalib::nbostream & request, bool oldWay);
    ~GroupingEngine();
    vespalib::nbostream & serializeOldWay(vespalib::nbostream & request) const;
    vespalib::nbostream & serialize(vespalib::nbostream & request) const;
    void aggregate(const RankedHit * rankedHit, unsigned int len);
    void merge(const GroupingEngine & b);
    aggregation::Group::UP createResult() const;
    const GroupEngines & getEngines() const { return _levels; }
private:
    void fillRootRequest(const aggregation::Group & r);
    void preFillEngines(const aggregation::Group & r, size_t levels);
    aggregation::Grouping &        _request;
    GroupEngines                   _levels;
    aggregation::GroupingLevel     _rootRequestLevel;
};

}