示例#1
0
class Node1(Serializable):
    a = IdentityField('a', ValueType.string)
    b1 = Int8Field('b1')
    b2 = Int16Field('b2')
    b3 = Int32Field('b3')
    b4 = Int64Field('b4')
    c1 = UInt8Field('c1')
    c2 = UInt16Field('c2')
    c3 = UInt32Field('c3')
    c4 = UInt64Field('c4')
    d1 = Float16Field('d1')
    d2 = Float32Field('d2')
    d3 = Float64Field('d3')
    cl1 = Complex64Field('cl1')
    cl2 = Complex128Field('cl2')
    e = BoolField('e')
    f = KeyField('f')
    g = ReferenceField('g', 'Node2')
    h = ListField('h')
    i = ListField('i', ValueType.reference('self'))

    def __new__(cls, *args, **kwargs):
        if 'a' in kwargs and kwargs['a'] == 'test1':
            return object.__new__(Node8)
        return object.__new__(cls)

    @classmethod
    def cls(cls, provider):
        if provider.type == ProviderType.protobuf:
            from mars.serialize.tests.testser_pb2 import Node1Def
            return Node1Def
        return super(Node1, cls).cls(provider)
示例#2
0
class Node1(Serializable):
    a = IdentityField('a', ValueType.string)
    b1 = Int8Field('b1')
    b2 = Int16Field('b2')
    b3 = Int32Field('b3')
    b4 = Int64Field('b4')
    c1 = UInt8Field('c1')
    c2 = UInt16Field('c2')
    c3 = UInt32Field('c3')
    c4 = UInt64Field('c4')
    d1 = Float16Field('d1')
    d2 = Float32Field('d2')
    d3 = Float64Field('d3')
    cl1 = Complex64Field('cl1')
    cl2 = Complex128Field('cl2')
    e = BoolField('e')
    f1 = KeyField('f1')
    f2 = AnyField('f2')
    f3 = AnyField('f3')
    g = ReferenceField('g', 'Node2')
    h = ListField('h')
    i = ListField('i', ValueType.reference('self'))
    j = ReferenceField('j', None)
    k = ListField('k', ValueType.reference(None))
    l = FunctionField('l')  # noqa: E741
    m = TZInfoField('m')
    n = IntervalArrayField('n')
    o = NamedtupleField('o')
    p = RegexField('p')

    def __new__(cls, *args, **kwargs):
        if 'a' in kwargs and kwargs['a'] == 'test1':
            return object.__new__(Node8)
        return object.__new__(cls)

    @classmethod
    def cls(cls, provider):
        if provider.type == ProviderType.protobuf:
            from mars.serialize.tests.testser_pb2 import Node1Def
            return Node1Def
        return super().cls(provider)