use of org.apache.carbondata.core.datastore.filesystem.CarbonFile in project carbondata by apache.
the class CarbonDataMergerUtil method compactBlockDeleteDeltaFiles.
/**
* method to compact Delete Delta files in case of IUD Compaction.
*
* @param seg
* @param blockName
* @param absoluteTableIdentifier
* @param segmentUpdateDetails
* @param timestamp
* @return
* @throws IOException
*/
public static List<CarbonDataMergerUtilResult> compactBlockDeleteDeltaFiles(String seg, String blockName, AbsoluteTableIdentifier absoluteTableIdentifier, SegmentUpdateDetails[] segmentUpdateDetails, Long timestamp) throws IOException {
SegmentUpdateStatusManager segmentUpdateStatusManager = new SegmentUpdateStatusManager(absoluteTableIdentifier);
List<CarbonDataMergerUtilResult> resultList = new ArrayList<CarbonDataMergerUtilResult>(1);
// set the update status.
segmentUpdateStatusManager.setUpdateStatusDetails(segmentUpdateDetails);
CarbonFile[] deleteDeltaFiles = segmentUpdateStatusManager.getDeleteDeltaFilesList(seg, blockName);
String destFileName = blockName + "-" + timestamp.toString() + CarbonCommonConstants.DELETE_DELTA_FILE_EXT;
String fullBlockFilePath = deleteDeltaFiles[0].getParentFile().getCanonicalPath() + CarbonCommonConstants.FILE_SEPARATOR + destFileName;
List<String> deleteFilePathList = new ArrayList<String>();
for (CarbonFile cFile : deleteDeltaFiles) {
deleteFilePathList.add(cFile.getCanonicalPath());
}
CarbonDataMergerUtilResult blockDetails = new CarbonDataMergerUtilResult();
blockDetails.setBlockName(blockName);
blockDetails.setSegmentName(seg);
blockDetails.setDeleteDeltaStartTimestamp(timestamp.toString());
blockDetails.setDeleteDeltaEndTimestamp(timestamp.toString());
try {
if (startCompactionDeleteDeltaFiles(deleteFilePathList, blockName, fullBlockFilePath)) {
blockDetails.setCompactionStatus(true);
} else {
blockDetails.setCompactionStatus(false);
}
resultList.add(blockDetails);
} catch (IOException e) {
LOGGER.error("Compaction of Delete Delta Files failed. The complete file path is " + fullBlockFilePath);
throw new IOException();
}
return resultList;
}
use of org.apache.carbondata.core.datastore.filesystem.CarbonFile in project carbondata by apache.
the class HdfsFileLock method unlock.
/* (non-Javadoc)
* @see org.apache.carbondata.core.locks.ICarbonLock#unlock()
*/
@Override
public boolean unlock() {
boolean status = false;
if (null != dataOutputStream) {
try {
dataOutputStream.close();
status = true;
} catch (IOException e) {
status = false;
} finally {
CarbonFile carbonFile = FileFactory.getCarbonFile(location, FileFactory.getFileType(location));
if (carbonFile.exists()) {
if (carbonFile.delete()) {
LOGGER.info("Deleted the lock file " + location);
} else {
LOGGER.error("Not able to delete the lock file " + location);
status = false;
}
} else {
LOGGER.error("Not able to delete the lock file because " + "it is not existed in location " + location);
status = false;
}
}
}
return status;
}
use of org.apache.carbondata.core.datastore.filesystem.CarbonFile in project carbondata by apache.
the class LocalFileLock method unlock.
/**
* Unlock API for unlocking of the acquired lock.
*
* @return
*/
@Override
public boolean unlock() {
boolean status;
try {
if (null != fileLock) {
fileLock.release();
}
status = true;
} catch (IOException e) {
status = false;
} finally {
if (null != fileOutputStream) {
try {
fileOutputStream.close();
// deleting the lock file after releasing the lock.
CarbonFile lockFile = FileFactory.getCarbonFile(lockFilePath, FileFactory.getFileType(lockFilePath));
if (!lockFile.exists() || lockFile.delete()) {
LOGGER.info("Successfully deleted the lock file " + lockFilePath);
} else {
LOGGER.error("Not able to delete the lock file " + lockFilePath);
status = false;
}
} catch (IOException e) {
LOGGER.error(e.getMessage());
}
}
}
return status;
}
use of org.apache.carbondata.core.datastore.filesystem.CarbonFile in project carbondata by apache.
the class CarbonFooterWriterTest method deleteFile.
/**
* this method will delete file
*/
private void deleteFile() {
FileFactory.FileType fileType = FileFactory.getFileType(this.filePath);
CarbonFile carbonFile = FileFactory.getCarbonFile(this.filePath, fileType);
carbonFile.delete();
}
use of org.apache.carbondata.core.datastore.filesystem.CarbonFile in project carbondata by apache.
the class CarbonUtil method getFileSize.
/**
* This method will return the size of a given file
*/
public static long getFileSize(String filePath) {
FileFactory.FileType fileType = FileFactory.getFileType(filePath);
CarbonFile carbonFile = FileFactory.getCarbonFile(filePath, fileType);
return carbonFile.getSize();
}
Aggregations