aboutsummaryrefslogtreecommitdiffstats
path: root/searchcommon
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2021-12-08 13:07:05 +0100
committerTor Egge <Tor.Egge@online.no>2021-12-08 13:07:05 +0100
commit7553a7267623edf2c45dd5a0fd1cea883ab691f7 (patch)
treea928677c7b0ac2d4b60ed0f5b33c0ba815210ac2 /searchcommon
parent2dd0a7ad258fa182ed3ac8a199751dd60f73b0f7 (diff)
Move CompactionStrategy from searchcommon to vespalib.
Diffstat (limited to 'searchcommon')
-rw-r--r--searchcommon/src/vespa/searchcommon/attribute/config.h3
-rw-r--r--searchcommon/src/vespa/searchcommon/common/CMakeLists.txt1
-rw-r--r--searchcommon/src/vespa/searchcommon/common/compaction_strategy.cpp15
-rw-r--r--searchcommon/src/vespa/searchcommon/common/compaction_strategy.h53
4 files changed, 2 insertions, 70 deletions
diff --git a/searchcommon/src/vespa/searchcommon/attribute/config.h b/searchcommon/src/vespa/searchcommon/attribute/config.h
index e6a428e5843..f572f5038fc 100644
--- a/searchcommon/src/vespa/searchcommon/attribute/config.h
+++ b/searchcommon/src/vespa/searchcommon/attribute/config.h
@@ -6,10 +6,10 @@
#include "collectiontype.h"
#include "hnsw_index_params.h"
#include "predicate_params.h"
-#include <vespa/searchcommon/common/compaction_strategy.h>
#include <vespa/searchcommon/common/growstrategy.h>
#include <vespa/searchcommon/common/dictionary_config.h>
#include <vespa/eval/eval/value_type.h>
+#include <vespa/vespalib/datastore/compaction_strategy.h>
#include <cassert>
#include <optional>
@@ -23,6 +23,7 @@ namespace search::attribute {
class Config {
public:
enum class Match { CASED, UNCASED };
+ using CompactionStrategy = vespalib::datastore::CompactionStrategy;
Config() noexcept;
Config(BasicType bt) noexcept : Config(bt, CollectionType::SINGLE) { }
Config(BasicType bt, CollectionType ct) noexcept : Config(bt, ct, false) { }
diff --git a/searchcommon/src/vespa/searchcommon/common/CMakeLists.txt b/searchcommon/src/vespa/searchcommon/common/CMakeLists.txt
index 77e638d7193..6cc02ae7884 100644
--- a/searchcommon/src/vespa/searchcommon/common/CMakeLists.txt
+++ b/searchcommon/src/vespa/searchcommon/common/CMakeLists.txt
@@ -1,7 +1,6 @@
# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
vespa_add_library(searchcommon_searchcommon_common OBJECT
SOURCES
- compaction_strategy.cpp
datatype.cpp
dictionary_config.cpp
growstrategy.cpp
diff --git a/searchcommon/src/vespa/searchcommon/common/compaction_strategy.cpp b/searchcommon/src/vespa/searchcommon/common/compaction_strategy.cpp
deleted file mode 100644
index 22f50ba3049..00000000000
--- a/searchcommon/src/vespa/searchcommon/common/compaction_strategy.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#include "compaction_strategy.h"
-#include <iostream>
-namespace search {
-
-std::ostream& operator<<(std::ostream& os, const CompactionStrategy& compaction_strategy)
-{
- os << "{maxDeadBytesRatio=" << compaction_strategy.getMaxDeadBytesRatio() <<
- ", maxDeadAddressSpaceRatio=" << compaction_strategy.getMaxDeadAddressSpaceRatio() <<
- "}";
- return os;
-}
-
-}
diff --git a/searchcommon/src/vespa/searchcommon/common/compaction_strategy.h b/searchcommon/src/vespa/searchcommon/common/compaction_strategy.h
deleted file mode 100644
index ced28436471..00000000000
--- a/searchcommon/src/vespa/searchcommon/common/compaction_strategy.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#pragma once
-
-#include <iosfwd>
-
-namespace search {
-
-/*
- * Class describing compaction strategy for a compactable data structure.
- */
-class CompactionStrategy
-{
-private:
- double _maxDeadBytesRatio; // Max ratio of dead bytes before compaction
- double _maxDeadAddressSpaceRatio; // Max ratio of dead address space before compaction
-public:
- CompactionStrategy() noexcept
- : _maxDeadBytesRatio(0.05),
- _maxDeadAddressSpaceRatio(0.2)
- {
- }
- CompactionStrategy(double maxDeadBytesRatio, double maxDeadAddressSpaceRatio) noexcept
- : _maxDeadBytesRatio(maxDeadBytesRatio),
- _maxDeadAddressSpaceRatio(maxDeadAddressSpaceRatio)
- {
- }
- double getMaxDeadBytesRatio() const { return _maxDeadBytesRatio; }
- double getMaxDeadAddressSpaceRatio() const { return _maxDeadAddressSpaceRatio; }
- bool operator==(const CompactionStrategy & rhs) const {
- return _maxDeadBytesRatio == rhs._maxDeadBytesRatio &&
- _maxDeadAddressSpaceRatio == rhs._maxDeadAddressSpaceRatio;
- }
- bool operator!=(const CompactionStrategy & rhs) const { return !(operator==(rhs)); }
-
- static constexpr size_t DEAD_BYTES_SLACK = 0x10000u;
-
- bool should_compact_memory(size_t used_bytes, size_t dead_bytes) const {
- return ((dead_bytes >= DEAD_BYTES_SLACK) &&
- (dead_bytes > used_bytes * getMaxDeadBytesRatio()));
- }
-
- static constexpr size_t DEAD_ADDRESS_SPACE_SLACK = 0x10000u;
-
- bool should_compact_address_space(size_t used_address_space, size_t dead_address_space) const {
- return ((dead_address_space >= DEAD_ADDRESS_SPACE_SLACK) &&
- (dead_address_space > used_address_space * getMaxDeadAddressSpaceRatio()));
- }
-};
-
-std::ostream& operator<<(std::ostream& os, const CompactionStrategy& compaction_strategy);
-
-} // namespace search