mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-18 00:40:30 -04:00
refactor: remove unused code
This commit is contained in:
parent
fa60881ad9
commit
dbdf7e2296
@ -54,9 +54,7 @@ class inode : public object {
|
||||
virtual void set_num(uint32_t num) = 0;
|
||||
virtual uint32_t num() const = 0;
|
||||
virtual bool has_category(fragment_category cat) const = 0;
|
||||
virtual uint32_t similarity_hash() const = 0;
|
||||
virtual uint32_t similarity_hash(fragment_category cat) const = 0;
|
||||
virtual nilsimsa::hash_type const& nilsimsa_similarity_hash() const = 0;
|
||||
virtual nilsimsa::hash_type const&
|
||||
nilsimsa_similarity_hash(fragment_category cat) const = 0;
|
||||
virtual size_t size() const = 0;
|
||||
|
@ -37,7 +37,6 @@ class inode_element_view
|
||||
public:
|
||||
inode_element_view() = default;
|
||||
|
||||
explicit inode_element_view(std::span<std::shared_ptr<inode> const> inodes);
|
||||
inode_element_view(std::span<std::shared_ptr<inode> const> inodes,
|
||||
std::span<uint32_t const> index, fragment_category cat);
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
#include "dwarfs/inode.h"
|
||||
|
||||
@ -48,15 +47,12 @@ class inode_ordering {
|
||||
impl_->by_reverse_path(sp);
|
||||
}
|
||||
|
||||
void
|
||||
by_similarity(sortable_inode_span& sp,
|
||||
std::optional<fragment_category> cat = std::nullopt) const {
|
||||
void by_similarity(sortable_inode_span& sp, fragment_category cat) const {
|
||||
impl_->by_similarity(sp, cat);
|
||||
}
|
||||
|
||||
void by_nilsimsa(worker_group& wg, similarity_ordering_options const& opts,
|
||||
sortable_inode_span& sp,
|
||||
std::optional<fragment_category> cat = std::nullopt) const {
|
||||
sortable_inode_span& sp, fragment_category cat) const {
|
||||
impl_->by_nilsimsa(wg, opts, sp, cat);
|
||||
}
|
||||
|
||||
@ -67,12 +63,11 @@ class inode_ordering {
|
||||
virtual void by_inode_number(sortable_inode_span& sp) const = 0;
|
||||
virtual void by_path(sortable_inode_span& sp) const = 0;
|
||||
virtual void by_reverse_path(sortable_inode_span& sp) const = 0;
|
||||
virtual void by_similarity(sortable_inode_span& sp,
|
||||
std::optional<fragment_category> cat) const = 0;
|
||||
virtual void
|
||||
by_similarity(sortable_inode_span& sp, fragment_category cat) const = 0;
|
||||
virtual void
|
||||
by_nilsimsa(worker_group& wg, similarity_ordering_options const& opts,
|
||||
sortable_inode_span& sp,
|
||||
std::optional<fragment_category> cat) const = 0;
|
||||
sortable_inode_span& sp, fragment_category cat) const = 0;
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -29,15 +29,6 @@
|
||||
|
||||
namespace dwarfs {
|
||||
|
||||
inode_element_view::inode_element_view(
|
||||
std::span<std::shared_ptr<inode> const> inodes)
|
||||
: inodes_{inodes} {
|
||||
hash_cache_.reserve(inodes_.size());
|
||||
for (auto& i : inodes_) {
|
||||
hash_cache_.push_back(&i->nilsimsa_similarity_hash());
|
||||
}
|
||||
}
|
||||
|
||||
inode_element_view::inode_element_view(
|
||||
std::span<std::shared_ptr<inode> const> inodes,
|
||||
std::span<uint32_t const> index, fragment_category cat)
|
||||
|
@ -96,20 +96,6 @@ class inode_ : public inode {
|
||||
fragments_, [cat](auto const& f) { return f.category() == cat; });
|
||||
}
|
||||
|
||||
uint32_t similarity_hash() const override {
|
||||
if (files_.empty()) {
|
||||
DWARFS_THROW(runtime_error, "inode has no file (similarity)");
|
||||
}
|
||||
return std::get<uint32_t>(similarity_);
|
||||
}
|
||||
|
||||
nilsimsa::hash_type const& nilsimsa_similarity_hash() const override {
|
||||
if (files_.empty()) {
|
||||
DWARFS_THROW(runtime_error, "inode has no file (nilsimsa)");
|
||||
}
|
||||
return std::get<nilsimsa::hash_type>(similarity_);
|
||||
}
|
||||
|
||||
uint32_t similarity_hash(fragment_category cat) const override {
|
||||
return find_similarity<uint32_t>(cat);
|
||||
}
|
||||
|
@ -43,11 +43,11 @@ class inode_ordering_ final : public inode_ordering::impl {
|
||||
void by_inode_number(sortable_inode_span& sp) const override;
|
||||
void by_path(sortable_inode_span& sp) const override;
|
||||
void by_reverse_path(sortable_inode_span& sp) const override;
|
||||
void by_similarity(sortable_inode_span& sp,
|
||||
std::optional<fragment_category> cat) const override;
|
||||
void by_nilsimsa(worker_group& wg, similarity_ordering_options const& opts,
|
||||
sortable_inode_span& sp,
|
||||
std::optional<fragment_category> cat) const override;
|
||||
void
|
||||
by_similarity(sortable_inode_span& sp, fragment_category cat) const override;
|
||||
void
|
||||
by_nilsimsa(worker_group& wg, similarity_ordering_options const& opts,
|
||||
sortable_inode_span& sp, fragment_category cat) const override;
|
||||
|
||||
private:
|
||||
LOG_PROXY_DECL(LoggerPolicy);
|
||||
@ -91,8 +91,8 @@ void inode_ordering_<LoggerPolicy>::by_reverse_path(
|
||||
}
|
||||
|
||||
template <typename LoggerPolicy>
|
||||
void inode_ordering_<LoggerPolicy>::by_similarity(
|
||||
sortable_inode_span& sp, std::optional<fragment_category> cat) const {
|
||||
void inode_ordering_<LoggerPolicy>::by_similarity(sortable_inode_span& sp,
|
||||
fragment_category cat) const {
|
||||
std::vector<uint32_t> hash_cache;
|
||||
|
||||
auto raw = sp.raw();
|
||||
@ -101,11 +101,7 @@ void inode_ordering_<LoggerPolicy>::by_similarity(
|
||||
hash_cache.resize(raw.size());
|
||||
|
||||
for (auto i : index) {
|
||||
if (cat) {
|
||||
hash_cache[i] = raw[i]->similarity_hash(*cat);
|
||||
} else {
|
||||
hash_cache[i] = raw[i]->similarity_hash();
|
||||
}
|
||||
hash_cache[i] = raw[i]->similarity_hash(cat);
|
||||
}
|
||||
|
||||
std::sort(index.begin(), index.end(), [&](auto a, auto b) {
|
||||
@ -131,13 +127,8 @@ void inode_ordering_<LoggerPolicy>::by_similarity(
|
||||
template <typename LoggerPolicy>
|
||||
void inode_ordering_<LoggerPolicy>::by_nilsimsa(
|
||||
worker_group& wg, similarity_ordering_options const& opts,
|
||||
sortable_inode_span& sp, std::optional<fragment_category> cat) const {
|
||||
inode_element_view ev;
|
||||
if (cat) {
|
||||
ev = inode_element_view(sp.raw(), sp.index(), *cat);
|
||||
} else {
|
||||
ev = inode_element_view(sp.raw());
|
||||
}
|
||||
sortable_inode_span& sp, fragment_category cat) const {
|
||||
auto ev = inode_element_view(sp.raw(), sp.index(), cat);
|
||||
std::promise<std::vector<uint32_t>> promise;
|
||||
auto future = promise.get_future();
|
||||
auto sim_order = similarity_ordering(LOG_GET_LOGGER, prog_, wg, opts);
|
||||
|
Loading…
x
Reference in New Issue
Block a user