public class ByteBufferBytes extends AbstractBytes implements IByteBufferBytes
END_OF_BUFFER, finished, SLEEP_THRESHOLD, UNSIGNED_INT_MASK| Constructor and Description |
|---|
ByteBufferBytes(ByteBuffer buffer)
Deprecated.
|
ByteBufferBytes(ByteBuffer buffer,
int start,
int capacity)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
long |
address() |
void |
alignPositionAddr(int powerOf2)
Align the position address to a power of 2.
|
ByteBuffer |
buffer()
Obtain the underlying ByteBuffer
|
ByteOrder |
byteOrder() |
ByteBufferBytes |
bytes()
Create a bytes whose content is the whole bytes store.
|
ByteBufferBytes |
bytes(long offset,
long length)
|
long |
capacity() |
void |
checkEndOfBuffer() |
protected void |
cleanup() |
boolean |
compareAndSwapInt(long offset,
int expected,
int x)
Perform a compare and set operation.
|
boolean |
compareAndSwapLong(long offset,
long expected,
long x)
Perform a compare and set operation.
|
long |
limit() |
ByteBufferBytes |
limit(long limit) |
Bytes |
load()
Access every page to ensure those pages are in memory.
|
long |
position() |
ByteBufferBytes |
position(long position) |
int |
read(byte[] bytes,
int off,
int len)
Reads into an array of bytes.
|
byte |
readByte()
Reads and returns one input byte.
|
byte |
readByte(long offset)
Reads and returns one input byte.
|
char |
readChar()
Reads two input bytes and returns a
char value. |
char |
readChar(long offset)
Reads two input bytes and returns a
char value. |
double |
readDouble()
Reads eight input bytes and returns a
double value. |
double |
readDouble(long offset)
Reads eight input bytes and returns a
double value. |
float |
readFloat()
Reads four input bytes and returns a
float value. |
float |
readFloat(long offset)
Reads four input bytes and returns a
float value. |
void |
readFully(byte[] b,
int off,
int len)
Reads
len bytes from an input stream. |
void |
readFully(char[] data,
int off,
int len) |
void |
readFully(long offset,
byte[] bytes,
int off,
int len) |
int |
readInt()
Reads four input bytes and returns an
int value. |
int |
readInt(long offset)
Reads four input bytes and returns an
int value. |
long |
readLong()
Reads eight input bytes and returns a
long value. |
long |
readLong(long offset)
Reads eight input bytes and returns a
long value. |
void |
readObject(Object object,
int start,
int end)
Read the object from start to end bytes
|
short |
readShort()
Reads two input bytes and returns a
short value. |
short |
readShort(long offset)
Reads two input bytes and returns a
short value. |
int |
readVolatileInt()
This is the same as readInt() except a read barrier is performed first.
|
int |
readVolatileInt(long offset)
This is the same as readInt() except a read barrier is performed first.
|
long |
readVolatileLong()
This is the same readLong() except a dread barrier is performed first
|
long |
readVolatileLong(long offset)
This is the same readLong() except a dread barrier is performed first
|
long |
remaining() |
ByteBufferBytes |
slice()
Creates a new bytes whose content is a shared subsequence of this bytes'
content.
|
ByteBufferBytes |
slice(long offset,
long length)
Creates a new bytes whose content is a shared subsequence of this bytes'
content.
|
CharSequence |
subSequence(int start,
int end) |
static IByteBufferBytes |
wrap(ByteBuffer buffer) |
static IByteBufferBytes |
wrap(ByteBuffer buffer,
int start,
int capacity) |
void |
write(int b)
Writes to the output stream the eight low-order bits of the argument
b. |
void |
writeByte(long offset,
int b)
Writes to the output stream the eight low-order bits of the argument
b. |
void |
writeChar(int v)
Writes a
char value, which is comprised of two bytes, to the output stream. |
void |
writeChar(long offset,
int v)
Writes a
char value, which is comprised of two bytes, to the output stream. |
void |
writeDouble(double v)
Writes a
double value, which is comprised of eight bytes, to the output stream. |
void |
writeDouble(long offset,
double v)
Writes a
double value, which is comprised of eight bytes, to the output stream. |
void |
writeFloat(float v)
Writes a
float value, which is comprised of four bytes, to the output stream. |
void |
writeFloat(long offset,
float v)
Writes a
float value, which is comprised of four bytes, to the output stream. |
void |
writeInt(int v)
Writes an
int value, which is comprised of four bytes, to the output stream. |
void |
writeInt(long offset,
int v)
Writes an
int value, which is comprised of four bytes, to the output stream. |
void |
writeLong(long v)
Writes a
long value, which is comprised of eight bytes, to the output stream. |
void |
writeLong(long offset,
long v)
Writes a
long value, which is comprised of eight bytes, to the output stream. |
void |
writeObject(Object object,
int start,
int end)
Copy data from an Object from bytes start to end.
|
void |
writeOrderedInt(int v)
Same as writeInt but include an ordered write barrier.
|
void |
writeOrderedInt(long offset,
int v)
Same as writeInt but include an ordered write barrier.
|
void |
writeOrderedLong(long v)
Same as writeLong but include an ordered write barrier.
|
void |
writeOrderedLong(long offset,
long v)
Same as writeLong but include an ordered write barrier.
|
void |
writeShort(int v)
Writes two bytes to the output stream to represent the value of the argument.
|
void |
writeShort(long offset,
int v)
Writes two bytes to the output stream to represent the value of the argument.
|
Bytes |
zeroOut()
fill the Bytes with zeros, and clear the position.
|
Bytes |
zeroOut(long start,
long end)
fill the Bytes with zeros.
|
Bytes |
zeroOut(long start,
long end,
boolean ifNotZero)
fill the Bytes with zeros, and clear the position, avoiding touching pages unnecessarily
|
addAndGetInt, addAtomicDouble, addAtomicFloat, addAtomicInt, addAtomicLong, addByte, addDouble, addFloat, addInt, addLong, addShort, addUnsignedByte, addUnsignedInt, addUnsignedShort, append, append, append, append, append, append, append, append, append, append, append, append, appendDateMillis, appendDateTimeMillis, appendTimeMillis, asString, asString, available, busyLockInt, busyLockLong, charAt, clear, clearThreadAssociation, close, compare, compareAndSwapDouble, compareRest, file, findUTFLength, findUTFLength, findUTFLength, finish, flip, flush, free, getAndAdd, inputStream, isFinished, length, nextSetBit, objectSerializer, outputStream, parseBoolean, parseDecimal, parseDouble, parseEnum, parseLong, parseLong, parseUtf8, parseUtf8, read, read, read, read, read8bitText, readBoolean, readBoolean, readByteOrThrow, readCompactDouble, readCompactInt, readCompactLong, readCompactShort, readCompactUnsignedInt, readCompactUnsignedShort, readEnum, readEnum, readFully, readFully, readIncompleteLong, readInstance, readInt24, readInt24, readInt48, readInt48, readLine, readList, readMap, readMarshallable, readObject, readObject, readStopBit, readUnsignedByte, readUnsignedByte, readUnsignedByteOrThrow, readUnsignedInt, readUnsignedInt, readUnsignedShort, readUnsignedShort, readUTF, readUTF0, readUTF2, readUTF2, readUTFΔ, readUTFΔ, readUTFΔ, readVolatileDouble, readVolatileFloat, refCount, release, reserve, resetLockInt, resetLockLong, selfTerminating, selfTerminating, setObjectSerializer, size, skip, skipBytes, skipTo, sliceAsByteBuffer, startsWith, stepBackAndSkipTo, threadIdForLockInt, threadIdForLockLong, toDebugString, toDebugString, toHex, toHexString, toHexString, toString, toString, toString, tryLockInt, tryLockLong, tryLockNanosInt, tryLockNanosLong, tryRWReadLock, tryRWWriteLock, unlockInt, unlockLong, unlockRWReadLock, unlockRWWriteLock, write, write, write, write, write, write, write, write, write, write, write, write8bitText, writeBoolean, writeBoolean, writeByte, writeBytes, writeChars, writeChars, writeCompactDouble, writeCompactInt, writeCompactLong, writeCompactShort, writeCompactUnsignedInt, writeCompactUnsignedShort, writeEnum, writeEnum, writeInstance, writeInt24, writeInt24, writeInt48, writeInt48, writeList, writeMap, writeMarshallable, writeObject, writeOrderedDouble, writeOrderedFloat, writeStopBit, writeUnsignedByte, writeUnsignedByte, writeUnsignedInt, writeUnsignedInt, writeUnsignedShort, writeUnsignedShort, writeUTF, writeUTF0, writeUTF1, writeUTFΔ, writeUTFΔclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclearThreadAssociationavailable, close, compare, nextSetBit, read, read, read, read, read8bitText, readBoolean, readBoolean, readCompactDouble, readCompactInt, readCompactLong, readCompactShort, readCompactUnsignedInt, readCompactUnsignedShort, readEnum, readEnum, readFully, readFully, readIncompleteLong, readInstance, readInt24, readInt24, readInt48, readInt48, readLine, readList, readMap, readObject, readObject, readStopBit, readUnsignedByte, readUnsignedByte, readUnsignedInt, readUnsignedInt, readUnsignedShort, readUnsignedShort, readUTF, readUTFΔ, readUTFΔ, readUTFΔ, readVolatileDouble, readVolatileFloat, skip, skipBytes, startsWithaddAndGetInt, close, compareAndSwapDouble, flush, getAndAdd, write, write, write, write, write, write, write, write, write, write, write, write8bitText, writeBoolean, writeBoolean, writeByte, writeBytes, writeChars, writeChars, writeCompactDouble, writeCompactInt, writeCompactLong, writeCompactShort, writeCompactUnsignedInt, writeCompactUnsignedShort, writeEnum, writeEnum, writeInstance, writeInt24, writeInt24, writeInt48, writeInt48, writeList, writeMap, writeObject, writeOrderedDouble, writeOrderedFloat, writeStopBit, writeUnsignedByte, writeUnsignedByte, writeUnsignedInt, writeUnsignedInt, writeUnsignedShort, writeUnsignedShort, writeUTF, writeUTFΔ, writeUTFΔaddAtomicDouble, addAtomicFloat, addAtomicInt, addAtomicLong, addByte, addDouble, addFloat, addInt, addLong, addShort, addUnsignedByte, addUnsignedInt, addUnsignedShort, busyLockInt, busyLockLong, resetLockInt, resetLockLong, threadIdForLockInt, threadIdForLockLong, tryLockInt, tryLockLong, tryLockNanosInt, tryLockNanosLong, tryRWReadLock, tryRWWriteLock, unlockInt, unlockLong, unlockRWReadLock, unlockRWWriteLockfile, free, objectSerializer, sizeappend, append, append, append, append, append, append, append, append, append, append, append, appendDateMillis, appendDateTimeMillis, appendTimeMillisasString, asString, parseBoolean, parseDecimal, parseDouble, parseEnum, parseLong, parseLong, parseUtf8, parseUtf8, readUnsignedByteOrThrow, selfTerminating, selfTerminating, skipTo, stepBackAndSkipToclear, finish, flip, inputStream, isFinished, objectSerializer, outputStream, sliceAsByteBuffer, toDebugString, toDebugString, toHexString, toStringcharAt, chars, codePoints, length, toStringreadMarshallable, writeMarshallablerefCount, release, reserve@Deprecated public ByteBufferBytes(ByteBuffer buffer)
@Deprecated public ByteBufferBytes(ByteBuffer buffer, int start, int capacity)
buffer - the buffer to populatestart - start of buffer
* @param capacity len of bufferpublic static IByteBufferBytes wrap(ByteBuffer buffer)
public static IByteBufferBytes wrap(ByteBuffer buffer, int start, int capacity)
public ByteBufferBytes slice()
BytesCommonThe content of the new bytes will start at this bytes' current position. Changes to this bytes' content will be visible in the new bytes, and vice versa; the two bytes' position and limit values will be independent.
The new bytes' position will be zero, its capacity and its limit will be the number of bytes remaining in this bytes.
slice() is equivalent of slice(0, remaining()).
slice in interface BytesCommonBytesCommon.slice(long, long)public ByteBufferBytes slice(long offset, long length)
BytesCommonThe content of the new bytes will start at this bytes' current
BytesCommon.position()+ offset. Changes to this bytes' content
will be visible in the new bytes, and vice versa; the two bytes'
position and limit values will be independent.
The new bytes' position will be zero, its capacity and its limit
will be equal to length.
offset can be negative (if current bytes' position is positive)
and length can run out of current bytes' limit, the restriction
is that new bytes' should be within this bytes' absolute bounds.
slice in interface BytesCommonoffset - relative offset of the new bytes from the current bytes'
positionlength - capacity of the new bytesBytesCommon.slice()public CharSequence subSequence(int start, int end)
subSequence in interface CharSequencepublic ByteBufferBytes bytes()
BytesStorebytes(0, size()) call.bytes in interface BytesStoreBytesStore.bytes(long, long)public ByteBufferBytes bytes(long offset, long length)
BytesStoreBytes object with start address of
address+ offset and capacity of length.
If this BytesStore is Bytes itself rather than natural
BytesStore object, this method will offset the new bytes from the
bytes' start, not from bytes' position like
BytesCommon.slice(long, long).
offset should be non-negative, length should be positive,
offset + length should be less or equal to size.
bytes in interface BytesStoreoffset - offset of the new bytes from the bytes store addresslength - capacity and limit of the new bytesBytesBytesStore.bytes()public long address()
address in interface BytesStorepublic Bytes zeroOut()
RandomDataOutputzeroOut in interface RandomDataOutputpublic Bytes zeroOut(long start, long end)
RandomDataOutputzeroOut in interface RandomDataOutputstart - first byte to zero outend - the first byte after the last to zero out (exclusive bound)public Bytes zeroOut(long start, long end, boolean ifNotZero)
RandomDataOutputzeroOut in interface RandomDataOutputstart - first byte to zero outend - the first byte after the last to zero out (exclusive bound)ifNotZero - only set to zero after checking the value is not zero.public ByteBuffer buffer()
IByteBufferBytesbuffer in interface IByteBufferBytespublic int read(@NotNull byte[] bytes, int off, int len)
RandomDataInputread in interface ObjectInputread in interface RandomDataInputread in class AbstractBytesbytes - the buffer into which the data is readoff - the start offset of the datalen - the maximum number of bytes readpublic byte readByte()
RandomDataInput-128 through
127, inclusive. This method is suitable for reading the byte written by the writeByte
method of interface DataOutput.readByte in interface DataInputreadByte in interface RandomDataInputpublic byte readByte(long offset)
RandomDataInput-128 through
127, inclusive. This method is suitable for reading the byte written by the writeByte
method of interface RandomDataOutput.readByte in interface RandomDataInputoffset - of byte to read.public void readFully(@NotNull byte[] b, int off, int len)
RandomDataInputReads len bytes from an input stream.
This method blocks until one of the following conditions occurs:
len bytes of input data are available, in which case a normal return is made.EOFException is thrown.IOException other than EOFException is thrown.
If bytes is null, a NullPointerException is thrown. If off is
negative, or len is negative, or off+len is greater than the length of the array
bytes, then an IndexOutOfBoundsException is thrown. If len is zero, then no
bytes are read. Otherwise, the first byte read is stored into element bytes[off], the next one into
bytes[off+1], and so on. The number of bytes read is, at most, equal to len.
readFully in interface DataInputreadFully in interface RandomDataInputb - the buffer into which the data is read.off - an int specifying the offset into the data.len - an int specifying the number of bytes to read.public void readFully(@NotNull char[] data, int off, int len)
readFully in interface RandomDataInputpublic void readFully(long offset,
byte[] bytes,
int off,
int len)
readFully in interface RandomDataInputpublic short readShort()
RandomDataInputshort value. Let a be the first byte read and
b be the second byte on big endian machines, and the opposite on little endian machines. The value
returned is:
(short)((a << 8) | (b & 0xff))
This method is suitable for reading the bytes written by the writeShort method of interface
DataOutput.readShort in interface DataInputreadShort in interface RandomDataInputpublic short readShort(long offset)
RandomDataInputshort value. Let a be the first byte read and
b be the second byte on big endian machines, and the opposite on little endian machines. The value
returned is:
(short)((a << 8) | (b & 0xff))
This method is suitable for reading the bytes written by the writeShort method of interface
RandomDataOutput.readShort in interface RandomDataInputoffset - of short to read.public char readChar()
RandomDataInputchar value. Let a be the first byte read and
b be the second byte on big endian machines, and the opposite on little endian machines. The value
returned is:
(char)((a << 8) | (b & 0xff))
This method is suitable for reading bytes written by the writeChar method of interface
DataOutput.readChar in interface DataInputreadChar in interface RandomDataInputchar value read.public char readChar(long offset)
RandomDataInputchar value. Let a be the first byte read and
b be the second byte on big endian machines, and the opposite on little endian machines. The value
returned is:
(char)((a << 8) | (b & 0xff))
This method is suitable for reading bytes written by the writeChar method of interface
RandomDataOutput.readChar in interface RandomDataInputoffset - of the char to read.char value read.public int readInt()
RandomDataInputint value. Let a-d be the first through fourth
bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
(((a & 0xff) << 24) | ((b & 0xff) << 16) | ((c & 0xff) << 8) | (d & 0xff))
This method is suitable for reading bytes written by the writeInt method of interface
DataOutput.readInt in interface DataInputreadInt in interface RandomDataInputint value read.public int readInt(long offset)
RandomDataInputint value. Let a-d be the first through fourth
bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
(((a & 0xff) << 24) | ((b & 0xff) << 16) | ((c & 0xff) << 8) | (d & 0xff))
This method is suitable for reading bytes written by the writeInt method of interface
RandomDataOutput.readInt in interface RandomDataInputoffset - to read fromint value read.public int readVolatileInt()
RandomDataInput Reads four input bytes and returns
an int value. Let a-d be the first through fourth bytes read on big endian machines,
and the opposite on little endian machines. The value returned is:
(((a & 0xff) << 24) | ((b & 0xff) << 16) | ((c & 0xff) << 8) | (d & 0xff))
This method is suitable for reading bytes written by the writeOrderedInt or
writeVolatileInt method of interface RandomDataOutput.readVolatileInt in interface RandomDataInputint value read.public int readVolatileInt(long offset)
RandomDataInput Reads four input bytes and returns
an int value. Let a-d be the first through fourth bytes read on big endian machines,
and the opposite on little endian machines. The value returned is:
(((a & 0xff) << 24) | ((b & 0xff) << 16) | ((c & 0xff) << 8) | (d & 0xff))
This method is suitable for reading bytes written by the writeOrderedInt or
writeVolatileInt method of interface RandomDataOutput.readVolatileInt in interface RandomDataInputoffset - to read fromint value read.public long readLong()
RandomDataInputlong value. Let a-h be the first through eighth
bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
(((long)(a & 0xff) << 56) |
((long)(b & 0xff) << 48) |
((long)(c & 0xff) << 40) |
((long)(d & 0xff) << 32) |
((long)(e & 0xff) << 24) |
((long)(f & 0xff) << 16) |
((long)(g & 0xff) << 8) |
((long)(h & 0xff)))
This method is suitable for reading bytes written by the writeLong method of interface
DataOutput.
readLong in interface DataInputreadLong in interface RandomDataInputlong value read.public long readLong(long offset)
RandomDataInputlong value. Let a-h be the first through eighth
bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
(((long)(a & 0xff) << 56) |
((long)(b & 0xff) << 48) |
((long)(c & 0xff) << 40) |
((long)(d & 0xff) << 32) |
((long)(e & 0xff) << 24) |
((long)(f & 0xff) << 16) |
((long)(g & 0xff) << 8) |
((long)(h & 0xff)))
This method is suitable for reading bytes written by the writeLong method of interface
RandomDataOutput.
readLong in interface RandomDataInputoffset - of the long to readlong value read.public long readVolatileLong()
RandomDataInputReads eight input bytes and returns a long value. Let a-h be the first through eighth
bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
(((long)(a & 0xff) << 56) |
((long)(b & 0xff) << 48) |
((long)(c & 0xff) << 40) |
((long)(d & 0xff) << 32) |
((long)(e & 0xff) << 24) |
((long)(f & 0xff) << 16) |
((long)(g & 0xff) << 8) |
((long)(h & 0xff)))
This method is suitable for reading bytes written by the writeOrderedLong or
writeVolatileLong method of interface RandomDataOutput.
readVolatileLong in interface RandomDataInputlong value read.public long readVolatileLong(long offset)
RandomDataInputReads eight input bytes and returns a long value. Let a-h be the first through eighth
bytes read on big endian machines, and the opposite on little endian machines. The value returned is:
(((long)(a & 0xff) << 56) |
((long)(b & 0xff) << 48) |
((long)(c & 0xff) << 40) |
((long)(d & 0xff) << 32) |
((long)(e & 0xff) << 24) |
((long)(f & 0xff) << 16) |
((long)(g & 0xff) << 8) |
((long)(h & 0xff)))
This method is suitable for reading bytes written by the writeOrderedLong or
writeVolatileLong method of interface RandomDataOutput.
readVolatileLong in interface RandomDataInputoffset - of the long to readlong value read.public float readFloat()
RandomDataInputfloat value. It does this by first constructing an
int value in exactly the manner of the readInt method, then converting this
int value to a float in exactly the manner of the method
Float.intBitsToFloat. This method is suitable for reading bytes written by the
writeFloat method of interface DataOutput.readFloat in interface DataInputreadFloat in interface RandomDataInputfloat value read.public float readFloat(long offset)
RandomDataInputfloat value. It does this by first constructing an
int value in exactly the manner of the readInt method, then converting this
int value to a float in exactly the manner of the method
Float.intBitsToFloat. This method is suitable for reading bytes written by the
writeFloat method of interface DataOutput.readFloat in interface RandomDataInputoffset - to read fromfloat value read.public double readDouble()
RandomDataInputdouble value. It does this by first constructing a
long value in exactly the manner of the readLong method, then converting this
long value to a double in exactly the manner of the method
Double.longBitsToDouble. This method is suitable for reading bytes written by the
writeDouble method of interface DataOutput.readDouble in interface DataInputreadDouble in interface RandomDataInputdouble value read.public double readDouble(long offset)
RandomDataInputdouble value. It does this by first constructing a
long value in exactly the manner of the readLong method, then converting this
long value to a double in exactly the manner of the method
Double.longBitsToDouble. This method is suitable for reading bytes written by the
writeDouble method of interface DataOutput.readDouble in interface RandomDataInputoffset - to read fromdouble value read.public void write(int b)
RandomDataOutputb. The 24 high-order bits of
b are ignored.write in interface DataOutputwrite in interface ObjectOutputwrite in interface RandomDataOutputb - the byte to be written.public void writeByte(long offset,
int b)
RandomDataOutputb. The 24 high-order bits of
b are ignored.writeByte in interface RandomDataOutputoffset - to write byteb - the byte to be written.public void writeShort(int v)
RandomDataOutput
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readShort method of interface
DataInput , which will then return a short equal to (short)v.
writeShort in interface DataOutputwriteShort in interface RandomDataOutputv - the short value to be written.public void writeShort(long offset,
int v)
RandomDataOutput
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readShort method of interface
DataInput , which will then return a short equal to (short)v.
writeShort in interface RandomDataOutputoffset - to be written tov - the short value to be written.public void writeChar(int v)
RandomDataOutputchar value, which is comprised of two bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readChar method of interface
DataInput , which will then return a char equal to (char)v.
writeChar in interface DataOutputwriteChar in interface RandomDataOutputv - the char value to be written.public void writeChar(long offset,
int v)
RandomDataOutputchar value, which is comprised of two bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readChar method of interface
DataInput , which will then return a char equal to (char)v.
writeChar in interface RandomDataOutputoffset - to be written tov - the char value to be written.public void writeInt(int v)
RandomDataOutputint value, which is comprised of four bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 24))
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readInt method of interface
DataInput , which will then return an int equal to v.
writeInt in interface DataOutputwriteInt in interface RandomDataOutputv - the int value to be written.public void writeInt(long offset,
int v)
RandomDataOutputint value, which is comprised of four bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 24))
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readInt method of interface
DataInput , which will then return an int equal to v.
writeInt in interface RandomDataOutputoffset - to be written tov - the int value to be written.public void writeOrderedInt(int v)
RandomDataOutputThis is much faster than a volatile write which stalls the pipeline. The data is visible to other threads at the same time.
writeOrderedInt in interface RandomDataOutputv - value to writepublic void writeOrderedInt(long offset,
int v)
RandomDataOutputThis is much faster than writeVolatileInt as the volatile write stalls the pipeline. The data is
visible to other threads at the same time.
writeOrderedInt in interface RandomDataOutputoffset - to write tov - value to writepublic boolean compareAndSwapInt(long offset,
int expected,
int x)
RandomDataOutputx provided the expected value
is set already. This operation is atomic.compareAndSwapInt in interface RandomDataOutputoffset - to write to.expected - to expectx - to set if expected was foundpublic void writeLong(long v)
RandomDataOutputlong value, which is comprised of eight bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 56))
(byte)(0xff & (v >> 48))
(byte)(0xff & (v >> 40))
(byte)(0xff & (v >> 32))
(byte)(0xff & (v >> 24))
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readLong method of interface
DataInput , which will then return a long equal to v.
writeLong in interface DataOutputwriteLong in interface RandomDataOutputv - the long value to be written.public void writeLong(long offset,
long v)
RandomDataOutputlong value, which is comprised of eight bytes, to the output stream. The byte values to be
written, in the order shown for big endian machines and the opposite for little endian, are:
(byte)(0xff & (v >> 56))
(byte)(0xff & (v >> 48))
(byte)(0xff & (v >> 40))
(byte)(0xff & (v >> 32))
(byte)(0xff & (v >> 24))
(byte)(0xff & (v >> 16))
(byte)(0xff & (v >> 8))
(byte)(0xff & v)
The bytes written by this method may be read by the readLong method of interface
DataInput , which will then return a long equal to v.
writeLong in interface RandomDataOutputoffset - to be written tov - the long value to be written.public void writeOrderedLong(long v)
RandomDataOutputThis is much faster than a volatile write which stalls the pipeline. The data is visible to other threads at the same time.
writeOrderedLong in interface RandomDataOutputv - value to writepublic void writeOrderedLong(long offset,
long v)
RandomDataOutputThis is much faster than a volatile write which stalls the pipeline. The data is visible to other threads at the same time.
writeOrderedLong in interface RandomDataOutputoffset - to be written tov - value to writepublic boolean compareAndSwapLong(long offset,
long expected,
long x)
RandomDataOutputx provided the expected value
is set already. This operation is atomic.compareAndSwapLong in interface RandomDataOutputoffset - to write to.expected - to expectx - to set if expected was foundpublic void writeFloat(float v)
RandomDataOutputfloat value, which is comprised of four bytes, to the output stream. It does this as if it
first converts this float value to an int in exactly the manner of the
Float.floatToIntBits method and then writes the int value in exactly the manner of the
writeInt method. The bytes written by this method may be read by the readFloat method
of interface DataInput, which will then return a float equal to v.writeFloat in interface DataOutputwriteFloat in interface RandomDataOutputv - the float value to be written.public void writeFloat(long offset,
float v)
RandomDataOutputfloat value, which is comprised of four bytes, to the output stream. It does this as if it
first converts this float value to an int in exactly the manner of the
Float.floatToIntBits method and then writes the int value in exactly the manner of the
writeInt method. The bytes written by this method may be read by the readFloat method
of interface DataInput, which will then return a float equal to v.writeFloat in interface RandomDataOutputoffset - to write tov - the float value to be written.public void writeDouble(double v)
RandomDataOutputdouble value, which is comprised of eight bytes, to the output stream. It does this as if
it first converts this double value to a long in exactly the manner of the
Double.doubleToLongBits method and then writes the long value in exactly the manner of
the writeLong method. The bytes written by this method may be read by the readDouble
method of interface DataInput, which will then return a double equal to
v.writeDouble in interface DataOutputwriteDouble in interface RandomDataOutputv - the double value to be written.public void writeDouble(long offset,
double v)
RandomDataOutputdouble value, which is comprised of eight bytes, to the output stream. It does this as if
it first converts this double value to a long in exactly the manner of the
Double.doubleToLongBits method and then writes the long value in exactly the manner of
the writeLong method. The bytes written by this method may be read by the readDouble
method of interface DataInput, which will then return a double equal to
v.writeDouble in interface RandomDataOutputoffset - to write tov - the double value to be written.public void readObject(Object object, int start, int end)
RandomDataInputreadObject in interface RandomDataInputobject - to read intostart - byte inclusiveend - byte exclusivepublic void writeObject(Object object, int start, int end)
RandomDataOutputwriteObject in interface RandomDataOutputobject - to copy fromstart - first byte inclusiveend - last byte exclusive.public long position()
position in interface BytesCommonpublic ByteBufferBytes position(long position)
position in interface BytesCommonposition - to skip topublic long capacity()
capacity in interface BytesCommonpublic long remaining()
remaining in interface BytesCommonpublic long limit()
limit in interface BytesCommonpublic ByteBufferBytes limit(long limit)
limit in interface BytesCommonlimit - the new limit which must be >= capacity()@NotNull public ByteOrder byteOrder()
byteOrder in interface BytesCommonpublic void checkEndOfBuffer()
throws IndexOutOfBoundsException
checkEndOfBuffer in interface BytesCommonIndexOutOfBoundsException - if the bounds of the Bytes has been exceeded.protected void cleanup()
cleanup in class AbstractBytespublic Bytes load()
BytesCommonload in interface BytesCommonpublic void alignPositionAddr(int powerOf2)
BytesCommonalignPositionAddr in interface BytesCommonpowerOf2 - power of 2 to align to.Copyright © 2019. All rights reserved.