public synchronized VanillaMappedBytes indexFor(int cycle, int indexCount, boolean forAppend) throws IOException { key.cycle = cycle; key.indexCount = indexCount; VanillaMappedBytes vmb = this.cache.get(key); if (vmb == null) { File file = this.indexFileMap.get(key); if (file == null) { this.indexFileMap.put( key.clone(), file = indexFileFor(cycle, indexCount, dateCache) ); } long start = System.nanoTime(); File parent = file.getParentFile(); if (forAppend && !VanillaChronicleUtils.exists(parent)) { parent.mkdirs(); } if (!forAppend && !VanillaChronicleUtils.exists(file)) { return null; } vmb = this.cache.put(key.clone(), file, 1L << blockBits, indexCount); fileLifecycleListener.onEvent(EventType.NEW, file, System.nanoTime() - start); } vmb.reserve(); return vmb; }
public synchronized VanillaMappedBytes dataFor(int cycle, int threadId, int dataCount, boolean forWrite) throws IOException { key.cycle = cycle; key.threadId = threadId; key.dataCount = dataCount; VanillaMappedBytes vmb = this.cache.get(key); if (vmb == null || vmb.refCount() < 1) { long start = System.nanoTime(); File file = VanillaChronicleUtils.mkFiles( dateCache.valueFor(cycle).path, FILE_NAME_PREFIX + threadId + "-" + dataCount, forWrite); vmb = this.cache.put(key.clone(), file, 1L << blockBits, dataCount); fileLifecycleListener.onEvent(EventType.NEW, file, System.nanoTime() - start); } vmb.reserve(); return vmb; }
public synchronized VanillaMappedBytes indexFor(int cycle, int indexCount, boolean forAppend) throws IOException { key.cycle = cycle; key.indexCount = indexCount << blockBits; VanillaMappedBytes vmb = this.cache.get(key); if(vmb == null) { vmb = this.cache.put( key.clone(), VanillaChronicleUtils.mkFiles( basePath, dateCache.formatFor(cycle), FILE_NAME_PREFIX + indexCount, forAppend), 1L << blockBits, indexCount); } vmb.reserve(); return vmb; }
public synchronized VanillaMappedBytes dataFor(int cycle, int threadId, int dataCount, boolean forWrite) throws IOException { key.cycle = cycle; key.threadId = threadId; key.dataCount = dataCount; VanillaMappedBytes vmb = this.cache.get(key); if(vmb == null) { vmb = this.cache.put( key.clone(), VanillaChronicleUtils.mkFiles( basePath, dateCache.formatFor(cycle), FILE_NAME_PREFIX + threadId + "-" + dataCount, forWrite), 1L << blockBits, dataCount); } vmb.reserve(); return vmb; }