aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/attribute/address_space_usage_stats.cpp
blob: 8904be6ed6d7d166cf1d8a6b8eabec5a22066674 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "address_space_usage_stats.h"
#include <ostream>

namespace proton {

AddressSpaceUsageStats::AddressSpaceUsageStats(const vespalib::AddressSpace & usage)
    : _usage(usage),
      _attributeName(),
      _component_name(),
      _subDbName()
{
}

AddressSpaceUsageStats::~AddressSpaceUsageStats() = default;

void
AddressSpaceUsageStats::merge(const vespalib::AddressSpace &usage,
                              const vespalib::string &attributeName,
                              const vespalib::string &component_name,
                              const vespalib::string &subDbName)
{
    if (attributeName.empty() || usage.usage() > _usage.usage()) {
        _usage = usage;
        _attributeName = attributeName;
        _component_name = component_name;
        _subDbName = subDbName;
    }
}

std::ostream&
operator<<(std::ostream& out, const AddressSpaceUsageStats& rhs)
{
    out << "{usage=" << rhs.getUsage() <<
           ", attribute_name=" << rhs.getAttributeName() <<
           ", component_name=" << rhs.get_component_name() <<
           ", subdb_name=" << rhs.getSubDbName() << "}";
    return out;
}

} // namespace proton