@@ -338,16 +338,16 @@ Compaction::Compaction(
338
338
_blob_garbage_collection_age_cutoff > 1
339
339
? mutable_cf_options().blob_garbage_collection_age_cutoff
340
340
: _blob_garbage_collection_age_cutoff),
341
- penultimate_level_ (
342
- // For simplicity, we don't support the concept of "penultimate level"
341
+ proximal_level_ (
342
+ // For simplicity, we don't support the concept of "proximal level"
343
343
// with `CompactionReason::kExternalSstIngestion` and
344
344
// `CompactionReason::kRefitLevel`
345
345
_compaction_reason == CompactionReason::kExternalSstIngestion ||
346
346
_compaction_reason == CompactionReason::kRefitLevel
347
347
? Compaction::kInvalidLevel
348
- : EvaluatePenultimateLevel (vstorage, mutable_cf_options_,
349
- immutable_options_, start_level_,
350
- output_level_)) {
348
+ : EvaluateProximalLevel (vstorage, mutable_cf_options_,
349
+ immutable_options_, start_level_,
350
+ output_level_)) {
351
351
MarkFilesBeingCompacted (true );
352
352
if (is_manual_compaction_) {
353
353
compaction_reason_ = CompactionReason::kManualCompaction ;
@@ -405,10 +405,10 @@ Compaction::Compaction(
405
405
}
406
406
}
407
407
408
- PopulatePenultimateLevelOutputRange ();
408
+ PopulateProximalLevelOutputRange ();
409
409
}
410
410
411
- void Compaction::PopulatePenultimateLevelOutputRange () {
411
+ void Compaction::PopulateProximalLevelOutputRange () {
412
412
if (!SupportsPerKeyPlacement ()) {
413
413
assert (keep_in_last_level_through_seqno_ == kMaxSequenceNumber );
414
414
return ;
@@ -417,46 +417,42 @@ void Compaction::PopulatePenultimateLevelOutputRange() {
417
417
// exclude the last level, the range of all input levels is the safe range
418
418
// of keys that can be moved up.
419
419
int exclude_level = number_levels_ - 1 ;
420
- penultimate_output_range_type_ = PenultimateOutputRangeType ::kNonLastRange ;
420
+ proximal_output_range_type_ = ProximalOutputRangeType ::kNonLastRange ;
421
421
422
- // For universal compaction, the penultimate_output_range could be extended if
423
- // all penultimate level files are included in the compaction (which includes
424
- // the case that the penultimate level is empty).
422
+ // For universal compaction, the proximal_output_range could be extended if
423
+ // all proximal level files are included in the compaction (which includes
424
+ // the case that the proximal level is empty).
425
425
if (immutable_options_.compaction_style == kCompactionStyleUniversal ) {
426
426
exclude_level = kInvalidLevel ;
427
- penultimate_output_range_type_ = PenultimateOutputRangeType ::kFullRange ;
428
- std::set<uint64_t > penultimate_inputs ;
427
+ proximal_output_range_type_ = ProximalOutputRangeType ::kFullRange ;
428
+ std::set<uint64_t > proximal_inputs ;
429
429
for (const auto & input_lvl : inputs_) {
430
- if (input_lvl.level == penultimate_level_ ) {
430
+ if (input_lvl.level == proximal_level_ ) {
431
431
for (const auto & file : input_lvl.files ) {
432
- penultimate_inputs .emplace (file->fd .GetNumber ());
432
+ proximal_inputs .emplace (file->fd .GetNumber ());
433
433
}
434
434
}
435
435
}
436
- auto penultimate_files = input_vstorage_->LevelFiles (penultimate_level_);
437
- for (const auto & file : penultimate_files) {
438
- if (penultimate_inputs.find (file->fd .GetNumber ()) ==
439
- penultimate_inputs.end ()) {
436
+ auto proximal_files = input_vstorage_->LevelFiles (proximal_level_);
437
+ for (const auto & file : proximal_files) {
438
+ if (proximal_inputs.find (file->fd .GetNumber ()) == proximal_inputs.end ()) {
440
439
exclude_level = number_levels_ - 1 ;
441
- penultimate_output_range_type_ =
442
- PenultimateOutputRangeType::kNonLastRange ;
440
+ proximal_output_range_type_ = ProximalOutputRangeType::kNonLastRange ;
443
441
break ;
444
442
}
445
443
}
446
444
}
447
445
448
- // FIXME: should make use of `penultimate_output_range_type_ `.
446
+ // FIXME: should make use of `proximal_output_range_type_ `.
449
447
// FIXME: when last level's input range does not overlap with
450
- // penultimate level, and penultimate level input is empty,
451
- // this call will not set penultimate_level_smallest_ or
452
- // penultimate_level_largest_. No keys will be compacted up.
453
- GetBoundaryInternalKeys (input_vstorage_, inputs_,
454
- &penultimate_level_smallest_,
455
- &penultimate_level_largest_, exclude_level);
456
-
457
- if (penultimate_output_range_type_ !=
458
- PenultimateOutputRangeType::kFullRange ) {
459
- // If not full range in penultimate level, must keep everything already
448
+ // proximal level, and proximal level input is empty,
449
+ // this call will not set proximal_level_smallest_ or
450
+ // proximal_level_largest_. No keys will be compacted up.
451
+ GetBoundaryInternalKeys (input_vstorage_, inputs_, &proximal_level_smallest_,
452
+ &proximal_level_largest_, exclude_level);
453
+
454
+ if (proximal_output_range_type_ != ProximalOutputRangeType::kFullRange ) {
455
+ // If not full range in proximal level, must keep everything already
460
456
// in the last level there, because moving it back up might cause
461
457
// overlap/placement issues that are difficult to resolve properly in the
462
458
// presence of range deletes
@@ -486,53 +482,53 @@ Compaction::~Compaction() {
486
482
}
487
483
488
484
bool Compaction::SupportsPerKeyPlacement () const {
489
- return penultimate_level_ != kInvalidLevel ;
485
+ return proximal_level_ != kInvalidLevel ;
490
486
}
491
487
492
- int Compaction::GetPenultimateLevel () const { return penultimate_level_ ; }
488
+ int Compaction::GetProximalLevel () const { return proximal_level_ ; }
493
489
494
490
// smallest_key and largest_key include timestamps if user-defined timestamp is
495
491
// enabled.
496
- bool Compaction::OverlapPenultimateLevelOutputRange (
492
+ bool Compaction::OverlapProximalLevelOutputRange (
497
493
const Slice& smallest_key, const Slice& largest_key) const {
498
494
if (!SupportsPerKeyPlacement ()) {
499
495
return false ;
500
496
}
501
497
502
- // See FIXME in Compaction::PopulatePenultimateLevelOutputRange ().
498
+ // See FIXME in Compaction::PopulateProximalLevelOutputRange ().
503
499
// We do not compact any key up in this case.
504
- if (penultimate_level_smallest_ .size () == 0 ||
505
- penultimate_level_largest_ .size () == 0 ) {
500
+ if (proximal_level_smallest_ .size () == 0 ||
501
+ proximal_level_largest_ .size () == 0 ) {
506
502
return false ;
507
503
}
508
504
509
505
const Comparator* ucmp =
510
506
input_vstorage_->InternalComparator ()->user_comparator ();
511
507
512
508
return ucmp->CompareWithoutTimestamp (
513
- smallest_key, penultimate_level_largest_ .user_key ()) <= 0 &&
509
+ smallest_key, proximal_level_largest_ .user_key ()) <= 0 &&
514
510
ucmp->CompareWithoutTimestamp (
515
- largest_key, penultimate_level_smallest_ .user_key ()) >= 0 ;
511
+ largest_key, proximal_level_smallest_ .user_key ()) >= 0 ;
516
512
}
517
513
518
514
// key includes timestamp if user-defined timestamp is enabled.
519
- void Compaction::TEST_AssertWithinPenultimateLevelOutputRange (
515
+ void Compaction::TEST_AssertWithinProximalLevelOutputRange (
520
516
const Slice& user_key, bool expect_failure) const {
521
517
#ifdef NDEBUG
522
518
(void )user_key;
523
519
(void )expect_failure;
524
520
#else
525
521
assert (SupportsPerKeyPlacement ());
526
522
527
- assert (penultimate_level_smallest_ .size () > 0 );
528
- assert (penultimate_level_largest_ .size () > 0 );
523
+ assert (proximal_level_smallest_ .size () > 0 );
524
+ assert (proximal_level_largest_ .size () > 0 );
529
525
530
526
auto * cmp = input_vstorage_->user_comparator ();
531
527
532
528
// op_type of a key can change during compaction, e.g. Merge -> Put.
533
- if (!(cmp->Compare (user_key, penultimate_level_smallest_ .user_key ()) >= 0 )) {
529
+ if (!(cmp->Compare (user_key, proximal_level_smallest_ .user_key ()) >= 0 )) {
534
530
assert (expect_failure);
535
- } else if (!(cmp->Compare (user_key, penultimate_level_largest_ .user_key ()) <=
531
+ } else if (!(cmp->Compare (user_key, proximal_level_largest_ .user_key ()) <=
536
532
0 )) {
537
533
assert (expect_failure);
538
534
} else {
@@ -1018,7 +1014,7 @@ uint64_t Compaction::MinInputFileEpochNumber() const {
1018
1014
return min_epoch_number;
1019
1015
}
1020
1016
1021
- int Compaction::EvaluatePenultimateLevel (
1017
+ int Compaction::EvaluateProximalLevel (
1022
1018
const VersionStorageInfo* vstorage,
1023
1019
const MutableCFOptions& mutable_cf_options,
1024
1020
const ImmutableOptions& immutable_options, const int start_level,
@@ -1033,21 +1029,21 @@ int Compaction::EvaluatePenultimateLevel(
1033
1029
return kInvalidLevel ;
1034
1030
}
1035
1031
1036
- int penultimate_level = output_level - 1 ;
1037
- assert (penultimate_level < immutable_options.num_levels );
1038
- if (penultimate_level <= 0 ) {
1032
+ int proximal_level = output_level - 1 ;
1033
+ assert (proximal_level < immutable_options.num_levels );
1034
+ if (proximal_level <= 0 ) {
1039
1035
return kInvalidLevel ;
1040
1036
}
1041
1037
1042
- // If the penultimate level is not within input level -> output level range
1043
- // check if the penultimate output level is empty, if it's empty, it could
1044
- // also be locked for the penultimate output.
1038
+ // If the proximal level is not within input level -> output level range
1039
+ // check if the proximal output level is empty, if it's empty, it could
1040
+ // also be locked for the proximal output.
1045
1041
// TODO: ideally, it only needs to check if there's a file within the
1046
1042
// compaction output key range. For simplicity, it just check if there's any
1047
- // file on the penultimate level.
1043
+ // file on the proximal level.
1048
1044
if (start_level == immutable_options.num_levels - 1 &&
1049
1045
(immutable_options.compaction_style != kCompactionStyleUniversal ||
1050
- !vstorage->LevelFiles (penultimate_level ).empty ())) {
1046
+ !vstorage->LevelFiles (proximal_level ).empty ())) {
1051
1047
return kInvalidLevel ;
1052
1048
}
1053
1049
@@ -1061,7 +1057,7 @@ int Compaction::EvaluatePenultimateLevel(
1061
1057
return kInvalidLevel ;
1062
1058
}
1063
1059
1064
- return penultimate_level ;
1060
+ return proximal_level ;
1065
1061
}
1066
1062
1067
1063
void Compaction::FilterInputsForCompactionIterator () {
0 commit comments