apache / lucene

Apache Lucene open-source search software
https://lucene.apache.org/
Apache License 2.0
2.45k stars 975 forks source link

Convert FieldEntry to record #13296

Closed iamsanjay closed 2 months ago

iamsanjay commented 2 months ago

Task from #13207

Avoid the usage of compact constructors because the compact constructor can only access the components of record, and most of FieldEntry relies on IndexInput object which is not a part of record class. Hence, The purposed code is using the static factory method to create the FieldEntry.

However, there is another way where we can make IndexInput a component of the record class and then access it in compact constructor. While it moves the code inside compact constructor, but the code accessing IndexInput has to be surrounded with try-catch as compact constructors cannot throw checked exception.

uschindler commented 2 months ago

The change looks good to me, I'd like @uschindler to have a look since he knows more about records than I do.

They are not too complicated, you just have to think simpler and use the special syntax. Something to keep in mind when you add records:

But here all is trivial, because its all private.

uschindler commented 2 months ago

Thanks, will merge soon.