@@ -75,7 +75,8 @@ class IndexBuilder {
75
75
virtual Slice AddIndexEntry (const Slice& last_key_in_current_block,
76
76
const Slice* first_key_in_next_block,
77
77
const BlockHandle& block_handle,
78
- std::string* separator_scratch) = 0;
78
+ std::string* separator_scratch,
79
+ bool add_restart_point) = 0;
79
80
80
81
// An abstract (extensible) holder for passing data from PrepareIndexEntry to
81
82
// FinishIndexEntry (see below).
@@ -286,12 +287,14 @@ class ShortenedIndexBuilder : public IndexBuilder {
286
287
void AddIndexEntryImpl (const Slice& separator_with_seq,
287
288
const Slice& first_internal_key,
288
289
const BlockHandle& block_handle,
289
- bool must_use_separator_with_seq) {
290
+ bool must_use_separator_with_seq,
291
+ bool add_restart_point) {
290
292
IndexValue entry (block_handle, first_internal_key);
291
293
std::string encoded_entry;
292
294
std::string delta_encoded_entry;
293
295
entry.EncodeTo (&encoded_entry, include_first_key_, nullptr );
294
- if (use_value_delta_encoding_ && !last_encoded_handle_.IsNull ()) {
296
+ if (use_value_delta_encoding_ && !last_encoded_handle_.IsNull () &&
297
+ !add_restart_point) {
295
298
entry.EncodeTo (&delta_encoded_entry, include_first_key_,
296
299
&last_encoded_handle_);
297
300
} else {
@@ -301,6 +304,10 @@ class ShortenedIndexBuilder : public IndexBuilder {
301
304
last_encoded_handle_ = block_handle;
302
305
const Slice delta_encoded_entry_slice (delta_encoded_entry);
303
306
307
+ if (add_restart_point) {
308
+ index_block_builder_.Restart ();
309
+ }
310
+
304
311
// TODO(yuzhangyu): fix this when "FindShortInternalKeySuccessor"
305
312
// optimization is available.
306
313
// Timestamp aware comparator currently doesn't provide override for
@@ -322,15 +329,16 @@ class ShortenedIndexBuilder : public IndexBuilder {
322
329
Slice AddIndexEntry (const Slice& last_key_in_current_block,
323
330
const Slice* first_key_in_next_block,
324
331
const BlockHandle& block_handle,
325
- std::string* separator_scratch) override {
332
+ std::string* separator_scratch,
333
+ bool add_restart_point) override {
326
334
Slice separator_with_seq = GetSeparatorWithSeq (
327
335
last_key_in_current_block, first_key_in_next_block, separator_scratch);
328
336
329
337
std::string first_internal_key_buf;
330
338
Slice first_internal_key = GetFirstInternalKey (&first_internal_key_buf);
331
339
332
340
AddIndexEntryImpl (separator_with_seq, first_internal_key, block_handle,
333
- must_use_separator_with_seq_);
341
+ must_use_separator_with_seq_, add_restart_point );
334
342
current_block_first_internal_key_.clear ();
335
343
return separator_with_seq;
336
344
}
@@ -388,7 +396,7 @@ class ShortenedIndexBuilder : public IndexBuilder {
388
396
ShortenedPreparedIndexEntry* entry =
389
397
static_cast <ShortenedPreparedIndexEntry*>(base_entry);
390
398
AddIndexEntryImpl (entry->separator_with_seq , entry->first_internal_key ,
391
- block_handle, entry->must_use_separator_with_seq );
399
+ block_handle, entry->must_use_separator_with_seq , false );
392
400
}
393
401
394
402
using IndexBuilder::Finish;
@@ -483,11 +491,12 @@ class HashIndexBuilder : public IndexBuilder {
483
491
Slice AddIndexEntry (const Slice& last_key_in_current_block,
484
492
const Slice* first_key_in_next_block,
485
493
const BlockHandle& block_handle,
486
- std::string* separator_scratch) override {
494
+ std::string* separator_scratch,
495
+ bool add_restart_point) override {
487
496
++current_restart_index_;
488
497
return primary_index_builder_.AddIndexEntry (
489
498
last_key_in_current_block, first_key_in_next_block, block_handle,
490
- separator_scratch);
499
+ separator_scratch, add_restart_point );
491
500
}
492
501
493
502
std::unique_ptr<PreparedIndexEntry> CreatePreparedIndexEntry () override {
@@ -611,7 +620,8 @@ class PartitionedIndexBuilder : public IndexBuilder {
611
620
Slice AddIndexEntry (const Slice& last_key_in_current_block,
612
621
const Slice* first_key_in_next_block,
613
622
const BlockHandle& block_handle,
614
- std::string* separator_scratch) override ;
623
+ std::string* separator_scratch,
624
+ bool add_restart_point) override ;
615
625
616
626
std::unique_ptr<PreparedIndexEntry> CreatePreparedIndexEntry () override ;
617
627
void PrepareIndexEntry (const Slice& last_key_in_current_block,
0 commit comments