ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vladimir Ozerov <voze...@gridgain.com>
Subject Re: Improve binary enum handling
Date Mon, 24 Apr 2017 14:02:59 GMT
Dima,

No. It is normal (and inevitably) practice to register enums before they
are used.

This is how enum is created in MySQL:

CREATE TABLE shirts (
    name VARCHAR(40),
    size ENUM('x-small', 'small', 'medium', 'large', 'x-large')
);

And in PostgreSQL:

CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');
CREATE TABLE person (
    name text,
    current_mood mood
);

We will do the same at some point. That is, in future users will register
enums from SQL, not from native API or configuration.

Vladimir.

On Mon, Apr 24, 2017 at 4:37 PM, Dmitriy Setrakyan <dsetrakyan@apache.org>
wrote:

> Vladimir,
>
> I would really like to avoid special registration of Enums. Can you find a
> way to handle it automatically?
>
> D.
>
> On Mon, Apr 24, 2017 at 6:33 AM, Vladimir Ozerov <vozerov@gridgain.com>
> wrote:
>
> > Sorry, looks like I mismanaged tickets in JIRA. In fact, we implemented
> H2
> > part, but Ignite's part is not ready yet and is managed in IGNITE-4575
> [1].
> > Ticket you mentioned was an umbrella.
> >
> > [1] https://issues.apache.org/jira/browse/IGNITE-4575
> >
> > On Mon, Apr 24, 2017 at 4:28 PM, Dmitriy Setrakyan <
> dsetrakyan@apache.org>
> > wrote:
> >
> > > Vladimir,
> > >
> > > I am very confused. I thought we already had resolved this issue in
> this
> > > ticket:
> > > https://issues.apache.org/jira/browse/IGNITE-3595
> > >
> > > Can you clarify?
> > >
> > > D.
> > >
> > > On Mon, Apr 24, 2017 at 5:58 AM, Vladimir Ozerov <vozerov@gridgain.com
> >
> > > wrote:
> > >
> > > > Igniters,
> > > >
> > > > Currently we have limited support of binary enums. The main problem
> is
> > > that
> > > > we do not store any metadata about enum names. For this reason it is
> > > > impossible to use enums in SQL even though H2 already supports it
> [1].
> > We
> > > > need to improve enum metadata support and provide some additional API
> > to
> > > > register new enums in runtime.
> > > >
> > > > Proposed API:
> > > >
> > > > 1) Enum mappings can be defined statically in
> BinaryTypeConfiguration:
> > > >
> > > > class BinaryTypeConfiguration {
> > > >     boolean isEnum;                  // Old method
> > > >     *Map<String, Integer> enumValues;* // New method
> > > > }
> > > >
> > > > 2) New enum could be registered through IgniteBinary (e.g. we will
> use
> > it
> > > > if enum is defined in CREATE TABLE statement). Elso it would be
> > possible
> > > to
> > > > build enum using only name.
> > > >
> > > > interface IgniteBinary {
> > > >     BinaryObject buildEnum(String typeName, int ordinal);
> > //
> > > > Old
> > > >     *BinaryObject buildEnum(String typeName, String name); *
> > >  //
> > > > New
> > > >
> > > >     *BinaryType defineEnum(String typeName, Map<String, Integer>
> > vals);*
> > > //
> > > > New
> > > > }
> > > >
> > > > 3) BinaryObject will have new method "enumName":
> > > >
> > > > interface BinaryObject {
> > > >     enumOrdinal();     // Old
> > > >     *String enumName();* // New
> > > > }
> > > >
> > > > 4) It would be possible to get the list of known values from
> > BinaryType:
> > > >
> > > > interface BinaryType {
> > > >     boolean isEnum();                      // Old
> > > >     *Collection<BinaryObject> enumValues();* // New
> > > > }
> > > >
> > > > Thoughts?
> > > >
> > > > Vladimir.
> > > >
> > > > [1] https://github.com/h2database/h2database/pull/487/commits
> > > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message