github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/pkg/state/impl.go (about) 1 /* 2 * Copyright (c) 2022-present unTill Pro, Ltd. 3 */ 4 5 package state 6 7 import ( 8 "fmt" 9 10 "github.com/voedger/voedger/pkg/appdef" 11 "github.com/voedger/voedger/pkg/istructs" 12 ) 13 14 func SimpleWSIDFunc(wsid istructs.WSID) WSIDFunc { 15 return func() istructs.WSID { return wsid } 16 } 17 func SimplePartitionIDFunc(partitionID istructs.PartitionID) PartitionIDFunc { 18 return func() istructs.PartitionID { return partitionID } 19 } 20 func put(fieldName string, kind appdef.DataKind, rr istructs.IRowReader, rw istructs.IRowWriter) { 21 switch kind { 22 case appdef.DataKind_int32: 23 rw.PutInt32(fieldName, rr.AsInt32(fieldName)) 24 case appdef.DataKind_int64: 25 rw.PutInt64(fieldName, rr.AsInt64(fieldName)) 26 case appdef.DataKind_float32: 27 rw.PutFloat32(fieldName, rr.AsFloat32(fieldName)) 28 case appdef.DataKind_float64: 29 rw.PutFloat64(fieldName, rr.AsFloat64(fieldName)) 30 case appdef.DataKind_bytes: 31 rw.PutBytes(fieldName, rr.AsBytes(fieldName)) 32 case appdef.DataKind_string: 33 rw.PutString(fieldName, rr.AsString(fieldName)) 34 case appdef.DataKind_QName: 35 rw.PutQName(fieldName, rr.AsQName(fieldName)) 36 case appdef.DataKind_bool: 37 rw.PutBool(fieldName, rr.AsBool(fieldName)) 38 case appdef.DataKind_RecordID: 39 rw.PutRecordID(fieldName, rr.AsRecordID(fieldName)) 40 default: 41 panic(fmt.Errorf("illegal state: field - '%s', kind - '%d': %w", fieldName, kind, ErrNotSupported)) 42 } 43 }