blob: 557580fdbc98ab028b97f817a655adda01e59e75 (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/vespalib/stllike/string.h>
namespace storage::spi {
/*
* Class representing attribute resource usage for persistence provider.
* Numbers are normalized to be between 0.0 and 1.0
*/
class AttributeResourceUsage
{
double _usage;
vespalib::string _name; // document_type.subdb.attribute.component
public:
AttributeResourceUsage(double usage, const vespalib::string& name)
: _usage(usage),
_name(name)
{
}
AttributeResourceUsage()
: AttributeResourceUsage(0.0, "")
{
}
double get_usage() const noexcept { return _usage; }
const vespalib::string& get_name() const noexcept { return _name; }
bool valid() const noexcept { return !_name.empty(); }
bool operator==(const AttributeResourceUsage& rhs) const noexcept {
return ((_usage == rhs._usage) && (_name == rhs._name));
}
bool operator!=(const AttributeResourceUsage& rhs) const noexcept {
return !operator==(rhs);
}
};
std::ostream& operator<<(std::ostream& out, const AttributeResourceUsage& attribute_resource_usage);
}
|