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, wait
clearThreadAssociation
available, 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, startsWith
addAndGetInt, 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, unlockRWWriteLock
file, free, objectSerializer, size
append, append, append, append, append, append, append, append, append, append, append, append, appendDateMillis, appendDateTimeMillis, appendTimeMillis
asString, asString, parseBoolean, parseDecimal, parseDouble, parseEnum, parseLong, parseLong, parseUtf8, parseUtf8, readUnsignedByteOrThrow, selfTerminating, selfTerminating, skipTo, stepBackAndSkipTo
clear, finish, flip, inputStream, isFinished, objectSerializer, outputStream, sliceAsByteBuffer, toDebugString, toDebugString, toHexString, toString
charAt, chars, codePoints, length, toString
readMarshallable, writeMarshallable
refCount, 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()
BytesCommon
The 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 BytesCommon
BytesCommon.slice(long, long)
public ByteBufferBytes slice(long offset, long length)
BytesCommon
The 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 BytesCommon
offset
- 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 CharSequence
public ByteBufferBytes bytes()
BytesStore
bytes(0, size())
call.bytes
in interface BytesStore
BytesStore.bytes(long, long)
public ByteBufferBytes bytes(long offset, long length)
BytesStore
Bytes
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 BytesStore
offset
- offset of the new bytes from the bytes store addresslength
- capacity and limit of the new bytesBytes
BytesStore.bytes()
public long address()
address
in interface BytesStore
public Bytes zeroOut()
RandomDataOutput
zeroOut
in interface RandomDataOutput
public Bytes zeroOut(long start, long end)
RandomDataOutput
zeroOut
in interface RandomDataOutput
start
- 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)
RandomDataOutput
zeroOut
in interface RandomDataOutput
start
- 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()
IByteBufferBytes
buffer
in interface IByteBufferBytes
public int read(@NotNull byte[] bytes, int off, int len)
RandomDataInput
read
in interface ObjectInput
read
in interface RandomDataInput
read
in class AbstractBytes
bytes
- 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 DataInput
readByte
in interface RandomDataInput
public 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 RandomDataInput
offset
- of byte to read.public void readFully(@NotNull byte[] b, int off, int len)
RandomDataInput
Reads 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 DataInput
readFully
in interface RandomDataInput
b
- 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 RandomDataInput
public void readFully(long offset, byte[] bytes, int off, int len)
readFully
in interface RandomDataInput
public short readShort()
RandomDataInput
short
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 DataInput
readShort
in interface RandomDataInput
public short readShort(long offset)
RandomDataInput
short
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 RandomDataInput
offset
- of short to read.public char readChar()
RandomDataInput
char
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 DataInput
readChar
in interface RandomDataInput
char
value read.public char readChar(long offset)
RandomDataInput
char
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 RandomDataInput
offset
- of the char to read.char
value read.public int readInt()
RandomDataInput
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 writeInt
method of interface
DataOutput
.readInt
in interface DataInput
readInt
in interface RandomDataInput
int
value read.public int readInt(long offset)
RandomDataInput
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 writeInt
method of interface
RandomDataOutput
.readInt
in interface RandomDataInput
offset
- 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 RandomDataInput
int
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 RandomDataInput
offset
- to read fromint
value read.public long readLong()
RandomDataInput
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 writeLong
method of interface
DataOutput
.
readLong
in interface DataInput
readLong
in interface RandomDataInput
long
value read.public long readLong(long offset)
RandomDataInput
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 writeLong
method of interface
RandomDataOutput
.
readLong
in interface RandomDataInput
offset
- of the long to readlong
value read.public long readVolatileLong()
RandomDataInput
Reads 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 RandomDataInput
long
value read.public long readVolatileLong(long offset)
RandomDataInput
Reads 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 RandomDataInput
offset
- of the long to readlong
value read.public float readFloat()
RandomDataInput
float
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 DataInput
readFloat
in interface RandomDataInput
float
value read.public float readFloat(long offset)
RandomDataInput
float
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 RandomDataInput
offset
- to read fromfloat
value read.public double readDouble()
RandomDataInput
double
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 DataInput
readDouble
in interface RandomDataInput
double
value read.public double readDouble(long offset)
RandomDataInput
double
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 RandomDataInput
offset
- to read fromdouble
value read.public void write(int b)
RandomDataOutput
b
. The 24 high-order bits of
b
are ignored.write
in interface DataOutput
write
in interface ObjectOutput
write
in interface RandomDataOutput
b
- the byte to be written.public void writeByte(long offset, int b)
RandomDataOutput
b
. The 24 high-order bits of
b
are ignored.writeByte
in interface RandomDataOutput
offset
- 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 DataOutput
writeShort
in interface RandomDataOutput
v
- 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 RandomDataOutput
offset
- to be written tov
- the short
value to be written.public void writeChar(int v)
RandomDataOutput
char
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 DataOutput
writeChar
in interface RandomDataOutput
v
- the char
value to be written.public void writeChar(long offset, int v)
RandomDataOutput
char
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 RandomDataOutput
offset
- to be written tov
- the char
value to be written.public void writeInt(int v)
RandomDataOutput
int
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 DataOutput
writeInt
in interface RandomDataOutput
v
- the int
value to be written.public void writeInt(long offset, int v)
RandomDataOutput
int
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 RandomDataOutput
offset
- to be written tov
- the int
value to be written.public void writeOrderedInt(int v)
RandomDataOutput
This 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 RandomDataOutput
v
- value to writepublic void writeOrderedInt(long offset, int v)
RandomDataOutput
This 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 RandomDataOutput
offset
- to write tov
- value to writepublic boolean compareAndSwapInt(long offset, int expected, int x)
RandomDataOutput
x
provided the expected
value
is set already. This operation is atomic.compareAndSwapInt
in interface RandomDataOutput
offset
- to write to.expected
- to expectx
- to set if expected was foundpublic void writeLong(long v)
RandomDataOutput
long
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 DataOutput
writeLong
in interface RandomDataOutput
v
- the long
value to be written.public void writeLong(long offset, long v)
RandomDataOutput
long
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 RandomDataOutput
offset
- to be written tov
- the long
value to be written.public void writeOrderedLong(long v)
RandomDataOutput
This 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 RandomDataOutput
v
- value to writepublic void writeOrderedLong(long offset, long v)
RandomDataOutput
This 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 RandomDataOutput
offset
- to be written tov
- value to writepublic boolean compareAndSwapLong(long offset, long expected, long x)
RandomDataOutput
x
provided the expected
value
is set already. This operation is atomic.compareAndSwapLong
in interface RandomDataOutput
offset
- to write to.expected
- to expectx
- to set if expected was foundpublic void writeFloat(float v)
RandomDataOutput
float
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 DataOutput
writeFloat
in interface RandomDataOutput
v
- the float
value to be written.public void writeFloat(long offset, float v)
RandomDataOutput
float
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 RandomDataOutput
offset
- to write tov
- the float
value to be written.public void writeDouble(double v)
RandomDataOutput
double
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 DataOutput
writeDouble
in interface RandomDataOutput
v
- the double
value to be written.public void writeDouble(long offset, double v)
RandomDataOutput
double
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 RandomDataOutput
offset
- to write tov
- the double
value to be written.public void readObject(Object object, int start, int end)
RandomDataInput
readObject
in interface RandomDataInput
object
- to read intostart
- byte inclusiveend
- byte exclusivepublic void writeObject(Object object, int start, int end)
RandomDataOutput
writeObject
in interface RandomDataOutput
object
- to copy fromstart
- first byte inclusiveend
- last byte exclusive.public long position()
position
in interface BytesCommon
public ByteBufferBytes position(long position)
position
in interface BytesCommon
position
- to skip topublic long capacity()
capacity
in interface BytesCommon
public long remaining()
remaining
in interface BytesCommon
public long limit()
limit
in interface BytesCommon
public ByteBufferBytes limit(long limit)
limit
in interface BytesCommon
limit
- the new limit which must be >= capacity()@NotNull public ByteOrder byteOrder()
byteOrder
in interface BytesCommon
public void checkEndOfBuffer() throws IndexOutOfBoundsException
checkEndOfBuffer
in interface BytesCommon
IndexOutOfBoundsException
- if the bounds of the Bytes has been exceeded.protected void cleanup()
cleanup
in class AbstractBytes
public Bytes load()
BytesCommon
load
in interface BytesCommon
public void alignPositionAddr(int powerOf2)
BytesCommon
alignPositionAddr
in interface BytesCommon
powerOf2
- power of 2 to align to.Copyright © 2019. All rights reserved.