You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Sam C <ja...@gmail.com> on 2019/10/03 06:43:23 UTC
Exception - Method rawReader can be called only once
Hello,
I am facing "org.apache.ignite.binary.BinaryObjectException: Method
"rawReader" can be called only once." when tried to use raw mode.
I have a super class and few extending classes, both are implementing
Binarylizable. In readBinary method of extending class calling
"super.readBinary(binaryReader)" which seems to cause the issue
because binaryReader.rawReader() is called once in extending class and
one more time in super class. To resolve I am having refactoring in
super class by adding public method with BinaryRawReader parameter, Is
there a better way to achieve rawmode for extending class?
Super Class -
public void writeBinary(BinaryWriter binaryWriter) throws
BinaryObjectException {
BinaryRawWriter writer = binaryWriter.rawWriter();
writer.writeLong(id);
...
...
...
}
public void readBinary(BinaryReader binaryReader) throws BinaryObjectException {
BinaryRawReader reader = binaryReader.rawReader();
id=reader.readLong();
...
...
...
}
Extending class -
public void writeBinary(BinaryWriter binaryWriter) throws
BinaryObjectException {
super.writeBinary(binaryWriter);
BinaryRawWriter writer = binaryWriter.rawWriter();
writer.writeLong(subId);
...
...
...
}
public void readBinary(BinaryReader binaryReader) throws BinaryObjectException {
super.readBinary(binaryReader);
BinaryRawReader reader = binaryReader.rawReader();
subId = reader.readLong();
...
...
...
}
I am Using Ignite 2.7
Thanks,
-Sam
Re: Exception - Method rawReader can be called only once
Posted by "javastuff.sam@gmail.com" <ja...@gmail.com>.
Hi Ilya,
Thanks for your reply. I tried to program it around and I do not see
exception anymore, but still need to verify object is built correctly or
not.
For complex or deep class hierarchy this seems a bit of hassle and not
maintainable. Could you please throw some light on why this limitation is
needed? and why it is not enforced for rawWriter?
Thanks,
-Sam
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Exception - Method rawReader can be called only once
Posted by "javastuff.sam@gmail.com" <ja...@gmail.com>.
The interface does not have 2 sets of methods, so second method with "raw"
reader is extra code with special programmatic changes in extending class to
call "raw" method from superclass. This is how I am using it for now,
however it needs extra code and special handling in extended class which
seems like workaround solution to traverse class chain and does not like
conceptually.
I have raised ticket to remove this limitation IGNITE-12280. Hope this gets
through and gets fixed soon.
Thanks,
-Sam
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Exception - Method rawReader can be called only once
Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!
You can have two chains of methods: one which only works with "regular"
reader, and second which works with "raw" reader.
Otherwise, you can file a ticket to Apache Ignite JIRA concerning removal
of this limitation.
Regards,
--
Ilya Kasnacheev
пт, 4 окт. 2019 г. в 22:22, javastuff.sam@gmail.com <javastuff.sam@gmail.com
>:
> Hi Ilya,
>
> Each object is also eligible for separate caching so if class level
> chaining
> is not working/allowed then its too much unnecessary code needs to be
> written and maintained throughout the class chains. Or separate value
> objects need to be created only for caching with Ignite.
> In my experience with other tools, serialization/de-serialization does not
> have limitation for class chaining. I believe restricting class chaining is
> a big limitation.
>
> Thanks,
> -Sam
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
Re: Exception - Method rawReader can be called only once
Posted by "javastuff.sam@gmail.com" <ja...@gmail.com>.
Hi Ilya,
Each object is also eligible for separate caching so if class level chaining
is not working/allowed then its too much unnecessary code needs to be
written and maintained throughout the class chains. Or separate value
objects need to be created only for caching with Ignite.
In my experience with other tools, serialization/de-serialization does not
have limitation for class chaining. I believe restricting class chaining is
a big limitation.
Thanks,
-Sam
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Exception - Method rawReader can be called only once
Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!
It's not recommended to have class hierarchies with raw reading/writing.
If you must, make sure to design your classes carefully so this isn't a
problem.
The limitation is in place because raw reader resets position in stream. I
think it could be removed with some effort, but I don't see why it would be
worth the hassle.
Regards,
--
Ilya Kasnacheev
чт, 3 окт. 2019 г. в 20:59, javastuff.sam@gmail.com <javastuff.sam@gmail.com
>:
> Hi Ilya,
>
> Thanks for your reply. I tried to program it around and I do not see
> exception anymore, but still need to verify object is built correctly or
> not.
>
> For complex or deep class hierarchy this seems a bit of hassle and not
> maintainable. Could you please throw some light on why this limitation is
> needed? and why it is not enforced for rawWriter?
>
> Thanks,
> -Sam
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
Re: Exception - Method rawReader can be called only once
Posted by "javastuff.sam@gmail.com" <ja...@gmail.com>.
Hi Ilya,
Thanks for your reply. I tried to program it around and I do not see
exception anymore, but still need to verify object is built correctly or
not.
For complex or deep class hierarchy this seems a bit of hassle and not
maintainable. Could you please throw some light on why this limitation is
needed? and why it is not enforced for rawWriter?
Thanks,
-Sam
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Exception - Method rawReader can be called only once
Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!
You can't call rawReader() from both superclass and extending class. You
need to program around it.
Regards,
--
Ilya Kasnacheev
чт, 3 окт. 2019 г. в 09:43, Sam C <ja...@gmail.com>:
> Hello,
>
> I am facing "org.apache.ignite.binary.BinaryObjectException: Method
> "rawReader" can be called only once." when tried to use raw mode.
>
> I have a super class and few extending classes, both are implementing
> Binarylizable. In readBinary method of extending class calling
> "super.readBinary(binaryReader)" which seems to cause the issue
> because binaryReader.rawReader() is called once in extending class and
> one more time in super class. To resolve I am having refactoring in
> super class by adding public method with BinaryRawReader parameter, Is
> there a better way to achieve rawmode for extending class?
>
> Super Class -
> public void writeBinary(BinaryWriter binaryWriter) throws
> BinaryObjectException {
> BinaryRawWriter writer = binaryWriter.rawWriter();
> writer.writeLong(id);
> ...
> ...
> ...
> }
>
> public void readBinary(BinaryReader binaryReader) throws
> BinaryObjectException {
> BinaryRawReader reader = binaryReader.rawReader();
> id=reader.readLong();
> ...
> ...
> ...
> }
>
> Extending class -
> public void writeBinary(BinaryWriter binaryWriter) throws
> BinaryObjectException {
> super.writeBinary(binaryWriter);
> BinaryRawWriter writer = binaryWriter.rawWriter();
> writer.writeLong(subId);
> ...
> ...
> ...
> }
>
> public void readBinary(BinaryReader binaryReader) throws
> BinaryObjectException {
> super.readBinary(binaryReader);
> BinaryRawReader reader = binaryReader.rawReader();
> subId = reader.readLong();
> ...
> ...
> ...
> }
>
> I am Using Ignite 2.7
>
> Thanks,
> -Sam
>