blob: e00f2e9aa0712b99ec4144fd2ae799e8be78a441 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
* @class storage::CountVisitor
* @ingroup visitors
*
* @brief A count visitor is a visitor that sends documentid statistics
* to the client.
*
*/
#pragma once
#include "visitor.h"
namespace storage {
class CountVisitor : public Visitor {
public:
CountVisitor(StorageComponent&,
const vdslib::Parameters& params);
void completedVisiting(HitCounter&) override;
private:
void handleDocuments(const document::BucketId& bucketId,
DocEntryList & entries,
HitCounter& hitCounter) override;
bool _doScheme;
std::map<std::string, int> _schemeCount;
bool _doNamespace;
using NamespaceCountMap = std::map<vespalib::string, int>;
NamespaceCountMap _namespaceCount;
bool _doUser;
std::map<uint64_t, int> _userCount;
bool _doGroup;
using GroupCountMap = std::map<vespalib::string, int>;
GroupCountMap _groupCount;
};
struct CountVisitorFactory : public VisitorFactory {
std::shared_ptr<VisitorEnvironment>
makeVisitorEnvironment(StorageComponent&) override {
return std::make_shared<VisitorEnvironment>();
};
Visitor*
makeVisitor(StorageComponent& c, VisitorEnvironment&,
const vdslib::Parameters& params) override
{
return new CountVisitor(c, params);
}
};
}
|