(CR-6756) Fixed IllegalArgumentException when import triggers index entry limits
IllegalArgumentException was triggered in ImportIDSet.addEntryID() when called with a negative entryID.
The negative entryID was read in IndexInputBuffer.mergeIDSet().
The problem comes from Importer.ScratchFileWriterTask.writeByteStreams() which writes a special value instead of an entryID which means "treat this ImportIDSet has undefined".
First problem, this special value is written as a byte, but read as a long. I fixed the code to write it as a long.
Second problem, the (illogical) code handling this specific case in ImportIDSet.addEntryID() was removed as part of r11948. I fixed this by properly handling this case at a higher level in IndexInputBuffer.mergeIDSet().
I finally applied similar changes to the JE code to explicit what it is doing.
pluggable.ImportIDSet.java:
Changed setUndefined() from private to package private.
Extracted method setUndefinedWithSize().
pluggable.IndexInputBuffer.java:
Added UNDEFINED_SIZE constant.
In mergeIDSet(), handled the undefined size case.
Added toString().
pluggable.Importer.java:
In writeByteStreams(), wrote UNDEFINED_SIZE as a long to the BAOS.
Changed toString() to output the index name.
pluggable.IndexOutputBuffer.java:
Added toString().
Reflected similar changes to JEB. In addition:
jeb.ImportIDSet.java:
In addEntryID(), reject negative entryIDs.
jeb.Importer.java:
In writeByteStreams(), write a packed long (although the encoded representation is the same as packed int, code was conceptually incorrect) + added writePackedLong() method.
jeb.IndexInputBuffer.java:
Extracted readKey().
In mergeIDSet(), handled the undefined size. There is a difference in behaviour: previous the undefined size could be maintained, but now it is no longer maintained: this is correct since there was no count to maintain for an undefined size.