Class ChunkWriter
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.nd.db.ChunkWriter
Combines sequential small writes into larger writes and that ensures that writes don't happen faster than a certain
maximum rate.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfaceInterface used to perform the uninterruptable writes when the buffer fills up. -
Constructor Summary
ConstructorsConstructorDescriptionChunkWriter(int bufferSize, double maxBytesPerMillisecond, ChunkWriter.WriteCallback callback)Constructs a newChunkWriter -
Method Summary
Modifier and TypeMethodDescriptionbooleanflush()Flushes any outstanding writes to disk immediately.longReturns the total number of bytes writtenlongReturns the total time spent in calls toChunkWriter.WriteCallback.write(ByteBuffer, long).voidsetSleepFunction(ChunkWriter.SleepCallback callback)Overrides the sleep callback function.booleanwrite(long position, byte[] data)Writes the given bytes to the given file position.
-
Constructor Details
-
ChunkWriter
public ChunkWriter(int bufferSize, double maxBytesPerMillisecond, ChunkWriter.WriteCallback callback)Constructs a newChunkWriter- Parameters:
bufferSize- size of the write buffer (the maximum number of bytes that will be written in a single write).maxBytesPerMillisecond- the maximum number of bytes that will be written per second. If an attempt is made to write more rapidly than this, the thread will be put to sleep.callback- will be invoked to perform the writes
-
-
Method Details
-
write
Writes the given bytes to the given file position.- Returns:
- true iff any attempt was made to interrupt the thread using
Thread.interrupt(). The write succeeds regardless of the return value. - Throws:
IOException- if unable to perform the write
-
flush
Flushes any outstanding writes to disk immediately.- Returns:
- true iff any attempt was made to interrupt the thread using
Thread.interrupt(). The write succeeds regardless of the return value. - Throws:
IOException- if unable to perform the write
-
setSleepFunction
Overrides the sleep callback function. -
getBytesWritten
public long getBytesWritten()Returns the total number of bytes written -
getTotalWriteTimeMs
public long getTotalWriteTimeMs()Returns the total time spent in calls toChunkWriter.WriteCallback.write(ByteBuffer, long).
-