Skip to content

Commit

Permalink
added javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Austin committed Jan 22, 2016
1 parent 0d2a380 commit e3c2881
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/main/java/net/openhft/chronicle/queue/ExcerptTailer.java
Expand Up @@ -51,7 +51,8 @@ public interface ExcerptTailer extends ExcerptCommon {


/**
* @return the index just read
* @return the index just read , this include the cycle and the sequence number from
* with this cycle
*/
long index();

Expand Down
35 changes: 30 additions & 5 deletions src/main/java/net/openhft/chronicle/queue/impl/Excerpts.java
Expand Up @@ -90,21 +90,24 @@ public ChronicleQueue queue() {
}



/**
* Unlike the other appenders the write methods are not able to return the index that he exceprt
* was written to, as the write is deferred using a ring buffer , and later written using a
* background thread
*
* @author Rob Austin.
*/
public static class BufferAppender implements ExcerptAppender {
public static class BufferedAppender implements ExcerptAppender {

private final BytesRingBuffer ringBuffer;
private final StoreAppender underlyingAppender;
private final Wire tempWire;
@NotNull
private final EventLoop eventLoop;

public BufferAppender(@NotNull final EventLoop eventLoop,
@NotNull final StoreAppender underlyingAppender,
final long ringBufferCapacity) {
public BufferedAppender(@NotNull final EventLoop eventLoop,
@NotNull final StoreAppender underlyingAppender,
final long ringBufferCapacity) {
this.eventLoop = eventLoop;
ringBuffer = BytesRingBuffer.newInstance(nativeStoreWithFixedCapacity(
ringBufferCapacity));
Expand Down Expand Up @@ -194,6 +197,13 @@ public BytesRingBuffer ringBuffer() {
return ringBuffer;
}

/**
* for the best performance use net.openhft.chronicle.queue.impl.Excerpts.BufferedAppender#writeBytes(net.openhft.chronicle.bytes.Bytes)
*
* @param writer to write to excerpt.
* @return always returns -1 when using the buffered appender
* @throws IOException
*/
@Override
public long writeDocument(@NotNull WriteMarshallable writer) throws IOException {
final Bytes<?> bytes = tempWire.bytes();
Expand All @@ -202,6 +212,13 @@ public long writeDocument(@NotNull WriteMarshallable writer) throws IOException
return writeBytes(bytes);
}

/**
* for the best performacne use net.openhft.chronicle.queue.impl.Excerpts.BufferedAppender#writeBytes(net.openhft.chronicle.bytes.Bytes)
*
* @param marshallable to write to excerpt.
* @return always returns -1 when using the buffered appender
* @throws IOException
*/
@Override
public long writeBytes(@NotNull WriteBytesMarshallable marshallable) throws IOException {
final Bytes<?> bytes = tempWire.bytes();
Expand All @@ -210,6 +227,14 @@ public long writeBytes(@NotNull WriteBytesMarshallable marshallable) throws IOEx
return writeBytes(bytes);
}

/**
* for the best performance call this method, rather than net.openhft.chronicle.queue.impl.Excerpts.BufferedAppender#writeBytes(net.openhft.chronicle.bytes.WriteBytesMarshallable)
* or net.openhft.chronicle.queue.impl.Excerpts.BufferedAppender#writeDocument(net.openhft.chronicle.wire.WriteMarshallable)
*
* @param bytes to write to excerpt.
* @return always returns -1 when using the buffered appender
* @throws IOException
*/
@Override
public long writeBytes(@NotNull Bytes<?> bytes) throws IOException {
try {
Expand Down
Expand Up @@ -64,7 +64,7 @@ boolean read(@NotNull Bytes using) throws
long maxCopyTimeSinceLastCall();


static BytesRingBuffer newInstance(NativeBytesStore<Void> bytesStore) {
static BytesRingBuffer newInstance(@NotNull NativeBytesStore<Void> bytesStore) {
try {
final Class<BytesRingBuffer> aClass = clazz();
final Constructor<BytesRingBuffer> constructor = aClass.getDeclaredConstructor(BytesStore.class);
Expand Down
Expand Up @@ -80,7 +80,7 @@ public ExcerptAppender createAppender() throws IOException {
if (bufferedAppends) {
long ringBufferCapacity = BytesRingBuffer.sizeFor(builder
.bufferCapacity());
return new Excerpts.BufferAppender(eventloop, storeAppender, ringBufferCapacity);
return new Excerpts.BufferedAppender(eventloop, storeAppender, ringBufferCapacity);
} else
return storeAppender;
}
Expand Down

0 comments on commit e3c2881

Please sign in to comment.