Ignite 'complex' type

classic Classic list List threaded Threaded
4 messages Options
Stéphane Thibaud-2 Stéphane Thibaud-2
Reply | Threaded
Open this post in threaded view
|

Ignite 'complex' type

Hello Ignite experts,

I am trying to store a python value of type 

Tuple[Dict[str, float], bytes]

in an Ignite cache. However, doing that without type hints I get:

TypeError: Type `array of None` is invalid

Do you know if this is possible?


Kind regards,

Stéphane Thibaud
Stéphane Thibaud-2 Stéphane Thibaud-2
Reply | Threaded
Open this post in threaded view
|

Re: Ignite 'complex' type

Any thoughts about this one?


Kind regards,

Stéphane Thibaud

2019年5月16日(木) 20:55 Stéphane Thibaud <[hidden email]>:
Hello Ignite experts,

I am trying to store a python value of type 

Tuple[Dict[str, float], bytes]

in an Ignite cache. However, doing that without type hints I get:

TypeError: Type `array of None` is invalid

Do you know if this is possible?


Kind regards,

Stéphane Thibaud
Dmitry Melnichuk Dmitry Melnichuk
Reply | Threaded
Open this post in threaded view
|

Re: Ignite 'complex' type

Stéphane,

I afraid this won't work. Ignite storage is typed, thus you can not use
values of arbitrary type, but only of Pythonic types that defined
here[1].

If you really want to store such a complex object as a whole, you can
either

1) serialize it with pickle/dill/protobuf/json/et c. and store as a
StringObject or a ByteArrayObject, or

2) define a class with a GenericObjectMeta[2] metaclass, with unique
class name and a schema. It will be an object of a special class, not
an arbitrary typed value, but it may do the job for you.

[1]
https://apacheignite.readme.io/docs/python-thin-client-initialization-and-configuration#section-data-types

[2] https://apacheignite.readme.io/docs/python-thin-client-binary-types

On Tue, 2019-05-21 at 07:15 +0900, Stéphane Thibaud wrote:

> Any thoughts about this one?
>
>
> Kind regards,
>
> Stéphane Thibaud
>
> 2019年5月16日(木) 20:55 Stéphane Thibaud <[hidden email]>:
> > Hello Ignite experts,
> >
> > I am trying to store a python value of type
> >
> > Tuple[Dict[str, float], bytes]
> >
> > in an Ignite cache. However, doing that without type hints I get:
> >
> > TypeError: Type `array of None` is invalid
> >
> > Do you know if this is possible?
> >
> >
> > Kind regards,
> >
> > Stéphane Thibaud

Stéphane Thibaud-2 Stéphane Thibaud-2
Reply | Threaded
Open this post in threaded view
|

Re: Ignite 'complex' type

Thank you Dmitry. I will use serialization in this case.


Kind regards,

Stéphane Thibaud 

2019年5月21日(火) 9:01 Dmitry Melnichuk <[hidden email]>:
Stéphane,

I afraid this won't work. Ignite storage is typed, thus you can not use
values of arbitrary type, but only of Pythonic types that defined
here[1].

If you really want to store such a complex object as a whole, you can
either

1) serialize it with pickle/dill/protobuf/json/et c. and store as a
StringObject or a ByteArrayObject, or

2) define a class with a GenericObjectMeta[2] metaclass, with unique
class name and a schema. It will be an object of a special class, not
an arbitrary typed value, but it may do the job for you.

[1]
https://apacheignite.readme.io/docs/python-thin-client-initialization-and-configuration#section-data-types

[2] https://apacheignite.readme.io/docs/python-thin-client-binary-types

On Tue, 2019-05-21 at 07:15 +0900, Stéphane Thibaud wrote:
> Any thoughts about this one?
>
>
> Kind regards,
>
> Stéphane Thibaud
>
> 2019年5月16日(木) 20:55 Stéphane Thibaud <[hidden email]>:
> > Hello Ignite experts,
> >
> > I am trying to store a python value of type
> >
> > Tuple[Dict[str, float], bytes]
> >
> > in an Ignite cache. However, doing that without type hints I get:
> >
> > TypeError: Type `array of None` is invalid
> >
> > Do you know if this is possible?
> >
> >
> > Kind regards,
> >
> > Stéphane Thibaud