Skip to content

Commit d22cc56

Browse files
committed
dropped internal/allocator package
1 parent 2253cec commit d22cc56

Some content is hidden

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

81 files changed

+431
-729
lines changed

examples/coordination/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ func awaitSemaphore(
127127
session coordination.Session,
128128
semaphoreName string,
129129
capacitySemaphore *semaphore.Weighted,
130-
leaseChan chan *coordination.Lease,
131-
) {
130+
leaseChan chan *coordination.Lease) {
132131
lease, err := session.AcquireSemaphore(
133132
ctx,
134133
semaphoreName,

examples/coordination/workers/main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ func awaitSemaphore(
173173
semaphoreName string,
174174
leaseChan chan *LeaseInfo,
175175
sem *semaphore.Weighted,
176-
cancel context.CancelFunc,
177-
) {
176+
cancel context.CancelFunc) {
178177
defer done.Done()
179178

180179
lease, err := session.AcquireSemaphore(
@@ -207,8 +206,7 @@ func awaitSemaphore(
207206

208207
func doWork(
209208
lease coordination.Lease,
210-
name string,
211-
) {
209+
name string) {
212210
fmt.Printf("worker %s: starting\n", name)
213211

214212
for {

examples/ddl/ddl.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ CREATE TABLE small_table (
1616
b Uint64,
1717
c Text,
1818
d Date,
19-
PRIMARY KEY (a, b)
19+
PRIMARY KEY (b)
2020
);
2121
`
2222
familyCreateQuery = `
@@ -26,7 +26,7 @@ CREATE TABLE small_table2 (
2626
b Uint64,
2727
c Text FAMILY family_large,
2828
d Date,
29-
PRIMARY KEY (a, b),
29+
PRIMARY KEY (b),
3030
FAMILY family_large (
3131
COMPRESSION = "lz4"
3232
)
@@ -39,7 +39,7 @@ CREATE TABLE small_table3 (
3939
b Uint64,
4040
c Text,
4141
d Date,
42-
PRIMARY KEY (a, b)
42+
PRIMARY KEY (b)
4343
)
4444
WITH (
4545
AUTO_PARTITIONING_BY_SIZE = ENABLED, --Automatic positioning mode by the size of the partition

examples/opensource_night2024/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ func getWeatherStatsFromTable(ctx context.Context, db *ydb.Driver, year int) (
297297
minTemperature float64,
298298
avgTemperature float64,
299299
maxTemperature float64,
300-
_ error,
301-
) {
300+
_ error) {
302301
row, err := db.Query().QueryRow(ctx, `
303302
SELECT
304303
MIN(MinTemperatureF),

examples/pagination/cities.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ func selectPaging(
1919
lastCity *string,
2020
) (
2121
empty bool,
22-
err error,
23-
) {
22+
err error) {
2423
query := fmt.Sprintf(`
2524
PRAGMA TablePathPrefix("%v");
2625

examples/ttl/series.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ const (
2020

2121
func readExpiredBatchTransaction(ctx context.Context, c table.Client, prefix string, queue,
2222
timestamp, prevTimestamp, prevDocID uint64) (result.Result,
23-
error,
24-
) {
23+
error) {
2524
query := fmt.Sprintf(`
2625
PRAGMA TablePathPrefix("%v");
2726

internal/allocator/allocator.go

Lines changed: 0 additions & 9 deletions
This file was deleted.

internal/balancer/balancer.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ func makeDiscoveryFunc(
226226
}
227227

228228
func New(ctx context.Context, driverConfig *config.Config, pool *conn.Pool, opts ...discoveryConfig.Option) (
229-
b *Balancer, finalErr error,
230-
) {
229+
b *Balancer, finalErr error) {
231230
onDone := trace.DriverOnBalancerInit(driverConfig.Trace(), &ctx,
232231
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/v3/internal/balancer.New"),
233232
driverConfig.Balancer().String(),

internal/bind/auto_declare.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ func (m AutoDeclare) blockID() blockID {
1414
}
1515

1616
func (m AutoDeclare) ToYdb(sql string, args ...any) (
17-
yql string, newArgs []any, err error,
18-
) {
17+
yql string, newArgs []any, err error) {
1918
params, err := Params(args...)
2019
if err != nil {
2120
return "", nil, xerrors.WithStackTrace(err)

internal/bind/bind.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ type Bind interface {
2929
type Bindings []Bind
3030

3131
func (bindings Bindings) ToYdb(sql string, args ...any) (
32-
yql string, params params.Params, err error,
33-
) {
32+
yql string, params params.Params, err error) {
3433
if len(bindings) == 0 {
3534
params, err = Params(args...)
3635
if err != nil {

internal/bind/positional_args.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ func (m PositionalArgs) blockID() blockID {
1717
}
1818

1919
func (m PositionalArgs) ToYdb(sql string, args ...any) (
20-
yql string, newArgs []any, err error,
21-
) {
20+
yql string, newArgs []any, err error) {
2221
l := &sqlLexer{
2322
src: sql,
2423
stateFn: positionalArgsStateFn,

internal/bind/table_path_prefix.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ func (tablePathPrefix TablePathPrefix) NormalizePath(folderOrTable string) strin
2525
}
2626

2727
func (tablePathPrefix TablePathPrefix) ToYdb(sql string, args ...any) (
28-
yql string, newArgs []any, err error,
29-
) {
28+
yql string, newArgs []any, err error) {
3029
buffer := xstring.Buffer()
3130
defer buffer.Free()
3231

internal/conn/conn.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,7 @@ func invoke(
357357
) (
358358
opID string,
359359
issues []trace.Issue,
360-
_ error,
361-
) {
360+
_ error) {
362361
useWrapping := UseWrapping(ctx)
363362

364363
ctx, traceID, err := meta.TraceID(ctx)

internal/coordination/client.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ func (c *Client) DescribeNode(
239239
) (
240240
entry *scheme.Entry,
241241
config *coordination.NodeConfig,
242-
finalErr error,
243-
) {
242+
finalErr error) {
244243
if c == nil {
245244
return nil, nil, xerrors.WithStackTrace(errNilClient)
246245
}
@@ -297,8 +296,7 @@ func describeNode(
297296
) (
298297
_ *scheme.Entry,
299298
_ *coordination.NodeConfig,
300-
err error,
301-
) {
299+
err error) {
302300
var (
303301
response *Ydb_Coordination.DescribeNodeResponse
304302
result Ydb_Coordination.DescribeNodeResult

internal/coordination/session.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,7 @@ func (s *session) receiveLoop( //nolint:funlen
408408
sessionClient Ydb_Coordination_V1.CoordinationService_SessionClient,
409409
cancelStream context.CancelFunc,
410410
sessionStarted chan *Ydb_Coordination.SessionResponse_SessionStarted,
411-
sessionStopped chan *Ydb_Coordination.SessionResponse_SessionStopped,
412-
) {
411+
sessionStopped chan *Ydb_Coordination.SessionResponse_SessionStopped) {
413412
// If the sendLoop is done, make sure the stream is also canceled to make the receiveLoop finish its work and cause
414413
// reconnect.
415414
defer wg.Done()
@@ -487,8 +486,7 @@ func (s *session) sendLoop(
487486
sessionClient Ydb_Coordination_V1.CoordinationService_SessionClient,
488487
streamCtx context.Context,
489488
cancelStream context.CancelFunc,
490-
startSending chan struct{},
491-
) {
489+
startSending chan struct{}) {
492490
// If the sendLoop is done, make sure the stream is also canceled to make the receiveLoop finish its work and cause
493491
// reconnect.
494492
defer wg.Done()

internal/grpcwrapper/rawtopic/client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ func (c *Client) DescribeTopic(ctx context.Context, req DescribeTopicRequest) (r
6060
}
6161

6262
func (c *Client) DescribeConsumer(ctx context.Context, req DescribeConsumerRequest) (
63-
res DescribeConsumerResult, err error,
64-
) {
63+
res DescribeConsumerResult, err error) {
6564
resp, err := c.service.DescribeConsumer(ctx, req.ToProto())
6665
if err != nil {
6766
return DescribeConsumerResult{}, xerrors.WithStackTrace(

internal/params/builder_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/stretchr/testify/require"
88
"github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
99

10-
"github.com/ydb-platform/ydb-go-sdk/v3/internal/allocator"
1110
"github.com/ydb-platform/ydb-go-sdk/v3/internal/value"
1211
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xtest"
1312
)
@@ -454,15 +453,13 @@ func TestBuilder(t *testing.T) {
454453

455454
for _, tc := range tests {
456455
t.Run(tc.method, func(t *testing.T) {
457-
a := allocator.New()
458-
defer a.Free()
459456

460457
item := Builder{}.Param("$x")
461458

462459
result, ok := xtest.CallMethod(item, tc.method, tc.args...)[0].(Builder)
463460
require.True(t, ok)
464461

465-
params := result.build().toYDB(a)
462+
params := result.build().toYDB()
466463

467464
require.Equal(t,
468465
xtest.ToJSON(

internal/params/dict_test.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/stretchr/testify/require"
1010
"github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
1111

12-
"github.com/ydb-platform/ydb-go-sdk/v3/internal/allocator"
1312
"github.com/ydb-platform/ydb-go-sdk/v3/internal/value"
1413
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xtest"
1514
)
@@ -429,8 +428,6 @@ func TestDict(t *testing.T) {
429428
for _, key := range tests {
430429
for _, val := range tests {
431430
t.Run(fmt.Sprintf("%s:%s", key.method, val.method), func(t *testing.T) {
432-
a := allocator.New()
433-
defer a.Free()
434431

435432
item := Builder{}.Param("$x").BeginDict().Add()
436433

@@ -440,7 +437,7 @@ func TestDict(t *testing.T) {
440437
d, ok := xtest.CallMethod(addedKey, val.method, val.args...)[0].(*dict)
441438
require.True(t, ok)
442439

443-
params := d.EndDict().build().toYDB(a)
440+
params := d.EndDict().build().toYDB()
444441
require.Equal(t, xtest.ToJSON(
445442
map[string]*Ydb.TypedValue{
446443
"$x": {
@@ -468,8 +465,6 @@ func TestDict(t *testing.T) {
468465
}
469466

470467
func TestDict_AddPairs(t *testing.T) {
471-
a := allocator.New()
472-
defer a.Free()
473468

474469
pairs := []value.DictValueField{
475470
{
@@ -482,7 +477,7 @@ func TestDict_AddPairs(t *testing.T) {
482477
},
483478
}
484479

485-
params := Builder{}.Param("$x").BeginDict().AddPairs(pairs...).EndDict().build().toYDB(a)
480+
params := Builder{}.Param("$x").BeginDict().AddPairs(pairs...).EndDict().build().toYDB()
486481

487482
require.Equal(t, xtest.ToJSON(
488483
map[string]*Ydb.TypedValue{

internal/params/list_test.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/stretchr/testify/require"
99
"github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
1010

11-
"github.com/ydb-platform/ydb-go-sdk/v3/internal/allocator"
1211
"github.com/ydb-platform/ydb-go-sdk/v3/internal/value"
1312
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xtest"
1413
)
@@ -427,15 +426,13 @@ func TestList(t *testing.T) {
427426

428427
for _, tc := range tests {
429428
t.Run(tc.method, func(t *testing.T) {
430-
a := allocator.New()
431-
defer a.Free()
432429

433430
item := Builder{}.Param("$x").BeginList().Add()
434431

435432
result, ok := xtest.CallMethod(item, tc.method, tc.args...)[0].(*list)
436433
require.True(t, ok)
437434

438-
params := result.EndList().build().toYDB(a)
435+
params := result.EndList().build().toYDB()
439436
require.Equal(t, xtest.ToJSON(
440437
map[string]*Ydb.TypedValue{
441438
"$x": {
@@ -458,11 +455,9 @@ func TestList(t *testing.T) {
458455
}
459456

460457
func TestList_AddItems(t *testing.T) {
461-
a := allocator.New()
462-
defer a.Free()
463458
params := Builder{}.Param("$x").BeginList().
464459
AddItems(value.Uint64Value(123), value.Uint64Value(321)).
465-
EndList().build().toYDB(a)
460+
EndList().build().toYDB()
466461
require.Equal(t, xtest.ToJSON(
467462
map[string]*Ydb.TypedValue{
468463
"$x": {

internal/params/optional_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/stretchr/testify/require"
99
"github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
1010

11-
"github.com/ydb-platform/ydb-go-sdk/v3/internal/allocator"
1211
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xtest"
1312
)
1413

@@ -582,15 +581,13 @@ func TestOptional(t *testing.T) {
582581

583582
for _, tc := range tests {
584583
t.Run(tc.method, func(t *testing.T) {
585-
a := allocator.New()
586-
defer a.Free()
587584

588585
item := Builder{}.Param("$x").BeginOptional()
589586

590587
result, ok := xtest.CallMethod(item, tc.method, tc.args...)[0].(*optionalBuilder)
591588
require.True(t, ok)
592589

593-
params := result.EndOptional().build().toYDB(a)
590+
params := result.EndOptional().build().toYDB()
594591
require.Equal(t, xtest.ToJSON(
595592
map[string]*Ydb.TypedValue{
596593
"$x": {

internal/params/parameters.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/google/uuid"
88
"github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
99

10-
"github.com/ydb-platform/ydb-go-sdk/v3/internal/allocator"
1110
"github.com/ydb-platform/ydb-go-sdk/v3/internal/value"
1211
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xstring"
1312
"github.com/ydb-platform/ydb-go-sdk/v3/table/types"
@@ -24,7 +23,7 @@ type (
2423
value value.Value
2524
}
2625
Parameters interface {
27-
ToYDB(a *allocator.Allocator) (map[string]*Ydb.TypedValue, error)
26+
ToYDB() (map[string]*Ydb.TypedValue, error)
2827
}
2928
Params []*Parameter
3029
)
@@ -67,26 +66,26 @@ func (p *Params) String() string {
6766
return buffer.String()
6867
}
6968

70-
func (p *Params) ToYDB(a *allocator.Allocator) (map[string]*Ydb.TypedValue, error) {
69+
func (p *Params) ToYDB() (map[string]*Ydb.TypedValue, error) {
7170
if p == nil {
7271
return nil, nil //nolint:nilnil
7372
}
7473

7574
parameters := make(map[string]*Ydb.TypedValue, len(*p))
7675
for _, param := range *p {
77-
parameters[param.name] = value.ToYDB(param.value, a)
76+
parameters[param.name] = value.ToYDB(param.value)
7877
}
7978

8079
return parameters, nil
8180
}
8281

83-
func (p *Params) toYDB(a *allocator.Allocator) map[string]*Ydb.TypedValue {
82+
func (p *Params) toYDB() map[string]*Ydb.TypedValue {
8483
if p == nil {
8584
return nil
8685
}
8786
parameters := make(map[string]*Ydb.TypedValue, len(*p))
8887
for _, param := range *p {
89-
parameters[param.name] = value.ToYDB(param.value, a)
88+
parameters[param.name] = value.ToYDB(param.value)
9089
}
9190

9291
return parameters

0 commit comments

Comments
 (0)