Search in sources :

Example 6 with CarbonRow

use of org.apache.carbondata.processing.newflow.row.CarbonRow 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 7 with CarbonRow

use of org.apache.carbondata.processing.newflow.row.CarbonRow 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)

Example 8 with CarbonRow

use of org.apache.carbondata.processing.newflow.row.CarbonRow in project carbondata by apache.

the class DataConverterProcessorWithBucketingStepImpl method processRowBatch.

/**
   * Process the batch of rows as per the step logic.
   *
   * @param rowBatch
   * @return processed row.
   */
protected CarbonRowBatch processRowBatch(CarbonRowBatch rowBatch, RowConverter localConverter) {
    CarbonRowBatch newBatch = new CarbonRowBatch(rowBatch.getSize());
    while (rowBatch.hasNext()) {
        CarbonRow next = rowBatch.next();
        short bucketNumber = (short) partitioner.getPartition(next.getData());
        CarbonRow convertRow = localConverter.convert(next);
        convertRow.bucketNumber = bucketNumber;
        newBatch.addRow(convertRow);
    }
    rowCounter.getAndAdd(newBatch.getSize());
    return newBatch;
}
Also used : CarbonRowBatch(org.apache.carbondata.processing.newflow.row.CarbonRowBatch) CarbonRow(org.apache.carbondata.processing.newflow.row.CarbonRow)

Example 9 with CarbonRow

use of org.apache.carbondata.processing.newflow.row.CarbonRow in project carbondata by apache.

the class CompactionResultSortProcessor method readAndLoadDataFromSortTempFiles.

/**
   * This method will read sort temp files, perform merge sort and add it to store for data loading
   */
private void readAndLoadDataFromSortTempFiles() throws Exception {
    try {
        intermediateFileMerger.finish();
        finalMerger.startFinalMerge();
        while (finalMerger.hasNext()) {
            Object[] row = finalMerger.next();
            dataHandler.addDataToStore(new CarbonRow(row));
        }
        dataHandler.finish();
    } catch (CarbonDataWriterException e) {
        LOGGER.error(e);
        throw new Exception("Problem loading data during compaction: " + e.getMessage());
    } catch (Exception e) {
        LOGGER.error(e);
        throw new Exception("Problem loading data during compaction: " + e.getMessage());
    } finally {
        if (null != dataHandler) {
            try {
                dataHandler.closeHandler();
            } catch (CarbonDataWriterException e) {
                LOGGER.error(e);
                throw new Exception("Problem loading data during compaction: " + e.getMessage());
            }
        }
    }
}
Also used : CarbonRow(org.apache.carbondata.processing.newflow.row.CarbonRow) CarbonDataWriterException(org.apache.carbondata.processing.store.writer.exception.CarbonDataWriterException) CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sortandgroupby.exception.CarbonSortKeyAndGroupByException) CarbonDataWriterException(org.apache.carbondata.processing.store.writer.exception.CarbonDataWriterException) IOException(java.io.IOException)

Aggregations

CarbonRow (org.apache.carbondata.processing.newflow.row.CarbonRow)9 CarbonDataLoadingException (org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException)5 CarbonDataWriterException (org.apache.carbondata.processing.store.writer.exception.CarbonDataWriterException)5 IOException (java.io.IOException)3 CarbonRowBatch (org.apache.carbondata.processing.newflow.row.CarbonRowBatch)3 CarbonSortKeyAndGroupByException (org.apache.carbondata.processing.sortandgroupby.exception.CarbonSortKeyAndGroupByException)3 Iterator (java.util.Iterator)2 CarbonIterator (org.apache.carbondata.common.CarbonIterator)2 BitSet (java.util.BitSet)1 IndexStorage (org.apache.carbondata.core.datastore.columnar.IndexStorage)1 FixLengthColumnPage (org.apache.carbondata.core.datastore.page.FixLengthColumnPage)1 KeyGenException (org.apache.carbondata.core.keygenerator.KeyGenException)1 NodeHolder (org.apache.carbondata.core.util.NodeHolder)1 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