@Override protected void performRelease() throws IllegalStateException { super.performRelease(); mappedFile.release(); }
@NotNull public static MappedBytes mappedBytes(@NotNull File file, long chunkSize, long overlapSize) throws FileNotFoundException, IllegalStateException { @NotNull MappedFile rw = MappedFile.of(file, chunkSize, overlapSize, false); try { return mappedBytes(rw); } finally { rw.release(); } }
@NotNull public static MappedBytes mappedBytes(@NotNull File file, long chunkSize, long overlapSize, boolean readOnly) throws FileNotFoundException, IllegalStateException { @NotNull MappedFile rw = MappedFile.of(file, chunkSize, overlapSize, readOnly); try { return mappedBytes(rw); } finally { rw.release(); } }
@NotNull public MappedBytes withSizes(long chunkSize, long overlapSize) { @NotNull MappedFile mappedFile2 = this.mappedFile.withSizes(chunkSize, overlapSize); if (mappedFile2 == this.mappedFile) return this; try { return mappedBytes(mappedFile2); } finally { mappedFile2.release(); release(); } }
@NotNull public MappedFile withSizes(long chunkSize, long overlapSize) { chunkSize = OS.mapAlign(chunkSize); overlapSize = OS.mapAlign(overlapSize); if (chunkSize == this.chunkSize && overlapSize == this.overlapSize) return this; try { return new MappedFile(file, raf, chunkSize, overlapSize, capacity, readOnly); } finally { release(); } }
public static void warmup() { try { Jvm.disableDebugHandler(); @NotNull File file = File.createTempFile("delete", "me"); file.deleteOnExit(); long mapAlignment = OS.mapAlignment(); int chunks = 64; int compileThreshold = Jvm.compileThreshold(); for (int j = 0; j <= compileThreshold; j += chunks) { try { try (@NotNull RandomAccessFile raf = new RandomAccessFile(file, "rw")) { @NotNull MappedFile mappedFile = new MappedFile(file, raf, mapAlignment, 0, mapAlignment * chunks, false); warmup0(mapAlignment, chunks, mappedFile); mappedFile.release(); } Thread.yield(); Files.delete(file.toPath()); } catch (IOException e) { Jvm.debug().on(MappedFile.class, "Error during warmup", e); } } } catch (IOException e) { Jvm.warn().on(MappedFile.class, "Error during warmup", e); } Jvm.resetExceptionHandlers(); }