Skip to content
Merged
Show file tree
Hide file tree
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
29 changes: 2 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,32 +85,7 @@ bin:

PHONY: gofmt
gofmt:
if [ "$(gofmt -l .)" != "" ]; then echo 'Please run `go fmt ./...` to format the code'; fi

.PHONY: impi
impi:
@echo Installing impi...
GO111MODULE=off go get -u github.com/pavius/impi/cmd/impi
@echo Verifying imports...
$(GOPATH)/bin/impi \
--local github.com/iguazio/provazio \
--skip pkg/controller/apis \
--skip pkg/controller/client \
--ignore-generated \
--scheme stdLocalThirdParty \
./...

$(GOPATH)/bin/golangci-lint:
@echo Installing golangci-lint...
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.49.0
cp ./bin/golangci-lint $(GOPATH)/bin/
@if [ "$(gofmt -l .)" != "" ]; then echo 'Please run `go fmt ./...` to format the code'; fi

.PHONY: lint
lint: gofmt impi $(GOPATH)/bin/golangci-lint
@echo Linting...
@$(GOPATH)/bin/golangci-lint run \
--disable-all --enable=deadcode --enable=goconst --enable=golint --enable=ineffassign \
--enable=interfacer --enable=unconvert --enable=varcheck --enable=errcheck --enable=gofmt --enable=misspell \
--enable=staticcheck --enable=gosimple --enable=govet --enable=goconst \
cmd/... pkg/... internal/...
@echo done linting
lint: gofmt
31 changes: 15 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,46 +1,45 @@
module github.com/v3io/v3io-tsdb

go 1.19
go 1.24

require (
github.com/cespare/xxhash v1.1.0
github.com/ghodss/yaml v1.0.0
github.com/imdario/mergo v0.3.7
github.com/nuclio/logger v0.0.1
github.com/nuclio/nuclio-sdk-go v0.0.0-20190205170814-3b507fbd0324
github.com/nuclio/zap v0.1.2
github.com/nuclio/zap v0.3.1
github.com/pkg/errors v0.8.1
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a
github.com/spf13/cobra v0.0.3
github.com/stretchr/testify v1.8.1
github.com/v3io/frames v0.10.5
github.com/v3io/v3io-go v0.3.0
github.com/stretchr/testify v1.8.4
github.com/v3io/frames v0.13.9
github.com/v3io/v3io-go v0.3.12
github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
)

