@@ -1072,40 +1072,6 @@ func newCombinedDeletionKeyspanIter(
1072
1072
return mIter , nil
1073
1073
}
1074
1074
1075
- // rangeKeySetsAnnotator is a manifest.TableAnnotator that annotates B-Tree nodes
1076
- // with the sum of the files' counts of range key fragments. The count of range
1077
- // key sets may change once a table's stats are loaded asynchronously, so its
1078
- // values are marked as cacheable only if a file's stats have been loaded.
1079
- var rangeKeySetsAnnotator = manifest .SumAnnotator (func (f * manifest.TableMetadata ) (uint64 , bool ) {
1080
- if props , ok := f .TableBacking .Properties (); ok {
1081
- return f .ScaleStatistic (props .NumRangeKeySets ), true
1082
- }
1083
- return 0 , false
1084
- })
1085
-
1086
- // tombstonesAnnotator is a manifest.TableAnnotator that annotates B-Tree nodes
1087
- // with the sum of the files' counts of tombstones (DEL, SINGLEDEL and RANGEDEL
1088
- // keys). The count of tombstones may change once a table's stats are loaded
1089
- // asynchronously, so its values are marked as cacheable only if a file's stats
1090
- // have been loaded.
1091
- var tombstonesAnnotator = manifest .SumAnnotator (func (f * manifest.TableMetadata ) (uint64 , bool ) {
1092
- if props , ok := f .TableBacking .Properties (); ok {
1093
- return f .ScaleStatistic (props .NumDeletions ), true
1094
- }
1095
- return 0 , false
1096
- })
1097
-
1098
- // valueBlocksSizeAnnotator is a manifest.TableAnnotator that annotates B-Tree
1099
- // nodes with the sum of the files' Properties.ValueBlocksSize. The value block
1100
- // size may change once a table's stats are loaded asynchronously, so its
1101
- // values are marked as cacheable only if a file's stats have been loaded.
1102
- var valueBlockSizeAnnotator = manifest .SumAnnotator (func (f * manifest.TableMetadata ) (uint64 , bool ) {
1103
- if props , ok := f .TableBacking .Properties (); ok {
1104
- return f .ScaleStatistic (props .ValueBlocksSize ), true
1105
- }
1106
- return 0 , false
1107
- })
1108
-
1109
1075
type deletionBytes struct {
1110
1076
// PointDels contains a sum of TableStats.PointDeletionsBytesEstimate.
1111
1077
PointDels uint64
@@ -1129,44 +1095,47 @@ var deletionBytesAnnotator = manifest.NewTableAnnotator[deletionBytes](manifest.
1129
1095
},
1130
1096
})
1131
1097
1132
- // compressionStatsAnnotator is a manifest.TableAnnotator that annotates B-tree nodes
1133
- // with the compression statistics for tables. Its annotation type is
1134
- // block.CompressionStats. The compression type may change once a table's stats
1135
- // are loaded asynchronously, so its values are marked as cacheable only if a
1136
- // file's stats have been loaded. Statistics for virtual tables are estimated
1137
- // from the physical table statistics, proportional to the estimated virtual
1138
- // table size.
1139
- var compressionStatsAnnotator = manifest.NewTableAnnotator [CompressionMetrics ](compressionStatsAggregator {})
1140
-
1141
- type compressionStatsAggregator struct {}
1142
-
1143
- func (a compressionStatsAggregator ) Zero () * CompressionMetrics {
1144
- return & CompressionMetrics {}
1145
- }
1146
-
1147
- func (a compressionStatsAggregator ) Accumulate (
1148
- f * manifest.TableMetadata , dst * CompressionMetrics ,
1149
- ) (v * CompressionMetrics , cacheOK bool ) {
1150
- stats , statsValid := f .TableBacking .Properties ()
1151
- if ! statsValid || stats .CompressionStats .IsEmpty () {
1152
- dst .CompressedBytesWithoutStats += f .Size
1153
- return dst , statsValid
1154
- }
1155
- compressionStats := stats .CompressionStats
1156
- if f .Virtual {
1157
- // Scale the compression stats for virtual tables.
1158
- compressionStats = compressionStats .Scale (f .Size , f .TableBacking .Size )
1159
- }
1160
- dst .Add (& compressionStats )
1161
- return dst , true
1098
+ // annotatedTableProps are properties derived from TableBackingProperties that
1099
+ // are aggregated for metrics.
1100
+ type aggregatedTableProps struct {
1101
+ // NumRangeKeySets is the sum of the tables' counts of range key fragments.
1102
+ NumRangeKeySets uint64
1103
+ // NumDeletions is the sum of the tables' counts of tombstones (DEL, SINGLEDEL
1104
+ // and RANGEDEL keys).
1105
+ NumDeletions uint64
1106
+ // ValueBlocksSize is the sum of the tables' Properties.ValueBlocksSize.
1107
+ ValueBlocksSize uint64
1108
+
1109
+ CompressionMetrics CompressionMetrics
1162
1110
}
1163
1111
1164
- func (a compressionStatsAggregator ) Merge (
1165
- src * CompressionMetrics , dst * CompressionMetrics ,
1166
- ) * CompressionMetrics {
1167
- dst .MergeWith (src )
1168
- return dst
1169
- }
1112
+ var tablePropsAnnotator = manifest.NewTableAnnotator [aggregatedTableProps ](manifest.SumAggregator [aggregatedTableProps ]{
1113
+ AddFunc : func (src , dst * aggregatedTableProps ) {
1114
+ dst .NumRangeKeySets += src .NumRangeKeySets
1115
+ dst .NumDeletions += src .NumDeletions
1116
+ dst .ValueBlocksSize += src .ValueBlocksSize
1117
+ dst .CompressionMetrics .MergeWith (& src .CompressionMetrics )
1118
+ },
1119
+ AccumulateFunc : func (f * manifest.TableMetadata ) (v aggregatedTableProps , cacheOK bool ) {
1120
+ props , propsValid := f .TableBacking .Properties ()
1121
+ if propsValid {
1122
+ v .NumRangeKeySets = props .NumRangeKeySets
1123
+ v .NumDeletions = props .NumDeletions
1124
+ v .ValueBlocksSize = props .ValueBlocksSize
1125
+ }
1126
+ if ! propsValid || props .CompressionStats .IsEmpty () {
1127
+ v .CompressionMetrics .CompressedBytesWithoutStats = f .ScaleStatistic (f .Size )
1128
+ } else {
1129
+ compressionStats := props .CompressionStats
1130
+ if f .Virtual {
1131
+ // Scale the compression stats for virtual tables.
1132
+ compressionStats = compressionStats .Scale (f .Size , f .TableBacking .Size )
1133
+ }
1134
+ v .CompressionMetrics .Add (& compressionStats )
1135
+ }
1136
+ return v , propsValid
1137
+ },
1138
+ })
1170
1139
1171
1140
// compressionStatsAnnotator is a manifest.TableAnnotator that annotates B-tree nodes
1172
1141
// with the compression statistics for tables. Its annotation type is
0 commit comments