Skip to content

Commit

Permalink
changed subIndex to sequenceNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Austin committed Jan 22, 2016
1 parent 77b6736 commit 93cfbd7
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 264 deletions.
Expand Up @@ -22,7 +22,6 @@
import net.openhft.chronicle.bytes.NativeBytesStore; import net.openhft.chronicle.bytes.NativeBytesStore;
import net.openhft.chronicle.queue.ChronicleQueueBuilder; import net.openhft.chronicle.queue.ChronicleQueueBuilder;
import net.openhft.chronicle.queue.impl.ringbuffer.BytesRingBuffer; import net.openhft.chronicle.queue.impl.ringbuffer.BytesRingBuffer;
import net.openhft.chronicle.queue.impl.ringbuffer.ZippedDocumentAppender;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
Expand Down
Expand Up @@ -102,7 +102,7 @@ public interface ChronicleQueue extends Closeable {




/** /**
* @return the lowest valid index available, or subindex=0 if none are found * @return the lowest valid index available, or sequenceNumber=0 if none are found
*/ */
long firstIndex(); long firstIndex();


Expand Down
14 changes: 6 additions & 8 deletions src/main/java/net/openhft/chronicle/queue/impl/Excerpts.java
Expand Up @@ -439,10 +439,8 @@ private <T> boolean readAtIndex(T t, @NotNull BiConsumer<T, Wire> c) throws IOEx
moveToIndex(firstIndex); moveToIndex(firstIndex);
} }


final boolean success = readAtSubIndex(t, c); final boolean success = readAt(t, c);

if (success) { if (success) {

this.index = ChronicleQueue.index(cycle, toSequenceNumber(index) + 1); this.index = ChronicleQueue.index(cycle, toSequenceNumber(index) + 1);
return true; return true;
} }
Expand All @@ -454,7 +452,7 @@ private <T> boolean readAtIndex(T t, @NotNull BiConsumer<T, Wire> c) throws IOEx
return false; return false;
} }


private <T> boolean readAtSubIndex(T t, @NotNull BiConsumer<T, Wire> c) throws IOException { private <T> boolean readAt(T t, @NotNull BiConsumer<T, Wire> c) throws IOException {


long roll; long roll;
for (; ; ) { for (; ; ) {
Expand Down Expand Up @@ -530,10 +528,10 @@ public boolean moveToIndex(long index) throws IOException {


final Bytes<?> bytes = wire.bytes(); final Bytes<?> bytes = wire.bytes();


final long subIndex = toSequenceNumber(index); final long sequenceNumber = toSequenceNumber(index);
if (subIndex == -1) { if (sequenceNumber == -1) {
bytes.readPosition(0); bytes.readPosition(0);
this.index = ChronicleQueue.index(cycle, subIndex); this.index = ChronicleQueue.index(cycle, sequenceNumber);
return true; return true;
} }


Expand All @@ -545,7 +543,7 @@ public boolean moveToIndex(long index) throws IOException {
bytes.readPosition(position); bytes.readPosition(position);
bytes.readLimit(bytes.realCapacity()); bytes.readLimit(bytes.realCapacity());


this.index = ChronicleQueue.index(cycle, subIndex - 1); this.index = ChronicleQueue.index(cycle, sequenceNumber - 1);
return true; return true;
} }


Expand Down
23 changes: 0 additions & 23 deletions src/main/java/net/openhft/chronicle/queue/impl/WireConstants.java

This file was deleted.

This file was deleted.

Expand Up @@ -115,8 +115,8 @@ public long firstIndex() {
if (cycle == -1) if (cycle == -1)
return -1; return -1;
final WireStore store = acquireStore(cycle, epoch()); final WireStore store = acquireStore(cycle, epoch());
final long subindex = store.firstSequenceNumber(); final long sequenceNumber = store.firstSequenceNumber();
return ChronicleQueue.index(store.cycle(), subindex); return ChronicleQueue.index(store.cycle(), sequenceNumber);
} }


private long firstCycle() { private long firstCycle() {
Expand Down Expand Up @@ -166,8 +166,8 @@ public long lastIndex() {
final long lastCycle = lastCycle(); final long lastCycle = lastCycle();
if (lastCycle == -1) if (lastCycle == -1)
return -1; return -1;
final long lastSubIndex = acquireStore(lastCycle, epoch()).sequenceNumber(); final long lastSequenceNumber = acquireStore(lastCycle, epoch()).sequenceNumber();
return ChronicleQueue.index(lastCycle, lastSubIndex); return ChronicleQueue.index(lastCycle, lastSequenceNumber);
} }


private long lastCycle() { private long lastCycle() {
Expand Down

0 comments on commit 93cfbd7

Please sign in to comment.