diff --git a/data/gen.go b/data/gen.go new file mode 100644 index 000000000..c9c29655d --- /dev/null +++ b/data/gen.go @@ -0,0 +1,5 @@ +package data + +//go:generate genny -in=generic_nullable_vector.go -out=nullable_vector.gen.go gen "gen=uint8,uint16,uint32,uint64,int8,int16,int32,int64,float32,float64,string,bool,time.Time,json.RawMessage" + +//go:generate genny -in=generic_vector.go -out=vector.gen.go gen "gen=uint8,uint16,uint32,uint64,int8,int16,int32,int64,float32,float64,string,bool,time.Time,json.RawMessage" diff --git a/data/generic_nullable_vector.go b/data/generic_nullable_vector.go new file mode 100644 index 000000000..1ddddbff8 --- /dev/null +++ b/data/generic_nullable_vector.go @@ -0,0 +1,92 @@ +package data + +type nullablegenVector []*gen + +func newNullablegenVector(n int) *nullablegenVector { + v := nullablegenVector(make([]*gen, n)) + return &v +} + +func newNullablegenVectorWithValues(s []*gen) *nullablegenVector { + v := make([]*gen, len(s)) + copy(v, s) + return (*nullablegenVector)(&v) +} + +func (v *nullablegenVector) Set(idx int, i interface{}) { + if i == nil { + (*v)[idx] = nil + return + } + (*v)[idx] = i.(*gen) +} + +func (v *nullablegenVector) SetConcrete(idx int, i interface{}) { + val := i.(gen) + (*v)[idx] = &val +} + +func (v *nullablegenVector) Append(i interface{}) { + if i == nil { + *v = append(*v, nil) + return + } + *v = append(*v, i.(*gen)) +} + +func (v *nullablegenVector) At(i int) interface{} { + return (*v)[i] +} + +func (v *nullablegenVector) CopyAt(i int) interface{} { + if (*v)[i] == nil { + var g *gen + return g + } + var g gen + g = *(*v)[i] + return &g +} + +func (v *nullablegenVector) ConcreteAt(i int) (interface{}, bool) { + var g gen + val := (*v)[i] + if val == nil { + return g, false + } + g = *val + return g, true +} + +func (v *nullablegenVector) PointerAt(i int) interface{} { + return &(*v)[i] +} + +func (v *nullablegenVector) Len() int { + return len(*v) +} + +func (v *nullablegenVector) Type() FieldType { + return vectorFieldType(v) +} + +func (v *nullablegenVector) Extend(i int) { + *v = append(*v, make([]*gen, i)...) +} + +func (v *nullablegenVector) Insert(i int, val interface{}) { + switch { + case i < v.Len(): + v.Extend(1) + copy((*v)[i+1:], (*v)[i:]) + v.Set(i, val) + case i == v.Len(): + v.Append(val) + case i > v.Len(): + panic("Invalid index; vector length should be greater or equal to that index") + } +} + +func (v *nullablegenVector) Delete(i int) { + *v = append((*v)[:i], (*v)[i+1:]...) +} diff --git a/data/generic_vector.go b/data/generic_vector.go new file mode 100644 index 000000000..7ffcf1b24 --- /dev/null +++ b/data/generic_vector.go @@ -0,0 +1,79 @@ +package data + +import ( + "github.com/cheekybits/genny/generic" +) + +type gen generic.Type + +type genVector []gen + +func newgenVector(n int) *genVector { + v := genVector(make([]gen, n)) + return &v +} + +func newgenVectorWithValues(s []gen) *genVector { + v := make([]gen, len(s)) + copy(v, s) + return (*genVector)(&v) +} + +func (v *genVector) Set(idx int, i interface{}) { + (*v)[idx] = i.(gen) +} + +func (v *genVector) SetConcrete(idx int, i interface{}) { + v.Set(idx, i) +} + +func (v *genVector) Append(i interface{}) { + *v = append(*v, i.(gen)) +} + +func (v *genVector) At(i int) interface{} { + return (*v)[i] +} + +func (v *genVector) PointerAt(i int) interface{} { + return &(*v)[i] +} + +func (v *genVector) Len() int { + return len(*v) +} + +func (v *genVector) CopyAt(i int) interface{} { + var g gen + g = (*v)[i] + return g +} + +func (v *genVector) ConcreteAt(i int) (interface{}, bool) { + return v.At(i), true +} + +func (v *genVector) Type() FieldType { + return vectorFieldType(v) +} + +func (v *genVector) Extend(i int) { + *v = append(*v, make([]gen, i)...) +} + +func (v *genVector) Insert(i int, val interface{}) { + switch { + case i < v.Len(): + v.Extend(1) + copy((*v)[i+1:], (*v)[i:]) + v.Set(i, val) + case i == v.Len(): + v.Append(val) + case i > v.Len(): + panic("Invalid index; vector length should be greater or equal to that index") + } +} + +func (v *genVector) Delete(i int) { + *v = append((*v)[:i], (*v)[i+1:]...) +} diff --git a/go.mod b/go.mod index ce6befcb5..dd2f3a33b 100644 --- a/go.mod +++ b/go.mod @@ -6,25 +6,36 @@ go 1.21 replace github.com/getkin/kin-openapi => github.com/getkin/kin-openapi v0.120.0 require ( - github.com/apache/arrow/go/v15 v15.0.0 - github.com/chromedp/cdproto v0.0.0-20220208224320-6efb837e6bc2 - github.com/elazarl/goproxy v0.0.0-20230731152917-f99041a5c027 - github.com/getkin/kin-openapi v0.120.0 - github.com/go-jose/go-jose/v3 v3.0.1 + github.com/cheekybits/genny v1.0.0 + github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.6.0 - github.com/google/uuid v1.6.0 github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/hashicorp/go-hclog v1.6.2 github.com/hashicorp/go-plugin v1.6.0 + github.com/hashicorp/yamux v0.1.1 // indirect github.com/json-iterator/go v1.1.12 github.com/magefile/mage v1.15.0 github.com/mattetti/filebuffer v1.0.1 + github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/reflectwalk v1.0.2 github.com/olekukonko/tablewriter v0.0.5 github.com/prometheus/client_golang v1.18.0 github.com/prometheus/common v0.46.0 github.com/stretchr/testify v1.8.4 + golang.org/x/sys v0.16.0 + google.golang.org/grpc v1.60.1 + google.golang.org/protobuf v1.32.0 + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +require ( + github.com/apache/arrow/go/v15 v15.0.0 + github.com/chromedp/cdproto v0.0.0-20220208224320-6efb837e6bc2 + github.com/elazarl/goproxy v0.0.0-20230731152917-f99041a5c027 + github.com/getkin/kin-openapi v0.120.0 + github.com/go-jose/go-jose/v3 v3.0.1 + github.com/google/uuid v1.6.0 github.com/unknwon/bra v0.0.0-20200517080246-1e3013ecaff8 github.com/urfave/cli v1.22.14 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0 @@ -39,10 +50,7 @@ require ( golang.org/x/exp v0.0.0-20231006140011-7918f672742d golang.org/x/net v0.20.0 golang.org/x/oauth2 v0.16.0 - golang.org/x/sys v0.16.0 golang.org/x/text v0.14.0 - google.golang.org/grpc v1.60.1 - google.golang.org/protobuf v1.32.0 ) require ( @@ -60,11 +68,9 @@ require ( github.com/go-openapi/swag v0.22.4 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect github.com/google/flatbuffers v23.5.26+incompatible // indirect github.com/gorilla/mux v1.8.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.2 // indirect - github.com/hashicorp/yamux v0.1.1 // indirect github.com/invopop/yaml v0.2.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/klauspost/compress v1.16.7 // indirect @@ -73,7 +79,6 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect - github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect @@ -99,5 +104,4 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect gopkg.in/fsnotify/fsnotify.v1 v1.4.7 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index f18ced80d..fab716237 100644 --- a/go.sum +++ b/go.sum @@ -19,6 +19,8 @@ github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitfE= +github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ= github.com/chromedp/cdproto v0.0.0-20220208224320-6efb837e6bc2 h1:XCdvHbz3LhewBHN7+mQPx0sg/Hxil/1USnBmxkjHcmY= github.com/chromedp/cdproto v0.0.0-20220208224320-6efb837e6bc2/go.mod h1:At5TxYYdxkbQL0TSefRjhLE3Q0lgvqKKMSFUglJ7i1U= github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww=