@@ -1557,62 +1557,58 @@ func (p *compactionPickerByScore) addScoresToPickedCompactionMetrics(
1557
1557
}
1558
1558
}
1559
1559
1560
- // elisionOnlyAnnotator is a manifest.Annotator that annotates B-Tree
1560
+ // elisionOnlyAnnotator is a manifest.TableAnnotator that annotates B-Tree
1561
1561
// nodes with the *fileMetadata of a file meeting the obsolete keys criteria
1562
1562
// for an elision-only compaction within the subtree. If multiple files meet
1563
1563
// the criteria, it chooses whichever file has the lowest LargestSeqNum. The
1564
1564
// lowest LargestSeqNum file will be the first eligible for an elision-only
1565
1565
// compaction once snapshots less than or equal to its LargestSeqNum are closed.
1566
- var elisionOnlyAnnotator = & manifest.Annotator [manifest.TableMetadata ]{
1567
- Aggregator : manifest.PickFileAggregator {
1568
- Filter : func (f * manifest.TableMetadata ) (eligible bool , cacheOK bool ) {
1569
- if f .IsCompacting () {
1570
- return false , true
1571
- }
1566
+ var elisionOnlyAnnotator = manifest.NewTableAnnotator [manifest.TableMetadata ](manifest.PickFileAggregator {
1567
+ Filter : func (f * manifest.TableMetadata ) (eligible bool , cacheOK bool ) {
1568
+ if f .IsCompacting () {
1569
+ return false , true
1570
+ }
1572
1571
1573
- backingProps , backingPropsValid := f .TableBacking .Properties ()
1574
- stats , statsValid := f .Stats ()
1575
- if ! backingPropsValid || ! statsValid {
1576
- return false , false
1577
- }
1572
+ backingProps , backingPropsValid := f .TableBacking .Properties ()
1573
+ stats , statsValid := f .Stats ()
1574
+ if ! backingPropsValid || ! statsValid {
1575
+ return false , false
1576
+ }
1578
1577
1579
- // Bottommost files are large and not worthwhile to compact just
1580
- // to remove a few tombstones. Consider a file eligible only if
1581
- // either its own range deletions delete at least 10% of its data or
1582
- // its deletion tombstones make at least 10% of its entries.
1583
- //
1584
- // TODO(jackson): This does not account for duplicate user keys
1585
- // which may be collapsed. Ideally, we would have 'obsolete keys'
1586
- // statistics that would include tombstones, the keys that are
1587
- // dropped by tombstones and duplicated user keys. See #847.
1588
- //
1589
- // Note that tables that contain exclusively range keys (i.e. no point keys,
1590
- // `NumEntries` and `RangeDeletionsBytesEstimate` are both zero) are excluded
1591
- // from elision-only compactions.
1592
- // TODO(travers): Consider an alternative heuristic for elision of range-keys.
1593
- eligible = stats .RangeDeletionsBytesEstimate * 10 >= f .Size || backingProps .NumDeletions * 10 > backingProps .NumEntries
1594
- return eligible , true
1595
- },
1596
- Compare : func (f1 * manifest.TableMetadata , f2 * manifest.TableMetadata ) bool {
1597
- return f1 .LargestSeqNum < f2 .LargestSeqNum
1598
- },
1578
+ // Bottommost files are large and not worthwhile to compact just
1579
+ // to remove a few tombstones. Consider a file eligible only if
1580
+ // either its own range deletions delete at least 10% of its data or
1581
+ // its deletion tombstones make at least 10% of its entries.
1582
+ //
1583
+ // TODO(jackson): This does not account for duplicate user keys
1584
+ // which may be collapsed. Ideally, we would have 'obsolete keys'
1585
+ // statistics that would include tombstones, the keys that are
1586
+ // dropped by tombstones and duplicated user keys. See #847.
1587
+ //
1588
+ // Note that tables that contain exclusively range keys (i.e. no point keys,
1589
+ // `NumEntries` and `RangeDeletionsBytesEstimate` are both zero) are excluded
1590
+ // from elision-only compactions.
1591
+ // TODO(travers): Consider an alternative heuristic for elision of range-keys.
1592
+ eligible = stats .RangeDeletionsBytesEstimate * 10 >= f .Size || backingProps .NumDeletions * 10 > backingProps .NumEntries
1593
+ return eligible , true
1599
1594
},
1600
- }
1595
+ Compare : func (f1 * manifest.TableMetadata , f2 * manifest.TableMetadata ) bool {
1596
+ return f1 .LargestSeqNum < f2 .LargestSeqNum
1597
+ },
1598
+ })
1601
1599
1602
- // markedForCompactionAnnotator is a manifest.Annotator that annotates B-Tree
1600
+ // markedForCompactionAnnotator is a manifest.TableAnnotator that annotates B-Tree
1603
1601
// nodes with the *fileMetadata of a file that is marked for compaction
1604
1602
// within the subtree. If multiple files meet the criteria, it chooses
1605
1603
// whichever file has the lowest LargestSeqNum.
1606
- var markedForCompactionAnnotator = & manifest.Annotator [manifest.TableMetadata ]{
1607
- Aggregator : manifest.PickFileAggregator {
1608
- Filter : func (f * manifest.TableMetadata ) (eligible bool , cacheOK bool ) {
1609
- return f .MarkedForCompaction , true
1610
- },
1611
- Compare : func (f1 * manifest.TableMetadata , f2 * manifest.TableMetadata ) bool {
1612
- return f1 .LargestSeqNum < f2 .LargestSeqNum
1613
- },
1604
+ var markedForCompactionAnnotator = manifest.NewTableAnnotator [manifest.TableMetadata ](manifest.PickFileAggregator {
1605
+ Filter : func (f * manifest.TableMetadata ) (eligible bool , cacheOK bool ) {
1606
+ return f .MarkedForCompaction , true
1614
1607
},
1615
- }
1608
+ Compare : func (f1 * manifest.TableMetadata , f2 * manifest.TableMetadata ) bool {
1609
+ return f1 .LargestSeqNum < f2 .LargestSeqNum
1610
+ },
1611
+ })
1616
1612
1617
1613
// pickedCompactionFromCandidateFile creates a pickedCompaction from a *fileMetadata
1618
1614
// with various checks to ensure that the file still exists in the expected level
0 commit comments