@Override public IndexOutput createTempOutput(String prefix, String suffix, IOContext context) throws IOException { ensureOpen(); // Make the file first... RAMFile file = newRAMFile(); // ... then try to find a unique name for it: while (true) { String name = IndexFileNames.segmentFileName(prefix, suffix + "_" + Long.toString(nextTempFileCounter.getAndIncrement(), Character.MAX_RADIX), "tmp"); if (fileMap.putIfAbsent(name, file) == null) { return new RAMOutputStream(name, file, true); } } }
@Override public IndexOutput createOutput(String name, IOContext context) throws IOException { ensureOpen(); RAMFile file = newRAMFile(); if (fileMap.putIfAbsent(name, file) != null) { throw new FileAlreadyExistsException(name); } return new RAMOutputStream(name, file, true); }
/** Creates a new, empty file in the directory with the given name. Returns a stream writing this file. */ @Override public IndexOutput createOutput(String name, IOContext context) throws IOException { ensureOpen(); RAMFile file = newRAMFile(); RAMFile existing = fileMap.remove(name); if (existing != null) { sizeInBytes.addAndGet(-existing.sizeInBytes); existing.directory = null; } fileMap.put(name, file); return new RAMOutputStream(name, file, true); }
/** Creates a new, empty file in the directory with the given name. Returns a stream writing this file. */ @Override public IndexOutput createOutput(String name, IOContext context) throws IOException { ensureOpen(); RAMFile file = newRAMFile(); RAMFile existing = fileMap.remove(name); if (existing != null) { sizeInBytes.addAndGet(-existing.sizeInBytes); existing.directory = null; } fileMap.put(name, file); return new RAMOutputStream(name, file, true); }
/** Creates a new, empty file in the directory with the given name. Returns a stream writing this file. */ @Override public IndexOutput createOutput(String name, IOContext context) throws IOException { ensureOpen(); RAMFile file = newRAMFile(); RAMFile existing = fileMap.remove(name); if (existing != null) { sizeInBytes.addAndGet(-existing.sizeInBytes); existing.directory = null; } fileMap.put(name, file); return new RAMOutputStream(file); }
@Override public IndexOutput createTempOutput(String prefix, String suffix, IOContext context) throws IOException { ensureOpen(); // Make the file first... RAMFile file = newRAMFile(); // ... then try to find a unique name for it: while (true) { String name = IndexFileNames.segmentFileName(prefix, suffix + "_" + Long.toString(nextTempFileCounter.getAndIncrement(), Character.MAX_RADIX), "tmp"); if (fileMap.putIfAbsent(name, file) == null) { return new RAMOutputStream(name, file, true); } } }
@Override public IndexOutput createOutput(String name, IOContext context) throws IOException { ensureOpen(); RAMFile file = newRAMFile(); if (fileMap.putIfAbsent(name, file) != null) { throw new FileAlreadyExistsException(name); } return new RAMOutputStream(name, file, true); }