Package org.rrd4j.core
Class ByteBufferBackend
java.lang.Object
org.rrd4j.core.RrdBackend
org.rrd4j.core.ByteBufferBackend
- Direct Known Subclasses:
RrdByteArrayBackend,RrdMemoryBackend,RrdNioBackend
public abstract class ByteBufferBackend extends RrdBackend
A backend that store and provides access to data using a
ByteBuffer, using java internal methods for
long, integer and others types.- Since:
- 3.4
- Author:
- Fabrice Bacchella
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protectedByteBufferBackend(String path) -
Method Summary
Modifier and Type Method Description protected voidclose()Closes the underlying backend.protected CharBuffergetCharBuffer(long offset, int size)Extract a CharBuffer from the backend, used by readStringprotected booleanisDirty()protected voidread(long offset, byte[] b)Reads a number of bytes from the RRD file on the diskdoublereadDouble(long offset)double[]readDouble(long offset, int count)protected intreadInt(long offset)protected longreadLong(long offset)protected shortreadShort(long offset)protected voidrrdClose()Closes the underlying backend.protected voidsetByteBuffer(ByteBuffer byteBuffer)protected voidwrite(long offset, byte[] b)Writes bytes to the underlying RRD file on the diskprotected voidwriteDouble(long offset, double value)protected voidwriteDouble(long offset, double[] values)protected voidwriteDouble(long offset, double value, int count)protected voidwriteInt(long offset, int value)protected voidwriteLong(long offset, long value)protected voidwriteShort(long offset, short value)protected voidwriteString(long offset, String value, int length)Methods inherited from class org.rrd4j.core.RrdBackend
done, getFactory, getLength, getPath, getUri, isCachingAllowed, isInstanceCreated, readAll, readString, setLength, writeString
-
Constructor Details
-
Method Details
-
setByteBuffer
-
write
Writes bytes to the underlying RRD file on the disk- Specified by:
writein classRrdBackend- Parameters:
offset- Starting file offsetb- Bytes to be written.- Throws:
IOException- if any.IllegalArgumentException- if offset is bigger that the possible mapping position (2GiB).
-
writeShort
- Overrides:
writeShortin classRrdBackend- Throws:
IOException
-
writeInt
- Overrides:
writeIntin classRrdBackend- Throws:
IOException
-
writeLong
- Overrides:
writeLongin classRrdBackend- Throws:
IOException
-
writeDouble
- Overrides:
writeDoublein classRrdBackend- Throws:
IOException
-
writeDouble
- Overrides:
writeDoublein classRrdBackend- Throws:
IOException
-
writeDouble
- Overrides:
writeDoublein classRrdBackend- Throws:
IOException
-
writeString
- Overrides:
writeStringin classRrdBackend- Throws:
IOException
-
read
Reads a number of bytes from the RRD file on the disk- Specified by:
readin classRrdBackend- Parameters:
offset- Starting file offsetb- Buffer which receives bytes read from the file.- Throws:
IOException- Thrown in case of I/O error.IllegalArgumentException- if offset is bigger that the possible mapping position (2GiB).
-
readShort
- Overrides:
readShortin classRrdBackend- Throws:
IOException
-
readInt
- Overrides:
readIntin classRrdBackend- Throws:
IOException
-
readLong
- Overrides:
readLongin classRrdBackend- Throws:
IOException
-
readDouble
- Overrides:
readDoublein classRrdBackend- Throws:
IOException
-
readDouble
- Overrides:
readDoublein classRrdBackend- Throws:
IOException
-
getCharBuffer
Description copied from class:RrdBackendExtract a CharBuffer from the backend, used by readString- Overrides:
getCharBufferin classRrdBackend- Parameters:
offset- the offset in the rrdsize- the size of the buffer, in character- Returns:
- a new CharBuffer
- Throws:
RrdException
-
close
Description copied from class:RrdBackendCloses the underlying backend. Used internally, should not be called from external code.- Specified by:
closein classRrdBackend- Throws:
IOException- Thrown in case of I/O error
-
isDirty
protected boolean isDirty() -
rrdClose
Description copied from class:RrdBackendCloses the underlying backend. Call byRrdDb#close()when it's closed. All subclass must keep calling it.- Overrides:
rrdClosein classRrdBackend- Throws:
IOException- Thrown in case of I/O error
-