github.com/matrixorigin/matrixone@v0.7.0/pkg/vm/engine/tae/containers/vecview.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 containers 16 17 import ( 18 "io" 19 "unsafe" 20 21 "github.com/RoaringBitmap/roaring" 22 "github.com/RoaringBitmap/roaring/roaring64" 23 "github.com/matrixorigin/matrixone/pkg/common/mpool" 24 "github.com/matrixorigin/matrixone/pkg/container/types" 25 ) 26 27 type vecView struct { 28 impl Vector 29 } 30 31 func newVecView(impl Vector) *vecView { 32 return &vecView{ 33 impl: impl, 34 } 35 } 36 37 // func (vec *vecView) Equals(o Vector) bool { 38 // if vec.Length() != o.Length() { 39 // return false 40 // } 41 // if vec.GetType() != o.GetType() { 42 // return false 43 // } 44 // if vec.Nullable() != o.Nullable() { 45 // return false 46 // } 47 // if vec.HasNull() != o.HasNull() { 48 // return false 49 // } 50 // if vec.HasNull() { 51 // if !vec.NullMask().Equals(o.NullMask()) { 52 // return false 53 // } 54 // } 55 // for i := 0; i < vec.Length(); i++ { 56 // if vec.Get(i) != o.Get(i) { 57 // return false 58 // } 59 // } 60 // return true 61 // } 62 func (vec *vecView) IsView() bool { return true } 63 func (vec *vecView) Nullable() bool { return vec.impl.Nullable() } 64 func (vec *vecView) IsNull(i int) bool { return vec.impl.IsNull(i) } 65 func (vec *vecView) HasNull() bool { return vec.impl.HasNull() } 66 func (vec *vecView) NullMask() *roaring64.Bitmap { return vec.impl.NullMask() } 67 func (vec *vecView) Bytes() *Bytes { return vec.impl.Bytes() } 68 func (vec *vecView) Data() []byte { return vec.impl.Data() } 69 func (vec *vecView) DataWindow(offset, length int) []byte { 70 return vec.impl.DataWindow(offset, length) 71 } 72 func (vec *vecView) Get(i int) (v any) { return vec.impl.Get(i) } 73 func (vec *vecView) Length() int { return vec.impl.Length() } 74 func (vec *vecView) Capacity() int { return vec.impl.Capacity() } 75 func (vec *vecView) Allocated() int { return vec.impl.Allocated() } 76 77 func (vec *vecView) GetAllocator() *mpool.MPool { return vec.impl.GetAllocator() } 78 func (vec *vecView) GetType() types.Type { return vec.impl.GetType() } 79 func (vec *vecView) String() string { return vec.impl.String() } 80 func (vec *vecView) PPString(num int) string { return vec.impl.PPString(num) } 81 func (vec *vecView) Close() {} 82 func (vec *vecView) Slice() any { return vec.impl.Slice() } 83 func (vec *vecView) SlicePtr() unsafe.Pointer { return vec.impl.SlicePtr() } 84 85 func (vec *vecView) ResetWithData(_ *Bytes, _ *roaring64.Bitmap) { panic("not supported") } 86 func (vec *vecView) Window() VectorView { panic("not implemented") } 87 88 func (vec *vecView) WriteTo(w io.Writer) (n int64, err error) { 89 return vec.impl.WriteTo(w) 90 } 91 92 func (vec *vecView) Foreach(op ItOp, sels *roaring.Bitmap) (err error) { 93 return vec.impl.ForeachWindow(0, vec.Length(), op, sels) 94 } 95 96 func (vec *vecView) ForeachWindow(offset, length int, op ItOp, sels *roaring.Bitmap) (err error) { 97 return vec.impl.ForeachWindow(offset, length, op, sels) 98 }