Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/column/lowcardinality.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type LowCardinality struct {
keys32 UInt32
keys64 UInt64

rowCache []any

append struct {
keys []int
index map[any]int
Expand All @@ -59,6 +61,7 @@ func (col *LowCardinality) Reset() {
col.keys16.Reset()
col.keys32.Reset()
col.keys64.Reset()
col.rowCache = nil
col.append.index = make(map[any]int)
col.append.keys = col.append.keys[:0]
}
Expand Down Expand Up @@ -96,6 +99,16 @@ func (col *LowCardinality) Row(i int, ptr bool) any {
if idx == 0 && col.nullable {
return nil
}
if !ptr {
if col.rowCache == nil {
n := col.index.Rows()
col.rowCache = make([]any, n)
for j := 0; j < n; j++ {
col.rowCache[j] = col.index.Row(j, false)
}
}
return col.rowCache[idx]
}
return col.index.Row(idx, ptr)
}

Expand Down