github.com/ydb-platform/ydb-go-sdk/v3@v3.89.2/internal/allocator/allocator.go (about) 1 package allocator 2 3 import ( 4 "github.com/ydb-platform/ydb-go-genproto/protos/Ydb" 5 "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Query" 6 "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Table" 7 8 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xsync" 9 ) 10 11 type ( 12 Allocator struct { 13 valueAllocator 14 typeAllocator 15 typedValueAllocator 16 boolAllocator 17 typeDecimalAllocator 18 typeListAllocator 19 typeEmptyListAllocator 20 typeEmptyDictAllocator 21 typeTupleAllocator 22 typeStructAllocator 23 typeDictAllocator 24 decimalAllocator 25 listAllocator 26 tupleAllocator 27 structAllocator 28 dictAllocator 29 structMemberAllocator 30 typeOptionalAllocator 31 optionalAllocator 32 bytesAllocator 33 textAllocator 34 uint32Allocator 35 int32Allocator 36 low128Allocator 37 uint64Allocator 38 int64Allocator 39 floatAllocator 40 doubleAllocator 41 nestedAllocator 42 pairAllocator 43 nullFlagAllocator 44 variantAllocator 45 typeVariantAllocator 46 variantStructItemsAllocator 47 variantTupleItemsAllocator 48 tableExecuteQueryResultAllocator 49 tableExecuteQueryRequestAllocator 50 tableQueryCachePolicyAllocator 51 tableQueryAllocator 52 tableQueryYqlTextAllocator 53 tableQueryIDAllocator 54 queryExecuteQueryRequestAllocator 55 queryExecuteQueryRequestQueryContentAllocator 56 queryExecuteQueryResponsePartAllocator 57 queryQueryContentAllocator 58 queryTransactionControlAllocator 59 queryTransactionControlBeginTxAllocator 60 queryTransactionControlTxIDAllocator 61 queryTransactionSettingsAllocator 62 queryTransactionSettingsSerializableReadWriteAllocator 63 } 64 ) 65 66 func New() (v *Allocator) { 67 return allocatorPool.GetOrNew() 68 } 69 70 //nolint:funlen 71 func (a *Allocator) Free() { 72 a.valueAllocator.free() 73 a.typeAllocator.free() 74 a.typedValueAllocator.free() 75 a.boolAllocator.free() 76 a.typeDecimalAllocator.free() 77 a.typeListAllocator.free() 78 a.typeEmptyListAllocator.free() 79 a.typeEmptyDictAllocator.free() 80 a.typeTupleAllocator.free() 81 a.typeStructAllocator.free() 82 a.typeDictAllocator.free() 83 a.decimalAllocator.free() 84 a.listAllocator.free() 85 a.tupleAllocator.free() 86 a.structAllocator.free() 87 a.dictAllocator.free() 88 a.structMemberAllocator.free() 89 a.typeOptionalAllocator.free() 90 a.optionalAllocator.free() 91 a.bytesAllocator.free() 92 a.textAllocator.free() 93 a.uint32Allocator.free() 94 a.int32Allocator.free() 95 a.low128Allocator.free() 96 a.uint64Allocator.free() 97 a.int64Allocator.free() 98 a.floatAllocator.free() 99 a.doubleAllocator.free() 100 a.nestedAllocator.free() 101 a.pairAllocator.free() 102 a.nullFlagAllocator.free() 103 a.variantAllocator.free() 104 a.typeVariantAllocator.free() 105 a.variantStructItemsAllocator.free() 106 a.variantTupleItemsAllocator.free() 107 a.tableExecuteQueryRequestAllocator.free() 108 a.tableExecuteQueryResultAllocator.free() 109 a.tableQueryCachePolicyAllocator.free() 110 a.tableQueryAllocator.free() 111 a.tableQueryYqlTextAllocator.free() 112 a.tableQueryIDAllocator.free() 113 a.queryExecuteQueryRequestAllocator.free() 114 a.queryExecuteQueryRequestQueryContentAllocator.free() 115 a.queryExecuteQueryResponsePartAllocator.free() 116 a.queryQueryContentAllocator.free() 117 a.queryTransactionControlAllocator.free() 118 a.queryTransactionControlBeginTxAllocator.free() 119 a.queryTransactionControlTxIDAllocator.free() 120 a.queryTransactionSettingsAllocator.free() 121 a.queryTransactionSettingsSerializableReadWriteAllocator.free() 122 123 allocatorPool.Put(a) 124 } 125 126 type boolAllocator struct { 127 allocations []*Ydb.Value_BoolValue 128 } 129 130 func (a *boolAllocator) Bool() (v *Ydb.Value_BoolValue) { 131 v = boolPool.GetOrNew() 132 a.allocations = append(a.allocations, v) 133 134 return v 135 } 136 137 func (a *boolAllocator) free() { 138 for _, v := range a.allocations { 139 *v = Ydb.Value_BoolValue{} 140 boolPool.Put(v) 141 } 142 a.allocations = a.allocations[:0] 143 } 144 145 type bytesAllocator struct { 146 allocations []*Ydb.Value_BytesValue 147 } 148 149 func (a *bytesAllocator) Bytes() (v *Ydb.Value_BytesValue) { 150 v = bytesPool.GetOrNew() 151 a.allocations = append(a.allocations, v) 152 153 return v 154 } 155 156 func (a *bytesAllocator) free() { 157 for _, v := range a.allocations { 158 *v = Ydb.Value_BytesValue{} 159 bytesPool.Put(v) 160 } 161 a.allocations = a.allocations[:0] 162 } 163 164 type decimalAllocator struct { 165 allocations []*Ydb.DecimalType 166 } 167 168 func (a *decimalAllocator) Decimal() (v *Ydb.DecimalType) { 169 v = decimalPool.GetOrNew() 170 a.allocations = append(a.allocations, v) 171 172 return v 173 } 174 175 func (a *decimalAllocator) free() { 176 for _, v := range a.allocations { 177 v.Reset() 178 decimalPool.Put(v) 179 } 180 a.allocations = a.allocations[:0] 181 } 182 183 type dictAllocator struct { 184 allocations []*Ydb.DictType 185 } 186 187 func (a *dictAllocator) Dict() (v *Ydb.DictType) { 188 v = dictPool.GetOrNew() 189 a.allocations = append(a.allocations, v) 190 191 return v 192 } 193 194 func (a *dictAllocator) free() { 195 for _, v := range a.allocations { 196 v.Reset() 197 dictPool.Put(v) 198 } 199 a.allocations = a.allocations[:0] 200 } 201 202 type doubleAllocator struct { 203 allocations []*Ydb.Value_DoubleValue 204 } 205 206 func (a *doubleAllocator) Double() (v *Ydb.Value_DoubleValue) { 207 v = doublePool.GetOrNew() 208 a.allocations = append(a.allocations, v) 209 210 return v 211 } 212 213 func (a *doubleAllocator) free() { 214 for _, v := range a.allocations { 215 *v = Ydb.Value_DoubleValue{} 216 doublePool.Put(v) 217 } 218 a.allocations = a.allocations[:0] 219 } 220 221 type floatAllocator struct { 222 allocations []*Ydb.Value_FloatValue 223 } 224 225 func (a *floatAllocator) Float() (v *Ydb.Value_FloatValue) { 226 v = floatPool.GetOrNew() 227 a.allocations = append(a.allocations, v) 228 229 return v 230 } 231 232 func (a *floatAllocator) free() { 233 for _, v := range a.allocations { 234 *v = Ydb.Value_FloatValue{} 235 floatPool.Put(v) 236 } 237 a.allocations = a.allocations[:0] 238 } 239 240 type int32Allocator struct { 241 allocations []*Ydb.Value_Int32Value 242 } 243 244 func (a *int32Allocator) Int32() (v *Ydb.Value_Int32Value) { 245 v = int32Pool.GetOrNew() 246 a.allocations = append(a.allocations, v) 247 248 return v 249 } 250 251 func (a *int32Allocator) free() { 252 for _, v := range a.allocations { 253 *v = Ydb.Value_Int32Value{} 254 int32Pool.Put(v) 255 } 256 a.allocations = a.allocations[:0] 257 } 258 259 type int64Allocator struct { 260 allocations []*Ydb.Value_Int64Value 261 } 262 263 func (a *int64Allocator) Int64() (v *Ydb.Value_Int64Value) { 264 v = int64Pool.GetOrNew() 265 a.allocations = append(a.allocations, v) 266 267 return v 268 } 269 270 func (a *int64Allocator) free() { 271 for _, v := range a.allocations { 272 *v = Ydb.Value_Int64Value{} 273 int64Pool.Put(v) 274 } 275 a.allocations = a.allocations[:0] 276 } 277 278 type listAllocator struct { 279 allocations []*Ydb.ListType 280 } 281 282 func (a *listAllocator) List() (v *Ydb.ListType) { 283 v = listPool.GetOrNew() 284 a.allocations = append(a.allocations, v) 285 286 return v 287 } 288 289 func (a *listAllocator) free() { 290 for _, v := range a.allocations { 291 v.Reset() 292 listPool.Put(v) 293 } 294 a.allocations = a.allocations[:0] 295 } 296 297 type low128Allocator struct { 298 allocations []*Ydb.Value_Low_128 299 } 300 301 func (a *low128Allocator) Low128() (v *Ydb.Value_Low_128) { 302 v = low128Pool.GetOrNew() 303 a.allocations = append(a.allocations, v) 304 305 return v 306 } 307 308 func (a *low128Allocator) free() { 309 for _, v := range a.allocations { 310 *v = Ydb.Value_Low_128{} 311 low128Pool.Put(v) 312 } 313 a.allocations = a.allocations[:0] 314 } 315 316 type nestedAllocator struct { 317 allocations []*Ydb.Value_NestedValue 318 } 319 320 func (a *nestedAllocator) Nested() (v *Ydb.Value_NestedValue) { 321 v = nestedPool.GetOrNew() 322 a.allocations = append(a.allocations, v) 323 324 return v 325 } 326 327 func (a *nestedAllocator) free() { 328 for _, v := range a.allocations { 329 *v = Ydb.Value_NestedValue{} 330 nestedPool.Put(v) 331 } 332 a.allocations = a.allocations[:0] 333 } 334 335 type nullFlagAllocator struct { 336 allocations []*Ydb.Value_NullFlagValue 337 } 338 339 func (a *nullFlagAllocator) NullFlag() (v *Ydb.Value_NullFlagValue) { 340 v = nullFlagPool.GetOrNew() 341 a.allocations = append(a.allocations, v) 342 343 return v 344 } 345 346 func (a *nullFlagAllocator) free() { 347 for _, v := range a.allocations { 348 *v = Ydb.Value_NullFlagValue{} 349 nullFlagPool.Put(v) 350 } 351 a.allocations = a.allocations[:0] 352 } 353 354 type optionalAllocator struct { 355 allocations []*Ydb.OptionalType 356 } 357 358 func (a *optionalAllocator) Optional() (v *Ydb.OptionalType) { 359 v = optionalPool.GetOrNew() 360 a.allocations = append(a.allocations, v) 361 362 return v 363 } 364 365 func (a *optionalAllocator) free() { 366 for _, v := range a.allocations { 367 v.Reset() 368 optionalPool.Put(v) 369 } 370 a.allocations = a.allocations[:0] 371 } 372 373 type pairAllocator struct { 374 allocations []*Ydb.ValuePair 375 } 376 377 func (a *pairAllocator) Pair() (v *Ydb.ValuePair) { 378 v = pairPool.GetOrNew() 379 a.allocations = append(a.allocations, v) 380 381 return v 382 } 383 384 func (a *pairAllocator) free() { 385 for _, v := range a.allocations { 386 *v = Ydb.ValuePair{} 387 pairPool.Put(v) 388 } 389 a.allocations = a.allocations[:0] 390 } 391 392 type structAllocator struct { 393 allocations []*Ydb.StructType 394 } 395 396 func (a *structAllocator) Struct() (v *Ydb.StructType) { 397 v = structPool.GetOrNew() 398 if cap(v.GetMembers()) <= 0 { 399 v.Members = make([]*Ydb.StructMember, 0, 10) //nolint:gomnd 400 } 401 a.allocations = append(a.allocations, v) 402 403 return v 404 } 405 406 func (a *structAllocator) free() { 407 for _, v := range a.allocations { 408 members := v.GetMembers() 409 for i := range members { 410 members[i] = nil 411 } 412 v.Reset() 413 v.Members = members[:0] 414 structPool.Put(v) 415 } 416 a.allocations = a.allocations[:0] 417 } 418 419 type structMemberAllocator struct { 420 allocations []*Ydb.StructMember 421 } 422 423 func (a *structMemberAllocator) StructMember() (v *Ydb.StructMember) { 424 v = structMemberPool.GetOrNew() 425 a.allocations = append(a.allocations, v) 426 427 return v 428 } 429 430 func (a *structMemberAllocator) free() { 431 for _, v := range a.allocations { 432 v.Reset() 433 structMemberPool.Put(v) 434 } 435 a.allocations = a.allocations[:0] 436 } 437 438 type textAllocator struct { 439 allocations []*Ydb.Value_TextValue 440 } 441 442 func (a *textAllocator) Text() (v *Ydb.Value_TextValue) { 443 v = textPool.GetOrNew() 444 a.allocations = append(a.allocations, v) 445 446 return v 447 } 448 449 func (a *textAllocator) free() { 450 for _, v := range a.allocations { 451 *v = Ydb.Value_TextValue{} 452 textPool.Put(v) 453 } 454 a.allocations = a.allocations[:0] 455 } 456 457 type tupleAllocator struct { 458 allocations []*Ydb.TupleType 459 } 460 461 func (a *tupleAllocator) Tuple() (v *Ydb.TupleType) { 462 v = tuplePool.GetOrNew() 463 a.allocations = append(a.allocations, v) 464 465 return v 466 } 467 468 func (a *tupleAllocator) free() { 469 for _, v := range a.allocations { 470 elements := v.GetElements() 471 for i := range elements { 472 elements[i] = nil 473 } 474 v.Reset() 475 v.Elements = elements[:0] 476 tuplePool.Put(v) 477 } 478 a.allocations = a.allocations[:0] 479 } 480 481 type typeDecimalAllocator struct { 482 allocations []*Ydb.Type_DecimalType 483 } 484 485 func (a *typeDecimalAllocator) TypeDecimal() (v *Ydb.Type_DecimalType) { 486 v = typeDecimalPool.GetOrNew() 487 a.allocations = append(a.allocations, v) 488 489 return v 490 } 491 492 func (a *typeDecimalAllocator) free() { 493 for _, v := range a.allocations { 494 *v = Ydb.Type_DecimalType{} 495 typeDecimalPool.Put(v) 496 } 497 a.allocations = a.allocations[:0] 498 } 499 500 type typeDictAllocator struct { 501 allocations []*Ydb.Type_DictType 502 } 503 504 func (a *typeDictAllocator) TypeDict() (v *Ydb.Type_DictType) { 505 v = typeDictPool.GetOrNew() 506 a.allocations = append(a.allocations, v) 507 508 return v 509 } 510 511 func (a *typeDictAllocator) free() { 512 for _, v := range a.allocations { 513 *v = Ydb.Type_DictType{} 514 typeDictPool.Put(v) 515 } 516 a.allocations = a.allocations[:0] 517 } 518 519 type typeEmptyListAllocator struct { 520 allocations []*Ydb.Type_EmptyListType 521 } 522 523 func (a *typeEmptyListAllocator) TypeEmptyList() (v *Ydb.Type_EmptyListType) { 524 v = typeEmptyListPool.GetOrNew() 525 a.allocations = append(a.allocations, v) 526 527 return v 528 } 529 530 func (a *typeEmptyListAllocator) free() { 531 for _, v := range a.allocations { 532 *v = Ydb.Type_EmptyListType{} 533 typeEmptyListPool.Put(v) 534 } 535 a.allocations = a.allocations[:0] 536 } 537 538 type typeEmptyDictAllocator struct { 539 allocations []*Ydb.Type_EmptyDictType 540 } 541 542 func (a *typeEmptyDictAllocator) TypeEmptyDict() (v *Ydb.Type_EmptyDictType) { 543 v = typeEmptyDictPool.GetOrNew() 544 a.allocations = append(a.allocations, v) 545 546 return v 547 } 548 549 func (a *typeEmptyDictAllocator) free() { 550 for _, v := range a.allocations { 551 *v = Ydb.Type_EmptyDictType{} 552 typeEmptyDictPool.Put(v) 553 } 554 a.allocations = a.allocations[:0] 555 } 556 557 type typeAllocator struct { 558 allocations []*Ydb.Type 559 } 560 561 func (a *typeAllocator) Type() (v *Ydb.Type) { 562 v = typePool.GetOrNew() 563 a.allocations = append(a.allocations, v) 564 565 return v 566 } 567 568 func (a *typeAllocator) free() { 569 for _, v := range a.allocations { 570 v.Reset() 571 typePool.Put(v) 572 } 573 a.allocations = a.allocations[:0] 574 } 575 576 type typeListAllocator struct { 577 allocations []*Ydb.Type_ListType 578 } 579 580 func (a *typeListAllocator) TypeList() (v *Ydb.Type_ListType) { 581 v = typeListPool.GetOrNew() 582 a.allocations = append(a.allocations, v) 583 584 return v 585 } 586 587 func (a *typeListAllocator) free() { 588 for _, v := range a.allocations { 589 *v = Ydb.Type_ListType{} 590 typeListPool.Put(v) 591 } 592 a.allocations = a.allocations[:0] 593 } 594 595 type typeOptionalAllocator struct { 596 allocations []*Ydb.Type_OptionalType 597 } 598 599 func (a *typeOptionalAllocator) TypeOptional() (v *Ydb.Type_OptionalType) { 600 v = typeOptionalPool.GetOrNew() 601 a.allocations = append(a.allocations, v) 602 603 return v 604 } 605 606 func (a *typeOptionalAllocator) free() { 607 for _, v := range a.allocations { 608 *v = Ydb.Type_OptionalType{} 609 typeOptionalPool.Put(v) 610 } 611 a.allocations = a.allocations[:0] 612 } 613 614 type typeStructAllocator struct { 615 allocations []*Ydb.Type_StructType 616 } 617 618 func (a *typeStructAllocator) TypeStruct() (v *Ydb.Type_StructType) { 619 v = typeStructPool.GetOrNew() 620 a.allocations = append(a.allocations, v) 621 622 return v 623 } 624 625 func (a *typeStructAllocator) free() { 626 for _, v := range a.allocations { 627 *v = Ydb.Type_StructType{} 628 typeStructPool.Put(v) 629 } 630 a.allocations = a.allocations[:0] 631 } 632 633 type typeTupleAllocator struct { 634 allocations []*Ydb.Type_TupleType 635 } 636 637 func (a *typeTupleAllocator) TypeTuple() (v *Ydb.Type_TupleType) { 638 v = typeTuplePool.GetOrNew() 639 a.allocations = append(a.allocations, v) 640 641 return v 642 } 643 644 func (a *typeTupleAllocator) free() { 645 for _, v := range a.allocations { 646 *v = Ydb.Type_TupleType{} 647 typeTuplePool.Put(v) 648 } 649 a.allocations = a.allocations[:0] 650 } 651 652 type typeVariantAllocator struct { 653 allocations []*Ydb.Type_VariantType 654 } 655 656 func (a *typeVariantAllocator) TypeVariant() (v *Ydb.Type_VariantType) { 657 v = typeVariantPool.GetOrNew() 658 a.allocations = append(a.allocations, v) 659 660 return v 661 } 662 663 func (a *typeVariantAllocator) free() { 664 for _, v := range a.allocations { 665 *v = Ydb.Type_VariantType{} 666 typeVariantPool.Put(v) 667 } 668 a.allocations = a.allocations[:0] 669 } 670 671 type typedValueAllocator struct { 672 allocations []*Ydb.TypedValue 673 } 674 675 func (a *typedValueAllocator) TypedValue() (v *Ydb.TypedValue) { 676 v = typedValuePool.GetOrNew() 677 a.allocations = append(a.allocations, v) 678 679 return v 680 } 681 682 func (a *typedValueAllocator) free() { 683 for _, v := range a.allocations { 684 v.Reset() 685 typedValuePool.Put(v) 686 } 687 a.allocations = a.allocations[:0] 688 } 689 690 type uint32Allocator struct { 691 allocations []*Ydb.Value_Uint32Value 692 } 693 694 func (a *uint32Allocator) Uint32() (v *Ydb.Value_Uint32Value) { 695 v = uint32Pool.GetOrNew() 696 a.allocations = append(a.allocations, v) 697 698 return v 699 } 700 701 func (a *uint32Allocator) free() { 702 for _, v := range a.allocations { 703 *v = Ydb.Value_Uint32Value{} 704 uint32Pool.Put(v) 705 } 706 a.allocations = a.allocations[:0] 707 } 708 709 type uint64Allocator struct { 710 allocations []*Ydb.Value_Uint64Value 711 } 712 713 func (a *uint64Allocator) Uint64() (v *Ydb.Value_Uint64Value) { 714 v = uint64Pool.GetOrNew() 715 a.allocations = append(a.allocations, v) 716 717 return v 718 } 719 720 func (a *uint64Allocator) free() { 721 for _, v := range a.allocations { 722 *v = Ydb.Value_Uint64Value{} 723 uint64Pool.Put(v) 724 } 725 a.allocations = a.allocations[:0] 726 } 727 728 type valueAllocator struct { 729 allocations []*Ydb.Value 730 } 731 732 func (a *valueAllocator) Value() (v *Ydb.Value) { 733 v = valuePool.GetOrNew() 734 a.allocations = append(a.allocations, v) 735 736 return v 737 } 738 739 func (a *valueAllocator) free() { 740 for _, v := range a.allocations { 741 items := v.GetItems() 742 pairs := v.GetPairs() 743 for i := range items { 744 items[i] = nil 745 } 746 for i := range pairs { 747 pairs[i] = nil 748 } 749 v.Reset() 750 v.Items = items[:0] 751 v.Pairs = pairs[:0] 752 valuePool.Put(v) 753 } 754 a.allocations = a.allocations[:0] 755 } 756 757 type variantAllocator struct { 758 allocations []*Ydb.VariantType 759 } 760 761 func (a *variantAllocator) Variant() (v *Ydb.VariantType) { 762 v = variantPool.GetOrNew() 763 a.allocations = append(a.allocations, v) 764 765 return v 766 } 767 768 func (a *variantAllocator) free() { 769 for _, v := range a.allocations { 770 variantPool.Put(v) 771 } 772 a.allocations = a.allocations[:0] 773 } 774 775 type variantStructItemsAllocator struct { 776 allocations []*Ydb.VariantType_StructItems 777 } 778 779 func (a *variantStructItemsAllocator) VariantStructItems() (v *Ydb.VariantType_StructItems) { 780 v = variantStructItemsPool.GetOrNew() 781 a.allocations = append(a.allocations, v) 782 783 return v 784 } 785 786 func (a *variantStructItemsAllocator) free() { 787 for _, v := range a.allocations { 788 variantStructItemsPool.Put(v) 789 } 790 a.allocations = a.allocations[:0] 791 } 792 793 type variantTupleItemsAllocator struct { 794 allocations []*Ydb.VariantType_TupleItems 795 } 796 797 func (a *variantTupleItemsAllocator) VariantTupleItems() (v *Ydb.VariantType_TupleItems) { 798 v = variantTupleItemsPool.GetOrNew() 799 a.allocations = append(a.allocations, v) 800 801 return v 802 } 803 804 func (a *variantTupleItemsAllocator) free() { 805 for _, v := range a.allocations { 806 variantTupleItemsPool.Put(v) 807 } 808 a.allocations = a.allocations[:0] 809 } 810 811 type tableExecuteQueryResultAllocator struct { 812 allocations []*Ydb_Table.ExecuteQueryResult 813 } 814 815 func (a *tableExecuteQueryResultAllocator) TableExecuteQueryResult() (v *Ydb_Table.ExecuteQueryResult) { 816 v = tableExecuteQueryResultPool.GetOrNew() 817 a.allocations = append(a.allocations, v) 818 819 return v 820 } 821 822 func (a *tableExecuteQueryResultAllocator) free() { 823 for _, v := range a.allocations { 824 v.Reset() 825 tableExecuteQueryResultPool.Put(v) 826 } 827 a.allocations = a.allocations[:0] 828 } 829 830 type tableExecuteQueryRequestAllocator struct { 831 allocations []*Ydb_Table.ExecuteDataQueryRequest 832 } 833 834 func (a *tableExecuteQueryRequestAllocator) TableExecuteDataQueryRequest() (v *Ydb_Table.ExecuteDataQueryRequest) { 835 v = tableExecuteDataQueryRequestPool.GetOrNew() 836 a.allocations = append(a.allocations, v) 837 838 return v 839 } 840 841 func (a *tableExecuteQueryRequestAllocator) free() { 842 for _, v := range a.allocations { 843 v.Reset() 844 tableExecuteDataQueryRequestPool.Put(v) 845 } 846 a.allocations = a.allocations[:0] 847 } 848 849 type tableQueryCachePolicyAllocator struct { 850 allocations []*Ydb_Table.QueryCachePolicy 851 } 852 853 func (a *tableQueryCachePolicyAllocator) TableQueryCachePolicy() (v *Ydb_Table.QueryCachePolicy) { 854 v = tableQueryCachePolicyPool.GetOrNew() 855 a.allocations = append(a.allocations, v) 856 857 return v 858 } 859 860 func (a *tableQueryCachePolicyAllocator) free() { 861 for _, v := range a.allocations { 862 v.Reset() 863 tableQueryCachePolicyPool.Put(v) 864 } 865 a.allocations = a.allocations[:0] 866 } 867 868 type tableQueryAllocator struct { 869 allocations []*Ydb_Table.Query 870 } 871 872 func (a *tableQueryAllocator) TableQuery() (v *Ydb_Table.Query) { 873 v = tableQueryPool.GetOrNew() 874 a.allocations = append(a.allocations, v) 875 876 return v 877 } 878 879 func (a *tableQueryAllocator) free() { 880 for _, v := range a.allocations { 881 v.Reset() 882 tableQueryPool.Put(v) 883 } 884 a.allocations = a.allocations[:0] 885 } 886 887 type tableQueryYqlTextAllocator struct { 888 allocations []*Ydb_Table.Query_YqlText 889 } 890 891 func (a *tableQueryYqlTextAllocator) TableQueryYqlText(s string) (v *Ydb_Table.Query_YqlText) { 892 v = tableQueryYqlTextPool.GetOrNew() 893 v.YqlText = s 894 a.allocations = append(a.allocations, v) 895 896 return v 897 } 898 899 func (a *tableQueryYqlTextAllocator) free() { 900 for _, v := range a.allocations { 901 tableQueryYqlTextPool.Put(v) 902 } 903 a.allocations = a.allocations[:0] 904 } 905 906 type tableQueryIDAllocator struct { 907 allocations []*Ydb_Table.Query_Id 908 } 909 910 func (a *tableQueryIDAllocator) TableQueryID(id string) (v *Ydb_Table.Query_Id) { 911 v = tableQueryIDPool.GetOrNew() 912 v.Id = id 913 a.allocations = append(a.allocations, v) 914 915 return v 916 } 917 918 func (a *tableQueryIDAllocator) free() { 919 for _, v := range a.allocations { 920 tableQueryIDPool.Put(v) 921 } 922 a.allocations = a.allocations[:0] 923 } 924 925 type queryExecuteQueryRequestAllocator struct { 926 allocations []*Ydb_Query.ExecuteQueryRequest 927 } 928 929 func (a *queryExecuteQueryRequestAllocator) QueryExecuteQueryRequest() ( 930 v *Ydb_Query.ExecuteQueryRequest, 931 ) { 932 v = queryExecuteQueryRequestPool.GetOrNew() 933 a.allocations = append(a.allocations, v) 934 935 return v 936 } 937 938 func (a *queryExecuteQueryRequestAllocator) free() { 939 for _, v := range a.allocations { 940 v.Reset() 941 queryExecuteQueryRequestPool.Put(v) 942 } 943 a.allocations = a.allocations[:0] 944 } 945 946 type queryExecuteQueryResponsePartAllocator struct { 947 allocations []*Ydb_Query.ExecuteQueryResponsePart 948 } 949 950 func (a *queryExecuteQueryResponsePartAllocator) QueryExecuteQueryResponsePart() ( 951 v *Ydb_Query.ExecuteQueryResponsePart, 952 ) { 953 v = queryExecuteQueryResponsePartPool.GetOrNew() 954 a.allocations = append(a.allocations, v) 955 956 return v 957 } 958 959 func (a *queryExecuteQueryResponsePartAllocator) free() { 960 for _, v := range a.allocations { 961 v.Reset() 962 queryExecuteQueryResponsePartPool.Put(v) 963 } 964 a.allocations = a.allocations[:0] 965 } 966 967 type queryExecuteQueryRequestQueryContentAllocator struct { 968 allocations []*Ydb_Query.ExecuteQueryRequest_QueryContent 969 } 970 971 func (a *queryExecuteQueryRequestQueryContentAllocator) QueryExecuteQueryRequestQueryContent() ( 972 v *Ydb_Query.ExecuteQueryRequest_QueryContent, 973 ) { 974 v = queryExecuteQueryRequestQueryContentPool.GetOrNew() 975 a.allocations = append(a.allocations, v) 976 977 return v 978 } 979 980 func (a *queryExecuteQueryRequestQueryContentAllocator) free() { 981 for _, v := range a.allocations { 982 queryExecuteQueryRequestQueryContentPool.Put(v) 983 } 984 a.allocations = a.allocations[:0] 985 } 986 987 type queryTransactionControlAllocator struct { 988 allocations []*Ydb_Query.TransactionControl 989 } 990 991 func (a *queryTransactionControlAllocator) QueryTransactionControl() (v *Ydb_Query.TransactionControl) { 992 v = queryTransactionControlPool.GetOrNew() 993 a.allocations = append(a.allocations, v) 994 995 return v 996 } 997 998 func (a *queryTransactionControlAllocator) free() { 999 for _, v := range a.allocations { 1000 v.Reset() 1001 queryTransactionControlPool.Put(v) 1002 } 1003 a.allocations = a.allocations[:0] 1004 } 1005 1006 type queryTransactionControlBeginTxAllocator struct { 1007 allocations []*Ydb_Query.TransactionControl_BeginTx 1008 } 1009 1010 func (a *queryTransactionControlBeginTxAllocator) QueryTransactionControlBeginTx() ( 1011 v *Ydb_Query.TransactionControl_BeginTx, 1012 ) { 1013 v = queryTransactionControlBeginTxPool.GetOrNew() 1014 a.allocations = append(a.allocations, v) 1015 1016 return v 1017 } 1018 1019 func (a *queryTransactionControlBeginTxAllocator) free() { 1020 for _, v := range a.allocations { 1021 queryTransactionControlBeginTxPool.Put(v) 1022 } 1023 a.allocations = a.allocations[:0] 1024 } 1025 1026 type queryTransactionControlTxIDAllocator struct { 1027 allocations []*Ydb_Query.TransactionControl_TxId 1028 } 1029 1030 func (a *queryTransactionControlTxIDAllocator) QueryTransactionControlTxID() (v *Ydb_Query.TransactionControl_TxId) { 1031 v = queryTransactionControlTxIDPool.GetOrNew() 1032 a.allocations = append(a.allocations, v) 1033 1034 return v 1035 } 1036 1037 func (a *queryTransactionControlTxIDAllocator) free() { 1038 for _, v := range a.allocations { 1039 queryTransactionControlTxIDPool.Put(v) 1040 } 1041 a.allocations = a.allocations[:0] 1042 } 1043 1044 type queryTransactionSettingsAllocator struct { 1045 allocations []*Ydb_Query.TransactionSettings 1046 } 1047 1048 func (a *queryTransactionSettingsAllocator) QueryTransactionSettings() (v *Ydb_Query.TransactionSettings) { 1049 v = queryTransactionSettingsPool.GetOrNew() 1050 a.allocations = append(a.allocations, v) 1051 1052 return v 1053 } 1054 1055 func (a *queryTransactionSettingsAllocator) free() { 1056 for _, v := range a.allocations { 1057 v.Reset() 1058 queryTransactionSettingsPool.Put(v) 1059 } 1060 a.allocations = a.allocations[:0] 1061 } 1062 1063 type queryTransactionSettingsSerializableReadWriteAllocator struct { 1064 allocations []*Ydb_Query.TransactionSettings_SerializableReadWrite 1065 } 1066 1067 func (a *queryTransactionSettingsSerializableReadWriteAllocator) QueryTransactionSettingsSerializableReadWrite() ( 1068 v *Ydb_Query.TransactionSettings_SerializableReadWrite, 1069 ) { 1070 v = queryTransactionSettingsSerializableReadWritePool.GetOrNew() 1071 a.allocations = append(a.allocations, v) 1072 1073 return v 1074 } 1075 1076 func (a *queryTransactionSettingsSerializableReadWriteAllocator) free() { 1077 for _, v := range a.allocations { 1078 queryTransactionSettingsSerializableReadWritePool.Put(v) 1079 } 1080 a.allocations = a.allocations[:0] 1081 } 1082 1083 type queryQueryContentAllocator struct { 1084 allocations []*Ydb_Query.QueryContent 1085 } 1086 1087 func (a *queryQueryContentAllocator) QueryQueryContent() (v *Ydb_Query.QueryContent) { 1088 v = queryQueryContentPool.GetOrNew() 1089 a.allocations = append(a.allocations, v) 1090 1091 return v 1092 } 1093 1094 func (a *queryQueryContentAllocator) free() { 1095 for _, v := range a.allocations { 1096 v.Reset() 1097 queryQueryContentPool.Put(v) 1098 } 1099 a.allocations = a.allocations[:0] 1100 } 1101 1102 var ( 1103 allocatorPool xsync.Pool[Allocator] 1104 valuePool xsync.Pool[Ydb.Value] 1105 typePool xsync.Pool[Ydb.Type] 1106 typeDecimalPool xsync.Pool[Ydb.Type_DecimalType] 1107 typeListPool xsync.Pool[Ydb.Type_ListType] 1108 typeEmptyListPool xsync.Pool[Ydb.Type_EmptyListType] 1109 typeEmptyDictPool xsync.Pool[Ydb.Type_EmptyDictType] 1110 typeTuplePool xsync.Pool[Ydb.Type_TupleType] 1111 typeStructPool xsync.Pool[Ydb.Type_StructType] 1112 typeDictPool xsync.Pool[Ydb.Type_DictType] 1113 typeVariantPool xsync.Pool[Ydb.Type_VariantType] 1114 decimalPool xsync.Pool[Ydb.DecimalType] 1115 listPool xsync.Pool[Ydb.ListType] 1116 tuplePool xsync.Pool[Ydb.TupleType] 1117 structPool xsync.Pool[Ydb.StructType] 1118 dictPool xsync.Pool[Ydb.DictType] 1119 variantPool xsync.Pool[Ydb.VariantType] 1120 variantTupleItemsPool xsync.Pool[Ydb.VariantType_TupleItems] 1121 variantStructItemsPool xsync.Pool[Ydb.VariantType_StructItems] 1122 structMemberPool xsync.Pool[Ydb.StructMember] 1123 typeOptionalPool xsync.Pool[Ydb.Type_OptionalType] 1124 optionalPool xsync.Pool[Ydb.OptionalType] 1125 typedValuePool xsync.Pool[Ydb.TypedValue] 1126 boolPool xsync.Pool[Ydb.Value_BoolValue] 1127 bytesPool xsync.Pool[Ydb.Value_BytesValue] 1128 textPool xsync.Pool[Ydb.Value_TextValue] 1129 int32Pool xsync.Pool[Ydb.Value_Int32Value] 1130 uint32Pool xsync.Pool[Ydb.Value_Uint32Value] 1131 low128Pool xsync.Pool[Ydb.Value_Low_128] 1132 int64Pool xsync.Pool[Ydb.Value_Int64Value] 1133 uint64Pool xsync.Pool[Ydb.Value_Uint64Value] 1134 floatPool xsync.Pool[Ydb.Value_FloatValue] 1135 doublePool xsync.Pool[Ydb.Value_DoubleValue] 1136 nestedPool xsync.Pool[Ydb.Value_NestedValue] 1137 nullFlagPool xsync.Pool[Ydb.Value_NullFlagValue] 1138 pairPool xsync.Pool[Ydb.ValuePair] 1139 tableExecuteQueryResultPool xsync.Pool[Ydb_Table.ExecuteQueryResult] 1140 tableExecuteDataQueryRequestPool xsync.Pool[Ydb_Table.ExecuteDataQueryRequest] 1141 tableQueryCachePolicyPool xsync.Pool[Ydb_Table.QueryCachePolicy] 1142 tableQueryPool xsync.Pool[Ydb_Table.Query] 1143 tableQueryYqlTextPool xsync.Pool[Ydb_Table.Query_YqlText] 1144 tableQueryIDPool xsync.Pool[Ydb_Table.Query_Id] 1145 queryExecuteQueryRequestPool xsync.Pool[Ydb_Query.ExecuteQueryRequest] 1146 queryExecuteQueryRequestQueryContentPool xsync.Pool[Ydb_Query.ExecuteQueryRequest_QueryContent] 1147 queryExecuteQueryResponsePartPool xsync.Pool[Ydb_Query.ExecuteQueryResponsePart] 1148 queryQueryContentPool xsync.Pool[Ydb_Query.QueryContent] 1149 queryTransactionControlPool xsync.Pool[Ydb_Query.TransactionControl] 1150 queryTransactionControlBeginTxPool xsync.Pool[Ydb_Query.TransactionControl_BeginTx] 1151 queryTransactionControlTxIDPool xsync.Pool[Ydb_Query.TransactionControl_TxId] 1152 queryTransactionSettingsPool xsync.Pool[Ydb_Query.TransactionSettings] 1153 queryTransactionSettingsSerializableReadWritePool xsync.Pool[Ydb_Query.TransactionSettings_SerializableReadWrite] 1154 )