Fix some comments

This commit is contained in:
Jingyu Zhou 2019-12-02 10:27:48 -08:00
parent 06fb45f32a
commit 690e93145e
2 changed files with 12 additions and 11 deletions

View File

@ -175,8 +175,6 @@ struct MutationFilesReadProgress : public ReferenceCounted<MutationFilesReadProg
MutationRef m; MutationRef m;
rd >> m; rd >> m;
count++; count++;
// std::cout << msgVersion << "." << sub << " m = " << m.toString() << " size=" << msgSize << " " <<
// fd->getFilename() << "\n";
if (msgVersion >= maxVersion) { if (msgVersion >= maxVersion) {
TraceEvent("FileDecodeEnd") TraceEvent("FileDecodeEnd")
.detail("MaxV", maxVersion) .detail("MaxV", maxVersion)

View File

@ -172,7 +172,6 @@ std::vector<MutationRef> decode_value(const StringRef& value) {
p1len = reader.consume<uint32_t>(); p1len = reader.consume<uint32_t>();
p2len = reader.consume<uint32_t>(); p2len = reader.consume<uint32_t>();
// ASSERT(totalBytes == sizeof(type) + sizeof(p1len) + sizeof(p2len) + p1len + p2len);
const uint8_t* key = reader.consume(p1len); const uint8_t* key = reader.consume(p1len);
const uint8_t* val = reader.consume(p2len); const uint8_t* val = reader.consume(p2len);
@ -184,7 +183,7 @@ std::vector<MutationRef> decode_value(const StringRef& value) {
struct VersionedMutations { struct VersionedMutations {
Version version; Version version;
std::vector<MutationRef> mutations; std::vector<MutationRef> mutations;
Arena arena; // The arena that contains mutation. Arena arena; // The arena that contains the mutations.
}; };
/* /*
@ -196,7 +195,12 @@ struct VersionedMutations {
* VersionedMutations m = wait(progress->getNextBatch()); * VersionedMutations m = wait(progress->getNextBatch());
* ... * ...
* } * }
} *
* Internally, the decoding process is done block by block -- each block is
* decoded into a list of key/value pairs, which are then decoded into batches
* of mutations. Because a version's mutations can be split into many key/value
* pairs, the decoding of mutation batch needs to look ahead one more pair. So
* at any time this object might have two blocks of data in memory.
*/ */
struct DecodeProgress { struct DecodeProgress {
DecodeProgress() = default; DecodeProgress() = default;
@ -212,8 +216,8 @@ struct DecodeProgress {
// The following are private APIs: // The following are private APIs:
// PRECONDITION: empty() must return true // PRECONDITION: finished() must return false before calling this function.
// Returns the next mutation along with the arena backing it. // Returns the next batch of mutations along with the arena backing it.
ACTOR static Future<VersionedMutations> getNextBatchImpl(DecodeProgress* self) { ACTOR static Future<VersionedMutations> getNextBatchImpl(DecodeProgress* self) {
ASSERT(!self->finished()); ASSERT(!self->finished());
@ -253,18 +257,17 @@ struct DecodeProgress {
Standalone<StringRef> buf = self->combineValues(idx, bufSize); Standalone<StringRef> buf = self->combineValues(idx, bufSize);
m.mutations = decode_value(buf); m.mutations = decode_value(buf);
m.arena = buf.arena(); m.arena = buf.arena();
self->keyValues.erase(self->keyValues.begin(), self->keyValues.begin() + idx);
} else { } else {
m.mutations = decode_value(arena_kv.second.value); m.mutations = decode_value(arena_kv.second.value);
m.arena = arena_kv.first; m.arena = arena_kv.first;
self->keyValues.erase(self->keyValues.begin());
} }
self->keyValues.erase(self->keyValues.begin(), self->keyValues.begin() + idx);
return m; return m;
} }
// Returns a buffer which stitches first "idx" values into one. // Returns a buffer which stitches first "idx" values into one.
// "len" should equal to the summation of these values. // "len" MUST equal the summation of these values.
Standalone<StringRef> combineValues(const int idx, const int len) { Standalone<StringRef> combineValues(const int idx, const int len) {
ASSERT(idx <= keyValues.size() && idx > 1); ASSERT(idx <= keyValues.size() && idx > 1);
@ -321,7 +324,7 @@ struct DecodeProgress {
return Void(); return Void();
} }
// Reads a file block and decodes it. // Reads a file block, decodes it into key/value pairs, and stores these pairs.
ACTOR static Future<Void> readAndDecodeFile(DecodeProgress* self) { ACTOR static Future<Void> readAndDecodeFile(DecodeProgress* self) {
try { try {
state int64_t len = std::min<int64_t>(self->file.blockSize, self->file.fileSize - self->offset); state int64_t len = std::min<int64_t>(self->file.blockSize, self->file.fileSize - self->offset);