Search in sources :

Example 1 with UnsafeIntermediateMerger

use of org.apache.carbondata.processing.loading.sort.unsafe.merger.UnsafeIntermediateMerger in project carbondata by apache.

the class UnsafeParallelReadMergeSorterImpl method initialize.

@Override
public void initialize(SortParameters sortParameters) {
    this.sortParameters = sortParameters;
    unsafeIntermediateFileMerger = new UnsafeIntermediateMerger(sortParameters);
    finalMerger = new UnsafeSingleThreadFinalSortFilesMerger(sortParameters, sortParameters.getTempFileLocation());
}
Also used : UnsafeSingleThreadFinalSortFilesMerger(org.apache.carbondata.processing.loading.sort.unsafe.merger.UnsafeSingleThreadFinalSortFilesMerger) UnsafeIntermediateMerger(org.apache.carbondata.processing.loading.sort.unsafe.merger.UnsafeIntermediateMerger)

Example 2 with UnsafeIntermediateMerger

use of org.apache.carbondata.processing.loading.sort.unsafe.merger.UnsafeIntermediateMerger in project carbondata by apache.

the class UnsafeParallelReadMergeSorterWithColumnRangeImpl method sort.

@Override
public Iterator<CarbonRowBatch>[] sort(Iterator<CarbonRowBatch>[] iterators) throws CarbonDataLoadingException {
    UnsafeSortDataRows[] sortDataRows = new UnsafeSortDataRows[columnRangeInfo.getNumOfRanges()];
    intermediateFileMergers = new UnsafeIntermediateMerger[columnRangeInfo.getNumOfRanges()];
    SortParameters[] sortParameterArray = new SortParameters[columnRangeInfo.getNumOfRanges()];
    try {
        for (int i = 0; i < columnRangeInfo.getNumOfRanges(); i++) {
            SortParameters parameters = originSortParameters.getCopy();
            parameters.setPartitionID(i + "");
            parameters.setRangeId(i);
            sortParameterArray[i] = parameters;
            setTempLocation(parameters);
            intermediateFileMergers[i] = new UnsafeIntermediateMerger(parameters);
            sortDataRows[i] = new UnsafeSortDataRows(parameters, intermediateFileMergers[i], inMemoryChunkSizeInMB);
            sortDataRows[i].initialize();
        }
    } catch (MemoryException e) {
        throw new CarbonDataLoadingException(e);
    }
    ExecutorService executorService = Executors.newFixedThreadPool(iterators.length);
    this.threadStatusObserver = new ThreadStatusObserver(executorService);
    final int batchSize = CarbonProperties.getInstance().getBatchSize();
    try {
        for (int i = 0; i < iterators.length; i++) {
            executorService.execute(new SortIteratorThread(iterators[i], sortDataRows, rowCounter, this.insideRowCounterList, this.threadStatusObserver));
        }
        executorService.shutdown();
        executorService.awaitTermination(2, TimeUnit.DAYS);
        processRowToNextStep(sortDataRows, originSortParameters);
    } catch (Exception e) {
        checkError();
        throw new CarbonDataLoadingException("Problem while shutdown the server ", e);
    }
    checkError();
    try {
        for (int i = 0; i < intermediateFileMergers.length; i++) {
            intermediateFileMergers[i].finish();
        }
    } catch (Exception e) {
        throw new CarbonDataLoadingException(e);
    }
    Iterator<CarbonRowBatch>[] batchIterator = new Iterator[columnRangeInfo.getNumOfRanges()];
    for (int i = 0; i < sortDataRows.length; i++) {
        batchIterator[i] = new MergedDataIterator(sortParameterArray[i], batchSize, intermediateFileMergers[i]);
    }
    return batchIterator;
}
Also used : CarbonDataLoadingException(org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException) UnsafeIntermediateMerger(org.apache.carbondata.processing.loading.sort.unsafe.merger.UnsafeIntermediateMerger) MemoryException(org.apache.carbondata.core.memory.MemoryException) CarbonDataLoadingException(org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException) MemoryException(org.apache.carbondata.core.memory.MemoryException) SortParameters(org.apache.carbondata.processing.sort.sortdata.SortParameters) ExecutorService(java.util.concurrent.ExecutorService) CarbonIterator(org.apache.carbondata.common.CarbonIterator) Iterator(java.util.Iterator) UnsafeSortDataRows(org.apache.carbondata.processing.loading.sort.unsafe.UnsafeSortDataRows)

Aggregations

UnsafeIntermediateMerger (org.apache.carbondata.processing.loading.sort.unsafe.merger.UnsafeIntermediateMerger)2 Iterator (java.util.Iterator)1 ExecutorService (java.util.concurrent.ExecutorService)1 CarbonIterator (org.apache.carbondata.common.CarbonIterator)1 MemoryException (org.apache.carbondata.core.memory.MemoryException)1 CarbonDataLoadingException (org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException)1 UnsafeSortDataRows (org.apache.carbondata.processing.loading.sort.unsafe.UnsafeSortDataRows)1 UnsafeSingleThreadFinalSortFilesMerger (org.apache.carbondata.processing.loading.sort.unsafe.merger.UnsafeSingleThreadFinalSortFilesMerger)1 SortParameters (org.apache.carbondata.processing.sort.sortdata.SortParameters)1