i propose to change it to RowPosition keys[] long offsets[]
this will lower number of java objects used per entry from 2 (KeyPosition + RowPosition) to 1.
For building these arrays convenient ArrayList class can be used and then call to .toArray() on it.