github.com/matrixorigin/matrixone@v1.2.0/pkg/vm/engine/memoryengine/operations.go (about) 1 // Copyright 2022 Matrix Origin 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package memoryengine 16 17 import ( 18 "encoding/binary" 19 20 "github.com/matrixorigin/matrixone/pkg/common/mpool" 21 "github.com/matrixorigin/matrixone/pkg/container/batch" 22 "github.com/matrixorigin/matrixone/pkg/container/vector" 23 apipb "github.com/matrixorigin/matrixone/pkg/pb/api" 24 "github.com/matrixorigin/matrixone/pkg/pb/plan" 25 "github.com/matrixorigin/matrixone/pkg/vm/engine" 26 ) 27 28 const ( 29 LengthBytes = 4 30 IDBytes = 8 31 ) 32 33 const ( 34 OpCreateDatabase = iota + 64 35 OpOpenDatabase 36 OpGetDatabases 37 OpDeleteDatabase 38 OpCreateRelation 39 OpDeleteRelation 40 OpTruncateRelation 41 OpOpenRelation 42 OpGetRelations 43 OpAddTableDef 44 OpDelTableDef 45 OpDelete 46 OpGetPrimaryKeys 47 OpGetTableColumns 48 OpGetTableDefs 49 OpGetHiddenKeys 50 OpUpdate 51 OpWrite 52 OpNewTableIter 53 OpRead 54 OpCloseTableIter 55 OpTableStats 56 OpPreCommit = uint32(apipb.OpCode_OpPreCommit) 57 OpGetLogTail = uint32(apipb.OpCode_OpGetLogTail) 58 ) 59 60 type ReadRequest interface { 61 OpenDatabaseReq | 62 GetDatabasesReq | 63 OpenRelationReq | 64 GetRelationsReq | 65 GetPrimaryKeysReq | 66 GetTableColumnsReq | 67 GetTableDefsReq | 68 GetHiddenKeysReq | 69 NewTableIterReq | 70 ReadReq | 71 CloseTableIterReq | 72 TableStatsReq | 73 apipb.SyncLogTailReq 74 } 75 76 type WriteReqeust interface { 77 CreateDatabaseReq | 78 DeleteDatabaseReq | 79 CreateRelationReq | 80 DeleteRelationReq | 81 TruncateRelationReq | 82 AddTableDefReq | 83 DelTableDefReq | 84 DeleteReq | 85 UpdateReq | 86 WriteReq 87 } 88 89 type Request interface { 90 ReadRequest | WriteReqeust 91 } 92 93 type Response interface { 94 CreateDatabaseResp | 95 OpenDatabaseResp | 96 GetDatabasesResp | 97 DeleteDatabaseResp | 98 CreateRelationResp | 99 DeleteRelationResp | 100 TruncateRelationResp | 101 OpenRelationResp | 102 GetRelationsResp | 103 AddTableDefResp | 104 DelTableDefResp | 105 DeleteResp | 106 GetPrimaryKeysResp | 107 GetTableColumnsResp | 108 GetTableDefsResp | 109 GetHiddenKeysResp | 110 UpdateResp | 111 WriteResp | 112 NewTableIterResp | 113 ReadResp | 114 CloseTableIterResp | 115 TableStatsResp | 116 apipb.SyncLogTailResp 117 } 118 119 type CreateDatabaseReq struct { 120 ID ID 121 AccessInfo AccessInfo 122 Name string 123 Typ string 124 CreateSql string 125 } 126 127 func (m *CreateDatabaseReq) MarshalBinary() ([]byte, error) { 128 return m.Marshal() 129 } 130 131 func (m *CreateDatabaseReq) UnmarshalBinary(data []byte) error { 132 return m.Unmarshal(data) 133 } 134 135 type CreateDatabaseResp struct { 136 ID ID 137 } 138 139 func (m *CreateDatabaseResp) MarshalBinary() ([]byte, error) { 140 return m.Marshal() 141 } 142 143 func (m *CreateDatabaseResp) UnmarshalBinary(data []byte) error { 144 return m.Unmarshal(data) 145 } 146 147 type OpenDatabaseReq struct { 148 AccessInfo AccessInfo 149 Name string 150 } 151 152 func (m *OpenDatabaseReq) MarshalBinary() ([]byte, error) { 153 return m.Marshal() 154 } 155 156 func (m *OpenDatabaseReq) UnmarshalBinary(data []byte) error { 157 return m.Unmarshal(data) 158 } 159 160 type OpenDatabaseResp struct { 161 ID ID 162 Name string 163 DatTyp string 164 CreateSql string 165 } 166 167 func (m *OpenDatabaseResp) MarshalBinary() ([]byte, error) { 168 return m.Marshal() 169 } 170 171 func (m *OpenDatabaseResp) UnmarshalBinary(data []byte) error { 172 return m.Unmarshal(data) 173 } 174 175 type GetDatabasesReq struct { 176 AccessInfo AccessInfo 177 } 178 179 func (m *GetDatabasesReq) MarshalBinary() ([]byte, error) { 180 return m.Marshal() 181 } 182 183 func (m *GetDatabasesReq) UnmarshalBinary(data []byte) error { 184 return m.Unmarshal(data) 185 } 186 187 type GetDatabasesResp struct { 188 Names []string 189 } 190 191 func (m *GetDatabasesResp) MarshalBinary() ([]byte, error) { 192 return m.Marshal() 193 } 194 195 func (m *GetDatabasesResp) UnmarshalBinary(data []byte) error { 196 return m.Unmarshal(data) 197 } 198 199 type DeleteDatabaseReq struct { 200 AccessInfo AccessInfo 201 Name string 202 } 203 204 func (m *DeleteDatabaseReq) MarshalBinary() ([]byte, error) { 205 return m.Marshal() 206 } 207 208 func (m *DeleteDatabaseReq) UnmarshalBinary(data []byte) error { 209 return m.Unmarshal(data) 210 } 211 212 type DeleteDatabaseResp struct { 213 ID ID 214 } 215 216 func (m *DeleteDatabaseResp) MarshalBinary() ([]byte, error) { 217 return m.Marshal() 218 } 219 220 func (m *DeleteDatabaseResp) UnmarshalBinary(data []byte) error { 221 return m.Unmarshal(data) 222 } 223 224 type CreateRelationReq struct { 225 ID ID 226 DatabaseID ID 227 DatabaseName string 228 Name string 229 Type RelationType 230 Defs []engine.TableDefPB 231 } 232 233 func (m *CreateRelationReq) MarshalBinary() ([]byte, error) { 234 return m.Marshal() 235 } 236 237 func (m *CreateRelationReq) UnmarshalBinary(data []byte) error { 238 return m.Unmarshal(data) 239 } 240 241 type CreateRelationResp struct { 242 ID ID 243 } 244 245 func (m *CreateRelationResp) MarshalBinary() ([]byte, error) { 246 return m.Marshal() 247 } 248 249 func (m *CreateRelationResp) UnmarshalBinary(data []byte) error { 250 return m.Unmarshal(data) 251 } 252 253 type DeleteRelationReq struct { 254 DatabaseID ID 255 DatabaseName string 256 Name string 257 } 258 259 func (m *DeleteRelationReq) MarshalBinary() ([]byte, error) { 260 return m.Marshal() 261 } 262 263 func (m *DeleteRelationReq) UnmarshalBinary(data []byte) error { 264 return m.Unmarshal(data) 265 } 266 267 type TruncateRelationReq struct { 268 NewTableID ID 269 OldTableID ID 270 DatabaseID ID 271 DatabaseName string 272 Name string 273 } 274 275 func (m *TruncateRelationReq) MarshalBinary() ([]byte, error) { 276 return m.Marshal() 277 } 278 279 func (m *TruncateRelationReq) UnmarshalBinary(data []byte) error { 280 return m.Unmarshal(data) 281 } 282 283 type DeleteRelationResp struct { 284 ID ID 285 } 286 287 func (m *DeleteRelationResp) MarshalBinary() ([]byte, error) { 288 return m.Marshal() 289 } 290 291 func (m *DeleteRelationResp) UnmarshalBinary(data []byte) error { 292 return m.Unmarshal(data) 293 } 294 295 type TruncateRelationResp struct { 296 ID ID 297 } 298 299 func (m *TruncateRelationResp) MarshalBinary() ([]byte, error) { 300 return m.Marshal() 301 } 302 303 func (m *TruncateRelationResp) UnmarshalBinary(data []byte) error { 304 return m.Unmarshal(data) 305 } 306 307 type OpenRelationReq struct { 308 DatabaseID ID 309 DatabaseName string 310 Name string 311 } 312 313 func (m *OpenRelationReq) MarshalBinary() ([]byte, error) { 314 return m.Marshal() 315 } 316 317 func (m *OpenRelationReq) UnmarshalBinary(data []byte) error { 318 return m.Unmarshal(data) 319 } 320 321 type OpenRelationResp struct { 322 ID ID 323 Type RelationType 324 DatabaseName string 325 RelationName string 326 } 327 328 func (m *OpenRelationResp) MarshalBinary() ([]byte, error) { 329 return m.Marshal() 330 } 331 332 func (m *OpenRelationResp) UnmarshalBinary(data []byte) error { 333 return m.Unmarshal(data) 334 } 335 336 type GetRelationsReq struct { 337 DatabaseID ID 338 } 339 340 func (m *GetRelationsReq) MarshalBinary() ([]byte, error) { 341 return m.Marshal() 342 } 343 344 func (m *GetRelationsReq) UnmarshalBinary(data []byte) error { 345 return m.Unmarshal(data) 346 } 347 348 type GetRelationsResp struct { 349 Names []string 350 } 351 352 func (m *GetRelationsResp) MarshalBinary() ([]byte, error) { 353 return m.Marshal() 354 } 355 356 func (m *GetRelationsResp) UnmarshalBinary(data []byte) error { 357 return m.Unmarshal(data) 358 } 359 360 type AddTableDefReq struct { 361 TableID ID 362 Def engine.TableDefPB 363 364 DatabaseName string 365 TableName string 366 } 367 368 func (m *AddTableDefReq) MarshalBinary() ([]byte, error) { 369 return m.Marshal() 370 } 371 372 func (m *AddTableDefReq) UnmarshalBinary(data []byte) error { 373 return m.Unmarshal(data) 374 } 375 376 type AddTableDefResp struct { 377 } 378 379 func (m *AddTableDefResp) MarshalBinary() ([]byte, error) { 380 return m.Marshal() 381 } 382 383 func (m *AddTableDefResp) UnmarshalBinary(data []byte) error { 384 return m.Unmarshal(data) 385 } 386 387 type DelTableDefReq struct { 388 TableID ID 389 DatabaseName string 390 TableName string 391 Def engine.TableDefPB 392 } 393 394 func (m *DelTableDefReq) MarshalBinary() ([]byte, error) { 395 return m.Marshal() 396 } 397 398 func (m *DelTableDefReq) UnmarshalBinary(data []byte) error { 399 return m.Unmarshal(data) 400 } 401 402 type DelTableDefResp struct { 403 } 404 405 func (m *DelTableDefResp) MarshalBinary() ([]byte, error) { 406 return m.Marshal() 407 } 408 409 func (m *DelTableDefResp) UnmarshalBinary(data []byte) error { 410 return m.Unmarshal(data) 411 } 412 413 type DeleteReq struct { 414 TableID ID 415 DatabaseName string 416 TableName string 417 ColumnName string 418 Vector *vector.Vector 419 } 420 421 func (r *DeleteReq) MarshalBinary() ([]byte, error) { 422 vecData, err := r.Vector.MarshalBinary() 423 if err != nil { 424 return nil, err 425 } 426 427 // ---------------------------------------------------------------------------------------------- 428 // | TableID | length | DatabaseName | length | TableName | length | ColumnName | length | Vector | 429 // ---------------------------------------------------------------------------------------------- 430 size := IDBytes + LengthBytes + len(r.DatabaseName) + LengthBytes + len(r.TableName) + LengthBytes + len(r.ColumnName) + LengthBytes + len(vecData) 431 data := make([]byte, size) 432 index := 0 433 434 // TableID 435 binary.BigEndian.PutUint64(data[index:index+IDBytes], uint64(r.TableID)) 436 index += IDBytes 437 438 // DatabaseName 439 binary.BigEndian.PutUint32(data[index:index+LengthBytes], uint32(len(r.DatabaseName))) 440 index += LengthBytes 441 n := copy(data[index:], r.DatabaseName) 442 index += n 443 444 // TableName 445 binary.BigEndian.PutUint32(data[index:index+LengthBytes], uint32(len(r.TableName))) 446 index += LengthBytes 447 n = copy(data[index:], r.TableName) 448 index += n 449 450 // ColumnName 451 binary.BigEndian.PutUint32(data[index:index+LengthBytes], uint32(len(r.ColumnName))) 452 index += LengthBytes 453 n = copy(data[index:], r.ColumnName) 454 index += n 455 456 // Vector 457 binary.BigEndian.PutUint32(data[index:index+LengthBytes], uint32(len(vecData))) 458 index += LengthBytes 459 copy(data[index:], vecData) 460 461 return data, nil 462 } 463 464 func (r *DeleteReq) UnmarshalBinary(data []byte) error { 465 index := 0 466 467 // TableID 468 r.TableID = ID(binary.BigEndian.Uint64(data[index : index+IDBytes])) 469 index += IDBytes 470 471 // DatabaseName 472 l := int(binary.BigEndian.Uint32(data[index : index+LengthBytes])) 473 index += LengthBytes 474 r.DatabaseName = string(data[index : index+l]) 475 index += l 476 477 // TableName 478 l = int(binary.BigEndian.Uint32(data[index : index+LengthBytes])) 479 index += LengthBytes 480 r.TableName = string(data[index : index+l]) 481 index += l 482 483 // ColumnName 484 l = int(binary.BigEndian.Uint32(data[index : index+LengthBytes])) 485 index += LengthBytes 486 r.ColumnName = string(data[index : index+l]) 487 index += l 488 489 // Vector 490 l = int(binary.BigEndian.Uint32(data[index : index+LengthBytes])) 491 index += LengthBytes 492 493 var vec vector.Vector 494 if err := vec.UnmarshalBinary(data[index : index+l]); err != nil { 495 return err 496 } 497 r.Vector = &vec 498 499 return nil 500 } 501 502 type DeleteResp struct { 503 } 504 505 func (m *DeleteResp) MarshalBinary() ([]byte, error) { 506 return m.Marshal() 507 } 508 509 func (m *DeleteResp) UnmarshalBinary(data []byte) error { 510 return m.Unmarshal(data) 511 } 512 513 type GetPrimaryKeysReq struct { 514 TableID ID 515 } 516 517 func (m *GetPrimaryKeysReq) MarshalBinary() ([]byte, error) { 518 return m.Marshal() 519 } 520 521 func (m *GetPrimaryKeysReq) UnmarshalBinary(data []byte) error { 522 return m.Unmarshal(data) 523 } 524 525 type GetPrimaryKeysResp struct { 526 Attrs []engine.Attribute 527 } 528 529 func (m *GetPrimaryKeysResp) MarshalBinary() ([]byte, error) { 530 return m.Marshal() 531 } 532 533 func (m *GetPrimaryKeysResp) UnmarshalBinary(data []byte) error { 534 return m.Unmarshal(data) 535 } 536 537 type GetTableDefsReq struct { 538 TableID ID 539 } 540 541 func (m *GetTableDefsReq) MarshalBinary() ([]byte, error) { 542 return m.Marshal() 543 } 544 545 func (m *GetTableDefsReq) UnmarshalBinary(data []byte) error { 546 return m.Unmarshal(data) 547 } 548 549 type GetTableColumnsReq struct { 550 TableID ID 551 } 552 553 func (m *GetTableColumnsReq) MarshalBinary() ([]byte, error) { 554 return m.Marshal() 555 } 556 557 func (m *GetTableColumnsReq) UnmarshalBinary(data []byte) error { 558 return m.Unmarshal(data) 559 } 560 561 type GetTableColumnsResp struct { 562 Attrs []engine.Attribute 563 } 564 565 func (m *GetTableColumnsResp) MarshalBinary() ([]byte, error) { 566 return m.Marshal() 567 } 568 569 func (m *GetTableColumnsResp) UnmarshalBinary(data []byte) error { 570 return m.Unmarshal(data) 571 } 572 573 type GetTableDefsResp struct { 574 Defs []engine.TableDefPB 575 } 576 577 func (m *GetTableDefsResp) MarshalBinary() ([]byte, error) { 578 return m.Marshal() 579 } 580 581 func (m *GetTableDefsResp) UnmarshalBinary(data []byte) error { 582 return m.Unmarshal(data) 583 } 584 585 type GetHiddenKeysReq struct { 586 TableID ID 587 } 588 589 func (m *GetHiddenKeysReq) MarshalBinary() ([]byte, error) { 590 return m.Marshal() 591 } 592 593 func (m *GetHiddenKeysReq) UnmarshalBinary(data []byte) error { 594 return m.Unmarshal(data) 595 } 596 597 type GetHiddenKeysResp struct { 598 Attrs []engine.Attribute 599 } 600 601 func (m *GetHiddenKeysResp) MarshalBinary() ([]byte, error) { 602 return m.Marshal() 603 } 604 605 func (m *GetHiddenKeysResp) UnmarshalBinary(data []byte) error { 606 return m.Unmarshal(data) 607 } 608 609 //type TruncateReq struct { 610 // TableID ID 611 // DatabaseName string 612 // TableName string 613 //} 614 // 615 //type TruncateResp struct { 616 // AffectedRows int64 617 //} 618 619 type UpdateReq struct { 620 TableID ID 621 DatabaseName string 622 TableName string 623 Batch *batch.Batch 624 } 625 626 func (r *UpdateReq) MarshalBinary() ([]byte, error) { 627 batchData, err := r.Batch.MarshalBinary() 628 if err != nil { 629 return nil, err 630 } 631 632 // ----------------------------------------------------------------------- 633 // | TableID | length | DatabaseName | length | TableName | length | Batch | 634 // ----------------------------------------------------------------------- 635 size := IDBytes + LengthBytes + len(r.DatabaseName) + LengthBytes + len(r.TableName) + LengthBytes + len(batchData) 636 data := make([]byte, size) 637 index := 0 638 639 // TableID 640 binary.BigEndian.PutUint64(data[index:index+IDBytes], uint64(r.TableID)) 641 index += IDBytes 642 643 // DatabaseName 644 binary.BigEndian.PutUint32(data[index:index+LengthBytes], uint32(len(r.DatabaseName))) 645 index += LengthBytes 646 n := copy(data[index:], r.DatabaseName) 647 index += n 648 649 // TableName 650 binary.BigEndian.PutUint32(data[index:index+LengthBytes], uint32(len(r.TableName))) 651 index += LengthBytes 652 n = copy(data[index:], r.TableName) 653 index += n 654 655 // Batch 656 binary.BigEndian.PutUint32(data[index:index+LengthBytes], uint32(len(batchData))) 657 index += LengthBytes 658 copy(data[index:], batchData) 659 660 return data, nil 661 } 662 663 func (r *UpdateReq) UnmarshalBinary(data []byte) error { 664 index := 0 665 666 // TableID 667 r.TableID = ID(binary.BigEndian.Uint64(data[index : index+IDBytes])) 668 index += IDBytes 669 670 // DatabaseName 671 l := int(binary.BigEndian.Uint32(data[index : index+LengthBytes])) 672 index += LengthBytes 673 r.DatabaseName = string(data[index : index+l]) 674 index += l 675 676 // TableName 677 l = int(binary.BigEndian.Uint32(data[index : index+LengthBytes])) 678 index += LengthBytes 679 r.TableName = string(data[index : index+l]) 680 index += l 681 682 // Batch 683 l = int(binary.BigEndian.Uint32(data[index : index+LengthBytes])) 684 index += LengthBytes 685 686 var bat batch.Batch 687 if err := bat.UnmarshalBinary(data[index : index+l]); err != nil { 688 return err 689 } 690 r.Batch = &bat 691 692 return nil 693 } 694 695 type UpdateResp struct { 696 } 697 698 func (m *UpdateResp) MarshalBinary() ([]byte, error) { 699 return m.Marshal() 700 } 701 702 func (m *UpdateResp) UnmarshalBinary(data []byte) error { 703 return m.Unmarshal(data) 704 } 705 706 type WriteReq struct { 707 TableID ID 708 DatabaseName string 709 TableName string 710 Batch *batch.Batch 711 } 712 713 func (r *WriteReq) MarshalBinary() ([]byte, error) { 714 batchData, err := r.Batch.MarshalBinary() 715 if err != nil { 716 return nil, err 717 } 718 719 // ----------------------------------------------------------------------- 720 // | TableID | length | DatabaseName | length | TableName | length | Batch | 721 // ----------------------------------------------------------------------- 722 size := IDBytes + LengthBytes + len(r.DatabaseName) + LengthBytes + len(r.TableName) + LengthBytes + len(batchData) 723 data := make([]byte, size) 724 index := 0 725 726 // TableID 727 binary.BigEndian.PutUint64(data[index:index+IDBytes], uint64(r.TableID)) 728 index += IDBytes 729 730 // DatabaseName 731 binary.BigEndian.PutUint32(data[index:index+LengthBytes], uint32(len(r.DatabaseName))) 732 index += LengthBytes 733 copy(data[index:], r.DatabaseName) 734 index += len(r.DatabaseName) 735 736 // TableName 737 binary.BigEndian.PutUint32(data[index:index+LengthBytes], uint32(len(r.TableName))) 738 index += LengthBytes 739 copy(data[index:], r.TableName) 740 index += len(r.TableName) 741 742 // Batch 743 binary.BigEndian.PutUint32(data[index:index+LengthBytes], uint32(len(batchData))) 744 index += LengthBytes 745 copy(data[index:], batchData) 746 747 return data, nil 748 } 749 750 func (r *WriteReq) UnmarshalBinary(data []byte) error { 751 index := 0 752 753 // TableID 754 r.TableID = ID(binary.BigEndian.Uint64(data[index : index+IDBytes])) 755 index += IDBytes 756 757 // DatabaseName 758 l := int(binary.BigEndian.Uint32(data[index : index+LengthBytes])) 759 index += LengthBytes 760 r.DatabaseName = string(data[index : index+l]) 761 index += l 762 763 // TableName 764 l = int(binary.BigEndian.Uint32(data[index : index+LengthBytes])) 765 index += LengthBytes 766 r.TableName = string(data[index : index+l]) 767 index += l 768 769 // Batch 770 l = int(binary.BigEndian.Uint32(data[index : index+LengthBytes])) 771 index += LengthBytes 772 773 var bat batch.Batch 774 if err := bat.UnmarshalBinary(data[index : index+l]); err != nil { 775 return err 776 } 777 r.Batch = &bat 778 779 return nil 780 } 781 782 type WriteResp struct { 783 } 784 785 func (m *WriteResp) MarshalBinary() ([]byte, error) { 786 return m.Marshal() 787 } 788 789 func (m *WriteResp) UnmarshalBinary(data []byte) error { 790 return m.Unmarshal(data) 791 } 792 793 type NewTableIterReq struct { 794 TableID ID 795 Expr *plan.Expr 796 } 797 798 func (m *NewTableIterReq) MarshalBinary() ([]byte, error) { 799 return m.Marshal() 800 } 801 802 func (m *NewTableIterReq) UnmarshalBinary(data []byte) error { 803 return m.Unmarshal(data) 804 } 805 806 type NewTableIterResp struct { 807 IterID ID 808 } 809 810 func (m *NewTableIterResp) MarshalBinary() ([]byte, error) { 811 return m.Marshal() 812 } 813 814 func (m *NewTableIterResp) UnmarshalBinary(data []byte) error { 815 return m.Unmarshal(data) 816 } 817 818 type ReadReq struct { 819 IterID ID 820 ColNames []string 821 } 822 823 func (m *ReadReq) MarshalBinary() ([]byte, error) { 824 return m.Marshal() 825 } 826 827 func (m *ReadReq) UnmarshalBinary(data []byte) error { 828 return m.Unmarshal(data) 829 } 830 831 type ReadResp struct { 832 Batch *batch.Batch 833 834 mp *mpool.MPool 835 } 836 837 func (r *ReadResp) MarshalBinary() ([]byte, error) { 838 if r.Batch != nil { 839 return r.Batch.MarshalBinary() 840 } 841 return nil, nil 842 } 843 844 func (r *ReadResp) UnmarshalBinary(data []byte) error { 845 if len(data) > 0 { 846 var bat batch.Batch 847 if err := bat.UnmarshalBinary(data); err != nil { 848 return err 849 } 850 r.Batch = &bat 851 } 852 return nil 853 } 854 855 func (r *ReadResp) Close() error { 856 if r.Batch != nil { 857 r.Batch.Clean(r.mp) 858 } 859 return nil 860 } 861 862 func (r *ReadResp) SetHeap(mp *mpool.MPool) { 863 r.mp = mp 864 } 865 866 type CloseTableIterReq struct { 867 IterID ID 868 } 869 870 func (m *CloseTableIterReq) MarshalBinary() ([]byte, error) { 871 return m.Marshal() 872 } 873 874 func (m *CloseTableIterReq) UnmarshalBinary(data []byte) error { 875 return m.Unmarshal(data) 876 } 877 878 type CloseTableIterResp struct { 879 } 880 881 func (m *CloseTableIterResp) MarshalBinary() ([]byte, error) { 882 return m.Marshal() 883 } 884 885 func (m *CloseTableIterResp) UnmarshalBinary(data []byte) error { 886 return m.Unmarshal(data) 887 } 888 889 type TableStatsReq struct { 890 TableID ID 891 } 892 893 func (m *TableStatsReq) MarshalBinary() ([]byte, error) { 894 return m.Marshal() 895 } 896 897 func (m *TableStatsReq) UnmarshalBinary(data []byte) error { 898 return m.Unmarshal(data) 899 } 900 901 type TableStatsResp struct { 902 Rows int 903 } 904 905 func (m *TableStatsResp) MarshalBinary() ([]byte, error) { 906 return m.Marshal() 907 } 908 909 func (m *TableStatsResp) UnmarshalBinary(data []byte) error { 910 return m.Unmarshal(data) 911 }