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

Function testPredicate

pkg/parquetquery/predicates_test.go:309–335  ·  view source on GitHub ↗

testPredicate by writing data and then iterating the column. The data model must contain a single column.

(t *testing.T, tc predicateTestCase)

Source from the content-addressed store, hash-verified

307// testPredicate by writing data and then iterating the column.
308// The data model must contain a single column.
309func testPredicate(t *testing.T, tc predicateTestCase) {
310 t.Helper()
311 buf := new(bytes.Buffer)
312 w := parquet.NewWriter(buf)
313 tc.writeData(w)
314 w.Flush()
315 w.Close()
316
317 file := bytes.NewReader(buf.Bytes())
318 r, err := parquet.OpenFile(file, int64(buf.Len()))
319 require.NoError(t, err)
320
321 p := InstrumentedPredicate{Pred: tc.predicate}
322
323 i := NewSyncIterator(context.TODO(), r.RowGroups(), 0, SyncIteratorOptPredicate(&p))
324 for {
325 res, err := i.Next()
326 require.NoError(t, err)
327 if res == nil {
328 break
329 }
330 }
331
332 require.Equal(t, tc.keptChunks, int(p.KeptColumnChunks), "keptChunks")
333 require.Equal(t, tc.keptPages, int(p.KeptPages), "keptPages")
334 require.Equal(t, tc.keptValues, int(p.KeptValues), "keptValues")
335}
336
337func BenchmarkSubstringPredicate(b *testing.B) {
338 p := NewSubstringPredicate("abc")

Callers 7

TestSubstringPredicateFunction · 0.85
TestNewStringInPredicateFunction · 0.85
TestNewRegexInPredicateFunction · 0.85
TestIntInPredicateFunction · 0.85
TestIntNotInPredicateFunction · 0.85

Calls 8

NextMethod · 0.95
NewSyncIteratorFunction · 0.85
SyncIteratorOptPredicateFunction · 0.85
BytesMethod · 0.80
FlushMethod · 0.65
CloseMethod · 0.65
LenMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected