Skip to content

Commit

Permalink
tsdb: Add MustIndex() function to Head
Browse files Browse the repository at this point in the history
  • Loading branch information
ying-jeanne committed Dec 24, 2024
1 parent b500527 commit 460b7be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tsdb/head_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ func (h *Head) Index() (IndexReader, error) {
return h.indexRange(math.MinInt64, math.MaxInt64), nil
}

func (h *Head) MustIndex() IndexReader {
return h.indexRange(math.MinInt64, math.MaxInt64)
}

func (h *Head) indexRange(mint, maxt int64) *headIndexReader {
if hmin := h.MinTime(); hmin > mint {
mint = hmin
Expand Down
3 changes: 3 additions & 0 deletions tsdb/head_read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ func TestHeadIndexReader_PostingsForLabelMatching(t *testing.T) {

ir, err := h.Index()
require.NoError(t, err)

irMust := h.MustIndex()
require.Equal(t, irMust, ir)
return ir
})
}
Expand Down

0 comments on commit 460b7be

Please sign in to comment.