github.com/matrixorigin/matrixone@v1.2.0/pkg/vm/engine/tae/catalog/dbmvccnode.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  
    20  	"github.com/matrixorigin/matrixone/pkg/objectio"
    21  )
    22  
    23  type EmptyMVCCNode struct{}
    24  
    25  func NewEmptyEmptyMVCCNode() *EmptyMVCCNode {
    26  	return &EmptyMVCCNode{}
    27  }
    28  
    29  func (e *EmptyMVCCNode) CloneAll() *EmptyMVCCNode {
    30  	node := &EmptyMVCCNode{}
    31  	return node
    32  }
    33  
    34  func (e *EmptyMVCCNode) CloneData() *EmptyMVCCNode {
    35  	return &EmptyMVCCNode{}
    36  }
    37  
    38  func (e *EmptyMVCCNode) String() string {
    39  	return ""
    40  }
    41  
    42  // for create drop in one txn
    43  func (e *EmptyMVCCNode) Update(vun *EmptyMVCCNode)           {}
    44  func (e *EmptyMVCCNode) IdempotentUpdate(vun *EmptyMVCCNode) {}
    45  
    46  func (e *EmptyMVCCNode) WriteTo(w io.Writer) (n int64, err error) { return }
    47  
    48  func (e *EmptyMVCCNode) ReadFromWithVersion(r io.Reader, ver uint16) (n int64, err error) { return }
    49  
    50  type DBNode struct {
    51  	acInfo    accessInfo
    52  	name      string
    53  	datType   string
    54  	createSql string
    55  }
    56  
    57  func (node *DBNode) ReadFrom(r io.Reader) (n int64, err error) {
    58  	var sn int64
    59  	if node.name, sn, err = objectio.ReadString(r); err != nil {
    60  		return
    61  	}
    62  	n += sn
    63  	if sn, err = node.acInfo.ReadFrom(r); err != nil {
    64  		return
    65  	}
    66  	n += sn
    67  	if node.createSql, sn, err = objectio.ReadString(r); err != nil {
    68  		return
    69  	}
    70  	n += sn
    71  	if node.datType, sn, err = objectio.ReadString(r); err != nil {
    72  		return
    73  	}
    74  	n += sn
    75  	return
    76  }
    77  
    78  func (node *DBNode) WriteTo(w io.Writer) (n int64, err error) {
    79  	var sn int64
    80  	if sn, err = objectio.WriteString(node.name, w); err != nil {
    81  		return
    82  	}
    83  	n += sn
    84  	if sn, err = node.acInfo.WriteTo(w); err != nil {
    85  		return
    86  	}
    87  	n += sn
    88  	if sn, err = objectio.WriteString(node.createSql, w); err != nil {
    89  		return
    90  	}
    91  	n += sn
    92  	if sn, err = objectio.WriteString(node.datType, w); err != nil {
    93  		return
    94  	}
    95  	n += sn
    96  	return
    97  }
    98  
    99  // only used in ut test
   100  func (node *DBNode) TestSetAccId(id uint32) {
   101  	node.acInfo.TenantID = id
   102  }