|
8 | 8 | "fmt"
|
9 | 9 | "iter"
|
10 | 10 | "math"
|
| 11 | + "slices" |
11 | 12 | "time"
|
12 | 13 | "unsafe"
|
13 | 14 |
|
@@ -655,19 +656,9 @@ var (
|
655 | 656 | table.Bytes("sstsz", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.TableBytesFlushed + m.TableBytesCompacted }),
|
656 | 657 | table.Bytes("blobsz", 6, table.AlignRight, func(m *LevelMetrics) uint64 { return m.BlobBytesFlushed + m.BlobBytesCompacted }),
|
657 | 658 | )
|
658 |
| - compactionKindTable = table.Define[compactionKindsInfo]( |
659 |
| - table.String("kind", 6, table.AlignRight, func(i compactionKindsInfo) string { return "count" }), |
660 |
| - table.Div(), |
661 |
| - table.String("default", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.def }), |
662 |
| - table.String("delete", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.delete }), |
663 |
| - table.String("elision", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.elision }), |
664 |
| - table.String("copy", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.copy }), |
665 |
| - table.String("move", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.move }), |
666 |
| - table.String("read", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.read }), |
667 |
| - table.String("tomb", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.tombstone }), |
668 |
| - table.String("rewrite", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.rewrite }), |
669 |
| - table.String("multi", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.multilevel }), |
670 |
| - table.String("blob", 8, table.AlignRight, func(i compactionKindsInfo) string { return i.blob }), |
| 659 | + compactionKindTable = table.Define[pair[string, int64]]( |
| 660 | + table.String("kind", 5, table.AlignRight, func(p pair[string, int64]) string { return p.k }), |
| 661 | + table.Count("count", 5, table.AlignRight, func(p pair[string, int64]) int64 { return p.v }), |
671 | 662 | )
|
672 | 663 | commitPipelineInfoTableTopHeader = `COMMIT PIPELINE`
|
673 | 664 | commitPipelineInfoTableSubHeader = ` wals | memtables | ingestions`
|
@@ -761,19 +752,6 @@ var (
|
761 | 752 | )
|
762 | 753 | )
|
763 | 754 |
|
764 |
| -type compactionKindsInfo struct { |
765 |
| - def string |
766 |
| - delete string |
767 |
| - elision string |
768 |
| - copy string |
769 |
| - move string |
770 |
| - read string |
771 |
| - tombstone string |
772 |
| - rewrite string |
773 |
| - multilevel string |
774 |
| - blob string |
775 |
| -} |
776 |
| - |
777 | 755 | type commitPipelineInfo struct {
|
778 | 756 | files string
|
779 | 757 | written string
|
@@ -837,6 +815,11 @@ type keysInfo struct {
|
837 | 815 | rangeDels string
|
838 | 816 | }
|
839 | 817 |
|
| 818 | +type pair[k, v any] struct { |
| 819 | + k k |
| 820 | + v v |
| 821 | +} |
| 822 | + |
840 | 823 | // String pretty-prints the metrics.
|
841 | 824 | //
|
842 | 825 | // See testdata/metrics for an example.
|
@@ -883,21 +866,20 @@ func (m *Metrics) String() string {
|
883 | 866 | cur = compactionLevelMetricsTable.Render(cur, table.RenderOptions{}, compactionLevelIter)
|
884 | 867 | cur.Offset(-1, 0).WriteString("total")
|
885 | 868 |
|
886 |
| - compactionKindsContents := compactionKindsInfo{ |
887 |
| - def: humanizeCount(m.Compact.DefaultCount).String(), |
888 |
| - delete: humanizeCount(m.Compact.DeleteOnlyCount).String(), |
889 |
| - elision: humanizeCount(m.Compact.ElisionOnlyCount).String(), |
890 |
| - copy: humanizeCount(m.Compact.CopyCount).String(), |
891 |
| - move: humanizeCount(m.Compact.MoveCount).String(), |
892 |
| - read: humanizeCount(m.Compact.ReadCount).String(), |
893 |
| - tombstone: humanizeCount(m.Compact.TombstoneDensityCount).String(), |
894 |
| - rewrite: humanizeCount(m.Compact.RewriteCount).String(), |
895 |
| - multilevel: humanizeCount(m.Compact.MultiLevelCount).String(), |
896 |
| - blob: humanizeCount(m.Compact.BlobFileRewriteCount).String(), |
897 |
| - } |
898 |
| - |
899 | 869 | cur = cur.NewlineReturn()
|
900 |
| - cur = compactionKindTable.Render(cur, table.RenderOptions{}, oneItemIter(compactionKindsContents)) |
| 870 | + compactionKindContents := []pair[string, int64]{ |
| 871 | + {k: "default", v: m.Compact.DefaultCount}, |
| 872 | + {k: "delete", v: m.Compact.DeleteOnlyCount}, |
| 873 | + {k: "elision", v: m.Compact.ElisionOnlyCount}, |
| 874 | + {k: "move", v: m.Compact.MoveCount}, |
| 875 | + {k: "read", v: m.Compact.ReadCount}, |
| 876 | + {k: "tomb", v: m.Compact.TombstoneDensityCount}, |
| 877 | + {k: "rewrite", v: m.Compact.RewriteCount}, |
| 878 | + {k: "copy", v: m.Compact.CopyCount}, |
| 879 | + {k: "multi", v: m.Compact.MultiLevelCount}, |
| 880 | + {k: "blob", v: m.Compact.BlobFileRewriteCount}, |
| 881 | + } |
| 882 | + cur = compactionKindTable.Render(cur, table.RenderOptions{Orientation: table.Horizontally}, slices.Values(compactionKindContents)) |
901 | 883 | cur = cur.NewlineReturn()
|
902 | 884 |
|
903 | 885 | commitPipelineInfoContents := commitPipelineInfo{
|
|
0 commit comments