Skip to content

Commit 966909e

Browse files
committed
different allocators by types
1 parent cf1d6d0 commit 966909e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+840
-451
lines changed

internal/value/exp/allocator/allocator.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func (a *Allocator) Value() (v *Ydb.Value) {
2121
return new(Ydb.Value)
2222
}
2323

24-
func (a *Allocator) TypedValue() (v *Ydb.TypedValue) {
24+
func (a *Allocator) Typed() (v *Ydb.TypedValue) {
2525
return new(Ydb.TypedValue)
2626
}
2727

@@ -57,51 +57,51 @@ func (a *Allocator) TypeTuple() (v *Ydb.Type_TupleType) {
5757
return new(Ydb.Type_TupleType)
5858
}
5959

60-
func (a *Allocator) EmptyTypeList() (v *Ydb.Type_EmptyListType) {
60+
func (a *Allocator) TypeEmptyList() (v *Ydb.Type_EmptyListType) {
6161
return new(Ydb.Type_EmptyListType)
6262
}
6363

6464
func (a *Allocator) TypeOptional() (v *Ydb.Type_OptionalType) {
6565
return new(Ydb.Type_OptionalType)
6666
}
6767

68-
func (a *Allocator) BoolValue() (v *Ydb.Value_BoolValue) {
68+
func (a *Allocator) Bool() (v *Ydb.Value_BoolValue) {
6969
return new(Ydb.Value_BoolValue)
7070
}
7171

72-
func (a *Allocator) BytesValue() (v *Ydb.Value_BytesValue) {
72+
func (a *Allocator) Bytes() (v *Ydb.Value_BytesValue) {
7373
return new(Ydb.Value_BytesValue)
7474
}
7575

76-
func (a *Allocator) Int32Value() (v *Ydb.Value_Int32Value) {
76+
func (a *Allocator) Int32() (v *Ydb.Value_Int32Value) {
7777
return new(Ydb.Value_Int32Value)
7878
}
7979

80-
func (a *Allocator) Int64Value() (v *Ydb.Value_Int64Value) {
80+
func (a *Allocator) Int64() (v *Ydb.Value_Int64Value) {
8181
return new(Ydb.Value_Int64Value)
8282
}
8383

84-
func (a *Allocator) Uint32Value() (v *Ydb.Value_Uint32Value) {
84+
func (a *Allocator) Uint32() (v *Ydb.Value_Uint32Value) {
8585
return new(Ydb.Value_Uint32Value)
8686
}
8787

88-
func (a *Allocator) FloatValue() (v *Ydb.Value_FloatValue) {
88+
func (a *Allocator) Float() (v *Ydb.Value_FloatValue) {
8989
return new(Ydb.Value_FloatValue)
9090
}
9191

92-
func (a *Allocator) DoubleValue() (v *Ydb.Value_DoubleValue) {
92+
func (a *Allocator) Double() (v *Ydb.Value_DoubleValue) {
9393
return new(Ydb.Value_DoubleValue)
9494
}
9595

96-
func (a *Allocator) Uint64Value() (v *Ydb.Value_Uint64Value) {
96+
func (a *Allocator) Uint64() (v *Ydb.Value_Uint64Value) {
9797
return new(Ydb.Value_Uint64Value)
9898
}
9999

100-
func (a *Allocator) TextValue() (v *Ydb.Value_TextValue) {
100+
func (a *Allocator) Text() (v *Ydb.Value_TextValue) {
101101
return new(Ydb.Value_TextValue)
102102
}
103103

104-
func (a *Allocator) Low128Value() (v *Ydb.Value_Low_128) {
104+
func (a *Allocator) Low128() (v *Ydb.Value_Low_128) {
105105
return new(Ydb.Value_Low_128)
106106
}
107107

@@ -121,7 +121,7 @@ func (a *Allocator) TypeStruct() (v *Ydb.Type_StructType) {
121121
return new(Ydb.Type_StructType)
122122
}
123123

124-
func (a *Allocator) NestedValue() (v *Ydb.Value_NestedValue) {
124+
func (a *Allocator) Nested() (v *Ydb.Value_NestedValue) {
125125
return new(Ydb.Value_NestedValue)
126126
}
127127

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//go:build go1.18
2+
// +build go1.18
3+
4+
package allocator
5+
6+
import "github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
7+
8+
type boolAllocator struct {
9+
allocations []*Ydb.Value_BoolValue
10+
}
11+
12+
func (a *boolAllocator) Bool() (v *Ydb.Value_BoolValue) {
13+
v = boolPool.Get()
14+
a.allocations = append(a.allocations, v)
15+
return v
16+
}
17+
18+
func (a *boolAllocator) free() {
19+
for _, v := range a.allocations {
20+
*v = Ydb.Value_BoolValue{}
21+
boolPool.Put(v)
22+
}
23+
a.allocations = a.allocations[:0]
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//go:build go1.18
2+
// +build go1.18
3+
4+
package allocator
5+
6+
import "github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
7+
8+
type bytesAllocator struct {
9+
allocations []*Ydb.Value_BytesValue
10+
}
11+
12+
func (a *bytesAllocator) Bytes() (v *Ydb.Value_BytesValue) {
13+
v = bytesPool.Get()
14+
a.allocations = append(a.allocations, v)
15+
return v
16+
}
17+
18+
func (a *bytesAllocator) free() {
19+
for _, v := range a.allocations {
20+
*v = Ydb.Value_BytesValue{}
21+
bytesPool.Put(v)
22+
}
23+
a.allocations = a.allocations[:0]
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//go:build go1.18
2+
// +build go1.18
3+
4+
package allocator
5+
6+
import "github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
7+
8+
type decimalAllocator struct {
9+
allocations []*Ydb.DecimalType
10+
}
11+
12+
func (a *decimalAllocator) Decimal() (v *Ydb.DecimalType) {
13+
v = decimalPool.Get()
14+
a.allocations = append(a.allocations, v)
15+
return v
16+
}
17+
18+
func (a *decimalAllocator) free() {
19+
for _, v := range a.allocations {
20+
v.Reset()
21+
decimalPool.Put(v)
22+
}
23+
a.allocations = a.allocations[:0]
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//go:build go1.18
2+
// +build go1.18
3+
4+
package allocator
5+
6+
import "github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
7+
8+
type dictAllocator struct {
9+
allocations []*Ydb.DictType
10+
}
11+
12+
func (a *dictAllocator) Dict() (v *Ydb.DictType) {
13+
v = dictPool.Get()
14+
a.allocations = append(a.allocations, v)
15+
return v
16+
}
17+
18+
func (a *dictAllocator) free() {
19+
for _, v := range a.allocations {
20+
v.Reset()
21+
dictPool.Put(v)
22+
}
23+
a.allocations = a.allocations[:0]
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//go:build go1.18
2+
// +build go1.18
3+
4+
package allocator
5+
6+
import "github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
7+
8+
type doubleAllocator struct {
9+
allocations []*Ydb.Value_DoubleValue
10+
}
11+
12+
func (a *doubleAllocator) Double() (v *Ydb.Value_DoubleValue) {
13+
v = doublePool.Get()
14+
a.allocations = append(a.allocations, v)
15+
return v
16+
}
17+
18+
func (a *doubleAllocator) free() {
19+
for _, v := range a.allocations {
20+
*v = Ydb.Value_DoubleValue{}
21+
doublePool.Put(v)
22+
}
23+
a.allocations = a.allocations[:0]
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//go:build go1.18
2+
// +build go1.18
3+
4+
package allocator
5+
6+
import "github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
7+
8+
type floatAllocator struct {
9+
allocations []*Ydb.Value_FloatValue
10+
}
11+
12+
func (a *floatAllocator) Float() (v *Ydb.Value_FloatValue) {
13+
v = floatPool.Get()
14+
a.allocations = append(a.allocations, v)
15+
return v
16+
}
17+
18+
func (a *floatAllocator) free() {
19+
for _, v := range a.allocations {
20+
*v = Ydb.Value_FloatValue{}
21+
floatPool.Put(v)
22+
}
23+
a.allocations = a.allocations[:0]
24+
}

0 commit comments

Comments
 (0)