Skip to content

Commit

Permalink
exports a few redefined compactor utility fns
Browse files Browse the repository at this point in the history
Signed-off-by: Owen Diehl <[email protected]>
  • Loading branch information
owen-d committed Jan 31, 2024
1 parent 4411649 commit 7845838
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pkg/compactor/compactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ func (c *Compactor) stopping(_ error) error {
}

func (c *Compactor) CompactTable(ctx context.Context, tableName string, applyRetention bool) error {
schemaCfg, ok := schemaPeriodForTable(c.schemaConfig, tableName)
schemaCfg, ok := SchemaPeriodForTable(c.schemaConfig, tableName)
if !ok {
level.Error(util_log.Logger).Log("msg", "skipping compaction since we can't find schema for table", "table", tableName)
return nil
Expand Down Expand Up @@ -720,7 +720,7 @@ func (c *Compactor) RunCompaction(ctx context.Context, applyRetention bool) (err
}

// process most recent tables first
sortTablesByRange(tables)
SortTablesByRange(tables)

// apply passed in compaction limits
if c.cfg.SkipLatestNTables <= len(tables) {
Expand Down Expand Up @@ -866,7 +866,7 @@ func (c *Compactor) ServeHTTP(w http.ResponseWriter, req *http.Request) {
c.ring.ServeHTTP(w, req)
}

func sortTablesByRange(tables []string) {
func SortTablesByRange(tables []string) {
tableRanges := make(map[string]model.Interval)
for _, table := range tables {
tableRanges[table] = retention.ExtractIntervalFromTableName(table)
Expand All @@ -879,7 +879,7 @@ func sortTablesByRange(tables []string) {

}

func schemaPeriodForTable(cfg config.SchemaConfig, tableName string) (config.PeriodConfig, bool) {
func SchemaPeriodForTable(cfg config.SchemaConfig, tableName string) (config.PeriodConfig, bool) {
tableInterval := retention.ExtractIntervalFromTableName(tableName)
schemaCfg, err := cfg.SchemaForTime(tableInterval.Start)
if err != nil || schemaCfg.IndexTables.TableFor(tableInterval.Start) != tableName {
Expand Down
4 changes: 2 additions & 2 deletions pkg/compactor/compactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func Test_schemaPeriodForTable(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
actual, actualFound := schemaPeriodForTable(tt.config, tt.tableName)
actual, actualFound := SchemaPeriodForTable(tt.config, tt.tableName)
require.Equal(t, tt.expectedFound, actualFound)
require.Equal(t, tt.expected, actual)
})
Expand All @@ -300,7 +300,7 @@ func Test_tableSort(t *testing.T) {
"index_19192",
}

sortTablesByRange(intervals)
SortTablesByRange(intervals)
require.Equal(t, []string{"index_19195", "index_19192", "index_19191"}, intervals)
}

Expand Down

0 comments on commit 7845838

Please sign in to comment.