Closed iamsanjay closed 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:
public Classname {
). This ensures that all checks are at one place. My recommendation is to override the default ctor. You can add additional ctors for easy usage for common special cases (see IOContext class for examples), calling the default one with this().But here all is trivial, because its all private.
Thanks, will merge soon.
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.