Skip to content

Commit

Permalink
WIP broken commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zalegrala committed Nov 6, 2024
1 parent 78468a2 commit 064d96b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
26 changes: 23 additions & 3 deletions pkg/parquetquery/intern/intern.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,44 @@
package intern

import (
"sync"
"unique"

pq "github.com/parquet-go/parquet-go"
)

type Interner struct{}
type Interner struct {
h map[unique.Handle[*pq.Value]]pq.Value
mtx sync.Mutex
}

func New() *Interner {
return &Interner{}
return &Interner{
mtx: sync.Mutex{},
h: make(map[unique.Handle[*pq.Value]]pq.Value),
}
}

// Clone returns a unique shalow copy of the input pq.Value or derefernces the
// received pointer.
func (i *Interner) Clone(v *pq.Value) pq.Value {
i.mtx.Lock()
defer i.mtx.Unlock()
switch v.Kind() {
case pq.ByteArray, pq.FixedLenByteArray:
return *unique.Make(v).Value()
if vv, ok := i.h[unique.Make(v)]; ok {
return vv
}
vv := unique.Make(v)
i.h[vv] = *vv.Value()
return i.h[vv]
default:
return *v
}
}

func (i *Interner) Close() {
i.mtx.Lock()
defer i.mtx.Unlock()
clear(i.h)
}
3 changes: 3 additions & 0 deletions pkg/parquetquery/iters.go
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,9 @@ func (c *SyncIterator) Close() {
c.closeCurrRowGroup()

c.span.End()
if c.intern {
c.interner.Close()
}
}

// ColumnIterator asynchronously iterates through the given row groups and column. Applies
Expand Down

0 comments on commit 064d96b

Please sign in to comment.