> These methods should only be able to call the read/write methods (which this
> issue moves to DataInput/Output), but not methods like close(), seek() etc..
Ah, so that's what it is.
In that case, let me vote my (non-binding) -1. I don't believe that the
enforcement of such a restriction justifies the complexity cost of adding a
new class to the public API.
First, adding yet another class to the hierarchy steepens the learning curve
for users and contributors. If you aren't in the rarefied echelon of
exceptional brilliance occupied by people named Michael who work for IBM ,
the gradual accumulation of complexity in the Lucene code base matters. Inch
by inch, things move out of reach.
Second, changing things now for what seems to me like a minor reason makes it
harder to refactor the class hierarchy in the future when other, more
important reasons are inevitably discovered.
For LUCENE-2125, I recommend two possible options.
- Do nothing and assume that the sort of advanced user who writes a posting
codec won't do something incredibly stupid like call indexInput.close().
- Add a note to the docs for writing posting codecs indicating which sort of
of IO methods you ought not to call.
> once we see a need to allow users to extend DataInput/Output outside of
> Lucene we can go ahead and make the additional changes that are mentioned in
> your in my comments here.
In Lucy, there are three tiers of IO usage:
- For low-level IO, use FileHandle.
- For most applications, use InStream's encoder/decoder methods.
- For performance-critical inner-loop material (e.g. posting decoders,
SortCollector), access the raw memory-mapped IO buffer using
InStream_Buf()/InStream_Advance_Buf() and use static inline functions
such as NumUtil_decode_c32 (which does no bounds checking) from
While you can extend InStream to add a codec, that's not generally the best
way to go about it, because adding a method to InStream requires that all of
your users both use your InStream class and use a subclassed Folder which
overrides the Folder_Open_In() factory method (analogous to
Directory.openInput()). Better is to use the extension point provided by
InStream_Buf()/InStream_Advance_Buf() and write a utility function which
accepts an InStream as an argument.
I don't expect and am not advocating that Lucene adopt the same IO hierarchy
as Lucy, but I wanted to provide an example of other reasons why you might
change things. (What I'd really like to see is for Lucene to come up with
something better than the Lucy IO hierarchy.)
One of the reasons Lucene has so many backwards compatibility headaches is
because the public APIs are so extensive and thus constitute such an elaborate
set of backwards compatibility promises. IMO, DataInput and DataOutput do
not offer sufficient benefit to compensate for the increased intricacy they add
to that backwards compatibility contract.