[thin_show_dups] remove variable number of mems per chunks.

Too slow and not used.
This commit is contained in:
Joe Thornber 2015-09-04 13:48:02 +01:00
parent 3b96812328
commit 216e5acb6c
6 changed files with 22 additions and 36 deletions

View File

@ -40,7 +40,7 @@ content_based_hash::content_based_hash(unsigned window_size)
// FIXME: hard coded values
backup_div_((window_size / 4) - 1),
div_((window_size / 2) - 1),
min_len_(window_size / 8),
min_len_(window_size / 4),
max_len_(window_size),
len_(0)
{

View File

@ -93,8 +93,8 @@ cache_stream::chunk_wrapper::chunk_wrapper(cache_stream &parent)
{
c_.offset_ = parent.current_index_ * parent.block_size_;
c_.len_ = parent.block_size_;
c_.mem_.push_back(mem(static_cast<uint8_t *>(block_.get_data()),
static_cast<uint8_t *>(block_.get_data()) + parent.block_size_));
c_.mem_.begin = static_cast<uint8_t *>(block_.get_data());
c_.mem_.end = c_.mem_.begin + parent.block_size_;
}
//----------------------------------------------------------------

View File

@ -5,19 +5,5 @@ using namespace thin_provisioning;
//----------------------------------------------------------------
uint8_t
chunk::operator[](uint64_t n) const
{
std::deque<mem>::const_iterator it;
for (it = mem_.begin(); it != mem_.end(); it++) {
uint64_t mem_len = it->end - it->begin;
if (n > mem_len)
n -= mem_len;
else
return it->begin[n];
}
throw runtime_error("chunk out of bounds");
}
//----------------------------------------------------------------

View File

@ -28,6 +28,11 @@
namespace thin_provisioning {
struct mem {
mem()
: begin(0),
end(0) {
}
mem(uint8_t *b, uint8_t *e)
: begin(b),
end(e) {
@ -38,9 +43,7 @@ namespace thin_provisioning {
struct chunk {
uint64_t offset_, len_;
std::deque<mem> mem_;
uint8_t operator[](uint64_t n) const;
mem mem_;
};
class chunk_stream {

View File

@ -142,8 +142,7 @@ namespace {
else {
digestor_.reset();
for (deque<mem>::const_iterator it = c.mem_.begin(); it != c.mem_.end(); it++)
digestor_.process_bytes(it->begin, it->end - it->begin);
digestor_.process_bytes(c.mem_.begin, c.mem_.end - c.mem_.begin);
unsigned int digest[5];
digestor_.get_digest(digest);
@ -167,12 +166,10 @@ namespace {
private:
bool all_zeroes(chunk const &c) const {
for (deque<mem>::const_iterator it = c.mem_.begin(); it != c.mem_.end(); it++) {
for (uint8_t *ptr = it->begin; ptr != it->end; ptr++) {
for (uint8_t *ptr = c.mem_.begin; ptr != c.mem_.end; ptr++) {
if (*ptr != 0)
return false;
}
}
return true;
}

View File

@ -59,8 +59,8 @@ variable_chunk_stream::get()
little_chunk_.len_ = little_e_ - little_b_;
little_chunk_.offset_ = big_chunk_->offset_ + little_chunk_.len_;
little_chunk_.mem_.clear();
little_chunk_.mem_.push_back(mem(little_b_, little_e_));
little_chunk_.mem_.begin = little_b_;
little_chunk_.mem_.end = little_e_;
return little_chunk_;
}
@ -80,7 +80,7 @@ variable_chunk_stream::next_big_chunk()
return false;
big_chunk_ = &stream_.get();
little_b_ = little_e_ = last_hashed_ = big_chunk_->mem_.front().begin;
little_b_ = little_e_ = last_hashed_ = big_chunk_->mem_.begin;
h_.reset();
return true;
@ -93,19 +93,19 @@ variable_chunk_stream::advance_one()
assert(big_chunk_);
big_e = big_chunk_->mem_.front().end;
big_e = big_chunk_->mem_.end;
little_b_ = little_e_;
little_e_ = last_hashed_;
if (little_b_ == big_e) {
if (next_big_chunk())
big_e = big_chunk_->mem_.front().end;
big_e = big_chunk_->mem_.end;
else
return false;
}
assert(little_e_ >= big_chunk_->mem_.front().begin);
assert(little_b_ >= big_chunk_->mem_.front().begin);
assert(little_e_ >= big_chunk_->mem_.begin);
assert(little_b_ >= big_chunk_->mem_.begin);
assert(little_e_ <= big_e);
assert(little_b_ <= big_e);
@ -126,8 +126,8 @@ variable_chunk_stream::advance_one()
if (little_e_ == big_e)
last_hashed_ = little_e_;
assert(little_e_ >= big_chunk_->mem_.front().begin);
assert(little_b_ >= big_chunk_->mem_.front().begin);
assert(little_e_ >= big_chunk_->mem_.begin);
assert(little_b_ >= big_chunk_->mem_.begin);
assert(little_e_ <= big_e);
assert(little_b_ <= big_e);