github.com/matrixorigin/matrixone@v0.7.0/pkg/vm/engine/tae/tables/utils.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 tables 16 17 import ( 18 "bytes" 19 20 "github.com/matrixorigin/matrixone/pkg/container/types" 21 "github.com/matrixorigin/matrixone/pkg/objectio" 22 "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/buffer/base" 23 "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/catalog" 24 "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/common" 25 "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/containers" 26 "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/dataio/blockio" 27 "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/tables/evictable" 28 ) 29 30 func LoadPersistedColumnData( 31 mgr base.INodeManager, 32 fs *objectio.ObjectFS, 33 id *common.ID, 34 def *catalog.ColDef, 35 location string, 36 buffer *bytes.Buffer) (vec containers.Vector, err error) { 37 return evictable.FetchColumnData( 38 id, 39 def, 40 location, 41 buffer, 42 mgr, 43 fs) 44 } 45 46 func ReadPersistedBlockRow(location string) int { 47 meta, err := blockio.DecodeMetaLocToMeta(location) 48 if err != nil { 49 panic(err) 50 } 51 return int(meta.GetRows()) 52 } 53 54 func LoadPersistedDeletes( 55 mgr base.INodeManager, 56 fs *objectio.ObjectFS, 57 location string) (bat *containers.Batch, err error) { 58 bat = containers.NewBatch() 59 colNames := []string{catalog.PhyAddrColumnName, catalog.AttrCommitTs, catalog.AttrAborted} 60 colTypes := []types.Type{types.T_Rowid.ToType(), types.T_TS.ToType(), types.T_bool.ToType()} 61 for i := 0; i < 3; i++ { 62 vec, err := evictable.FetchDeltaData(nil, mgr, fs, location, uint16(i), colTypes[i]) 63 if err != nil { 64 return bat, err 65 } 66 bat.AddVector(colNames[i], vec) 67 } 68 return 69 }