Skip to content

Commit

Permalink
Adapt the tests to read/write Bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-lawrey committed Feb 5, 2015
1 parent 0fe82ce commit 562e6df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Expand Up @@ -12,7 +12,7 @@
public interface DirectChronicle extends Chronicle { public interface DirectChronicle extends Chronicle {
void appendDocument(Bytes buffer); void appendDocument(Bytes buffer);


void readDocument(AtomicLong offset, Bytes buffer); boolean readDocument(AtomicLong offset, Bytes buffer);


Bytes bytes(); Bytes bytes();


Expand Down
Expand Up @@ -23,6 +23,8 @@
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;


import static net.openhft.chronicle.wire.BinaryWire.isDocument;

/** /**
* SingleChronicle implements Chronicle over a single streaming file * SingleChronicle implements Chronicle over a single streaming file
* *
Expand Down Expand Up @@ -77,7 +79,7 @@ public void appendDocument(Bytes buffer) {
} }


@Override @Override
public void readDocument(AtomicLong offset, Bytes buffer) { public boolean readDocument(AtomicLong offset, Bytes buffer) {
buffer.clear(); buffer.clear();
long lastByte = offset.get(); long lastByte = offset.get();
for (; ; ) { for (; ; ) {
Expand All @@ -88,7 +90,7 @@ public void readDocument(AtomicLong offset, Bytes buffer) {
buffer.write(bytes, lastByte, length2); buffer.write(bytes, lastByte, length2);
lastByte += length2; lastByte += length2;
offset.set(lastByte); offset.set(lastByte);
return; return isDocument(length);
} }
Jvm.checkInterrupted(); Jvm.checkInterrupted();
} }
Expand Down

0 comments on commit 562e6df

Please sign in to comment.