[thin_show_dups] remove variable number of mems per chunks.
Too slow and not used.
This commit is contained in:
parent
3b96812328
commit
216e5acb6c
@ -40,7 +40,7 @@ content_based_hash::content_based_hash(unsigned window_size)
|
|||||||
// FIXME: hard coded values
|
// FIXME: hard coded values
|
||||||
backup_div_((window_size / 4) - 1),
|
backup_div_((window_size / 4) - 1),
|
||||||
div_((window_size / 2) - 1),
|
div_((window_size / 2) - 1),
|
||||||
min_len_(window_size / 8),
|
min_len_(window_size / 4),
|
||||||
max_len_(window_size),
|
max_len_(window_size),
|
||||||
len_(0)
|
len_(0)
|
||||||
{
|
{
|
||||||
|
@ -93,8 +93,8 @@ cache_stream::chunk_wrapper::chunk_wrapper(cache_stream &parent)
|
|||||||
{
|
{
|
||||||
c_.offset_ = parent.current_index_ * parent.block_size_;
|
c_.offset_ = parent.current_index_ * parent.block_size_;
|
||||||
c_.len_ = parent.block_size_;
|
c_.len_ = parent.block_size_;
|
||||||
c_.mem_.push_back(mem(static_cast<uint8_t *>(block_.get_data()),
|
c_.mem_.begin = static_cast<uint8_t *>(block_.get_data());
|
||||||
static_cast<uint8_t *>(block_.get_data()) + parent.block_size_));
|
c_.mem_.end = c_.mem_.begin + parent.block_size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
@ -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");
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
@ -28,6 +28,11 @@
|
|||||||
|
|
||||||
namespace thin_provisioning {
|
namespace thin_provisioning {
|
||||||
struct mem {
|
struct mem {
|
||||||
|
mem()
|
||||||
|
: begin(0),
|
||||||
|
end(0) {
|
||||||
|
}
|
||||||
|
|
||||||
mem(uint8_t *b, uint8_t *e)
|
mem(uint8_t *b, uint8_t *e)
|
||||||
: begin(b),
|
: begin(b),
|
||||||
end(e) {
|
end(e) {
|
||||||
@ -38,9 +43,7 @@ namespace thin_provisioning {
|
|||||||
|
|
||||||
struct chunk {
|
struct chunk {
|
||||||
uint64_t offset_, len_;
|
uint64_t offset_, len_;
|
||||||
std::deque<mem> mem_;
|
mem mem_;
|
||||||
|
|
||||||
uint8_t operator[](uint64_t n) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class chunk_stream {
|
class chunk_stream {
|
||||||
|
@ -142,8 +142,7 @@ namespace {
|
|||||||
else {
|
else {
|
||||||
digestor_.reset();
|
digestor_.reset();
|
||||||
|
|
||||||
for (deque<mem>::const_iterator it = c.mem_.begin(); it != c.mem_.end(); it++)
|
digestor_.process_bytes(c.mem_.begin, c.mem_.end - c.mem_.begin);
|
||||||
digestor_.process_bytes(it->begin, it->end - it->begin);
|
|
||||||
|
|
||||||
unsigned int digest[5];
|
unsigned int digest[5];
|
||||||
digestor_.get_digest(digest);
|
digestor_.get_digest(digest);
|
||||||
@ -167,11 +166,9 @@ namespace {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool all_zeroes(chunk const &c) const {
|
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 = c.mem_.begin; ptr != c.mem_.end; ptr++) {
|
||||||
for (uint8_t *ptr = it->begin; ptr != it->end; ptr++) {
|
if (*ptr != 0)
|
||||||
if (*ptr != 0)
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -59,8 +59,8 @@ variable_chunk_stream::get()
|
|||||||
little_chunk_.len_ = little_e_ - little_b_;
|
little_chunk_.len_ = little_e_ - little_b_;
|
||||||
little_chunk_.offset_ = big_chunk_->offset_ + little_chunk_.len_;
|
little_chunk_.offset_ = big_chunk_->offset_ + little_chunk_.len_;
|
||||||
|
|
||||||
little_chunk_.mem_.clear();
|
little_chunk_.mem_.begin = little_b_;
|
||||||
little_chunk_.mem_.push_back(mem(little_b_, little_e_));
|
little_chunk_.mem_.end = little_e_;
|
||||||
|
|
||||||
return little_chunk_;
|
return little_chunk_;
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ variable_chunk_stream::next_big_chunk()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
big_chunk_ = &stream_.get();
|
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();
|
h_.reset();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -93,19 +93,19 @@ variable_chunk_stream::advance_one()
|
|||||||
|
|
||||||
assert(big_chunk_);
|
assert(big_chunk_);
|
||||||
|
|
||||||
big_e = big_chunk_->mem_.front().end;
|
big_e = big_chunk_->mem_.end;
|
||||||
little_b_ = little_e_;
|
little_b_ = little_e_;
|
||||||
little_e_ = last_hashed_;
|
little_e_ = last_hashed_;
|
||||||
|
|
||||||
if (little_b_ == big_e) {
|
if (little_b_ == big_e) {
|
||||||
if (next_big_chunk())
|
if (next_big_chunk())
|
||||||
big_e = big_chunk_->mem_.front().end;
|
big_e = big_chunk_->mem_.end;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(little_e_ >= big_chunk_->mem_.front().begin);
|
assert(little_e_ >= big_chunk_->mem_.begin);
|
||||||
assert(little_b_ >= big_chunk_->mem_.front().begin);
|
assert(little_b_ >= big_chunk_->mem_.begin);
|
||||||
assert(little_e_ <= big_e);
|
assert(little_e_ <= big_e);
|
||||||
assert(little_b_ <= big_e);
|
assert(little_b_ <= big_e);
|
||||||
|
|
||||||
@ -126,8 +126,8 @@ variable_chunk_stream::advance_one()
|
|||||||
if (little_e_ == big_e)
|
if (little_e_ == big_e)
|
||||||
last_hashed_ = little_e_;
|
last_hashed_ = little_e_;
|
||||||
|
|
||||||
assert(little_e_ >= big_chunk_->mem_.front().begin);
|
assert(little_e_ >= big_chunk_->mem_.begin);
|
||||||
assert(little_b_ >= big_chunk_->mem_.front().begin);
|
assert(little_b_ >= big_chunk_->mem_.begin);
|
||||||
assert(little_e_ <= big_e);
|
assert(little_e_ <= big_e);
|
||||||
assert(little_b_ <= big_e);
|
assert(little_b_ <= big_e);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user