You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by zbyszek <zb...@yahoo.com> on 2018/01/15 15:08:21 UTC

Create BinaryObject without starting Ignite?

Hello Igniters,

Is it possible to create BinaryObject without starting Ignite?

I was trying the following:

    private static BinaryObject createPrototype() throws
IgniteCheckedException {
        // based on
http://apache-ignite-users.70518.x6.nabble.com/Working-Directly-with-Binary-objects-td5131.html
        IgniteConfiguration iCfg = new IgniteConfiguration();
        BinaryConfiguration bCfg = new BinaryConfiguration();
        iCfg.setBinaryConfiguration(bCfg);
        BinaryContext ctx = new
BinaryContext(BinaryCachingMetadataHandler.create(), iCfg, new
NullLogger());
        BinaryMarshaller marsh = new BinaryMarshaller();
        marsh.setContext(new MarshallerContextImpl(null));
        IgniteUtils.invoke(BinaryMarshaller.class, marsh,
"setBinaryContext", ctx, iCfg);
        BinaryObjectBuilder builder = new BinaryObjectBuilderImpl(ctx,
"MyBinaryName");
        builder.setField("f1", (String) null);
        builder.setField("f2", (String) null);
        builder.setField("f3", (String) null);
        BinaryObject res = builder.build(); //  ---> throws NPE here
        return res;
    }

but this throws NPE on builder.build() due to null transport member in
MarshallerContextImpl.

Thank you for your help,
zbyszek



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Create BinaryObject without starting Ignite?

Posted by zbyszek <zb...@yahoo.com>.
Hi Val,

thank you for confirmation.

>> What is the purpose of this?
Purpose of that was to prepare object prototype (object with the same
structure layout to ensure the same schema version for all updates) without
having access to Ignite.
But as it turned out I managed to obtain the reference to Ignite hence my
particular problem is solved.

But it is good to know that it is not easily achievable.

thanx and regards,
zbyszek



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Create BinaryObject without starting Ignite?

Posted by vkulichenko <va...@gmail.com>.
zbyszek,

Generally, the answer is no. Binary format depends on internal Ignite
context, so there is no clean way to create a binary object without starting
Ignite. The code that was provided in the referenced thread is a hacky
workaround which could probably worked in one of the previous versions, but
there is a big chance it doesn't work anymore in the latest.

What is the purpose of this?

-Val



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/