@Override public int defaultIndexSpacing() { return delegate.defaultIndexSpacing(); }
public int indexSpacing() { return indexSpacing == null || indexSpacing <= 0 ? rollCycle().defaultIndexSpacing() : indexSpacing; }
/** * @param rollCycle the current rollCycle * @param wireType the wire type that is being used * @param mappedBytes used to mapped the data store file * @param indexCount the number of entries in each index. * @param indexSpacing the spacing between indexed entries. */ public SingleChronicleQueueStore(@NotNull RollCycle rollCycle, @NotNull final WireType wireType, @NotNull MappedBytes mappedBytes, int indexCount, int indexSpacing) { this.mappedBytes = mappedBytes; this.mappedFile = mappedBytes.mappedFile(); this.refCount = ReferenceCounter.onReleased(this::onCleanup); indexCount = Maths.nextPower2(indexCount, 8); indexSpacing = Maths.nextPower2(indexSpacing, 1); this.indexing = new SCQIndexing(wireType, indexCount, indexSpacing); this.indexing.writePosition = this.writePosition = wireType.newTwoLongReference().get(); this.indexing.sequence = this.sequence = new RollCycleEncodeSequence(writePosition, rollCycle.defaultIndexCount(), rollCycle.defaultIndexSpacing()); }
long lastIndex = -1; do { int defaultIndexSpacing = this.queue.rollCycle().defaultIndexSpacing(); Wire wire = wire(); int writeCount = Math.min(128 << 10,
@Test public void testForwardFollowedBackBackwardTailer() { try (ChronicleQueue chronicle = builder(getTmpDir(), this.wireType) .rollCycle(TEST2_DAILY) .build()) { ExcerptAppender appender = chronicle.acquireAppender(); int entries = chronicle.rollCycle().defaultIndexSpacing() + 2; for (int i = 0; i < entries; i++) { int finalI = i; appender.writeDocument(w -> w.writeEventName("hello").text("world" + finalI)); } for (int i = 0; i < 3; i++) { readForward(chronicle, entries); readBackward(chronicle, entries); } } }
long lastIndex = -1; do { int defaultIndexSpacing = q.rollCycle().defaultIndexSpacing(); Wire wire = appender.wire(); int writeCount = (int) (defaultIndexSpacing - (lastIndex & (defaultIndexSpacing - 1)) - 1);
@Test public void testToEndBeforeWrite() { try (ChronicleQueue chronicle = builder(getTmpDir(), wireType) .rollCycle(TEST2_DAILY) .build()) { ExcerptAppender appender = chronicle.acquireAppender(); ExcerptTailer tailer = chronicle.createTailer(); int entries = chronicle.rollCycle().defaultIndexSpacing() * 2 + 2; for (int i = 0; i < entries; i++) { tailer.toEnd(); int finalI = i; appender.writeDocument(w -> w.writeEventName("hello").text("world" + finalI)); tailer.readDocument(w -> w.read().text("world" + finalI, Assert::assertEquals)); } } }
@Test public void testSomeMessages() { try (ChronicleQueue chronicle = builder(getTmpDir(), wireType) .rollCycle(TEST2_DAILY) .build()) { ExcerptAppender appender = chronicle.acquireAppender(); ExcerptTailer tailer = chronicle.createTailer(); int entries = chronicle.rollCycle().defaultIndexSpacing() * 2 + 2; for (long i = 0; i < entries; i++) { long finalI = i; appender.writeDocument(w -> w.writeEventName("hello").int64(finalI)); long seq = chronicle.rollCycle().toSequenceNumber(appender.lastIndexAppended()); assertEquals(i, seq); // System.out.println(chronicle.dump()); tailer.readDocument(w -> w.read().int64(finalI, (a, b) -> Assert.assertEquals((long) a, b))); } } }
public int indexSpacing() { return indexSpacing == null || indexSpacing <= 0 ? rollCycle().defaultIndexSpacing() : indexSpacing; }
/** * @param rollCycle the current rollCycle * @param wireType the wire type that is being used * @param mappedBytes used to mapped the data store file * @param indexCount the number of entries in each index. * @param indexSpacing the spacing between indexed entries. */ public SingleChronicleQueueStore(@NotNull RollCycle rollCycle, @NotNull final WireType wireType, @NotNull MappedBytes mappedBytes, int indexCount, int indexSpacing) { this.mappedBytes = mappedBytes; this.mappedFile = mappedBytes.mappedFile(); this.refCount = ReferenceCounter.onReleased(this::onCleanup); indexCount = Maths.nextPower2(indexCount, 8); indexSpacing = Maths.nextPower2(indexSpacing, 1); this.indexing = new SCQIndexing(wireType, indexCount, indexSpacing); this.indexing.writePosition = this.writePosition = wireType.newTwoLongReference().get(); this.indexing.sequence = this.sequence = new RollCycleEncodeSequence(writePosition, rollCycle.defaultIndexCount(), rollCycle.defaultIndexSpacing()); }
long lastIndex = -1; do { int defaultIndexSpacing = this.queue.rollCycle().defaultIndexSpacing(); Wire wire = wire(); int writeCount = Math.min(128 << 10,