Upgrade cclib and remove usage of obsolete util.Float

This commit is contained in:
2026-01-26 08:38:53 +01:00
parent 525d99140f
commit c782043c64
5 changed files with 19 additions and 18 deletions

4
go.mod
View File

@@ -11,7 +11,7 @@ tool (
require ( require (
github.com/99designs/gqlgen v0.17.85 github.com/99designs/gqlgen v0.17.85
github.com/ClusterCockpit/cc-lib/v2 v2.1.0 github.com/ClusterCockpit/cc-lib/v2 v2.2.0
github.com/Masterminds/squirrel v1.5.4 github.com/Masterminds/squirrel v1.5.4
github.com/aws/aws-sdk-go-v2 v1.41.1 github.com/aws/aws-sdk-go-v2 v1.41.1
github.com/aws/aws-sdk-go-v2/config v1.32.6 github.com/aws/aws-sdk-go-v2/config v1.32.6
@@ -32,7 +32,6 @@ require (
github.com/joho/godotenv v1.5.1 github.com/joho/godotenv v1.5.1
github.com/linkedin/goavro/v2 v2.14.1 github.com/linkedin/goavro/v2 v2.14.1
github.com/mattn/go-sqlite3 v1.14.33 github.com/mattn/go-sqlite3 v1.14.33
github.com/nats-io/nats.go v1.47.0
github.com/qustavo/sqlhooks/v2 v2.1.0 github.com/qustavo/sqlhooks/v2 v2.1.0
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
github.com/stretchr/testify v1.11.1 github.com/stretchr/testify v1.11.1
@@ -95,6 +94,7 @@ require (
github.com/kr/pretty v0.3.1 // indirect github.com/kr/pretty v0.3.1 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/nats-io/nats.go v1.47.0 // indirect
github.com/nats-io/nkeys v0.4.12 // indirect github.com/nats-io/nkeys v0.4.12 // indirect
github.com/nats-io/nuid v1.0.1 // indirect github.com/nats-io/nuid v1.0.1 // indirect
github.com/oapi-codegen/runtime v1.1.1 // indirect github.com/oapi-codegen/runtime v1.1.1 // indirect

4
go.sum
View File

@@ -4,8 +4,8 @@ github.com/99designs/gqlgen v0.17.85 h1:EkGx3U2FDcxQm8YDLQSpXIAVmpDyZ3IcBMOJi2nH
github.com/99designs/gqlgen v0.17.85/go.mod h1:yvs8s0bkQlRfqg03YXr3eR4OQUowVhODT/tHzCXnbOU= github.com/99designs/gqlgen v0.17.85/go.mod h1:yvs8s0bkQlRfqg03YXr3eR4OQUowVhODT/tHzCXnbOU=
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 h1:mFRzDkZVAjdal+s7s0MwaRv9igoPqLRdzOLzw/8Xvq8= github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 h1:mFRzDkZVAjdal+s7s0MwaRv9igoPqLRdzOLzw/8Xvq8=
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU=
github.com/ClusterCockpit/cc-lib/v2 v2.1.0 h1:B6l6h0IjfEuY9DU6aVM3fSsj24lQ1eudXK9QTKmJjqg= github.com/ClusterCockpit/cc-lib/v2 v2.2.0 h1:gqMsh7zsJMUhaXviXzaZ3gqXcLVgerjRJHzIcwX4FmQ=
github.com/ClusterCockpit/cc-lib/v2 v2.1.0/go.mod h1:JuxMAuEOaLLNEnnL9U3ejha8kMvsSatLdKPZEgJw6iw= github.com/ClusterCockpit/cc-lib/v2 v2.2.0/go.mod h1:JuxMAuEOaLLNEnnL9U3ejha8kMvsSatLdKPZEgJw6iw=
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM= github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=

View File

@@ -44,6 +44,7 @@ import (
"sync" "sync"
"unsafe" "unsafe"
"github.com/ClusterCockpit/cc-lib/v2/schema"
"github.com/ClusterCockpit/cc-lib/v2/util" "github.com/ClusterCockpit/cc-lib/v2/util"
) )
@@ -272,7 +273,7 @@ func (l *Level) sizeInBytes() int64 {
for _, b := range l.metrics { for _, b := range l.metrics {
if b != nil { if b != nil {
size += b.count() * int64(unsafe.Sizeof(util.Float(0))) size += b.count() * int64(unsafe.Sizeof(schema.Float(0)))
} }
} }

View File

@@ -37,7 +37,7 @@ import (
"github.com/ClusterCockpit/cc-lib/v2/util" "github.com/ClusterCockpit/cc-lib/v2/util"
) )
// Define a struct to hold your globals and the mutex // GlobalState holds the global state for the metric store with thread-safe access.
type GlobalState struct { type GlobalState struct {
mu sync.RWMutex mu sync.RWMutex
lastRetentionTime int64 lastRetentionTime int64
@@ -740,8 +740,7 @@ func (m *MemoryStore) Free(selector []string, t int64) (int, error) {
return m.GetLevel(selector).free(t) return m.GetLevel(selector).free(t)
} }
// Free releases all buffers for the selected level and all its children that // ForceFree unconditionally removes the oldest buffer from each metric chain.
// contain only values older than `t`.
func (m *MemoryStore) ForceFree() (int, error) { func (m *MemoryStore) ForceFree() (int, error) {
return m.GetLevel(nil).forceFree() return m.GetLevel(nil).forceFree()
} }

View File

@@ -9,14 +9,15 @@ import (
"errors" "errors"
"math" "math"
"github.com/ClusterCockpit/cc-lib/v2/schema"
"github.com/ClusterCockpit/cc-lib/v2/util" "github.com/ClusterCockpit/cc-lib/v2/util"
) )
type Stats struct { type Stats struct {
Samples int Samples int
Avg util.Float Avg schema.Float
Min util.Float Min schema.Float
Max util.Float Max schema.Float
} }
func (b *buffer) stats(from, to int64) (Stats, int64, int64, error) { func (b *buffer) stats(from, to int64) (Stats, int64, int64, error) {
@@ -61,9 +62,9 @@ func (b *buffer) stats(from, to int64) (Stats, int64, int64, error) {
return Stats{ return Stats{
Samples: samples, Samples: samples,
Avg: util.Float(sum) / util.Float(samples), Avg: schema.Float(sum) / schema.Float(samples),
Min: util.Float(min), Min: schema.Float(min),
Max: util.Float(max), Max: schema.Float(max),
}, from, t, nil }, from, t, nil
} }
@@ -81,7 +82,7 @@ func (m *MemoryStore) Stats(selector util.Selector, metric string, from, to int6
} }
n, samples := 0, 0 n, samples := 0, 0
avg, min, max := util.Float(0), math.MaxFloat32, -math.MaxFloat32 avg, min, max := schema.Float(0), math.MaxFloat32, -math.MaxFloat32
err := m.root.findBuffers(selector, minfo.offset, func(b *buffer) error { err := m.root.findBuffers(selector, minfo.offset, func(b *buffer) error {
stats, cfrom, cto, err := b.stats(from, to) stats, cfrom, cto, err := b.stats(from, to)
if err != nil { if err != nil {
@@ -110,7 +111,7 @@ func (m *MemoryStore) Stats(selector util.Selector, metric string, from, to int6
} }
if minfo.Aggregation == AvgAggregation { if minfo.Aggregation == AvgAggregation {
avg /= util.Float(n) avg /= schema.Float(n)
} else if n > 1 && minfo.Aggregation != SumAggregation { } else if n > 1 && minfo.Aggregation != SumAggregation {
return nil, 0, 0, errors.New("invalid aggregation") return nil, 0, 0, errors.New("invalid aggregation")
} }
@@ -118,7 +119,7 @@ func (m *MemoryStore) Stats(selector util.Selector, metric string, from, to int6
return &Stats{ return &Stats{
Samples: samples, Samples: samples,
Avg: avg, Avg: avg,
Min: util.Float(min), Min: schema.Float(min),
Max: util.Float(max), Max: schema.Float(max),
}, from, to, nil }, from, to, nil
} }