/** * Test how much bytes we need to store long. */ @Test public void testLongFitsIn() { assertEquals(1, ByteBufferUtils.longFitsIn(0)); assertEquals(1, ByteBufferUtils.longFitsIn(1)); assertEquals(3, ByteBufferUtils.longFitsIn(1L << 16)); assertEquals(5, ByteBufferUtils.longFitsIn(1L << 32)); assertEquals(8, ByteBufferUtils.longFitsIn(-1)); assertEquals(8, ByteBufferUtils.longFitsIn(Long.MIN_VALUE)); assertEquals(8, ByteBufferUtils.longFitsIn(Long.MAX_VALUE)); }
timestamp = -timestamp; timestampFitsInBytes = ByteBufferUtils.longFitsIn(timestamp); flag |= (timestampFitsInBytes - 1) << SHIFT_TIMESTAMP_LENGTH; timestamp = -timestamp; timestampFitsInBytes = ByteBufferUtils.longFitsIn(timestamp); boolean minusDiffTimestamp = diffTimestamp < 0; if (minusDiffTimestamp) { diffTimestamp = -diffTimestamp; diffTimestampFitsInBytes = ByteBufferUtils.longFitsIn(diffTimestamp); if (diffTimestampFitsInBytes < timestampFitsInBytes) { flag |= (diffTimestampFitsInBytes - 1) << SHIFT_TIMESTAMP_LENGTH;
/** * Test how much bytes we need to store long. */ @Test public void testLongFitsIn() { assertEquals(1, ByteBufferUtils.longFitsIn(0)); assertEquals(1, ByteBufferUtils.longFitsIn(1)); assertEquals(3, ByteBufferUtils.longFitsIn(1L << 16)); assertEquals(5, ByteBufferUtils.longFitsIn(1L << 32)); assertEquals(8, ByteBufferUtils.longFitsIn(-1)); assertEquals(8, ByteBufferUtils.longFitsIn(Long.MIN_VALUE)); assertEquals(8, ByteBufferUtils.longFitsIn(Long.MAX_VALUE)); }
/** * Test how much bytes we need to store long. */ @Test public void testLongFitsIn() { assertEquals(1, ByteBufferUtils.longFitsIn(0)); assertEquals(1, ByteBufferUtils.longFitsIn(1)); assertEquals(3, ByteBufferUtils.longFitsIn(1L << 16)); assertEquals(5, ByteBufferUtils.longFitsIn(1L << 32)); assertEquals(8, ByteBufferUtils.longFitsIn(-1)); assertEquals(8, ByteBufferUtils.longFitsIn(Long.MIN_VALUE)); assertEquals(8, ByteBufferUtils.longFitsIn(Long.MAX_VALUE)); }
timestamp = -timestamp; timestampFitsInBytes = ByteBufferUtils.longFitsIn(timestamp); timestamp = -timestamp; timestampFitsInBytes = ByteBufferUtils.longFitsIn(timestamp); diffTimestamp = -diffTimestamp; diffTimestampFitsInBytes = ByteBufferUtils.longFitsIn(diffTimestamp); if (diffTimestampFitsInBytes < timestampFitsInBytes) { flag |= (diffTimestampFitsInBytes - 1) << SHIFT_TIMESTAMP_LENGTH;
timestamp = -timestamp; timestampFitsInBytes = ByteBufferUtils.longFitsIn(timestamp); flag |= (timestampFitsInBytes - 1) << SHIFT_TIMESTAMP_LENGTH; timestamp = -timestamp; timestampFitsInBytes = ByteBufferUtils.longFitsIn(timestamp); boolean minusDiffTimestamp = diffTimestamp < 0; if (minusDiffTimestamp) { diffTimestamp = -diffTimestamp; diffTimestampFitsInBytes = ByteBufferUtils.longFitsIn(diffTimestamp); if (diffTimestampFitsInBytes < timestampFitsInBytes) { flag |= (diffTimestampFitsInBytes - 1) << SHIFT_TIMESTAMP_LENGTH;
timestamp = -timestamp; timestampFitsInBytes = ByteBufferUtils.longFitsIn(timestamp); flag |= (timestampFitsInBytes - 1) << SHIFT_TIMESTAMP_LENGTH; timestamp = -timestamp; timestampFitsInBytes = ByteBufferUtils.longFitsIn(timestamp); boolean minusDiffTimestamp = diffTimestamp < 0; if (minusDiffTimestamp) { diffTimestamp = -diffTimestamp; diffTimestampFitsInBytes = ByteBufferUtils.longFitsIn(diffTimestamp); if (diffTimestampFitsInBytes < timestampFitsInBytes) { flag |= (diffTimestampFitsInBytes - 1) << SHIFT_TIMESTAMP_LENGTH;
timestamp = -timestamp; timestampFitsInBytes = ByteBufferUtils.longFitsIn(timestamp); flag |= (timestampFitsInBytes - 1) << SHIFT_TIMESTAMP_LENGTH; timestamp = -timestamp; timestampFitsInBytes = ByteBufferUtils.longFitsIn(timestamp); boolean minusDiffTimestamp = diffTimestamp < 0; if (minusDiffTimestamp) { diffTimestamp = -diffTimestamp; diffTimestampFitsInBytes = ByteBufferUtils.longFitsIn(diffTimestamp); if (diffTimestampFitsInBytes < timestampFitsInBytes) { flag |= (diffTimestampFitsInBytes - 1) << SHIFT_TIMESTAMP_LENGTH;