Skip to content

Commit e78cfd5

Browse files
authored
Revert "Remove github.com/cheekybits/genny (#913)" (#914)
This reverts commit 4de1ccd.
1 parent 9648074 commit e78cfd5

File tree

5 files changed

+195
-13
lines changed

5 files changed

+195
-13
lines changed

data/gen.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package data
2+
3+
//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"
4+
5+
//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"

data/generic_nullable_vector.go

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package data
2+
3+
type nullablegenVector []*gen
4+
5+
func newNullablegenVector(n int) *nullablegenVector {
6+
v := nullablegenVector(make([]*gen, n))
7+
return &v
8+
}
9+
10+
func newNullablegenVectorWithValues(s []*gen) *nullablegenVector {
11+
v := make([]*gen, len(s))
12+
copy(v, s)
13+
return (*nullablegenVector)(&v)
14+
}
15+
16+
func (v *nullablegenVector) Set(idx int, i interface{}) {
17+
if i == nil {
18+
(*v)[idx] = nil
19+
return
20+
}
21+
(*v)[idx] = i.(*gen)
22+
}
23+
24+
func (v *nullablegenVector) SetConcrete(idx int, i interface{}) {
25+
val := i.(gen)
26+
(*v)[idx] = &val
27+
}
28+
29+
func (v *nullablegenVector) Append(i interface{}) {
30+
if i == nil {
31+
*v = append(*v, nil)
32+
return
33+
}
34+
*v = append(*v, i.(*gen))
35+
}
36+
37+
func (v *nullablegenVector) At(i int) interface{} {
38+
return (*v)[i]
39+
}
40+
41+
func (v *nullablegenVector) CopyAt(i int) interface{} {
42+
if (*v)[i] == nil {
43+
var g *gen
44+
return g
45+
}
46+
var g gen
47+
g = *(*v)[i]
48+
return &g
49+
}
50+
51+
func (v *nullablegenVector) ConcreteAt(i int) (interface{}, bool) {
52+
var g gen
53+
val := (*v)[i]
54+
if val == nil {
55+
return g, false
56+
}
57+
g = *val
58+
return g, true
59+
}
60+
61+
func (v *nullablegenVector) PointerAt(i int) interface{} {
62+
return &(*v)[i]
63+
}
64+
65+
func (v *nullablegenVector) Len() int {
66+
return len(*v)
67+
}
68+
69+
func (v *nullablegenVector) Type() FieldType {
70+
return vectorFieldType(v)
71+
}
72+
73+
func (v *nullablegenVector) Extend(i int) {
74+
*v = append(*v, make([]*gen, i)...)
75+
}
76+
77+
func (v *nullablegenVector) Insert(i int, val interface{}) {
78+
switch {
79+
case i < v.Len():
80+
v.Extend(1)
81+
copy((*v)[i+1:], (*v)[i:])
82+
v.Set(i, val)
83+
case i == v.Len():
84+
v.Append(val)
85+
case i > v.Len():
86+
panic("Invalid index; vector length should be greater or equal to that index")
87+
}
88+
}
89+
90+
func (v *nullablegenVector) Delete(i int) {
91+
*v = append((*v)[:i], (*v)[i+1:]...)
92+
}

data/generic_vector.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package data
2+
3+
import (
4+
"github.com/cheekybits/genny/generic"
5+
)
6+
7+
type gen generic.Type
8+
9+
type genVector []gen
10+
11+
func newgenVector(n int) *genVector {
12+
v := genVector(make([]gen, n))
13+
return &v
14+
}
15+
16+
func newgenVectorWithValues(s []gen) *genVector {
17+
v := make([]gen, len(s))
18+
copy(v, s)
19+
return (*genVector)(&v)
20+
}
21+
22+
func (v *genVector) Set(idx int, i interface{}) {
23+
(*v)[idx] = i.(gen)
24+
}
25+
26+
func (v *genVector) SetConcrete(idx int, i interface{}) {
27+
v.Set(idx, i)
28+
}
29+
30+
func (v *genVector) Append(i interface{}) {
31+
*v = append(*v, i.(gen))
32+
}
33+
34+
func (v *genVector) At(i int) interface{} {
35+
return (*v)[i]
36+
}
37+
38+
func (v *genVector) PointerAt(i int) interface{} {
39+
return &(*v)[i]
40+
}
41+
42+
func (v *genVector) Len() int {
43+
return len(*v)
44+
}
45+
46+
func (v *genVector) CopyAt(i int) interface{} {
47+
var g gen
48+
g = (*v)[i]
49+
return g
50+
}
51+
52+
func (v *genVector) ConcreteAt(i int) (interface{}, bool) {
53+
return v.At(i), true
54+
}
55+
56+
func (v *genVector) Type() FieldType {
57+
return vectorFieldType(v)
58+
}
59+
60+
func (v *genVector) Extend(i int) {
61+
*v = append(*v, make([]gen, i)...)
62+
}
63+
64+
func (v *genVector) Insert(i int, val interface{}) {
65+
switch {
66+
case i < v.Len():
67+
v.Extend(1)
68+
copy((*v)[i+1:], (*v)[i:])
69+
v.Set(i, val)
70+
case i == v.Len():
71+
v.Append(val)
72+
case i > v.Len():
73+
panic("Invalid index; vector length should be greater or equal to that index")
74+
}
75+
}
76+
77+
func (v *genVector) Delete(i int) {
78+
*v = append((*v)[:i], (*v)[i+1:]...)
79+
}

go.mod

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,36 @@ go 1.21
66
replace github.com/getkin/kin-openapi => github.com/getkin/kin-openapi v0.120.0
77

88
require (
9-
github.com/apache/arrow/go/v15 v15.0.0
10-
github.com/chromedp/cdproto v0.0.0-20220208224320-6efb837e6bc2
11-
github.com/elazarl/goproxy v0.0.0-20230731152917-f99041a5c027
12-
github.com/getkin/kin-openapi v0.120.0
13-
github.com/go-jose/go-jose/v3 v3.0.1
9+
github.com/cheekybits/genny v1.0.0
10+
github.com/golang/protobuf v1.5.3 // indirect
1411
github.com/google/go-cmp v0.6.0
15-
github.com/google/uuid v1.6.0
1612
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
1713
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
1814
github.com/hashicorp/go-hclog v1.6.2
1915
github.com/hashicorp/go-plugin v1.6.0
16+
github.com/hashicorp/yamux v0.1.1 // indirect
2017
github.com/json-iterator/go v1.1.12
2118
github.com/magefile/mage v1.15.0
2219
github.com/mattetti/filebuffer v1.0.1
20+
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
2321
github.com/mitchellh/reflectwalk v1.0.2
2422
github.com/olekukonko/tablewriter v0.0.5
2523
github.com/prometheus/client_golang v1.18.0
2624
github.com/prometheus/common v0.46.0
2725
github.com/stretchr/testify v1.8.4
26+
golang.org/x/sys v0.16.0
27+
google.golang.org/grpc v1.60.1
28+
google.golang.org/protobuf v1.32.0
29+
gopkg.in/yaml.v3 v3.0.1 // indirect
30+
)
31+
32+
require (
33+
github.com/apache/arrow/go/v15 v15.0.0
34+
github.com/chromedp/cdproto v0.0.0-20220208224320-6efb837e6bc2
35+
github.com/elazarl/goproxy v0.0.0-20230731152917-f99041a5c027
36+
github.com/getkin/kin-openapi v0.120.0
37+
github.com/go-jose/go-jose/v3 v3.0.1
38+
github.com/google/uuid v1.6.0
2839
github.com/unknwon/bra v0.0.0-20200517080246-1e3013ecaff8
2940
github.com/urfave/cli v1.22.14
3041
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0
@@ -39,10 +50,7 @@ require (
3950
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
4051
golang.org/x/net v0.20.0
4152
golang.org/x/oauth2 v0.16.0
42-
golang.org/x/sys v0.16.0
4353
golang.org/x/text v0.14.0
44-
google.golang.org/grpc v1.60.1
45-
google.golang.org/protobuf v1.32.0
4654
)
4755

4856
require (
@@ -60,11 +68,9 @@ require (
6068
github.com/go-openapi/swag v0.22.4 // indirect
6169
github.com/goccy/go-json v0.10.2 // indirect
6270
github.com/gogo/protobuf v1.3.2 // indirect
63-
github.com/golang/protobuf v1.5.3 // indirect
6471
github.com/google/flatbuffers v23.5.26+incompatible // indirect
6572
github.com/gorilla/mux v1.8.0 // indirect
6673
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.2 // indirect
67-
github.com/hashicorp/yamux v0.1.1 // indirect
6874
github.com/invopop/yaml v0.2.0 // indirect
6975
github.com/josharian/intern v1.0.0 // indirect
7076
github.com/klauspost/compress v1.16.7 // indirect
@@ -73,7 +79,6 @@ require (
7379
github.com/mattn/go-colorable v0.1.13 // indirect
7480
github.com/mattn/go-isatty v0.0.19 // indirect
7581
github.com/mattn/go-runewidth v0.0.9 // indirect
76-
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
7782
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
7883
github.com/modern-go/reflect2 v1.0.2 // indirect
7984
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
@@ -99,5 +104,4 @@ require (
99104
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect
100105
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect
101106
gopkg.in/fsnotify/fsnotify.v1 v1.4.7 // indirect
102-
gopkg.in/yaml.v3 v3.0.1 // indirect
103107
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY
1919
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
2020
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
2121
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
22+
github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitfE=
23+
github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
2224
github.com/chromedp/cdproto v0.0.0-20220208224320-6efb837e6bc2 h1:XCdvHbz3LhewBHN7+mQPx0sg/Hxil/1USnBmxkjHcmY=
2325
github.com/chromedp/cdproto v0.0.0-20220208224320-6efb837e6bc2/go.mod h1:At5TxYYdxkbQL0TSefRjhLE3Q0lgvqKKMSFUglJ7i1U=
2426
github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww=

0 commit comments

Comments
 (0)