/** * It commits the index file by copying the file from temp folder to actual folder * * @param dataMapFile file path of index file * @throws IOException if IO fails */ protected void commitFile(String dataMapFile) throws IOException { if (!dataMapFile.startsWith(dataMapPath)) { throw new UnsupportedOperationException( "Datamap file " + dataMapFile + " is not written in provided directory path " + dataMapPath); } String dataMapFileName = dataMapFile.substring(dataMapPath.length(), dataMapFile.length()); String carbonFilePath = dataMapFileName.substring(0, dataMapFileName.lastIndexOf("/")); String segmentPath = CarbonTablePath.getSegmentPath(tablePath, segmentId); if (carbonFilePath.length() > 0) { carbonFilePath = segmentPath + carbonFilePath; FileFactory.mkdirs(carbonFilePath, FileFactory.getFileType(carbonFilePath)); } else { carbonFilePath = segmentPath; } CarbonUtil.copyCarbonDataFileToCarbonStorePath(dataMapFile, carbonFilePath, 0); }
/** * Computes a result, or throws an exception if unable to do so. * * @return computed result * @throws Exception if unable to compute a result */ @Override public Void call() throws Exception { CarbonUtil.copyCarbonDataFileToCarbonStorePath(fileName, model.getCarbonDataDirectoryPath(), fileSizeInBytes); FileFactory.deleteFile(fileName, FileFactory.getFileType(fileName)); return null; } }
/** * Finish writing current file. It will flush stream, copy and rename temp file to final file * @param copyInCurrentThread set to false if want to do data copy in a new thread */ protected void commitCurrentFile(boolean copyInCurrentThread) { notifyDataMapBlockEnd(); CarbonUtil.closeStreams(this.fileOutputStream, this.fileChannel); if (!enableDirectlyWriteDataToStorePath) { try { if (copyInCurrentThread) { CarbonUtil.copyCarbonDataFileToCarbonStorePath(carbonDataFileTempPath, model.getCarbonDataDirectoryPath(), fileSizeInBytes); FileFactory .deleteFile(carbonDataFileTempPath, FileFactory.getFileType(carbonDataFileTempPath)); } else { executorServiceSubmitList .add(executorService.submit(new CompleteHdfsBackendThread(carbonDataFileTempPath))); } } catch (IOException e) { LOGGER.error(e); } } }
if (!enableDirectlyWriteDataToStorePath) { CarbonUtil .copyCarbonDataFileToCarbonStorePath(indexFileName, model.getCarbonDataDirectoryPath(), fileSizeInBytes); FileFactory.deleteFile(indexFileName, FileFactory.getFileType(indexFileName));