github.com/matrixorigin/matrixone@v1.2.0/pkg/objectio/versions.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 objectio 16 17 import ( 18 "github.com/matrixorigin/matrixone/pkg/container/types" 19 "github.com/matrixorigin/matrixone/pkg/container/vector" 20 ) 21 22 type ObjectWriter = objectWriterV1 23 24 type ObjectReader = objectReaderV1 25 26 type ObjectDataMeta = objectDataMetaV1 27 28 var ( 29 BuildObjectMeta = buildObjectDataMetaV1 30 NewObjectWriterSpecial = newObjectWriterSpecialV1 31 NewObjectWriter = newObjectWriterV1 32 NewObjectReaderWithStr = newObjectReaderWithStrV1 33 NewObjectReader = newObjectReaderV1 34 ) 35 36 const ( 37 IOET_ObjectMeta_V1 = 1 38 IOET_ObjectMeta_V2 = 2 39 IOET_ObjectMeta_V3 = 3 40 IOET_ColumnData_V1 = 1 41 IOET_BloomFilter_V1 = 1 42 IOET_BloomFilter_V2 = 2 43 IOET_ZoneMap_V1 = 1 44 45 IOET_ObjectMeta_CurrVer = IOET_ObjectMeta_V3 46 IOET_ColumnData_CurrVer = IOET_ColumnData_V1 47 IOET_BloomFilter_CurrVer = IOET_BloomFilter_V2 48 IOET_ZoneMap_CurrVer = IOET_ZoneMap_V1 49 ) 50 51 func init() { 52 RegisterIOEnrtyCodec(IOEntryHeader{IOET_ObjMeta, IOET_ObjectMeta_V1}, nil, DecodeObjectMetaV1) 53 RegisterIOEnrtyCodec(IOEntryHeader{IOET_ObjMeta, IOET_ObjectMeta_V2}, nil, DecodeObjectMetaV2) 54 RegisterIOEnrtyCodec(IOEntryHeader{IOET_ObjMeta, IOET_ObjectMeta_V3}, nil, DecodeObjectMetaV3) 55 RegisterIOEnrtyCodec(IOEntryHeader{IOET_ColData, IOET_ColumnData_V1}, EncodeColumnDataV1, DecodeColumnDataV1) 56 RegisterIOEnrtyCodec(IOEntryHeader{IOET_BF, IOET_BloomFilter_V1}, nil, nil) 57 RegisterIOEnrtyCodec(IOEntryHeader{IOET_BF, IOET_BloomFilter_V2}, nil, nil) 58 RegisterIOEnrtyCodec(IOEntryHeader{IOET_ZM, IOET_ZoneMap_V1}, nil, nil) 59 } 60 61 func EncodeColumnDataV1(ioe any) (buf []byte, err error) { 62 return ioe.(*vector.Vector).MarshalBinary() 63 } 64 65 func DecodeColumnDataV1(buf []byte) (ioe any, err error) { 66 vec := vector.NewVec(types.Type{}) 67 if err = vec.UnmarshalBinary(buf); err != nil { 68 return 69 } 70 return vec, err 71 } 72 73 func DecodeObjectMetaV1(buf []byte) (ioe any, err error) { 74 return objectMetaV1(buf), nil 75 } 76 77 func DecodeObjectMetaV2(buf []byte) (ioe any, err error) { 78 return objectMetaV2(buf), nil 79 } 80 81 func DecodeObjectMetaV3(buf []byte) (ioe any, err error) { 82 return objectMetaV3(buf), nil 83 }