use of org.apache.carbondata.core.carbon.CarbonTableIdentifier in project carbondata by apache.
the class FileFooterValidator method setUp.
@Before
public void setUp() throws Exception {
if (setUpIsDone) {
return;
}
CarbonHiveContext.sql("CREATE CUBE validatefooter DIMENSIONS (empno Integer, empname String," + " designation String," + " doj Timestamp, workgroupcategory Integer, workgroupcategoryname String, " + "deptno Integer, deptname String, projectcode Integer, projectjoindate Timestamp," + " projectenddate Timestamp) MEASURES (attendance Integer,utilization Integer," + "salary Integer) OPTIONS (PARTITIONER [PARTITION_COUNT=1])");
CarbonHiveContext.sql("LOAD DATA fact from './src/test/resources/data.csv' INTO CUBE validatefooter " + "PARTITIONDATA(DELIMITER ',', QUOTECHAR '\"')");
String storePath = CarbonProperties.getInstance().getProperty(CarbonCommonConstants.STORE_LOCATION);
CarbonTableIdentifier tableIdentifier = new CarbonTableIdentifier(CarbonCommonConstants.DATABASE_DEFAULT_NAME, "validatefooter", "1");
String segmentPath = CarbonStorePath.getCarbonTablePath(storePath, tableIdentifier).getCarbonDataDirectoryPath("0", "0");
CarbonFile carbonFile = FileFactory.getCarbonFile(segmentPath, FileFactory.getFileType(segmentPath));
CarbonFile[] list = carbonFile.listFiles(new CarbonFileFilter() {
@Override
public boolean accept(CarbonFile file) {
if (file.getName().endsWith(CarbonCommonConstants.FACT_FILE_EXT)) {
return true;
}
return false;
}
});
for (CarbonFile file : list) {
String fileLocation = file.getAbsolutePath();
CarbonFile factFile = FileFactory.getCarbonFile(fileLocation, FileFactory.getFileType(fileLocation));
long offset = factFile.getSize() - CarbonCommonConstants.LONG_SIZE_IN_BYTE;
FileHolder fileHolder = FileFactory.getFileHolder(FileFactory.getFileType(fileLocation));
offset = fileHolder.readLong(fileLocation, offset);
CarbonFooterReader metaDataReader = new CarbonFooterReader(fileLocation, offset);
fileFooter = metaDataReader.readFooter();
}
setUpIsDone = true;
}
Aggregations