Package elki.datasource.bundle
Class BundleWriter
- java.lang.Object
-
- elki.datasource.bundle.BundleWriter
-
public class BundleWriter extends java.lang.ObjectWrite an object bundle stream to a file channel. Bundle streams that add new columns are not supported.- Since:
- 0.5.5
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description private static intINITIAL_BUFFERInitial buffer size.private static LoggingLOGClass logger for the bundle writer.static intMAGICRandom magic number.
-
Constructor Summary
Constructors Constructor Description BundleWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.nio.ByteBufferensureBuffer(int size, java.nio.ByteBuffer buffer, java.nio.channels.WritableByteChannel output)Ensure the buffer is large enough.private voidflushBuffer(java.nio.ByteBuffer buffer, java.nio.channels.WritableByteChannel output)Flush the current write buffer to disk.voidwriteBundleStream(BundleStreamSource source, java.nio.channels.WritableByteChannel output)Write a bundle stream to a file output channel.private ByteBufferSerializer<?>[]writeHeader(BundleStreamSource source, java.nio.ByteBuffer buffer, java.nio.channels.WritableByteChannel output)Write the header for the given stream to the stream.
-
-
-
Field Detail
-
LOG
private static final Logging LOG
Class logger for the bundle writer.
-
INITIAL_BUFFER
private static final int INITIAL_BUFFER
Initial buffer size.- See Also:
- Constant Field Values
-
MAGIC
public static final int MAGIC
Random magic number.- See Also:
- Constant Field Values
-
-
Method Detail
-
writeBundleStream
public void writeBundleStream(BundleStreamSource source, java.nio.channels.WritableByteChannel output) throws java.io.IOException
Write a bundle stream to a file output channel.- Parameters:
source- Data sourceoutput- Output channel- Throws:
java.io.IOException- on IO errors
-
flushBuffer
private void flushBuffer(java.nio.ByteBuffer buffer, java.nio.channels.WritableByteChannel output) throws java.io.IOExceptionFlush the current write buffer to disk.- Parameters:
buffer- Buffer to writeoutput- Output channel- Throws:
java.io.IOException- on IO errors
-
ensureBuffer
private java.nio.ByteBuffer ensureBuffer(int size, java.nio.ByteBuffer buffer, java.nio.channels.WritableByteChannel output) throws java.io.IOExceptionEnsure the buffer is large enough.- Parameters:
size- Required size to addbuffer- Existing bufferoutput- Output channel- Returns:
- Buffer, eventually resized
- Throws:
java.io.IOException- on IO errors
-
writeHeader
private ByteBufferSerializer<?>[] writeHeader(BundleStreamSource source, java.nio.ByteBuffer buffer, java.nio.channels.WritableByteChannel output) throws java.io.IOException
Write the header for the given stream to the stream.- Parameters:
source- Bundle streambuffer- Buffer to use for writingoutput- Output channel- Returns:
- Array of serializers
- Throws:
java.io.IOException- on IO errors
-
-