Java Code Examples for net.openhft.chronicle.bytes.Bytes#readLimitToCapacity()
The following examples show how to use
net.openhft.chronicle.bytes.Bytes#readLimitToCapacity() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StoreTailer.java From Chronicle-Queue with Apache License 2.0 | 6 votes |
private boolean inACycle2(boolean includeMetaData, Wire wire, Bytes<?> bytes) throws EOFException { bytes.readLimitToCapacity(); switch (wire.readDataHeader(includeMetaData)) { case NONE: // Jvm.optionalSafepoint(); // no more polling - appender will always write (or recover) EOF return false; case META_DATA: // Jvm.optionalSafepoint(); context.metaData(true); break; case DATA: // Jvm.optionalSafepoint(); context.metaData(false); break; case EOF: throw EOF_EXCEPTION; } // Jvm.optionalSafepoint(); inACycleFound(bytes); // Jvm.optionalSafepoint(); return true; }
Example 2
Source File: RollEOFTest.java From Chronicle-Queue with Apache License 2.0 | 6 votes |
private void removeEOF(Path path) throws IOException { long blockSize = 64 << 10; long chunkSize = OS.pageAlign(blockSize); long overlapSize = OS.pageAlign(blockSize / 4); final MappedBytes mappedBytes = MappedBytes.mappedBytes(path.toFile(), chunkSize, overlapSize, false); mappedBytes.reserve(test); try { final Wire wire = WireType.BINARY_LIGHT.apply(mappedBytes); final Bytes<?> bytes = wire.bytes(); bytes.readLimitToCapacity(); bytes.readSkip(4); // move past header try (final SingleChronicleQueueStore qs = loadStore(wire)) { assertNotNull(qs); long l = qs.writePosition(); long len = Wires.lengthOf(bytes.readVolatileInt(l)); long eofOffset = l + len + 4L; bytes.writePosition(eofOffset); bytes.writeInt(0); } } finally { mappedBytes.release(test); } }
Example 3
Source File: StoreTailer.java From Chronicle-Queue with Apache License 2.0 | 5 votes |
@NotNull private Wire readAnywhere(@NotNull final Wire wire) { final Bytes<?> bytes = wire.bytes(); bytes.readLimitToCapacity(); if (store.dataVersion() > 0) wire.usePadding(true); return wire; }
Example 4
Source File: VanillaChronicleMap.java From Chronicle-Map with Apache License 2.0 | 4 votes |
private V searchValue(CompiledMapQueryContext<K, V, R> q, long searchKey, long searchStartPos, long tierBaseAddr, long inputKeySize, Data<K> inputKey, V using) { CompactOffHeapLinearHashTable hl = this.hashLookup; PointerBytesStore segmentBytesStore = q.segmentBS; segmentBytesStore.set(tierBaseAddr, tierSize); Bytes bs = q.segmentBytes; bs.clear(); long freeListOffset = tierHashLookupOuterSize + TIER_COUNTERS_AREA_SIZE; long entrySpaceOffset = freeListOffset + tierFreeListOuterSize + tierEntrySpaceInnerOffset; long hlPos = searchStartPos; searchLoop: while (true) { long entryPos; nextPos: { while (true) { long entry = hl.readEntryVolatile(tierBaseAddr, hlPos); if (hl.empty(entry)) { break searchLoop; } hlPos = hl.step(hlPos); if (hlPos == searchStartPos) { throw new IllegalStateException( toIdentityString() + ": HashLookup overflow should never occur"); } if ((hl.key(entry)) == searchKey) { entryPos = hl.value(entry); break nextPos; } } } long keySizeOffset = entrySpaceOffset + (entryPos * chunkSize); bs.readLimitToCapacity(); bs.readPosition(keySizeOffset); long keySize = keySizeMarshaller.readSize(bs); long keyOffset = bs.readPosition(); if (!((inputKeySize == keySize) && (inputKey.equivalent(segmentBytesStore, keyOffset)))) { continue; } long valueSizeOffset = keyOffset + keySize; bs.readPosition(valueSizeOffset); long valueSize = readValueSize(bs); return q.valueReader.read(bs, valueSize, using); } return null; }