use of org.apache.carbondata.processing.store.CarbonFactDataHandlerModel in project carbondata by apache.
the class SecondaryIndexQueryResultProcessor method initDataHandler.
/**
* initialise carbon data writer instance
*/
private void initDataHandler() throws SecondaryIndexException {
String carbonStoreLocation = CarbonDataProcessorUtil.createCarbonStoreLocation(this.indexTable, segmentId);
CarbonFactDataHandlerModel carbonFactDataHandlerModel = CarbonFactDataHandlerModel.getCarbonFactDataHandlerModel(carbonLoadModel, indexTable, segmentProperties, indexTable.getTableName(), tempStoreLocation, carbonStoreLocation);
carbonFactDataHandlerModel.setSchemaUpdatedTimeStamp(indexTable.getTableLastUpdatedTime());
CarbonDataFileAttributes carbonDataFileAttributes = new CarbonDataFileAttributes(Integer.parseInt(carbonLoadModel.getTaskNo()), carbonLoadModel.getFactTimeStamp());
carbonFactDataHandlerModel.setCarbonDataFileAttributes(carbonDataFileAttributes);
dataHandler = CarbonFactHandlerFactory.createCarbonFactHandler(carbonFactDataHandlerModel);
try {
dataHandler.initialise();
} catch (CarbonDataWriterException e) {
this.sortDataRows.close();
LOGGER.error(e);
throw new SecondaryIndexException("Problem initialising data handler while creating secondary index: " + e.getMessage());
}
}
use of org.apache.carbondata.processing.store.CarbonFactDataHandlerModel in project carbondata by apache.
the class CarbonRowDataWriterProcessorStepImpl method execute.
@Override
public Iterator<CarbonRowBatch>[] execute() throws CarbonDataLoadingException {
final Iterator<CarbonRowBatch>[] iterators = child.execute();
tableIdentifier = configuration.getTableIdentifier().getCarbonTableIdentifier();
tableName = tableIdentifier.getTableName();
try {
readCounter = new long[iterators.length];
writeCounter = new long[iterators.length];
dimensionWithComplexCount = configuration.getDimensionCount();
noDictWithComplextCount = configuration.getNoDictionaryCount() + configuration.getComplexColumnCount();
dimensionCount = configuration.getDimensionCount() - noDictWithComplextCount;
isNoDictionaryDimensionColumn = CarbonDataProcessorUtil.getNoDictionaryMapping(configuration.getDataFields());
measureDataType = configuration.getMeasureDataType();
CarbonFactDataHandlerModel dataHandlerModel = CarbonFactDataHandlerModel.createCarbonFactDataHandlerModel(configuration, getStoreLocation(tableIdentifier, String.valueOf(0)), 0, 0);
measureCount = dataHandlerModel.getMeasureCount();
outputLength = measureCount + (this.noDictWithComplextCount > 0 ? 1 : 0) + 1;
CarbonTimeStatisticsFactory.getLoadStatisticsInstance().recordDictionaryValue2MdkAdd2FileTime(configuration.getPartitionId(), System.currentTimeMillis());
if (iterators.length == 1) {
doExecute(iterators[0], 0, 0);
} else {
ExecutorService executorService = Executors.newFixedThreadPool(iterators.length);
Future[] futures = new Future[iterators.length];
for (int i = 0; i < iterators.length; i++) {
futures[i] = executorService.submit(new DataWriterRunnable(iterators[i], i));
}
for (Future future : futures) {
future.get();
}
}
} catch (CarbonDataWriterException e) {
LOGGER.error(e, "Failed for table: " + tableName + " in DataWriterProcessorStepImpl");
throw new CarbonDataLoadingException("Error while initializing data handler : " + e.getMessage());
} catch (Exception e) {
LOGGER.error(e, "Failed for table: " + tableName + " in DataWriterProcessorStepImpl");
throw new CarbonDataLoadingException("There is an unexpected error: " + e.getMessage(), e);
}
return null;
}
use of org.apache.carbondata.processing.store.CarbonFactDataHandlerModel in project carbondata by apache.
the class CarbonRowDataWriterProcessorStepImpl method doExecute.
private void doExecute(Iterator<CarbonRowBatch> iterator, int partitionId, int iteratorIndex) {
String storeLocation = getStoreLocation(tableIdentifier, String.valueOf(partitionId));
CarbonFactDataHandlerModel model = CarbonFactDataHandlerModel.createCarbonFactDataHandlerModel(configuration, storeLocation, partitionId, iteratorIndex);
CarbonFactHandler dataHandler = null;
boolean rowsNotExist = true;
while (iterator.hasNext()) {
if (rowsNotExist) {
rowsNotExist = false;
dataHandler = CarbonFactHandlerFactory.createCarbonFactHandler(model, CarbonFactHandlerFactory.FactHandlerType.COLUMNAR);
dataHandler.initialise();
}
processBatch(iterator.next(), dataHandler, iteratorIndex);
}
if (!rowsNotExist) {
finish(dataHandler, iteratorIndex);
}
}
use of org.apache.carbondata.processing.store.CarbonFactDataHandlerModel in project carbondata by apache.
the class DataWriterBatchProcessorStepImpl method execute.
@Override
public Iterator<CarbonRowBatch>[] execute() throws CarbonDataLoadingException {
Iterator<CarbonRowBatch>[] iterators = child.execute();
CarbonTableIdentifier tableIdentifier = configuration.getTableIdentifier().getCarbonTableIdentifier();
String tableName = tableIdentifier.getTableName();
try {
CarbonTimeStatisticsFactory.getLoadStatisticsInstance().recordDictionaryValue2MdkAdd2FileTime(configuration.getPartitionId(), System.currentTimeMillis());
int i = 0;
for (Iterator<CarbonRowBatch> iterator : iterators) {
String storeLocation = getStoreLocation(tableIdentifier, String.valueOf(i));
int k = 0;
while (iterator.hasNext()) {
CarbonRowBatch next = iterator.next();
CarbonFactDataHandlerModel model = CarbonFactDataHandlerModel.createCarbonFactDataHandlerModel(configuration, storeLocation, i, k++);
CarbonFactHandler dataHandler = CarbonFactHandlerFactory.createCarbonFactHandler(model, CarbonFactHandlerFactory.FactHandlerType.COLUMNAR);
dataHandler.initialise();
processBatch(next, dataHandler);
finish(tableName, dataHandler);
}
i++;
}
} catch (Exception e) {
LOGGER.error(e, "Failed for table: " + tableName + " in DataWriterBatchProcessorStepImpl");
throw new CarbonDataLoadingException("There is an unexpected error: " + e.getMessage());
}
return null;
}
use of org.apache.carbondata.processing.store.CarbonFactDataHandlerModel in project carbondata by apache.
the class DataWriterProcessorStepImpl method execute.
@Override
public Iterator<CarbonRowBatch>[] execute() throws CarbonDataLoadingException {
Iterator<CarbonRowBatch>[] iterators = child.execute();
CarbonTableIdentifier tableIdentifier = configuration.getTableIdentifier().getCarbonTableIdentifier();
String tableName = tableIdentifier.getTableName();
try {
CarbonTimeStatisticsFactory.getLoadStatisticsInstance().recordDictionaryValue2MdkAdd2FileTime(configuration.getPartitionId(), System.currentTimeMillis());
int i = 0;
for (Iterator<CarbonRowBatch> iterator : iterators) {
String storeLocation = getStoreLocation(tableIdentifier, String.valueOf(i));
CarbonFactDataHandlerModel model = CarbonFactDataHandlerModel.createCarbonFactDataHandlerModel(configuration, storeLocation, i, 0);
CarbonFactHandler dataHandler = null;
boolean rowsNotExist = true;
while (iterator.hasNext()) {
if (rowsNotExist) {
rowsNotExist = false;
dataHandler = CarbonFactHandlerFactory.createCarbonFactHandler(model, CarbonFactHandlerFactory.FactHandlerType.COLUMNAR);
dataHandler.initialise();
}
processBatch(iterator.next(), dataHandler);
}
if (!rowsNotExist) {
finish(tableName, dataHandler);
}
i++;
}
} catch (CarbonDataWriterException e) {
LOGGER.error(e, "Failed for table: " + tableName + " in DataWriterProcessorStepImpl");
throw new CarbonDataLoadingException("Error while initializing data handler : " + e.getMessage());
} catch (Exception e) {
LOGGER.error(e, "Failed for table: " + tableName + " in DataWriterProcessorStepImpl");
throw new CarbonDataLoadingException("There is an unexpected error: " + e.getMessage(), e);
}
return null;
}
Aggregations