mirror of
https://github.com/grafana/loki.git
synced 2026-03-13 09:33:58 +08:00
This PR introduces an option for the column builder to limit the number of rows in a page. It can be set for logs object and index objects separately using `-dataobj-consumer.max-page-rows` and `-dataobj-index-builder.max-page-rows` respectively. Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
59 lines
1.0 KiB
Go
59 lines
1.0 KiB
Go
package indexpointers
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/grafana/loki/v3/pkg/dataobj"
|
|
)
|
|
|
|
func TestBuilder(t *testing.T) {
|
|
type pointers struct {
|
|
path string
|
|
start time.Time
|
|
end time.Time
|
|
}
|
|
|
|
pp := []pointers{
|
|
{path: "foo", start: unixTime(10), end: unixTime(20)},
|
|
{path: "bar", start: unixTime(10), end: unixTime(20)},
|
|
}
|
|
|
|
ib := NewBuilder(nil, 1024, 0)
|
|
for _, p := range pp {
|
|
ib.Append(p.path, p.start, p.end)
|
|
}
|
|
|
|
b := dataobj.NewBuilder(nil)
|
|
require.NoError(t, b.Append(ib))
|
|
|
|
obj, closer, err := b.Flush()
|
|
require.NoError(t, err)
|
|
defer closer.Close()
|
|
|
|
expect := []IndexPointer{
|
|
{
|
|
Path: "foo",
|
|
StartTs: unixTime(10),
|
|
EndTs: unixTime(20),
|
|
},
|
|
{
|
|
Path: "bar",
|
|
StartTs: unixTime(10),
|
|
EndTs: unixTime(20),
|
|
},
|
|
}
|
|
|
|
var actual []IndexPointer
|
|
for result := range Iter(context.Background(), obj) {
|
|
pointer, err := result.Value()
|
|
require.NoError(t, err)
|
|
actual = append(actual, pointer)
|
|
}
|
|
|
|
require.Equal(t, expect, actual)
|
|
}
|