( remoteTypeId: number, localTypeId: number, builder: CodecBuilder, )
| 189 | } |
| 190 | |
| 191 | function compatibleScalarFieldReadExpr( |
| 192 | remoteTypeId: number, |
| 193 | localTypeId: number, |
| 194 | builder: CodecBuilder, |
| 195 | ): string | null { |
| 196 | const converter = builder.getExternal(CompatibleScalarConverter.name); |
| 197 | const remoteRead = compatibleScalarRemoteReadExpr( |
| 198 | remoteTypeId, |
| 199 | builder, |
| 200 | converter, |
| 201 | ); |
| 202 | if (remoteRead === null) { |
| 203 | return null; |
| 204 | } |
| 205 | if (remoteTypeId === localTypeId) { |
| 206 | return remoteRead; |
| 207 | } |
| 208 | const remoteCanonical = canonicalScalarTypeId(remoteTypeId); |
| 209 | const localCanonical = canonicalScalarTypeId(localTypeId); |
| 210 | switch (localCanonical) { |
| 211 | case TypeId.BOOL: |
| 212 | return scalarToBoolExpr(remoteCanonical, remoteRead, converter); |
| 213 | case TypeId.STRING: |
| 214 | return scalarToStringExpr(remoteCanonical, remoteRead, converter); |
| 215 | case TypeId.DECIMAL: |
| 216 | return scalarToDecimalExpr(remoteCanonical, remoteRead, converter); |
| 217 | case TypeId.INT8: |
| 218 | case TypeId.INT16: |
| 219 | case TypeId.INT32: |
| 220 | case TypeId.INT64: |
| 221 | case TypeId.UINT8: |
| 222 | case TypeId.UINT16: |
| 223 | case TypeId.UINT32: |
| 224 | case TypeId.UINT64: |
| 225 | return scalarToIntegerExpr( |
| 226 | remoteCanonical, |
| 227 | localCanonical, |
| 228 | remoteRead, |
| 229 | converter, |
| 230 | ); |
| 231 | case TypeId.FLOAT16: |
| 232 | case TypeId.BFLOAT16: |
| 233 | case TypeId.FLOAT32: |
| 234 | case TypeId.FLOAT64: |
| 235 | return scalarToFloatExpr( |
| 236 | remoteCanonical, |
| 237 | localCanonical, |
| 238 | remoteRead, |
| 239 | converter, |
| 240 | ); |
| 241 | default: |
| 242 | return null; |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | function canonicalScalarTypeId(typeId: number): number { |
| 247 | switch (typeId) { |
no test coverage detected