GitLab maintenance scheduled for Today, 2019-12-05, from 17:00 to 18:00 CT - Services will be unavailable during this time.

Commit fac5ba6d authored by Matthieu Dorier's avatar Matthieu Dorier

corrected bug in read operations and covermap

parent dc59a4c2
......@@ -196,12 +196,10 @@ void read_op_exec_read(void* u, uint64_t offset, size_t len, buffer_u buf, size_
case seg_type_t::ZERO:
coverage.set(seg.start_index, seg.end_index);
if(*bytes_read < seg.end_index) *bytes_read = seg.end_index;
break;
case seg_type_t::TOMBSTONE:
coverage.set(seg.start_index, seg.end_index);
if(*bytes_read < seg.start_index) *bytes_read = seg.start_index;
break;
case seg_type_t::BAKE_REGION: {
......@@ -218,7 +216,6 @@ void read_op_exec_read(void* u, uint64_t offset, size_t len, buffer_u buf, size_
LEAVING;
return;
}
if(*bytes_read < r.end) *bytes_read = r.end;
}
break;
} // end case seg_type_t::BAKE_REGION
......@@ -258,7 +255,6 @@ void read_op_exec_read(void* u, uint64_t offset, size_t len, buffer_u buf, size_
LEAVING;
return;
} // end if
if(*bytes_read < r.end) *bytes_read = r.end;
} // end for
} // end case seg_type_t::SMALL_REGION
......@@ -267,6 +263,7 @@ void read_op_exec_read(void* u, uint64_t offset, size_t len, buffer_u buf, size_
if(num_segments != max_segments) done = true;
}
*bytes_read = coverage.bytes_read();
LEAVING;
}
......
......@@ -37,13 +37,15 @@ class covermap {
};
covermap(T s, T e)
: m_start(s), m_end(e) {}
: m_start(s), m_end(e), m_level(0) {}
std::list<segment> set(T start, T end) {
// make start and end match the bounds
if(start < m_start) start = m_start;
if(end > m_end) end = m_end;
if(end-start == 0) return std::list<segment>();
std::list<segment> result;
// easy case: the coverage map is empty
if(m_segments.empty()) {
......@@ -115,6 +117,18 @@ class covermap {
bool full() const {
return capacity() == level();
}
uint64_t bytes_read() const {
if(full()) return capacity();
if(m_segments.empty()) return 0;
uint64_t start = m_end;
uint64_t end = m_start;
for(const auto& s : m_segments) {
if(s.first < start) start = s.first;
if(s.second > end) end = s.second;
}
return end-start;
}
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment