github.com/matrixorigin/matrixone@v1.2.0/pkg/sql/plan/function/functionUtil/quickCast.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 functionUtil 16 17 import ( 18 "github.com/matrixorigin/matrixone/pkg/common/util" 19 "github.com/matrixorigin/matrixone/pkg/container/types" 20 ) 21 22 func ConvertD64ToD128(v types.Decimal64) types.Decimal128 { 23 x := types.Decimal128{B0_63: uint64(v), B64_127: 0} 24 if v>>63 != 0 { 25 x.B64_127 = ^x.B64_127 26 } 27 return x 28 } 29 30 func QuickStrToBytes(s string) []byte { 31 return util.UnsafeStringToBytes(s) 32 } 33 34 func QuickBytesToStr(data []byte) string { 35 return util.UnsafeBytesToString(data) 36 }