static File getFile(MappedBytes bytes) { if (bytes == null) return new File("none"); MappedFile mappedFile = bytes.mappedFile(); assert (mappedFile != null); File file = mappedFile.file(); assert (file != null); return file; }
/** * @param wireType the wire type that is being used * @param mappedBytes used to mapped the data store file * @param recovery used to recover from concurrent modifications */ SingleTableStore(@NotNull final WireType wireType, @NotNull MappedBytes mappedBytes, @NotNull StoreRecovery recovery, @NotNull T metadata) { this.wireType = wireType; this.metadata = metadata; this.recovery = recovery; this.mappedBytes = mappedBytes; this.mappedFile = mappedBytes.mappedFile(); this.refCount = ReferenceCounter.onReleased(this::onCleanup); mappedWire = wireType.apply(mappedBytes); }
private MappedFile toMappedFile(@NotNull DocumentContext documentContext) { MappedFile mappedFile; MappedBytes bytes = (MappedBytes) documentContext.wire().bytes(); mappedFile = bytes.mappedFile(); return mappedFile; }
/** * @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()); }
if (bytes instanceof MappedBytes) { MappedBytes mb = (MappedBytes) bytes; sizeToSkip = Maths.toUInt31(mb.mappedFile().overlapSize() / 2);
/** * used by {@link net.openhft.chronicle.wire.Demarshallable} * * @param wire a wire */ @UsedViaReflection private SingleChronicleQueueStore(@NotNull WireIn wire) { assert wire.startUse(); try { writePosition = loadWritePosition(wire); this.mappedBytes = (MappedBytes) (wire.bytes()); this.mappedFile = mappedBytes.mappedFile(); this.refCount = ReferenceCounter.onReleased(this::onCleanup); this.indexing = Objects.requireNonNull(wire.read(MetaDataField.indexing).typedMarshallable()); assert indexing != null; this.indexing.writePosition = writePosition; this.sequence = new RollCycleEncodeSequence(writePosition, rollIndexCount(), rollIndexSpacing()); this.indexing.sequence = sequence; } finally { assert wire.endUse(); } }
/** * used by {@link Demarshallable} * * @param wire a wire */ @SuppressWarnings("unused") @UsedViaReflection private SingleTableStore(@NotNull WireIn wire) { assert wire.startUse(); try { this.wireType = Objects.requireNonNull(wire.read(MetaDataField.wireType).object(WireType.class)); this.mappedBytes = (MappedBytes) (wire.bytes()); this.mappedFile = mappedBytes.mappedFile(); this.refCount = ReferenceCounter.onReleased(this::onCleanup); if (wire.bytes().readRemaining() > 0) { this.recovery = Objects.requireNonNull(wire.read(MetaDataField.recovery).typedMarshallable()); } else { this.recovery = new SimpleStoreRecovery(); // disabled. } if (wire.bytes().readRemaining() > 0) { this.metadata = Objects.requireNonNull(wire.read(MetaDataField.metadata).typedMarshallable()); } else { this.metadata = (T) Metadata.NoMeta.INSTANCE; } mappedWire = wireType.apply(mappedBytes); } finally { assert wire.endUse(); } }
static File getFile(MappedBytes bytes) { if (bytes == null) return new File("none"); return bytes.mappedFile().file(); }
/** * @param wireType the wire type that is being used * @param mappedBytes used to mapped the data store file * @param recovery used to recover from concurrent modifications */ SingleTableStore(@NotNull final WireType wireType, @NotNull MappedBytes mappedBytes, @NotNull StoreRecovery recovery, @NotNull T metadata) { this.wireType = wireType; this.metadata = metadata; this.recovery = recovery; this.mappedBytes = mappedBytes; this.mappedFile = mappedBytes.mappedFile(); this.refCount = ReferenceCounter.onReleased(this::onCleanup); mappedWire = wireType.apply(mappedBytes); }
/** * @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()); }
/** * used by {@link net.openhft.chronicle.wire.Demarshallable} * * @param wire a wire */ @UsedViaReflection private SingleChronicleQueueStore(@NotNull WireIn wire) { assert wire.startUse(); try { writePosition = loadWritePosition(wire); this.mappedBytes = (MappedBytes) (wire.bytes()); this.mappedFile = mappedBytes.mappedFile(); this.refCount = ReferenceCounter.onReleased(this::onCleanup); this.indexing = Objects.requireNonNull(wire.read(MetaDataField.indexing).typedMarshallable()); this.indexing.writePosition = writePosition; this.sequence = new RollCycleEncodeSequence(writePosition, rollIndexCount(), rollIndexSpacing()); this.indexing.sequence = sequence; } finally { assert wire.endUse(); } }
if (bytes instanceof MappedBytes) { MappedBytes mb = (MappedBytes) bytes; sizeToSkip = Maths.toUInt31(mb.mappedFile().overlapSize() / 2);
/** * used by {@link Demarshallable} * * @param wire a wire */ @SuppressWarnings("unused") @UsedViaReflection private SingleTableStore(@NotNull WireIn wire) { assert wire.startUse(); try { this.wireType = Objects.requireNonNull(wire.read(MetaDataField.wireType).object(WireType.class)); this.mappedBytes = (MappedBytes) (wire.bytes()); this.mappedFile = mappedBytes.mappedFile(); this.refCount = ReferenceCounter.onReleased(this::onCleanup); if (wire.bytes().readRemaining() > 0) { this.recovery = Objects.requireNonNull(wire.read(MetaDataField.recovery).typedMarshallable()); } else { this.recovery = new SimpleStoreRecovery(); // disabled. } if (wire.bytes().readRemaining() > 0) { this.metadata = Objects.requireNonNull(wire.read(MetaDataField.metadata).typedMarshallable()); } else { this.metadata = (T) Metadata.NoMeta.INSTANCE; } mappedWire = wireType.apply(mappedBytes); } finally { assert wire.endUse(); } }