/** * Get the local file represented by this split * * @param ioManager * @return * @throws HyracksDataException */ @Override public File getFile(IIOManager ioManager) throws HyracksDataException { return getFileReference(ioManager).getFile(); }
@Override public File getFile(IIOManager ioManager) throws HyracksDataException { return getFileReference(ioManager).getFile(); }
private static FileReference getLocalResourceFileByName(IIOManager ioManager, String resourcePath) throws HyracksDataException { String fileName = resourcePath + File.separator + StorageConstants.METADATA_FILE_NAME; return ioManager.resolve(fileName); }
/** * @return the absolute path for LAF file */ public String getLAFAbsolutePath() { return lafFileRef.getAbsolutePath(); } }
@Override public FileReference getFileReference(IIOManager ioManager) throws HyracksDataException { if (cached == null) { cached = new FileReference(ioManager.getIODevices().get(ioDevice), getPath()); } return cached; } }
public static int getDeviceId(IIOManager ioManager, FileReference fileRef) { IODeviceHandle device = fileRef.getDeviceHandle(); List<IODeviceHandle> devices = ioManager.getIODevices(); int deviceId = 0; for (int i = 0; i < devices.size(); i++) { IODeviceHandle next = devices.get(i); if (next == device) { deviceId = i; } } return deviceId; }
public CompressedFileReference(IODeviceHandle dev, ICompressorDecompressor compressorDecompressor, String path, String lafPath) { super(dev, path); this.lafPath = lafPath; lafFileRef = new FileReference(dev, lafPath); this.compressorDecompressor = compressorDecompressor; }
@Override public void deallocate() { if (partitionFile != null) { partitionFile.delete(); } }
private void doCloseFileHandle() { if (--referenceCount == 0) { // close the file if there is no more reference try { ioManager.close(fileHandle); } catch (IOException e) { // Since file handle could not be closed, just ignore. } fileHandle = null; } }
@Override public void open() throws HyracksDataException { // Opens RW mode because we need to truncate the given file if required. handle = ioManager.open(file, IIOManager.FileReadWriteMode.READ_ONLY, IIOManager.FileSyncMode.METADATA_ASYNC_DATA_ASYNC); readPtr = 0; }
/** * Force the file into disk * * @param metadata * see {@link java.nio.channels.FileChannel#force(boolean)} * @throws HyracksDataException */ public void force(boolean metadata) throws HyracksDataException { ioManager.sync(fileHandle, metadata); }
@Override public FileReference createUnmanagedWorkspaceFile(String prefix) throws HyracksDataException { return ioManager.createWorkspaceFile(prefix); } }
@Override public FileReference createManagedWorkspaceFile(String prefix) throws HyracksDataException { return fileFactory.createManagedWorkspaceFile(prefix); }
/** * Create a file reference * * @param relPath * the relative path * @return */ public FileReference createFileRef(String relPath) { return new FileReference(this, relPath); }
@Override public void close() throws HyracksDataException { if (!failed) { ioManager.close(handle); } }
/** * Open the file * * @throws HyracksDataException */ public void open(FileReference fileRef) throws HyracksDataException { fileHandle = ioManager.open(fileRef, IIOManager.FileReadWriteMode.READ_WRITE, IIOManager.FileSyncMode.METADATA_ASYNC_DATA_ASYNC); hasOpen = true; }
@Override public void fail() throws HyracksDataException { ioManager.close(handle); failed = true; }
@Override public void open() throws HyracksDataException { handle = ioManager.open(file, IIOManager.FileReadWriteMode.READ_WRITE, IIOManager.FileSyncMode.METADATA_ASYNC_DATA_ASYNC); size = 0; failed = false; maxOutputFrameSize = 0; }
/** * Close the file * * @throws HyracksDataException */ public void close() throws HyracksDataException { if (hasOpen) { ioManager.close(fileHandle); } }