@Override public void close() { bytes.release(); } }
@Override public void close() { if (this.bytes != null) { this.bytes.release(); this.bytes = null; } }
void performRelease() throws IllegalStateException { try { this.bytesStore.release(); } finally { this.bytesStore = NoBytesStore.noBytesStore(); } }
private Stream<Map.Entry<String, BytesStore>> getEntryStream() { return getFiles() .map(p -> { @Nullable BytesStore fileContents = null; try { fileContents = getFileContents(p, null); return (Map.Entry<String, BytesStore>) new SimpleEntry<>(p.getFileName().toString(), fileContents); } finally { if (fileContents != null) fileContents.release(); } }); }
private void bytesStore(@NotNull BytesStore<Bytes<Underlying>, Underlying> bytesStore) throws IllegalStateException { @Nullable BytesStore oldBS = this.bytesStore; this.bytesStore = bytesStore; bytesStore.reserve(); oldBS.release(); clear(); }
protected void acceptNewBytesStore(@NotNull final BytesStore bytes) { if (this.bytes != null) { this.bytes.release(); } this.bytes = bytes.bytesStore(); this.bytes.reserve(); }
@Nullable @Override public String getAndPut(String key, @NotNull String value) { Buffers b = BUFFERS.get(); Bytes<ByteBuffer> bytes = b.valueBuffer; bytes.clear(); bytes.appendUtf8(value); @Nullable BytesStore retBytes = kvStore.getAndPut(key, bytes); if (retBytes == null) return null; else { String s = retBytes.toString(); retBytes.release(); return s; } }
private void entriesFor0(@NotNull SubscriptionConsumer<MapEvent<String, BytesStore>> kvConsumer) throws InvalidSubscriberException { getFiles().forEach(p -> { @Nullable BytesStore fileContents = null; try { // in case the file has been deleted in the meantime. fileContents = getFileContents(p, null); if (fileContents != null) { @NotNull InsertedEvent e = InsertedEvent.of(asset.fullName(), p.getFileName().toString(), fileContents, false); kvConsumer.accept(e); } } catch (InvalidSubscriberException ise) { throw Jvm.rethrow(ise); } finally { if (fileContents != null) fileContents.release(); } }); }
@Override public void ensureCapacity(long capacity) { long cap = lookup.sizeFor(capacity); if (cap > bytes.realCapacity()) { // BytesStore bytes2 = NativeBytesStore.lazyNativeBytesStoreWithFixedCapacity(Maths.divideRoundUp(cap, OS.pageSize())); BytesStore bytes2 = Bytes.wrapForRead(ByteBuffer.allocateDirect(Math.toIntExact(lookup.sizeFor(capacity)))); bytes2.write(0, bytes); bytes.release(); bytes = bytes2; } }
return bs.bytesForWrite(); } finally { bs.release();
private synchronized void acquireNextByteStore0(final long offset, final boolean set) { @Nullable BytesStore oldBS = this.bytesStore; try { @Nullable BytesStore newBS = mappedFile.acquireByteStore(offset); this.bytesStore = newBS; oldBS.release(); } catch (@NotNull IOException | IllegalStateException | IllegalArgumentException e) { @NotNull BufferOverflowException boe = new BufferOverflowException(); boe.initCause(e); throw boe; } if (set) { if (writeLimit() < readPosition) writeLimit(readPosition); if (readLimit() < readPosition) readLimit(readPosition); readPosition = offset; } }
@Override public void ensureCapacity(long capacity) { long cap = lookup.sizeFor(capacity); if (cap > bytes.realCapacity()) { long value = lookup.sizeFor(capacity); BytesStore bytes2 = Jvm.isDebug() ? Bytes.wrapForRead(ByteBuffer.allocateDirect(Math.toIntExact(value))) : NativeBytesStore.lazyNativeBytesStoreWithFixedCapacity(value); bytes2.write(0, bytes); bytes.release(); bytes = bytes2; } }
return bbb; } finally { bs.release();
return bbb; } finally { bs.release();
public void setBytes(@NotNull Bytes bytes) throws IllegalStateException { BytesStore underlyingBytes = bytes.bytesStore(); if (bytesStore != underlyingBytes) { bytesStore.release(); this.bytesStore = underlyingBytes; bytesStore.reserve(); } readPosition(bytes.readPosition()); this.uncheckedWritePosition(bytes.writePosition()); this.writeLimit = bytes.writeLimit(); assert !bytesStore.isDirectMemory() || BytesUtil.register(this); this.underlyingBytes = bytes; }
task.join(); trend.release();
this.bytesStore = store; try { tempStore.release(); } catch (IllegalStateException e) { Jvm.debug().on(getClass(), e);