You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by sunfishyc <su...@gmail.com> on 2018/01/25 09:23:37 UTC

Confused by two classes

Hi there!
I'm reading NiFi's source code recently, and I got confused by these two classes:
org.apache.nifi.repository.schema.ComplexRecordField and
org.apache.nifi.repository.schema.UnionRecordField

It seems to me that these two classes are almost the same, except that ComplexRecordField has customed hashCode and equals method.
Are they designed to be this similar or it's accidently duplicated? Can they be simplyfied to one?

In addition, I think there should be more javadocs in this project, to improve the readability.

2018-01-25


sunfishyc 

Re: Confused by two classes

Posted by Koji Kawamura <ij...@gmail.com>.
Hello,

ComplexRecordField is used to represent child record which can have
multiple fields in it. I.e. embedded objects.
ComplexRecordField corresponds to Records type in Avro terminology [1].
UnionRecordField represents a field which data type can be one of
defined types. It is often used to represents optional field, e.g.
["null", "string"].
So does UnionRecordField to Unions [2].

RepositoryRecordSchema [3] may be a good example to use Complex and
Union types to represent a top level field that can either
"createOrUpdate", "delete", "swapOut" or "swapIn" child record.

Hope this helps and my understanding is correct. If not Mark Payne
will describe it better :)

For the demand of more javadocs, I totally agree with you. Please feel
free to submit a JIRA for improvements.
https://issues.apache.org/jira/projects/NIFI

[1] http://avro.apache.org/docs/current/spec.html#schema_record
[2] http://avro.apache.org/docs/current/spec.html#Unions
[3] https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-flowfile-repo-serialization/src/main/java/org/apache/nifi/controller/repository/schema/RepositoryRecordSchema.java#L97

Thanks,
Koji

On Thu, Jan 25, 2018 at 6:23 PM, sunfishyc <su...@gmail.com> wrote:
> Hi there!
> I'm reading NiFi's source code recently, and I got confused by these two classes:
> org.apache.nifi.repository.schema.ComplexRecordField and
> org.apache.nifi.repository.schema.UnionRecordField
>
> It seems to me that these two classes are almost the same, except that ComplexRecordField has customed hashCode and equals method.
> Are they designed to be this similar or it's accidently duplicated? Can they be simplyfied to one?
>
> In addition, I think there should be more javadocs in this project, to improve the readability.
>
> 2018-01-25
>
>
> sunfishyc