diff --git a/fdbclient/MutationLogReader.actor.cpp b/fdbclient/MutationLogReader.actor.cpp index 4f9d61eb52..3cbcce5da2 100644 --- a/fdbclient/MutationLogReader.actor.cpp +++ b/fdbclient/MutationLogReader.actor.cpp @@ -103,7 +103,7 @@ ACTOR Future PipelinedReader::getNext_impl(PipelinedReader* self, Database return Void(); } - begin = kvs.getReadThrough(begin.arena()); + begin = kvs.getReadThrough(); break; } catch (Error& e) { diff --git a/fdbclient/include/fdbclient/FDBTypes.h b/fdbclient/include/fdbclient/FDBTypes.h index 3d64cff4af..fa1cd30247 100644 --- a/fdbclient/include/fdbclient/FDBTypes.h +++ b/fdbclient/include/fdbclient/FDBTypes.h @@ -750,11 +750,14 @@ struct GetRangeLimits { struct RangeResultRef : VectorRef { constexpr static FileIdentifier file_identifier = 3985192; - bool more; // True if values remain in the *key* range requested (possibly beyond the - // limits requested), but not necessarily only if, for example, in getRangeStream(), 'more' is always set - // to true, as each stream fragment doesn't know if it's the last one. Instead, it uses - // `error_code_end_of_stream` for the end. - // False implies that no such values remain + + // True if the range may have more keys in it (possibly beyond the specified limits). + // 'more' can be true even if there are no keys left in the range, e.g. if a shard boundary is hit, it may or may + // not have more keys left, but 'more' will be set to true in that case. + // Additionally, 'getRangeStream()' always sets 'more' to true and uses the 'end_of_stream' error to indicate that a + // range is exhausted. + // If 'more' is false, the range is guaranteed to have been exhausted. + bool more; // Only present when 'more' is true, for example, when the read reaches the shard boundary, 'readThrough' is set to // the shard boundary and the client's next range read should start with the 'readThrough'. @@ -765,18 +768,18 @@ struct RangeResultRef : VectorRef { // if reverse) of the range which was read. Optional readThrough; - // return the value represent the end (or beginning if reverse) of the range which was read - KeyRef getReadThrough(Arena& arena) const { + // return the value represent the end of the range which was read, it's only for non-reverse range read. + // TODO: add support for reverse range read + Key getReadThrough() const { ASSERT(more); if (readThrough.present()) { return readThrough.get(); } ASSERT(size() > 0); - // TODO: is this still right if reverse - return keyAfter(back().key, arena); + return keyAfter(back().key); } - // Helper function to get the next range scan's BeginKeySelector, currently only for non-reverse range read. + // Helper function to get the next range scan's BeginKeySelector, it's only for non-reverse range read. // TODO: add another function for reverse range read KeySelectorRef nextBeginKeySelector() const { ASSERT(more); diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 4a18925335..ab723555fa 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -7617,7 +7617,7 @@ ACTOR Future fetchKeys(StorageServer* data, AddingShard* shard) { data->byteSampleApplySet(*kvItr, invalidVersion); } if (this_block.more) { - blockBegin = this_block.getReadThrough(blockBegin.arena()); + blockBegin = this_block.getReadThrough(); } else { ASSERT(!this_block.readThrough.present()); blockBegin = rangeEnd; @@ -9717,7 +9717,7 @@ ACTOR Future createSstFileForCheckpointShardBytesSample(StorageServer* dat numSampledKeys++; } if (readResult.more) { - readBegin = readResult.getReadThrough(readBegin.arena()); + readBegin = readResult.getReadThrough(); ASSERT(readBegin <= readEnd); } else { break; // finish for current metaDataRangesIter