mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* Define default dedicated attribute columns * Use default dedicated columns in block config * vp4 ignores well-known attrs in dedicated columns * vp3 ignores well-known attrs in dedicated columns * Improve tenantindex benchmarks * Use LRU cache for unmarshaled JSON columns * Set version to vParquet5-preview3 * Remove well-known attribute columns on span level * Remove well-known attribute columns on resource level * Convert vp5 test-data and re-enable find by ID test * Generate manifest.md * vp3 and vp4 ignore all unsupported attributes * vp5 ignores unsupported attributes * CHANGELOG.md
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package backend
|
|
|
|
import (
|
|
"bytes"
|
|
"unsafe"
|
|
|
|
lru "github.com/hashicorp/golang-lru/v2"
|
|
)
|
|
|
|
var (
|
|
dedicatedColumnsCacheNull = []byte("null")
|
|
dedicatedColumnsCacheEmpty = []byte("[]")
|
|
dedicatedColumnsCacheSize = 1024
|
|
dedicatedColumnsCache *lru.Cache[string, DedicatedColumns]
|
|
)
|
|
|
|
func init() {
|
|
var err error
|
|
dedicatedColumnsCache, err = lru.New[string, DedicatedColumns](dedicatedColumnsCacheSize)
|
|
if err != nil { // only errors if dedicatedColumnsCacheSize <= 0
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func getDedicatedColumnsFromCache(marshalled []byte) (DedicatedColumns, bool) {
|
|
if bytes.Equal(marshalled, dedicatedColumnsCacheNull) {
|
|
return nil, true
|
|
}
|
|
if bytes.Equal(marshalled, dedicatedColumnsCacheEmpty) {
|
|
return DedicatedColumns{}, true
|
|
}
|
|
if len(marshalled) == 0 {
|
|
return nil, false
|
|
}
|
|
s := unsafe.String(unsafe.SliceData(marshalled), len(marshalled)) // unsafe conversion is safe for lookups
|
|
return dedicatedColumnsCache.Get(s)
|
|
}
|
|
|
|
func putDedicatedColumnsToCache(marshalled []byte, cols DedicatedColumns) {
|
|
if len(marshalled) == 0 {
|
|
return
|
|
}
|
|
_ = dedicatedColumnsCache.Add(string(marshalled), cols)
|
|
}
|