Skip to main content

Type Mapping of Xlang Serialization

Note:

  • For type definition, see Type Systems in Spec
  • int16_t[n]/vector<T> indicates int16_t[n]/vector<int16_t>
  • The cross-language serialization is not stable, do not use it in your production environment.

Type Mapping

Fury TypeFury Type IDJavaPythonJavascriptC++GolangRust
bool1bool/BooleanboolBooleanboolboolbool
int82byte/Byteint/pyfury.Int8Type.int8()int8_tint8i8
int163short/Shortint/pyfury.Int16Type.int16()int16_tint16i6
int324int/Integerint/pyfury.Int32Type.int32()int32_tint32i32
var_int325int/Integerint/pyfury.VarInt32Type.varint32()fury::varint32_tfury.varint32fury::varint32
int646long/Longint/pyfury.Int64Type.int64()int64_tint64i64
var_int647long/Longint/pyfury.VarInt64Type.varint64()fury::varint64_tfury.varint64fury::varint64
sli_int648long/Longint/pyfury.SliInt64Type.sliint64()fury::sliint64_tfury.sliint64fury::sliint64
float169float/Floatfloat/pyfury.Float16Type.float16()fury::float16_tfury.float16fury::f16
float3210float/Floatfloat/pyfury.Float32Type.float32()floatfloat32f32
float6411double/Doublefloat/pyfury.Float64Type.float64()doublefloat64f64
string12StringstrStringstringstringString/str
enum13Enum subclassesenum subclasses/enum/enum
named_enum14Enum subclassesenum subclasses/enum/enum
struct15pojo/recorddata class / type with type hintsobjectstruct/classstructstruct
polymorphic_struct16pojo/recorddata class / type with type hintsobjectstruct/classstructstruct
compatible_struct17pojo/recorddata class / type with type hintsobjectstruct/classstructstruct
polymorphic_compatible_struct18pojo/recorddata class / type with type hintsobjectstruct/classstructstruct
named_struct19pojo/recorddata class / type with type hintsobjectstruct/classstructstruct
named_polymorphic_struct20pojo/recorddata class / type with type hintsobjectstruct/classstructstruct
named_compatible_struct21pojo/recorddata class / type with type hintsobjectstruct/classstructstruct
named_polymorphic_compatible_struct22pojo/recorddata class / type with type hintsobjectstruct/classstructstruct
ext23pojo/recorddata class / type with type hintsobjectstruct/classstructstruct
polymorphic_ext24pojo/recorddata class / type with type hintsobjectstruct/classstructstruct
named_ext25pojo/recorddata class / type with type hintsobjectstruct/classstructstruct
named_polymorphic_ext26pojo/recorddata class / type with type hintsobjectstruct/classstructstruct
list27List/Collectionlist/tuplearrayvectorsliceVec
set28Setset/setfury.SetSet
map29MapdictMapunordered_mapmapHashMap
duration30DurationtimedeltaNumberdurationDurationDuration
timestamp31InstantdatetimeNumberstd::chrono::nanosecondsTimeDateTime
local_date32DatedatetimeNumberstd::chrono::nanosecondsTimeDateTime
decimal33BigDecimalDecimalbigint///
binary34byte[]bytes/uint8_t[n]/vector<T>[n]uint8/[]TVec<uint8_t>
array35arraynp.ndarray//array/sliceVec
bool_array36bool[]ndarray(np.bool_)/bool[n][n]bool/[]TVec<bool>
int8_array37byte[]ndarray(int8)/int8_t[n]/vector<T>[n]int8/[]TVec<i18>
int16_array38short[]ndarray(int16)/int16_t[n]/vector<T>[n]int16/[]TVec<i16>
int32_array39int[]ndarray(int32)/int32_t[n]/vector<T>[n]int32/[]TVec<i32>
int64_array40long[]ndarray(int64)/int64_t[n]/vector<T>[n]int64/[]TVec<i64>
float16_array41float[]ndarray(float16)/fury::float16_t[n]/vector<T>[n]float16/[]TVec<fury::f16>
float32_array42float[]ndarray(float32)/float[n]/vector<T>[n]float32/[]TVec<f32>
float64_array43double[]ndarray(float64)/double[n]/vector<T>[n]float64/[]TVec<f64>
arrow record batch44//////
arrow table45//////

Type info(not implemented currently)

Due to differences between type systems of languages, those types can't be mapped one-to-one between languages.

If the user notices that one type on a language corresponds to multiple types in Fury type systems, for example, long in java has type int64/varint64/sliint64, it means the language lacks some types, and the user must provide extra type info when using Fury.

Type annotation

If the type is a field of another class, users can provide meta hints for fields of a type, or for the whole type. Such information can be provided in other languages too:

  • java: use annotation.
  • cpp: use macro and template.
  • golang: use struct tag.
  • python: use typehint.
  • rust: use macro.

Here is en example:

  • Java:

    class Foo {
    @Int32Type(varint = true)
    int f1;
    List<@Int32Type(varint = true) Integer> f2;
    }
  • Python:

    class Foo:
    f1: Int32Type(varint=True)
    f2: List[Int32Type(varint=True)]

Type wrapper

If the type is not a field of a class, the user must wrap this type with a Fury type to pass the extra type info.

For example, suppose Fury Java provide a VarInt64 type, when a user invoke fury.serialize(long_value), he need to invoke like fury.serialize(new VarInt64(long_value)).