github.com/matrixorigin/matrixone@v0.7.0/pkg/vm/engine/tae/catalog/base.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 catalog 16 17 import ( 18 "io" 19 "sync" 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/wal" 25 ) 26 27 // JXM TODO: 28 // Generic BaseEntry can't work in go 1.19 because of compiler bug: 29 // https://github.com/golang/go/issues/54671 30 // Refactor catalog and use generic BaseEntry after go 1.19.1 release. 31 type BaseEntry interface { 32 RLock() 33 RUnlock() 34 35 String() string 36 StringLocked() string 37 PPString(common.PPLevel, int, string) string 38 39 GetTxn() txnif.TxnReader 40 GetID() uint64 41 GetIndexes() []*wal.Index 42 GetLogIndex() *wal.Index 43 44 GetLatestNodeLocked() txnif.MVCCNode 45 IsVisible(ts types.TS, mu *sync.RWMutex) (ok bool, err error) 46 47 HasCommittedNodeInRange(minTs, MaxTs types.TS) bool 48 IsCreatingOrAborted() bool 49 IsCommitting() bool 50 DeleteBefore(ts types.TS) bool 51 HasDropCommitted() bool 52 HasDropCommittedLocked() bool 53 54 WriteOneNodeTo(w io.Writer) (n int64, err error) 55 ReadOneNodeFrom(r io.Reader) (n int64, err error) 56 CloneCommittedInRange(start, end types.TS) (ret BaseEntry) 57 58 PrepareCommit() error 59 PrepareRollback() (bool, error) 60 ApplyCommit(index *wal.Index) error 61 ApplyRollback(index *wal.Index) error 62 } 63 64 func CompareUint64(left, right uint64) int { 65 if left > right { 66 return 1 67 } else if left < right { 68 return -1 69 } 70 return 0 71 }