Search in sources :

Example 21 with CarbonSortKeyAndGroupByException

use of org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException in project carbondata by apache.

the class UnsafeSortDataRows method addBatch.

private void addBatch(Object[][] rowBatch, int size) throws CarbonSortKeyAndGroupByException {
    for (int i = 0; i < size; i++) {
        if (rowPage.canAdd()) {
            bytesAdded += rowPage.addRow(rowBatch[i], rowBuffer.get());
        } else {
            try {
                if (enableInMemoryIntermediateMerge) {
                    unsafeInMemoryIntermediateFileMerger.startInmemoryMergingIfPossible();
                }
                unsafeInMemoryIntermediateFileMerger.startFileMergingIfPossible();
                semaphore.acquire();
                dataSorterAndWriterExecutorService.execute(new DataSorterAndWriter(rowPage));
                rowPage = createUnsafeRowPage();
                bytesAdded += rowPage.addRow(rowBatch[i], rowBuffer.get());
            } catch (Exception e) {
                LOGGER.error("exception occurred while trying to acquire a semaphore lock: " + e.getMessage());
                throw new CarbonSortKeyAndGroupByException(e);
            }
        }
    }
}
Also used : CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException) CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException) MemoryException(org.apache.carbondata.core.memory.MemoryException) IOException(java.io.IOException)

Example 22 with CarbonSortKeyAndGroupByException

use of org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException in project carbondata by apache.

the class UnsafeSortDataRows method addRow.

/**
 * This method will be used to add new row
 */
public void addRow(Object[] row) throws CarbonSortKeyAndGroupByException {
    // sort the list and then write current list data to file
    if (rowPage.canAdd()) {
        rowPage.addRow(row, rowBuffer.get());
    } else {
        try {
            if (enableInMemoryIntermediateMerge) {
                unsafeInMemoryIntermediateFileMerger.startInmemoryMergingIfPossible();
            }
            unsafeInMemoryIntermediateFileMerger.startFileMergingIfPossible();
            semaphore.acquire();
            dataSorterAndWriterExecutorService.submit(new DataSorterAndWriter(rowPage));
            rowPage = createUnsafeRowPage();
            rowPage.addRow(row, rowBuffer.get());
        } catch (Exception e) {
            LOGGER.error("exception occurred while trying to acquire a semaphore lock: " + e.getMessage());
            throw new CarbonSortKeyAndGroupByException(e);
        }
    }
}
Also used : CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException) CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException) MemoryException(org.apache.carbondata.core.memory.MemoryException) IOException(java.io.IOException)

Example 23 with CarbonSortKeyAndGroupByException

use of org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException in project carbondata by apache.

the class IntermediateFileMerger method initialize.

/**
 * This method is responsible for initializing the out stream
 *
 * @throws CarbonSortKeyAndGroupByException
 */
private void initialize() throws CarbonSortKeyAndGroupByException {
    try {
        stream = FileFactory.getDataOutputStream(outPutFile.getPath(), FileFactory.FileType.LOCAL, writeBufferSize, compressorName);
        this.stream.writeInt(this.totalNumberOfRecords);
    } catch (FileNotFoundException e) {
        throw new CarbonSortKeyAndGroupByException("Problem while getting the file", e);
    } catch (IOException e) {
        throw new CarbonSortKeyAndGroupByException("Problem while writing the data to file", e);
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException) IOException(java.io.IOException)

Aggregations

CarbonSortKeyAndGroupByException (org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException)23 IOException (java.io.IOException)12 CarbonDataWriterException (org.apache.carbondata.core.datastore.exception.CarbonDataWriterException)7 CarbonDataLoadingException (org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException)5 FileNotFoundException (java.io.FileNotFoundException)3 Iterator (java.util.Iterator)3 CarbonIterator (org.apache.carbondata.common.CarbonIterator)3 MemoryException (org.apache.carbondata.core.memory.MemoryException)3 SortDataRows (org.apache.carbondata.processing.sort.sortdata.SortDataRows)3 DataOutputStream (java.io.DataOutputStream)2 CarbonRow (org.apache.carbondata.core.datastore.row.CarbonRow)2 CarbonThreadFactory (org.apache.carbondata.core.util.CarbonThreadFactory)2 CarbonRowBatch (org.apache.carbondata.processing.loading.row.CarbonRowBatch)2 SortIntermediateFileMerger (org.apache.carbondata.processing.sort.sortdata.SortIntermediateFileMerger)2 File (java.io.File)1 Callable (java.util.concurrent.Callable)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)1 RawResultIterator (org.apache.carbondata.core.scan.result.iterator.RawResultIterator)1