github.com/matrixorigin/matrixone@v1.2.0/pkg/vm/engine/tae/containers/colview.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 containers 16 17 // TODO: remove this ColumnView later 18 // Use Batch with one vector instead 19 type ColumnView struct { 20 *BaseView 21 ColIdx int 22 data Vector 23 } 24 25 func NewColumnView(colIdx int) *ColumnView { 26 return &ColumnView{ 27 BaseView: &BaseView{}, 28 ColIdx: colIdx, 29 } 30 } 31 32 func (view *ColumnView) Orphan() Vector { 33 data := view.data 34 view.data = nil 35 return data 36 } 37 38 func (view *ColumnView) SetData(data Vector) { 39 view.data = data 40 } 41 42 func (view *ColumnView) ApplyDeletes() Vector { 43 if view.DeleteMask.IsEmpty() { 44 return view.data 45 } 46 view.data.CompactByBitmap(view.DeleteMask) 47 view.DeleteMask = nil 48 return view.data 49 } 50 51 func (view *ColumnView) GetData() Vector { 52 return view.data 53 } 54 55 func (view *ColumnView) Length() int { 56 return view.data.Length() 57 } 58 59 func (view *ColumnView) String() string { 60 if view.data != nil { 61 return view.data.String() 62 } 63 return "empty" 64 } 65 66 func (view *ColumnView) GetValue(row int) (any, bool) { 67 return view.data.Get(row), view.data.IsNull(row) 68 } 69 70 func (view *ColumnView) IsDeleted(row int) bool { 71 return view.DeleteMask.Contains(uint64(row)) 72 } 73 74 func (view *ColumnView) Close() { 75 if view.data != nil { 76 view.data.Close() 77 } 78 view.data = nil 79 view.DeleteMask = nil 80 }