Skip to content

Commit

Permalink
java docs
Browse files Browse the repository at this point in the history
  • Loading branch information
iverase committed Dec 3, 2024
1 parent dbf807a commit fe89780
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,26 @@ static int decodeInts(RandomAccessInput input, long start, long[] dest) throws I
return dest.length * Integer.BYTES;
}

/**
* Decodes a int value previously written with {@link
* org.apache.lucene.util.NumericUtils#intToSortableBytes}
*
* @see org.apache.lucene.util.NumericUtils#intToSortableBytes(int, byte[], int)
* @see org.apache.lucene.util.NumericUtils#sortableBytesToInt(byte[], int)
*/
static int sortableBytesToInt(RandomAccessInput encoded, long offset) throws IOException {
int i = Integer.reverseBytes(encoded.readInt(offset));
// Re-flip the sign bit to restore the original value:
return i ^ 0x80000000;
}

/**
* Decodes a long value previously written with {@link
* org.apache.lucene.util.NumericUtils#longToSortableBytes}
*
* @see org.apache.lucene.util.NumericUtils#longToSortableBytes(long, byte[], int)
* @see org.apache.lucene.util.NumericUtils#sortableBytesToLong(byte[], int)
*/
static long sortableBytesToLong(RandomAccessInput encoded, long offset) throws IOException {
long l = Long.reverseBytes(encoded.readLong(offset));
// Flip the sign bit back
Expand Down

0 comments on commit fe89780

Please sign in to comment.