github.com/matrixorigin/matrixone@v1.2.0/pkg/vm/engine/tae/tables/txnentries/compactblkcmd.go (about) 1 // Copyright 2021 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 txnentries 16 17 import ( 18 "bytes" 19 "io" 20 21 "github.com/matrixorigin/matrixone/pkg/container/types" 22 "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/common" 23 "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/iface/txnif" 24 "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/txn/txnbase" 25 ) 26 27 type compactBlockCmd struct { 28 txnbase.BaseCmd 29 from *common.ID 30 to *common.ID 31 txn txnif.AsyncTxn 32 id uint32 33 } 34 35 func newCompactBlockCmd(from, to *common.ID, txn txnif.AsyncTxn, id uint32) *compactBlockCmd { 36 return &compactBlockCmd{ 37 txn: txn, 38 from: from, 39 to: to, 40 id: id, 41 } 42 } 43 func (cmd *compactBlockCmd) GetType() uint16 { return IOET_WALTxnCommand_Compact } 44 func (cmd *compactBlockCmd) WriteTo(w io.Writer) (n int64, err error) { 45 typ := cmd.GetType() 46 if _, err = w.Write(types.EncodeUint16(&typ)); err != nil { 47 return 48 } 49 n = 2 50 ver := IOET_WALTxnCommand_Compact_CurrVer 51 if _, err = w.Write(types.EncodeUint16(&ver)); err != nil { 52 return 53 } 54 n = 2 55 return 56 } 57 func (cmd *compactBlockCmd) ReadFrom(r io.Reader) (n int64, err error) { 58 return 59 } 60 func (cmd *compactBlockCmd) MarshalBinary() (buf []byte, err error) { 61 var bbuf bytes.Buffer 62 if _, err = cmd.WriteTo(&bbuf); err != nil { 63 return 64 } 65 buf = bbuf.Bytes() 66 return 67 } 68 func (cmd *compactBlockCmd) UnmarshalBinary(buf []byte) (err error) { 69 bbuf := bytes.NewBuffer(buf) 70 _, err = cmd.ReadFrom(bbuf) 71 return 72 } 73 func (cmd *compactBlockCmd) Desc() string { 74 return "CmdName=CPCT" 75 } 76 func (cmd *compactBlockCmd) String() string { 77 return "CmdName=CPCT" 78 } 79 func (cmd *compactBlockCmd) VerboseString() string { 80 return "CmdName=CPCT" 81 } 82 func (cmd *compactBlockCmd) ApplyCommit() {} 83 func (cmd *compactBlockCmd) ApplyRollback() {} 84 func (cmd *compactBlockCmd) SetReplayTxn(_ txnif.AsyncTxn) {}