MCPcopy
hub / github.com/grafana/tempo / TestNilIterator

Function TestNilIterator

pkg/parquetquery/nil_iter_test.go:11–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestNilIterator(t *testing.T) {
12 count := 90_000
13 pf := createNilIterTestFile(t, count)
14 column := "attrs.list.element.Key"
15
16 idx, _, _ := GetColumnIndexByPath(pf, column)
17 filter := NewIncludeNilStringEqualPredicate([]byte("special-key"))
18 iter := NewNilSyncIterator(context.TODO(), pf.RowGroups(), idx, SyncIteratorOptSelectAs(column), SyncIteratorOptPredicate(filter), SyncIteratorOptMaxDefinitionLevel(1))
19 defer iter.Close()
20
21 matchedRow := []int{}
22 for i := 0; i < count; i++ {
23 if i%3 != 0 {
24 matchedRow = append(matchedRow, i)
25 }
26 }
27
28 // special key is added to every 3rd row, so we should get 60,000 results where the key is NOT present
29 for j := 0; j < count*2/3; j++ {
30 res, err := iter.Next()
31 require.NoError(t, err)
32 require.NotNil(t, res, "j=%d", j)
33 rowEqual := EqualRowNumber(0, RowNumber{int32(matchedRow[j]), -1, -1, -1, -1, -1, -1, -1}, res.RowNumber)
34 require.True(t, rowEqual, "expected row %v but got %v", matchedRow[j], res.RowNumber)
35 }
36
37 res, err := iter.Next()
38 require.NoError(t, err)
39 require.Nil(t, res)
40}
41
42func createNilIterTestFile(t testing.TB, count int) *parquet.File {
43 type Attr struct {

Callers

nothing calls this directly

Calls 10

NextMethod · 0.95
createNilIterTestFileFunction · 0.85
GetColumnIndexByPathFunction · 0.85
NewNilSyncIteratorFunction · 0.85
SyncIteratorOptSelectAsFunction · 0.85
SyncIteratorOptPredicateFunction · 0.85
EqualRowNumberFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected