Search in sources :

Example 11 with CarbonDataLoadingException

use of org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException in project carbondata by apache.

the class DataLoadExecutor method execute.

public void execute(CarbonLoadModel loadModel, String storeLocation, CarbonIterator<Object[]>[] inputIterators) throws Exception {
    AbstractDataLoadProcessorStep loadProcessorStep = null;
    try {
        loadProcessorStep = new DataLoadProcessBuilder().build(loadModel, storeLocation, inputIterators);
        // 1. initialize
        loadProcessorStep.initialize();
        LOGGER.info("Data Loading is started for table " + loadModel.getTableName());
        // 2. execute the step
        loadProcessorStep.execute();
    } catch (CarbonDataLoadingException e) {
        throw e;
    } catch (Exception e) {
        LOGGER.error(e, "Data Loading failed for table " + loadModel.getTableName());
        throw new CarbonDataLoadingException("Data Loading failed for table " + loadModel.getTableName(), e);
    } finally {
        if (loadProcessorStep != null) {
            // 3. Close the step
            loadProcessorStep.close();
        }
    }
    String key = new CarbonTableIdentifier(loadModel.getDatabaseName(), loadModel.getTableName(), null).getBadRecordLoggerKey();
    if (null != BadRecordsLogger.hasBadRecord(key)) {
        LOGGER.error("Data Load is partially success for table " + loadModel.getTableName());
        throw new BadRecordFoundException("Bad records found during load");
    } else {
        LOGGER.info("Data loading is successful for table " + loadModel.getTableName());
    }
}
Also used : CarbonDataLoadingException(org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException) CarbonTableIdentifier(org.apache.carbondata.core.metadata.CarbonTableIdentifier) BadRecordFoundException(org.apache.carbondata.processing.newflow.exception.BadRecordFoundException) CarbonDataLoadingException(org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException) BadRecordFoundException(org.apache.carbondata.processing.newflow.exception.BadRecordFoundException)

Example 12 with CarbonDataLoadingException

use of org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException in project carbondata by apache.

the class DictionaryFieldConverterImpl method convert.

@Override
public void convert(CarbonRow row, BadRecordLogHolder logHolder) throws CarbonDataLoadingException {
    try {
        String parsedValue = null;
        String dimensionValue = row.getString(index);
        if (dimensionValue == null || dimensionValue.equals(nullFormat)) {
            parsedValue = CarbonCommonConstants.MEMBER_DEFAULT_VAL;
        } else {
            parsedValue = DataTypeUtil.parseValue(dimensionValue, carbonDimension);
        }
        if (null == parsedValue) {
            if ((dimensionValue.length() > 0) || (dimensionValue.length() == 0 && isEmptyBadRecord)) {
                String dataType = carbonDimension.getDataType().getName();
                logHolder.setReason("The value " + " \"" + dimensionValue + "\"" + " with column name " + carbonDimension.getColName() + " and column data type " + dataType + " is not a valid " + dataType + " type.");
            }
            row.update(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY, index);
        } else {
            row.update(dictionaryGenerator.getOrGenerateKey(parsedValue), index);
        }
    } catch (DictionaryGenerationException e) {
        throw new CarbonDataLoadingException(e);
    }
}
Also used : CarbonDataLoadingException(org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException) DictionaryGenerationException(org.apache.carbondata.core.devapi.DictionaryGenerationException)

Example 13 with CarbonDataLoadingException

use of org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException in project carbondata by apache.

the class RowConverterImpl method convert.

@Override
public CarbonRow convert(CarbonRow row) throws CarbonDataLoadingException {
    //TODO: only copy if it is bad record
    CarbonRow copy = row.getCopy();
    logHolder.setLogged(false);
    logHolder.clear();
    for (int i = 0; i < fieldConverters.length; i++) {
        fieldConverters[i].convert(row, logHolder);
        if (!logHolder.isLogged() && logHolder.isBadRecordNotAdded()) {
            if (badRecordLogger.isDataLoadFail()) {
                String error = "Data load failed due to bad record: " + logHolder.getReason();
                throw new CarbonDataLoadingException(error);
            }
            badRecordLogger.addBadRecordsToBuilder(copy.getData(), logHolder.getReason());
            logHolder.clear();
            logHolder.setLogged(true);
            if (badRecordLogger.isBadRecordConvertNullDisable()) {
                return null;
            }
        }
    }
    return row;
}
Also used : CarbonDataLoadingException(org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException) CarbonRow(org.apache.carbondata.processing.newflow.row.CarbonRow)

Example 14 with CarbonDataLoadingException

use of org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException in project carbondata by apache.

the class CSVRecordReaderIterator method next.

@Override
public Object[] next() {
    try {
        String[] data = recordReader.getCurrentValue().get();
        isConsumed = false;
        return data;
    } catch (Exception e) {
        throw new CarbonDataLoadingException(e);
    }
}
Also used : CarbonDataLoadingException(org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException) IOException(java.io.IOException) CarbonDataLoadingException(org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException)

Example 15 with CarbonDataLoadingException

use of org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException in project carbondata by apache.

the class CarbonRowDataWriterProcessorStepImpl method processBatch.

private void processBatch(CarbonRowBatch batch, CarbonFactHandler dataHandler, int iteratorIndex) throws CarbonDataLoadingException {
    try {
        while (batch.hasNext()) {
            CarbonRow row = batch.next();
            CarbonRow converted = convertRow(row);
            dataHandler.addDataToStore(converted);
            readCounter[iteratorIndex]++;
        }
        writeCounter[iteratorIndex] += batch.getSize();
    } catch (Exception e) {
        throw new CarbonDataLoadingException("unable to generate the mdkey", e);
    }
    rowCounter.getAndAdd(batch.getSize());
}
Also used : CarbonDataLoadingException(org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException) CarbonRow(org.apache.carbondata.processing.newflow.row.CarbonRow) KeyGenException(org.apache.carbondata.core.keygenerator.KeyGenException) CarbonDataWriterException(org.apache.carbondata.processing.store.writer.exception.CarbonDataWriterException) IOException(java.io.IOException) CarbonDataLoadingException(org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException)

Aggregations

CarbonDataLoadingException (org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException)20 Iterator (java.util.Iterator)9 CarbonSortKeyAndGroupByException (org.apache.carbondata.processing.sortandgroupby.exception.CarbonSortKeyAndGroupByException)8 CarbonDataWriterException (org.apache.carbondata.processing.store.writer.exception.CarbonDataWriterException)8 IOException (java.io.IOException)6 CarbonIterator (org.apache.carbondata.common.CarbonIterator)5 CarbonRow (org.apache.carbondata.processing.newflow.row.CarbonRow)5 CarbonRowBatch (org.apache.carbondata.processing.newflow.row.CarbonRowBatch)4 CarbonTableIdentifier (org.apache.carbondata.core.metadata.CarbonTableIdentifier)3 CarbonFactDataHandlerModel (org.apache.carbondata.processing.store.CarbonFactDataHandlerModel)3 KeyGenException (org.apache.carbondata.core.keygenerator.KeyGenException)2 UnsafeSortDataRows (org.apache.carbondata.processing.newflow.sort.unsafe.UnsafeSortDataRows)2 SortDataRows (org.apache.carbondata.processing.sortandgroupby.sortdata.SortDataRows)2 SortParameters (org.apache.carbondata.processing.sortandgroupby.sortdata.SortParameters)2 CarbonFactHandler (org.apache.carbondata.processing.store.CarbonFactHandler)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataOutputStream (java.io.DataOutputStream)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1 DictionaryGenerationException (org.apache.carbondata.core.devapi.DictionaryGenerationException)1