public class PackedInteger
extends java.lang.Object
Most applications should use the classes in the com.sleepycat.bind.tuple
package rather than using this class directly.
Modifier and Type | Field and Description |
---|---|
static int |
MAX_LENGTH
The maximum number of bytes needed to store an int value (5).
|
static int |
MAX_LONG_LENGTH
The maximum number of bytes needed to store a long value (9).
|
Constructor and Description |
---|
PackedInteger() |
Modifier and Type | Method and Description |
---|---|
static int |
getReadIntLength(byte[] buf,
int off)
Returns the number of bytes that would be read by
readInt(byte[], int) . |
static int |
getReadLongLength(byte[] buf,
int off)
Returns the number of bytes that would be read by
readLong(byte[], int) . |
static int |
getReadSortedIntLength(byte[] buf,
int off)
Returns the number of bytes that would be read by
readSortedInt(byte[], int) . |
static int |
getReadSortedLongLength(byte[] buf,
int off)
Returns the number of bytes that would be read by
readSortedLong(byte[], int) . |
static int |
getWriteIntLength(int value)
Returns the number of bytes that would be written by
writeInt(byte[], int, int) . |
static int |
getWriteLongLength(long value)
Returns the number of bytes that would be written by
writeLong(byte[], int, long) . |
static int |
getWriteSortedIntLength(int value)
Returns the number of bytes that would be written by
writeSortedInt(byte[], int, int) . |
static int |
getWriteSortedLongLength(long value)
Returns the number of bytes that would be written by
writeSortedLong(byte[], int, long) . |
static int |
readInt(byte[] buf,
int off)
Reads a packed integer at the given buffer offset and returns it.
|
static long |
readLong(byte[] buf,
int off)
Reads a packed long integer at the given buffer offset and returns it.
|
static int |
readSortedInt(byte[] buf,
int off)
Reads a sorted packed integer at the given buffer offset and returns it.
|
static long |
readSortedLong(byte[] buf,
int off)
Reads a sorted packed long integer at the given buffer offset and
returns it.
|
static int |
writeInt(byte[] buf,
int offset,
int value)
Writes a packed integer starting at the given buffer offset and returns
the next offset to be written.
|
static int |
writeLong(byte[] buf,
int offset,
long value)
Writes a packed long integer starting at the given buffer offset and
returns the next offset to be written.
|
static int |
writeSortedInt(byte[] buf,
int offset,
int value)
Writes a packed sorted integer starting at the given buffer offset and
returns the next offset to be written.
|
static int |
writeSortedLong(byte[] buf,
int offset,
long value)
Writes a packed sorted long integer starting at the given buffer offset
and returns the next offset to be written.
|
public static final int MAX_LENGTH
public static final int MAX_LONG_LENGTH
public static int readInt(byte[] buf, int off)
buf
- the buffer to read from.off
- the offset in the buffer at which to start reading.public static long readLong(byte[] buf, int off)
buf
- the buffer to read from.off
- the offset in the buffer at which to start reading.public static int getReadIntLength(byte[] buf, int off)
readInt(byte[], int)
.
Because the length is stored in the first byte, this method may be called with only the first byte of the packed integer in the given buffer. This method only accesses one byte at the given offset.
buf
- the buffer to read from.off
- the offset in the buffer at which to start reading.public static int getReadLongLength(byte[] buf, int off)
readLong(byte[], int)
.
Because the length is stored in the first byte, this method may be called with only the first byte of the packed integer in the given buffer. This method only accesses one byte at the given offset.
buf
- the buffer to read from.off
- the offset in the buffer at which to start reading.public static int writeInt(byte[] buf, int offset, int value)
buf
- the buffer to write to.offset
- the offset in the buffer at which to start writing.value
- the integer to be written.public static int writeLong(byte[] buf, int offset, long value)
buf
- the buffer to write to.offset
- the offset in the buffer at which to start writing.value
- the long integer to be written.public static int getWriteIntLength(int value)
writeInt(byte[], int, int)
.value
- the integer to be written.public static int getWriteLongLength(long value)
writeLong(byte[], int, long)
.value
- the long integer to be written.public static int readSortedInt(byte[] buf, int off)
buf
- the buffer to read from.off
- the offset in the buffer at which to start reading.public static long readSortedLong(byte[] buf, int off)
buf
- the buffer to read from.off
- the offset in the buffer at which to start reading.public static int getReadSortedIntLength(byte[] buf, int off)
readSortedInt(byte[], int)
.
Because the length is stored in the first byte, this method may be called with only the first byte of the packed integer in the given buffer. This method only accesses one byte at the given offset.
buf
- the buffer to read from.off
- the offset in the buffer at which to start reading.public static int getReadSortedLongLength(byte[] buf, int off)
readSortedLong(byte[], int)
.
Because the length is stored in the first byte, this method may be called with only the first byte of the packed integer in the given buffer. This method only accesses one byte at the given offset.
buf
- the buffer to read from.off
- the offset in the buffer at which to start reading.public static int writeSortedInt(byte[] buf, int offset, int value)
buf
- the buffer to write to.offset
- the offset in the buffer at which to start writing.value
- the integer to be written.public static int writeSortedLong(byte[] buf, int offset, long value)
buf
- the buffer to write to.offset
- the offset in the buffer at which to start writing.value
- the long integer to be written.public static int getWriteSortedIntLength(int value)
writeSortedInt(byte[], int, int)
.value
- the integer to be written.public static int getWriteSortedLongLength(long value)
writeSortedLong(byte[], int, long)
.value
- the long integer to be written.Copyright (c) 2002, 2017 Oracle and/or its affiliates. All rights reserved.