require (
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/cpuguy83/go-md2man v1.0.10 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.2.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/liranbg/uberzap v1.20.0-nuclio.1 // indirect
github.com/logrusorgru/aurora/v3 v3.0.0 // indirect
github.com/logrusorgru/aurora/v4 v4.0.0 // indirect
github.com/nuclio/errors v0.0.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday v1.5.2 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.44.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 // indirect
google.golang.org/grpc v1.20.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/net v0.43.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/text v0.28.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250512202823-5a2f75b736a9 // indirect
google.golang.org/grpc v1.72.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
zombiezen.com/go/capnproto2 v2.17.0+incompatible // indirect
Expand Down
148 changes: 61 additions & 87 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/aggregate/aggregate_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build unit
//go:build unit

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
2 changes: 1 addition & 1 deletion pkg/appender/appender.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (mc *MetricsCache) AddFast(ref uint64, t int64, v interface{}) error {
metric, ok := mc.getMetric(ref)
if !ok {
// do not change error msg, it's parsed by prom
return fmt.Errorf(fmt.Sprintf("metric not found. ref=%v", ref))
return fmt.Errorf("metric not found. ref=%v", ref)
}

err = metric.error()
Expand Down
2 changes: 1 addition & 1 deletion pkg/chunkenc/chunkenc_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build unit
//go:build unit

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
2 changes: 1 addition & 1 deletion pkg/chunkenc/vartype_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build unit
//go:build unit

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build unit
//go:build unit

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
2 changes: 1 addition & 1 deletion pkg/partmgr/partmgr_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build unit
//go:build unit

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
2 changes: 1 addition & 1 deletion pkg/pquerier/chunkIterator_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build integration
//go:build integration

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
4 changes: 2 additions & 2 deletions pkg/pquerier/frames.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (fi *frameIterator) Next() bool {

series := fi.ctx.frameList[fi.setIndex]
// If raw series is nil
if series.isRawSeries && series.rawColumns[fi.seriesIndex] == nil {
if series.isRawSeries && any(series.rawColumns[fi.seriesIndex]) == nil {
return fi.Next()
}

Expand Down Expand Up @@ -716,7 +716,7 @@ func (c *basicColumn) Name() string {

// Len returns the number of elements
func (c *basicColumn) Len() int {
if c.framesCol != nil {
if any(c.framesCol) != nil {
return c.framesCol.Len()
}
return c.size
Expand Down
2 changes: 1 addition & 1 deletion pkg/pquerier/interpolate_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build unit
//go:build unit

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
2 changes: 1 addition & 1 deletion pkg/pquerier/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func (queryCtx *selectQueryContext) processQueryResults(query *partQuery) error
if !ok {
encoding = chunkenc.EncXOR
} else {
intEncoding, err := strconv.Atoi(encodingStr)
intEncoding, err := strconv.ParseInt(encodingStr, 10, 8)
if err != nil {
return fmt.Errorf("error parsing encoding type of chunk, got: %v, error: %v", encodingStr, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/pquerier/selectQueryContext_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build unit
//go:build unit

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
2 changes: 1 addition & 1 deletion pkg/pquerier/sql_parser_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build unit
//go:build unit

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
2 changes: 1 addition & 1 deletion pkg/querier/multipart_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build unit
//go:build unit

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
2 changes: 1 addition & 1 deletion pkg/tsdb/delete_integration_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build integration
//go:build integration

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
2 changes: 1 addition & 1 deletion pkg/tsdb/schema/schema_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build unit
//go:build unit

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
2 changes: 1 addition & 1 deletion pkg/tsdb/tsdb_integration_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build integration
//go:build integration

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
2 changes: 1 addition & 1 deletion pkg/tsdb/tsdbtest/config_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build unit
//go:build unit

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
21 changes: 10 additions & 11 deletions pkg/tsdb/tsdbtest/tsdbtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ import (
"github.com/v3io/v3io-tsdb/pkg/chunkenc"
"github.com/v3io/v3io-tsdb/pkg/config"
"github.com/v3io/v3io-tsdb/pkg/pquerier"
// nolint: golint
. "github.com/v3io/v3io-tsdb/pkg/tsdb"
"github.com/v3io/v3io-tsdb/pkg/tsdb"
"github.com/v3io/v3io-tsdb/pkg/tsdb/tsdbtest/testutils"
"github.com/v3io/v3io-tsdb/pkg/utils"
)
Expand Down Expand Up @@ -164,12 +163,12 @@ type Sample struct {
}

func DeleteTSDB(t testing.TB, v3ioConfig *config.V3ioConfig) {
adapter, err := NewV3ioAdapter(v3ioConfig, nil, nil)
adapter, err := tsdb.NewV3ioAdapter(v3ioConfig, nil, nil)
if err != nil {
t.Fatalf("Failed to create an adapter. Reason: %s", err)
}

if err := adapter.DeleteDB(DeleteParams{DeleteAll: true, IgnoreErrors: true}); err != nil {
if err := adapter.DeleteDB(tsdb.DeleteParams{DeleteAll: true, IgnoreErrors: true}); err != nil {
t.Fatalf("Failed to delete a TSDB instance (table) on teardown. Reason: %s", err)
}
}
Expand All @@ -180,7 +179,7 @@ func CreateTestTSDB(t testing.TB, v3ioConfig *config.V3ioConfig) {

func CreateTestTSDBWithAggregates(t testing.TB, v3ioConfig *config.V3ioConfig, aggregates string) {
schema := testutils.CreateSchema(t, aggregates)
if err := CreateTSDB(v3ioConfig, schema, nil); err != nil {
if err := tsdb.CreateTSDB(v3ioConfig, schema, nil); err != nil {
v3ioConfigAsJSON, _ := json2.MarshalIndent(v3ioConfig, "", " ")
t.Fatalf("Failed to create a TSDB instance (table). Reason: %v\nConfiguration:\n%s", err, string(v3ioConfigAsJSON))
}
Expand Down Expand Up @@ -219,7 +218,7 @@ func SetUp(t testing.TB, testParams TestParams) func() {
}
}

func SetUpWithData(t *testing.T, testOpts TestParams) (*V3ioAdapter, func()) {
func SetUpWithData(t *testing.T, testOpts TestParams) (*tsdb.V3ioAdapter, func()) {
teardown := SetUp(t, testOpts)
adapter := InsertData(t, testOpts)
return adapter, teardown
Expand All @@ -228,7 +227,7 @@ func SetUpWithData(t *testing.T, testOpts TestParams) (*V3ioAdapter, func()) {
func SetUpWithDBConfig(t *testing.T, schema *config.Schema, testParams TestParams) func() {
v3ioConfig := testParams.V3ioConfig()
v3ioConfig.TablePath = PrefixTablePath(fmt.Sprintf("%s-%d", t.Name(), time.Now().Nanosecond()))
if err := CreateTSDB(v3ioConfig, schema, nil); err != nil {
if err := tsdb.CreateTSDB(v3ioConfig, schema, nil); err != nil {
v3ioConfigAsJSON, _ := json2.MarshalIndent(v3ioConfig, "", " ")
t.Fatalf("Failed to create a TSDB instance (table). Reason: %s\nConfiguration:\n%s", err, string(v3ioConfigAsJSON))
}
Expand All @@ -248,8 +247,8 @@ func SetUpWithDBConfig(t *testing.T, schema *config.Schema, testParams TestParam
}
}

func InsertData(t *testing.T, testParams TestParams) *V3ioAdapter {
adapter, err := NewV3ioAdapter(testParams.V3ioConfig(), nil, nil)
func InsertData(t *testing.T, testParams TestParams) *tsdb.V3ioAdapter {
adapter, err := tsdb.NewV3ioAdapter(testParams.V3ioConfig(), nil, nil)
if err != nil {
t.Fatalf("Failed to create a V3IO TSDB adapter. Reason: %s", err)
}
Expand Down Expand Up @@ -285,7 +284,7 @@ func InsertData(t *testing.T, testParams TestParams) *V3ioAdapter {
return adapter
}

func ValidateCountOfSamples(t testing.TB, adapter *V3ioAdapter, metricName string, expected int, startTimeMs, endTimeMs int64, queryAggStep int64) {
func ValidateCountOfSamples(t testing.TB, adapter *tsdb.V3ioAdapter, metricName string, expected int, startTimeMs, endTimeMs int64, queryAggStep int64) {

var stepSize int64
if queryAggStep <= 0 {
Expand Down Expand Up @@ -338,7 +337,7 @@ func ValidateCountOfSamples(t testing.TB, adapter *V3ioAdapter, metricName strin
t.Logf("PASS: the metric-samples actual count matches the expected total count [%d(actualCount) == %d(expected)].", actualCount, expected)
}

func ValidateRawData(t testing.TB, adapter *V3ioAdapter, metricName string, startTimeMs, endTimeMs int64, isValid func(*DataPoint, *DataPoint) bool) {
func ValidateRawData(t testing.TB, adapter *tsdb.V3ioAdapter, metricName string, startTimeMs, endTimeMs int64, isValid func(*DataPoint, *DataPoint) bool) {

qry, err := adapter.Querier(context.TODO(), startTimeMs, endTimeMs)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/tsdb/v3iotsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"github.com/nuclio/logger"
"github.com/pkg/errors"
"github.com/v3io/v3io-go/pkg/dataplane"
"github.com/v3io/v3io-go/pkg/dataplane/http"
v3iohttp "github.com/v3io/v3io-go/pkg/dataplane/http"
v3ioerrors "github.com/v3io/v3io-go/pkg/errors"
"github.com/v3io/v3io-tsdb/pkg/aggregate"
"github.com/v3io/v3io-tsdb/pkg/appender"
Expand Down Expand Up @@ -100,7 +100,7 @@ func CreateTSDB(cfg *config.V3ioConfig, schema *config.Schema, container v3io.Co
for i := 0; i < 8; i++ {
_, err = container.GetObjectSync(&v3io.GetObjectInput{Path: path, DataPlaneInput: dataPlaneInput})
if err == nil {
return fmt.Errorf("A TSDB table already exists at path '" + cfg.TablePath + "'.")
return fmt.Errorf("A TSDB table already exists at path '%s'.", cfg.TablePath)
} else if e, hasStatusCode := err.(v3ioerrors.ErrorWithStatusCode); hasStatusCode && e.StatusCode() != http.StatusNotFound {
err = errors.Wrapf(err, "Failed to check TSDB schema at path '%s/%s/%s'.", cfg.WebAPIEndpoint, cfg.Container, path)
lgr.Error(err)
Expand Down Expand Up @@ -709,7 +709,7 @@ func getEncoding(itemToDelete v3io.Item) (chunkenc.Encoding, error) {
if !ok {
encoding = chunkenc.EncXOR
} else {
intEncoding, err := strconv.Atoi(encodingStr)
intEncoding, err := strconv.ParseInt(encodingStr, 10, 8)
if err != nil {
return 0, fmt.Errorf("error parsing encoding type of chunk, got: %v, error: %v", encodingStr, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/tsdb/v3iotsdb_integration_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build integration
//go:build integration

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
2 changes: 1 addition & 1 deletion pkg/tsdbctl/add_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build unit
//go:build unit

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
2 changes: 1 addition & 1 deletion pkg/tsdbctl/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func getSchema(cfg *config.V3ioConfig, container v3io.Container) (*config.Schema
}

func getEncoding(enc string) (chunkenc.Encoding, error) {
intEncoding, err := strconv.Atoi(enc)
intEncoding, err := strconv.ParseInt(enc, 10, 8)
if err != nil {
return 0, fmt.Errorf("error parsing encoding type, encoding type should be numberic, got: %v", enc)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/tsdbctl/tsdbctl_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build unit
//go:build unit

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down
4 changes: 2 additions & 2 deletions pkg/utils/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import (
"time"

"github.com/nuclio/logger"
"github.com/nuclio/zap"
nucliozap "github.com/nuclio/zap"
"github.com/pkg/errors"
"github.com/v3io/v3io-go/pkg/dataplane"
"github.com/v3io/v3io-go/pkg/dataplane/http"
v3iohttp "github.com/v3io/v3io-go/pkg/dataplane/http"
"github.com/v3io/v3io-tsdb/pkg/config"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/timeutils_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build unit
//go:build unit

/*
Copyright 2018 Iguazio Systems Ltd.
Expand Down