/** * Reverses the effect of {@link #encode(long)}. * * @param u * An encoded long value. * * @return The decode long value. */ public long decode(final long u) { // reverse high word and mask to recover the low-N bits. final int fwd = Integer.reverse(((int) (u >>> 32))) & mask; /* * Left-shift to make room for the (un-)reversed bits and then combine * them back in. */ final int ctr = ((int) (u << N) | fwd); /* * Bring the partition identifier back to an int by shifting it the * same number of bits in the other direction. */ final int pid = ((int) (u >>> (32 - N))); // reconstruct the long counter value. return combine(pid, ctr); }
/** * Reverses the effect of {@link #encode(long)}. * * @param u * An encoded long value. * * @return The decode long value. */ public long decode(final long u) { // reverse high word and mask to recover the low-N bits. final int fwd = Integer.reverse(((int) (u >>> 32))) & mask; /* * Left-shift to make room for the (un-)reversed bits and then combine * them back in. */ final int ctr = ((int) (u << N) | fwd); /* * Bring the partition identifier back to an int by shifting it the * same number of bits in the other direction. */ final int pid = ((int) (u >>> (32 - N))); // reconstruct the long counter value. return combine(pid, ctr); }
final long v0 = TermIdEncoder.combine(pid, ctr);
final long v0 = TermIdEncoder.combine(pid, ctr);
final long v0 = TermIdEncoder.combine(pid, ctr);