You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@storm.apache.org by "zhonghongfei@yy.com" <zh...@yy.com> on 2014/10/22 12:05:27 UTC
Must a inner class be serialized to emit ?
for example:
public Class A implements Serializable {
Class B{
....
}
}
my question is if B should implements Serializable to be transfer to another component ?
Re: Re: Must a inner class be serialized to emit ?
Posted by "zhonghongfei@yy.com" <zh...@yy.com>.
Thank you.
I my class A, it has a reference to B.
When A is emitted to next bolt, I found that when I access B, it's null.
So I think it's neccesory to implement serializable for B.
From: Dan DeCapria, CivicScience
Date: 2014-10-22 22:27
To: user
Subject: Re: Must a inner class be serialized to emit ?
I believe you need to implement Serializable for both classes. For example, I use:
public class A implements Serializable {
public static class B implements Serializable {
public B() {/*default constructor required*/}
@Override
public String toString() { /*stuff*/}
@Override
public boolean equals(Object obj) {/*stuff*/}
@Override
public int hashCode() {/*stuff*/}
}
}
Hope this helps, -Dan
On Wed, Oct 22, 2014 at 7:06 AM, Samit Sasan <sa...@gmail.com> wrote:
My guess is only if Class A holds a reference to an object of Class B, otherwise its fine.
-Samit
On Wed, Oct 22, 2014 at 3:35 PM, zhonghongfei@yy.com <zh...@yy.com> wrote:
for example:
public Class A implements Serializable {
Class B{
....
}
}
my question is if B should implements Serializable to be transfer to another component ?
--
Dan DeCapria
CivicScience, Inc.
Back-End Data IS/BI/DM/ML Specialist
Re: Must a inner class be serialized to emit ?
Posted by "Dan DeCapria, CivicScience" <da...@civicscience.com>.
I believe you need to implement Serializable for both classes. For example,
I use:
public class A implements Serializable {
public static class B implements Serializable {
public B() {/*default constructor required*/}
@Override
public String toString() { /*stuff*/}
@Override
public boolean equals(Object obj) {/*stuff*/}
@Override
public int hashCode() {/*stuff*/}
}
}
Hope this helps, -Dan
On Wed, Oct 22, 2014 at 7:06 AM, Samit Sasan <sa...@gmail.com> wrote:
> My guess is only if Class A holds a reference to an object of Class B,
> otherwise its fine.
>
> -Samit
>
> On Wed, Oct 22, 2014 at 3:35 PM, zhonghongfei@yy.com <zh...@yy.com>
> wrote:
>
>> for example:
>>
>> public Class A implements Serializable {
>> Class B{
>> ....
>> }
>> }
>>
>> my question is if B should implements Serializable to be transfer to
>> another component ?
>>
>
>
--
Dan DeCapria
CivicScience, Inc.
Back-End Data IS/BI/DM/ML Specialist
Re: Must a inner class be serialized to emit ?
Posted by Samit Sasan <sa...@gmail.com>.
My guess is only if Class A holds a reference to an object of Class B,
otherwise its fine.
-Samit
On Wed, Oct 22, 2014 at 3:35 PM, zhonghongfei@yy.com <zh...@yy.com>
wrote:
> for example:
>
> public Class A implements Serializable {
> Class B{
> ....
> }
> }
>
> my question is if B should implements Serializable to be transfer to
> another component ?
>