use of org.apache.carbondata.core.util.path.CarbonTablePath in project carbondata by apache.
the class AbstractDictionaryCacheTest method prepareWriterAndWriteData.
/**
* write dictionary data
*
* @param data
* @throws IOException
*/
protected void prepareWriterAndWriteData(List<String> data, String columnId) throws IOException {
ColumnIdentifier columnIdentifier = new ColumnIdentifier(columnId, null, null);
CarbonDictionaryWriter carbonDictionaryWriter = new CarbonDictionaryWriterImpl(carbonStorePath, carbonTableIdentifier, columnIdentifier);
CarbonTablePath carbonTablePath = CarbonStorePath.getCarbonTablePath(carbonStorePath, carbonTableIdentifier);
CarbonUtil.checkAndCreateFolder(carbonTablePath.getMetadataDirectoryPath());
List<byte[]> valueList = convertStringListToByteArray(data);
try {
carbonDictionaryWriter.write(valueList);
} finally {
carbonDictionaryWriter.close();
carbonDictionaryWriter.commit();
}
}
use of org.apache.carbondata.core.util.path.CarbonTablePath in project carbondata by apache.
the class CarbonDictionaryWriterImpl method initPaths.
protected void initPaths() {
PathService pathService = CarbonCommonFactory.getPathService();
CarbonTablePath carbonTablePath = pathService.getCarbonTablePath(this.storePath, carbonTableIdentifier);
this.dictionaryFilePath = carbonTablePath.getDictionaryFilePath(columnIdentifier.getColumnId());
this.dictionaryMetaFilePath = carbonTablePath.getDictionaryMetaFilePath(columnIdentifier.getColumnId());
}
use of org.apache.carbondata.core.util.path.CarbonTablePath in project carbondata by apache.
the class CarbonDictionarySortIndexWriterImpl method initPath.
protected void initPath() {
PathService pathService = CarbonCommonFactory.getPathService();
CarbonTablePath carbonTablePath = pathService.getCarbonTablePath(carbonStorePath, carbonTableIdentifier);
String dictionaryPath = carbonTablePath.getDictionaryFilePath(columnIdentifier.getColumnId());
long dictOffset = CarbonUtil.getFileSize(dictionaryPath);
this.sortIndexFilePath = carbonTablePath.getSortIndexFilePath(columnIdentifier.getColumnId(), dictOffset);
cleanUpOldSortIndex(carbonTablePath, dictionaryPath);
}
use of org.apache.carbondata.core.util.path.CarbonTablePath in project carbondata by apache.
the class CarbonUpdateUtil method cleanStaleDeltaFiles.
/**
* This will handle the clean up cases if the update fails.
*
* @param table
* @param timeStamp
*/
public static void cleanStaleDeltaFiles(CarbonTable table, final String timeStamp) {
AbsoluteTableIdentifier absoluteTableIdentifier = table.getAbsoluteTableIdentifier();
CarbonTablePath carbonTablePath = CarbonStorePath.getCarbonTablePath(absoluteTableIdentifier.getStorePath(), absoluteTableIdentifier.getCarbonTableIdentifier());
// as of now considering only partition 0.
String partitionId = "0";
String partitionDir = carbonTablePath.getPartitionDir(partitionId);
CarbonFile file = FileFactory.getCarbonFile(partitionDir, FileFactory.getFileType(partitionDir));
if (!file.exists()) {
return;
}
for (CarbonFile eachDir : file.listFiles()) {
// for each dir check if the file with the delta timestamp is present or not.
CarbonFile[] toBeDeleted = eachDir.listFiles(new CarbonFileFilter() {
@Override
public boolean accept(CarbonFile file) {
String fileName = file.getName();
return (fileName.endsWith(timeStamp + CarbonCommonConstants.UPDATE_DELTA_FILE_EXT) || fileName.endsWith(timeStamp + CarbonCommonConstants.UPDATE_INDEX_FILE_EXT) || fileName.endsWith(timeStamp + CarbonCommonConstants.DELETE_DELTA_FILE_EXT));
}
});
// deleting the files of a segment.
try {
CarbonUtil.deleteFoldersAndFilesSilent(toBeDeleted);
} catch (IOException e) {
LOGGER.error("Exception in deleting the delta files." + e);
} catch (InterruptedException e) {
LOGGER.error("Exception in deleting the delta files." + e);
}
}
}
use of org.apache.carbondata.core.util.path.CarbonTablePath in project carbondata by apache.
the class ManageDictionaryAndBTree method deleteDictionaryFileAndCache.
/**
* This method will delete the dictionary files for the given column IDs and
* clear the dictionary cache
*
* @param columnSchema
* @param carbonTableIdentifier
* @param storePath
*/
public static void deleteDictionaryFileAndCache(final ColumnSchema columnSchema, CarbonTableIdentifier carbonTableIdentifier, String storePath) {
CarbonTablePath carbonTablePath = CarbonStorePath.getCarbonTablePath(storePath, carbonTableIdentifier);
String metadataDirectoryPath = carbonTablePath.getMetadataDirectoryPath();
CarbonFile metadataDir = FileFactory.getCarbonFile(metadataDirectoryPath, FileFactory.getFileType(metadataDirectoryPath));
// sort index file is created with dictionary size appended to it. So all the files
// with a given column ID need to be listed
CarbonFile[] listFiles = metadataDir.listFiles(new CarbonFileFilter() {
@Override
public boolean accept(CarbonFile path) {
if (path.getName().startsWith(columnSchema.getColumnUniqueId())) {
return true;
}
return false;
}
});
for (CarbonFile file : listFiles) {
// still need to be deleted
try {
FileFactory.deleteFile(file.getCanonicalPath(), FileFactory.getFileType(file.getCanonicalPath()));
} catch (IOException e) {
LOGGER.error("Failed to delete dictionary or sortIndex file for column " + columnSchema.getColumnName() + "with column ID " + columnSchema.getColumnUniqueId());
}
}
// remove dictionary cache
removeDictionaryColumnFromCache(carbonTableIdentifier, storePath, columnSchema.getColumnUniqueId());
}
Aggregations