From fcf6678833f59f9233cf80d871aa563c8477f3d5 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Wed, 3 Mar 2021 15:21:03 +0100 Subject: [PATCH] Remove inode_hasher --- include/dwarfs/inode_hasher.h | 81 ----------------------------------- 1 file changed, 81 deletions(-) delete mode 100644 include/dwarfs/inode_hasher.h diff --git a/include/dwarfs/inode_hasher.h b/include/dwarfs/inode_hasher.h deleted file mode 100644 index 32d7c140..00000000 --- a/include/dwarfs/inode_hasher.h +++ /dev/null @@ -1,81 +0,0 @@ -/* vim:set ts=2 sw=2 sts=2 et: */ -/** - * \author Marcus Holland-Moritz (github@mhxnet.de) - * \copyright Copyright (c) Marcus Holland-Moritz - * - * This file is part of dwarfs. - * - * dwarfs is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * dwarfs is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with dwarfs. If not, see . - */ - -#pragma once - -#include -#include - -#include "dwarfs/cyclic_hash.h" -#include "dwarfs/logger.h" - -namespace dwarfs { - -template -class inode_hasher { - public: - using result_type = - typename std::unordered_map>; - - inode_hasher(logger& lgr, const std::vector& blockhash_window_size) - : window_(blockhash_window_size) - , log_(lgr) {} - - void operator()(result_type& m, const uint8_t* data, size_t size) const { - auto tt = LOG_TIMED_TRACE; - - for (size_t wsize : window_) { - if (size >= wsize) { - hashit(m[wsize], wsize, data, size); - } - } - - tt << "hashed " << size << " bytes"; - } - - private: - void hashit(std::vector& vec, size_t window, const uint8_t* data, - size_t size) const { - rsync_hash hasher; - - vec.clear(); - vec.reserve(size - window); - - size_t i = 0; - - while (i < window) { - hasher.update(data[i++]); - } - - vec.push_back(hasher()); - - while (i < size) { - hasher.update(data[i - window], data[i]); - vec.push_back(hasher()); - ++i; - } - } - - const std::vector window_; - log_proxy log_; -}; - -} // namespace dwarfs