github.com/matrixorigin/matrixone@v0.7.0/pkg/vm/engine/tae/model/preparer.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 model 16 17 import ( 18 "github.com/matrixorigin/matrixone/pkg/common/mpool" 19 "github.com/matrixorigin/matrixone/pkg/container/types" 20 "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/containers" 21 ) 22 23 func PreparePhyAddrData(typ types.Type, prefix []byte, startRow, length uint32) (col containers.Vector, err error) { 24 col = containers.MakeVector(typ, false) 25 for i := uint32(0); i < length; i++ { 26 rowid := EncodePhyAddrKeyWithPrefix(prefix, startRow+i) 27 col.Append(rowid) 28 } 29 return 30 } 31 32 func PreparePhyAddrDataWithPool(typ types.Type, prefix []byte, startRow, length uint32, pool *mpool.MPool) (col containers.Vector, err error) { 33 col = containers.MakeVector(typ, false, containers.Options{Allocator: pool}) 34 for i := uint32(0); i < length; i++ { 35 rowid := EncodePhyAddrKeyWithPrefix(prefix, startRow+i) 36 col.Append(rowid) 37 } 38 return 39 } 40 41 type PreparedCompactedBlockData struct { 42 Columns *containers.Batch 43 SortKey containers.Vector 44 } 45 46 func NewPreparedCompactedBlockData() *PreparedCompactedBlockData { 47 return &PreparedCompactedBlockData{} 48 } 49 50 func (preparer *PreparedCompactedBlockData) Close() { 51 if preparer.Columns != nil { 52 preparer.Columns.Close() 53 } 54 preparer.Columns.Close() 55 if preparer.SortKey != nil { 56 preparer.SortKey.Close() 57 } 58 }