Skip to content

Commit 2bbf368

Browse files
committed
chore(metastore): update the reader_test
1 parent c2401dd commit 2bbf368

File tree

1 file changed

+45
-12
lines changed

1 file changed

+45
-12
lines changed

pkg/dataobj/sections/pointers/reader_test.go

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,22 @@ func TestReaderWithLessThanPredicate(t *testing.T) {
309309

310310
// TestReaderWithTimestampPredicates tests reading with timestamp predicates.
311311
func TestReaderWithTimestampPredicates(t *testing.T) {
312+
var (
313+
t10 = unixTime(10)
314+
t20 = unixTime(20)
315+
t25 = unixTime(25)
316+
t25s = scalar.NewTimestampScalar(arrow.Timestamp(t25.UnixNano()), &arrow.TimestampType{Unit: arrow.Nanosecond})
317+
t30 = unixTime(30)
318+
t40 = unixTime(40)
319+
t50 = unixTime(50)
320+
t55 = unixTime(55)
321+
t55s = scalar.NewTimestampScalar(arrow.Timestamp(t55.UnixNano()), &arrow.TimestampType{Unit: arrow.Nanosecond})
322+
t60 = unixTime(60)
323+
)
312324
sec := buildSection(t, []pointers.SectionPointer{
313-
{Path: "path1", Section: 1, PointerKind: pointers.PointerKindStreamIndex, StreamID: 10, StreamIDRef: 100, StartTs: unixTime(10), EndTs: unixTime(20), LineCount: 5, UncompressedSize: 1024},
314-
{Path: "path2", Section: 2, PointerKind: pointers.PointerKindStreamIndex, StreamID: 20, StreamIDRef: 200, StartTs: unixTime(30), EndTs: unixTime(40), LineCount: 10, UncompressedSize: 2048},
315-
{Path: "path3", Section: 3, PointerKind: pointers.PointerKindStreamIndex, StreamID: 30, StreamIDRef: 300, StartTs: unixTime(50), EndTs: unixTime(60), LineCount: 15, UncompressedSize: 3072},
325+
{Path: "path1", Section: 1, PointerKind: pointers.PointerKindStreamIndex, StreamID: 10, StreamIDRef: 100, StartTs: t10, EndTs: t20, LineCount: 5, UncompressedSize: 1024},
326+
{Path: "path2", Section: 2, PointerKind: pointers.PointerKindStreamIndex, StreamID: 20, StreamIDRef: 200, StartTs: t30, EndTs: t40, LineCount: 10, UncompressedSize: 2048},
327+
{Path: "path3", Section: 3, PointerKind: pointers.PointerKindStreamIndex, StreamID: 30, StreamIDRef: 300, StartTs: t50, EndTs: t60, LineCount: 15, UncompressedSize: 3072},
316328
})
317329

318330
var (
@@ -325,14 +337,29 @@ func TestReaderWithTimestampPredicates(t *testing.T) {
325337
r := pointers.NewReader(pointers.ReaderOptions{
326338
Columns: []*pointers.Column{pathCol, sectionCol, minTimestampCol, maxTimestampCol},
327339
Allocator: memory.DefaultAllocator,
340+
// find an overlap
328341
Predicates: []pointers.Predicate{
329-
pointers.GreaterThanPredicate{
330-
Column: minTimestampCol,
331-
Value: scalar.NewTimestampScalar(arrow.Timestamp(unixTime(25).UnixNano()), &arrow.TimestampType{Unit: arrow.Nanosecond}),
332-
},
333-
pointers.LessThanPredicate{
334-
Column: maxTimestampCol,
335-
Value: scalar.NewTimestampScalar(arrow.Timestamp(unixTime(55).UnixNano()), &arrow.TimestampType{Unit: arrow.Nanosecond}),
342+
pointers.AndPredicate{
343+
Left: pointers.OrPredicate{
344+
Left: pointers.EqualPredicate{
345+
Column: maxTimestampCol,
346+
Value: t25s,
347+
},
348+
Right: pointers.GreaterThanPredicate{
349+
Column: maxTimestampCol,
350+
Value: t25s,
351+
},
352+
},
353+
Right: pointers.OrPredicate{
354+
Left: pointers.EqualPredicate{
355+
Column: minTimestampCol,
356+
Value: t55s,
357+
},
358+
Right: pointers.LessThanPredicate{
359+
Column: minTimestampCol,
360+
Value: t55s,
361+
},
362+
},
336363
},
337364
},
338365
})
@@ -347,8 +374,14 @@ func TestReaderWithTimestampPredicates(t *testing.T) {
347374
{
348375
"path.path.utf8": "path2",
349376
"section.int64": int64(2),
350-
"min_timestamp.timestamp": unixTime(30).UTC(),
351-
"max_timestamp.timestamp": unixTime(40).UTC(),
377+
"min_timestamp.timestamp": t30.UTC(),
378+
"max_timestamp.timestamp": t40.UTC(),
379+
},
380+
{
381+
"path.path.utf8": "path3",
382+
"section.int64": int64(3),
383+
"min_timestamp.timestamp": t50.UTC(),
384+
"max_timestamp.timestamp": t60.UTC(),
352385
},
353386
}
354387
require.Equal(t, expected, actual)

0 commit comments

Comments
 (0)