Igniters,
I was creating an example showing how to use BinaryObjects and EntryProcessor for the case when server nodes do not have cache classes definitions and realized that there is no straightforward way to get an instance of BinaryObjectBuilder inside of an EntryProcessor. Currently the only way to do this is to inject an instance of Ignite to the instance of EntryProcessor and get a reference to IgniteBinary from it, which looks a bit too verbose to me: class MyEntryProcessor { @IgniteInstanceResource private Ignite ignite; BinaryObject invoke(...) { BinaryObjectBulder bld = ignite.binary().builder(entry.getValue()); entry.setValue(bld.setField("a", 2).build()); } } I think we can add something like a "BinaryBuilder buildCopy();" method to the BinaryObject interface which will create a new binary builder initialized with the current binary object. Now the above EntryProcessor will look as follows: class MyEntryProcessor { BinaryObject invoke(...) { entry.setValue(entry.getValue().buildCopy().setField("a", 2).build()); } } Thoughts? |
how about "toBuilder()"?
--Yakov 2015-12-11 13:02 GMT+03:00 Alexey Goncharuk <[hidden email]>: > Igniters, > > I was creating an example showing how to use BinaryObjects and > EntryProcessor for the case when server nodes do not have cache classes > definitions and realized that there is no straightforward way to get an > instance of BinaryObjectBuilder inside of an EntryProcessor. > > Currently the only way to do this is to inject an instance of Ignite to the > instance of EntryProcessor and get a reference to IgniteBinary from it, > which looks a bit too verbose to me: > > class MyEntryProcessor { > @IgniteInstanceResource > private Ignite ignite; > > BinaryObject invoke(...) { > BinaryObjectBulder bld = ignite.binary().builder(entry.getValue()); > > entry.setValue(bld.setField("a", 2).build()); > } > } > > I think we can add something like a "BinaryBuilder buildCopy();" method to > the BinaryObject interface which will create a new binary builder > initialized with the current binary object. Now the above EntryProcessor > will look as follows: > > class MyEntryProcessor { > BinaryObject invoke(...) { > entry.setValue(entry.getValue().buildCopy().setField("a", > 2).build()); > } > } > > Thoughts? > |
On Fri, Dec 11, 2015 at 3:44 AM, Yakov Zhdanov <[hidden email]> wrote:
> how about "toBuilder()"? > I like it. Also, does it make sense to pass a copy of the BinaryObject into the EntryProcessor? > > --Yakov > > 2015-12-11 13:02 GMT+03:00 Alexey Goncharuk <[hidden email]>: > > > Igniters, > > > > I was creating an example showing how to use BinaryObjects and > > EntryProcessor for the case when server nodes do not have cache classes > > definitions and realized that there is no straightforward way to get an > > instance of BinaryObjectBuilder inside of an EntryProcessor. > > > > Currently the only way to do this is to inject an instance of Ignite to > the > > instance of EntryProcessor and get a reference to IgniteBinary from it, > > which looks a bit too verbose to me: > > > > class MyEntryProcessor { > > @IgniteInstanceResource > > private Ignite ignite; > > > > BinaryObject invoke(...) { > > BinaryObjectBulder bld = > ignite.binary().builder(entry.getValue()); > > > > entry.setValue(bld.setField("a", 2).build()); > > } > > } > > > > I think we can add something like a "BinaryBuilder buildCopy();" method > to > > the BinaryObject interface which will create a new binary builder > > initialized with the current binary object. Now the above EntryProcessor > > will look as follows: > > > > class MyEntryProcessor { > > BinaryObject invoke(...) { > > entry.setValue(entry.getValue().buildCopy().setField("a", > > 2).build()); > > } > > } > > > > Thoughts? > > > |
>
> I like it. I will add this method if there will be no objections. > Also, does it make sense to pass a copy of the BinaryObject into > the EntryProcessor? I am not sure I understood the question correctly. We never copy BinaryObject since it is immutable. |
On Fri, Dec 11, 2015 at 6:03 AM, Alexey Goncharuk <
[hidden email]> wrote: > > > > I like it. > > > I will add this method if there will be no objections. > Alexey, do you think we should also add “rawBytes()” method to the IgniteObject? > > > > Also, does it make sense to pass a copy of the BinaryObject into > > the EntryProcessor? > > > I am not sure I understood the question correctly. We never copy > BinaryObject since it is immutable. > Got it. |
Free forum by Nabble | Edit this page |