Fix DataBlockList::DataSize()

Parameters got filled opposite to what they were supposed to be and
also didn't consider cutoffs that land in the middle of a block.
This commit is contained in:
Jon Siwek 2019-09-24 10:21:20 -07:00
parent e30035910e
commit 5ce68bd20a
2 changed files with 14 additions and 5 deletions

View file

@ -24,9 +24,17 @@ void DataBlockList::DataSize(uint64_t seq_cutoff, uint64_t* below, uint64_t* abo
const auto& b = e.second; const auto& b = e.second;
if ( b.seq <= seq_cutoff ) if ( b.seq <= seq_cutoff )
*above += b.Size(); {
if ( b.upper <= seq_cutoff )
*below += b.Size();
else
{
*below += seq_cutoff - b.seq;
*above += b.upper - seq_cutoff;
}
}
else else
*below += b.Size(); *above += b.Size();
} }
} }

View file

@ -155,12 +155,13 @@ public:
{ return total_data_size; } { return total_data_size; }
/** /**
* Counts the total size of all list elements paritioned by some cuttof. * Counts the total size of all data contained in list elements
* partitioned by some cutoff.
* WARNING: this is an O(n) operation and potentially very slow. * WARNING: this is an O(n) operation and potentially very slow.
* @param seq_cutoff the sequence number used to partition * @param seq_cutoff the sequence number used to partition
* element sizes returned via "below" and "above" parameters * element sizes returned via "below" and "above" parameters
* @param below the size in bytes of all elements below "seq_cutoff" * @param below the size in bytes of all data below "seq_cutoff"
* @param above the size in bytes of all elements above "seq_cutoff" * @param above the size in bytes of all data above "seq_cutoff"
*/ */
void DataSize(uint64_t seq_cutoff, uint64_t* below, uint64_t* above) const; void DataSize(uint64_t seq_cutoff, uint64_t* below, uint64_t* above) const;