public class MappedNativeBytes extends AbstractBytes
NativeBytes, accept that the memory address resolution
is left to ChronicleUnsafe, rather than being part of this class.| Modifier and Type | Field and Description |
|---|---|
protected long |
capacity |
protected long |
limit |
protected long |
position |
protected long |
start |
ThreadLocal<ChronicleUnsafe> |
threadLocal |
END_OF_BUFFER, finished, SLEEP_THRESHOLD, UNSIGNED_INT_MASK| Constructor and Description |
|---|
MappedNativeBytes(MappedFile mappedFile,
boolean isSingleThreaded) |
MappedNativeBytes(ObjectSerializer objectSerializer,
long sliceStart,
long capacity,
AtomicInteger refCount,
MappedFile mappedFile,
boolean singleThreaded) |
| Modifier and Type | Method and Description |
|---|---|
long |
address() |
void |
alignPositionAddr(int powerOf2)
Align the position address to a power of 2.
|
ByteOrder |
byteOrder() |
MappedNativeBytes |
bytes()
Create a bytes whose content is the whole bytes store.
|
MappedNativeBytes |
bytes(long offset,
long length)
|
long |
capacity() |
void |
checkEndOfBuffer() |
protected void |
cleanup() |
boolean |
compare(long offset,
RandomDataInput input,
long inputOffset,
long len) |
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.
|
ChronicleUnsafe |
getChronicleUnsafe() |
MappedNativeBytes |
lazyPosition(long position)
Change the position acknowleging there is no thread safety assumptions.
|
long |
limit() |
MappedNativeBytes |
limit(long limit) |
Bytes |
load()
Access every page to ensure those pages are in memory.
|
long |
position() |
MappedNativeBytes |
position(long position) |
long |
positionAddr() |
void |
positionAddr(long positionAddr) |
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() |
MappedNativeBytes |
slice()
Creates a new bytes whose content is a shared subsequence of this bytes'
content.
|
MappedNativeBytes |
slice(long offset,
long length)
Creates a new bytes whose content is a shared subsequence of this bytes'
content.
|
ByteBuffer |
sliceAsByteBuffer(ByteBuffer toReuse)
Returns a
ByteBuffer whose content is a shared subsequence of this bytes' content. |
protected ByteBuffer |
sliceAsByteBuffer(ByteBuffer toReuse,
Object att) |
long |
startAddr() |
CharSequence |
subSequence(int start,
int end) |
void |
write(byte[] bytes,
int off,
int len)
Writes
len bytes from array bytes, in order, to the output stream. |
void |
write(int b)
Writes to the output stream the eight low-order bits of the argument
b. |
void |
write(long offset,
byte[] bytes)
Writes to the output stream all the bytes in array
bytes. |
void |
write(long offset,
byte[] bytes,
int off,
int len) |
void |
write(RandomDataInput bytes,
long position,
long length)
Copy from one Bytes to another, moves the position of "this" RandomDataOutput by the length.
|
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, 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, 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, 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, waitchars, codePoints@NotNull public final ThreadLocal<ChronicleUnsafe> threadLocal
protected long start
protected long position
protected long limit
protected long capacity
public MappedNativeBytes(@NotNull
MappedFile mappedFile,
boolean isSingleThreaded)
public MappedNativeBytes(ObjectSerializer objectSerializer, long sliceStart, long capacity, @NotNull AtomicInteger refCount, @NotNull MappedFile mappedFile, boolean singleThreaded)
public MappedNativeBytes 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()).
BytesCommon.slice(long, long)public MappedNativeBytes 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.
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)
public MappedNativeBytes bytes()
BytesStorebytes(0, size()) call.BytesStore.bytes(long, long)public MappedNativeBytes 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.
offset - offset of the new bytes from the bytes store addresslength - capacity and limit of the new bytesBytesBytesStore.bytes()public long address()
public Bytes zeroOut()
RandomDataOutputpublic Bytes zeroOut(long start, long end)
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)
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 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.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.offset - 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.
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(long offset,
byte[] bytes,
int off,
int len)
public void readFully(@NotNull
char[] data,
int off,
int len)
public 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.public 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.offset - 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.char 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.offset - 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.int 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.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.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.offset - 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.
long 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.
offset - 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.
long 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.
offset - 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.float 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.offset - 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.double 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.offset - to read fromdouble value read.public void write(int b)
RandomDataOutputb. The 24 high-order bits of
b are ignored.b - the byte to be written.public void writeByte(long offset,
int b)
RandomDataOutputb. The 24 high-order bits of
b are ignored.offset - to write byteb - the byte to be written.public void write(long offset,
@NotNull
byte[] bytes)
RandomDataOutputbytes. If bytes is
null, a NullPointerException is thrown. If bytes.length is zero, then no
bytes are written. Otherwise, the byte bytes[0] is written first, then bytes[1], and so
on; the last byte written is bytes[bytes.length-1].write in interface RandomDataOutputwrite in class AbstractBytesoffset - to be writtenbytes - the data.public void write(byte[] bytes,
int off,
int len)
RandomDataOutputlen bytes from array bytes, in order, to the output stream. 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 written. Otherwise, the byte bytes[off] is written first, then
bytes[off+1], and so on; the last byte written is bytes[off+len-1].write in interface DataOutputwrite in interface ObjectOutputwrite in interface RandomDataOutputwrite in class AbstractBytesbytes - the data.off - the start offset in the data.len - the number of bytes to write.public void write(long offset,
byte[] bytes,
int off,
int len)
write in interface RandomDataOutputwrite in class AbstractBytespublic 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.
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.
offset - 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.
v - 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.
offset - 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.
v - 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.
offset - 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.
v - 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.
offset - 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.offset - 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.
v - 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.
offset - 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.
v - 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.
offset - 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.offset - 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.v - 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.offset - 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.v - 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.offset - to write tov - the double value to be written.public void readObject(Object object, int start, int end)
RandomDataInputobject - to read intostart - byte inclusiveend - byte exclusivepublic void writeObject(Object object, int start, int end)
RandomDataOutputobject - to copy fromstart - first byte inclusiveend - last byte exclusive.public boolean compare(long offset,
RandomDataInput input,
long inputOffset,
long len)
compare in interface RandomDataInputcompare in class AbstractBytespublic long position()
public MappedNativeBytes position(long position)
position - to skip topublic MappedNativeBytes lazyPosition(long position)
position - to set if we can.public void write(RandomDataInput bytes, long position, long length)
RandomDataOutputwrite in interface RandomDataOutputwrite in class AbstractBytesbytes - to copyposition - to copy fromlength - to copypublic long capacity()
public long remaining()
public long limit()
public MappedNativeBytes limit(long limit)
limit - the new limit which must be >= capacity()@NotNull public ByteOrder byteOrder()
public void checkEndOfBuffer()
throws IndexOutOfBoundsException
IndexOutOfBoundsException - if the bounds of the Bytes has been exceeded.public long startAddr()
protected void cleanup()
cleanup in class AbstractBytespublic Bytes load()
BytesCommonpublic void alignPositionAddr(int powerOf2)
BytesCommonpowerOf2 - power of 2 to align to.public void positionAddr(long positionAddr)
public long positionAddr()
public ByteBuffer sliceAsByteBuffer(ByteBuffer toReuse)
BytesCommonByteBuffer whose content is a shared subsequence of this bytes' content.
The content of the returned ByteBuffer will start at this bytes' current
position. Changes to this bytes' content will be visible in the returned ByteBuffer,
and vice versa; this bytes' and the returned ByteBuffer's position and limit values
will be independent.
The returned ByteBuffer's position will be zero, its capacity and its limit
will be the number of bytes remaining in this bytes.
If this bytes object is able to reuse to given toReuse ByteBuffer, it will
be reused and returned back from this method, otherwise a new ByteBuffer instance
is created and returned.
sliceAsByteBuffer in interface BytesCommonsliceAsByteBuffer in class AbstractBytestoReuse - a ByteBuffer to reuseByteBuffer view of this BytesBytesCommon.slice(),
ByteBuffer.slice()protected ByteBuffer sliceAsByteBuffer(ByteBuffer toReuse, Object att)
@NotNull public ChronicleUnsafe getChronicleUnsafe()
Copyright © 2019. All rights reserved.