Search in sources :

Example 6 with CarbonRowBatch

use of org.apache.carbondata.processing.newflow.row.CarbonRowBatch 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;
}
Also used : CarbonRowBatch(org.apache.carbondata.processing.newflow.row.CarbonRowBatch) CarbonFactDataHandlerModel(org.apache.carbondata.processing.store.CarbonFactDataHandlerModel) CarbonDataLoadingException(org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException) CarbonFactHandler(org.apache.carbondata.processing.store.CarbonFactHandler) CarbonDataWriterException(org.apache.carbondata.processing.store.writer.exception.CarbonDataWriterException) CarbonDataWriterException(org.apache.carbondata.processing.store.writer.exception.CarbonDataWriterException) IOException(java.io.IOException) CarbonDataLoadingException(org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException) CarbonTableIdentifier(org.apache.carbondata.core.metadata.CarbonTableIdentifier) Iterator(java.util.Iterator)

Aggregations

CarbonRowBatch (org.apache.carbondata.processing.newflow.row.CarbonRowBatch)6 Iterator (java.util.Iterator)4 CarbonDataLoadingException (org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException)4 CarbonRow (org.apache.carbondata.processing.newflow.row.CarbonRow)3 CarbonDataWriterException (org.apache.carbondata.processing.store.writer.exception.CarbonDataWriterException)3 IOException (java.io.IOException)2 CarbonIterator (org.apache.carbondata.common.CarbonIterator)2 CarbonTableIdentifier (org.apache.carbondata.core.metadata.CarbonTableIdentifier)2 CarbonSortKeyAndGroupByException (org.apache.carbondata.processing.sortandgroupby.exception.CarbonSortKeyAndGroupByException)2 CarbonFactDataHandlerModel (org.apache.carbondata.processing.store.CarbonFactDataHandlerModel)2 CarbonFactHandler (org.apache.carbondata.processing.store.CarbonFactHandler)2 UnsafeCarbonRowPage (org.apache.carbondata.processing.newflow.sort.unsafe.UnsafeCarbonRowPage)1 UnsafeSortDataRows (org.apache.carbondata.processing.newflow.sort.unsafe.UnsafeSortDataRows)1 SortDataRows (org.apache.carbondata.processing.sortandgroupby.sortdata.SortDataRows)1