Search in sources :

Example 1 with MemoryException

use of org.apache.carbondata.core.memory.MemoryException in project carbondata by apache.

the class MinMaxIndexDataMapFactory method getDataMaps.

/**
 * getDataMaps Factory method Initializes the Min Max Data Map and returns.
 *
 * @param segment
 * @return
 * @throws IOException
 */
@Override
public List<CoarseGrainDataMap> getDataMaps(Segment segment) throws IOException {
    List<CoarseGrainDataMap> dataMapList = new ArrayList<>();
    // Form a dataMap of Type MinMaxIndexDataMap.
    MinMaxIndexDataMap dataMap = new MinMaxIndexDataMap();
    try {
        dataMap.init(new DataMapModel(CarbonTablePath.getSegmentPath(identifier.getTablePath(), segment.getSegmentNo())));
    } catch (MemoryException ex) {
        throw new IOException(ex);
    }
    dataMapList.add(dataMap);
    return dataMapList;
}
Also used : MemoryException(org.apache.carbondata.core.memory.MemoryException) DataMapModel(org.apache.carbondata.core.datamap.dev.DataMapModel) CoarseGrainDataMap(org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 2 with MemoryException

use of org.apache.carbondata.core.memory.MemoryException in project carbondata by apache.

the class UnsafeParallelReadMergeSorterImpl method sort.

@Override
public Iterator<CarbonRowBatch>[] sort(Iterator<CarbonRowBatch>[] iterators) throws CarbonDataLoadingException {
    int inMemoryChunkSizeInMB = CarbonProperties.getInstance().getSortMemoryChunkSizeInMB();
    UnsafeSortDataRows sortDataRow = new UnsafeSortDataRows(sortParameters, unsafeIntermediateFileMerger, inMemoryChunkSizeInMB);
    final int batchSize = CarbonProperties.getInstance().getBatchSize();
    try {
        sortDataRow.initialize();
    } catch (MemoryException e) {
        throw new CarbonDataLoadingException(e);
    }
    this.executorService = Executors.newFixedThreadPool(iterators.length, new CarbonThreadFactory("UnsafeParallelSorterPool:" + sortParameters.getTableName()));
    this.threadStatusObserver = new ThreadStatusObserver(executorService);
    try {
        for (int i = 0; i < iterators.length; i++) {
            executorService.execute(new SortIteratorThread(iterators[i], sortDataRow, batchSize, rowCounter, this.threadStatusObserver));
        }
        executorService.shutdown();
        executorService.awaitTermination(2, TimeUnit.DAYS);
        processRowToNextStep(sortDataRow, sortParameters);
    } catch (Exception e) {
        checkError();
        throw new CarbonDataLoadingException("Problem while shutdown the server ", e);
    }
    checkError();
    try {
        unsafeIntermediateFileMerger.finish();
        List<UnsafeCarbonRowPage> rowPages = unsafeIntermediateFileMerger.getRowPages();
        finalMerger.startFinalMerge(rowPages.toArray(new UnsafeCarbonRowPage[rowPages.size()]), unsafeIntermediateFileMerger.getMergedPages());
    } catch (CarbonDataWriterException e) {
        throw new CarbonDataLoadingException(e);
    } catch (CarbonSortKeyAndGroupByException e) {
        throw new CarbonDataLoadingException(e);
    }
    // Creates the iterator to read from merge sorter.
    Iterator<CarbonRowBatch> batchIterator = new CarbonIterator<CarbonRowBatch>() {

        @Override
        public boolean hasNext() {
            return finalMerger.hasNext();
        }

        @Override
        public CarbonRowBatch next() {
            int counter = 0;
            CarbonRowBatch rowBatch = new CarbonRowBatch(batchSize);
            while (finalMerger.hasNext() && counter < batchSize) {
                rowBatch.addRow(new CarbonRow(finalMerger.next()));
                counter++;
            }
            return rowBatch;
        }
    };
    return new Iterator[] { batchIterator };
}
Also used : CarbonRowBatch(org.apache.carbondata.processing.loading.row.CarbonRowBatch) CarbonDataLoadingException(org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException) CarbonRow(org.apache.carbondata.core.datastore.row.CarbonRow) UnsafeCarbonRowPage(org.apache.carbondata.processing.loading.sort.unsafe.UnsafeCarbonRowPage) CarbonDataWriterException(org.apache.carbondata.core.datastore.exception.CarbonDataWriterException) CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException) MemoryException(org.apache.carbondata.core.memory.MemoryException) CarbonDataLoadingException(org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException) CarbonDataWriterException(org.apache.carbondata.core.datastore.exception.CarbonDataWriterException) MemoryException(org.apache.carbondata.core.memory.MemoryException) CarbonIterator(org.apache.carbondata.common.CarbonIterator) CarbonThreadFactory(org.apache.carbondata.core.util.CarbonThreadFactory) CarbonIterator(org.apache.carbondata.common.CarbonIterator) Iterator(java.util.Iterator) CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException) UnsafeSortDataRows(org.apache.carbondata.processing.loading.sort.unsafe.UnsafeSortDataRows)

Example 3 with MemoryException

use of org.apache.carbondata.core.memory.MemoryException 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)

Example 4 with MemoryException

use of org.apache.carbondata.core.memory.MemoryException in project carbondata by apache.

the class BlockletDataMapIndexStore method get.

@Override
public BlockletDataMap get(TableBlockIndexUniqueIdentifier identifier) throws IOException {
    String lruCacheKey = identifier.getUniqueTableSegmentIdentifier();
    BlockletDataMap dataMap = (BlockletDataMap) lruCache.get(lruCacheKey);
    if (dataMap == null) {
        try {
            SegmentIndexFileStore indexFileStore = new SegmentIndexFileStore();
            Set<String> filesRead = new HashSet<>();
            Map<String, BlockMetaInfo> blockMetaInfoMap = getBlockMetaInfoMap(identifier, indexFileStore, filesRead);
            dataMap = loadAndGetDataMap(identifier, indexFileStore, blockMetaInfoMap);
        } catch (MemoryException e) {
            LOGGER.error("memory exception when loading datamap: " + e.getMessage());
            throw new RuntimeException(e.getMessage(), e);
        }
    }
    return dataMap;
}
Also used : MemoryException(org.apache.carbondata.core.memory.MemoryException) SegmentIndexFileStore(org.apache.carbondata.core.indexstore.blockletindex.SegmentIndexFileStore) BlockletDataMap(org.apache.carbondata.core.indexstore.blockletindex.BlockletDataMap) HashSet(java.util.HashSet)

Example 5 with MemoryException

use of org.apache.carbondata.core.memory.MemoryException in project carbondata by apache.

the class LuceneCoarseGrainDataMapFactory method getDataMaps.

/**
 * Get the datamap for segmentid
 */
@Override
public List<CoarseGrainDataMap> getDataMaps(Segment segment) throws IOException {
    List<CoarseGrainDataMap> lstDataMap = new ArrayList<>();
    CoarseGrainDataMap dataMap = new LuceneCoarseGrainDataMap(analyzer);
    try {
        dataMap.init(new DataMapModel(LuceneDataMapWriter.genDataMapStorePath(tableIdentifier.getTablePath(), segment.getSegmentNo(), dataMapName)));
    } catch (MemoryException e) {
        LOGGER.error("failed to get lucene datamap , detail is {}" + e.getMessage());
        return lstDataMap;
    }
    lstDataMap.add(dataMap);
    return lstDataMap;
}
Also used : MemoryException(org.apache.carbondata.core.memory.MemoryException) DataMapModel(org.apache.carbondata.core.datamap.dev.DataMapModel) CoarseGrainDataMap(org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap) ArrayList(java.util.ArrayList)

Aggregations

MemoryException (org.apache.carbondata.core.memory.MemoryException)6 ArrayList (java.util.ArrayList)3 DataMapModel (org.apache.carbondata.core.datamap.dev.DataMapModel)3 Iterator (java.util.Iterator)2 CarbonIterator (org.apache.carbondata.common.CarbonIterator)2 CoarseGrainDataMap (org.apache.carbondata.core.datamap.dev.cgdatamap.CoarseGrainDataMap)2 CarbonDataLoadingException (org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException)2 UnsafeSortDataRows (org.apache.carbondata.processing.loading.sort.unsafe.UnsafeSortDataRows)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 ExecutorService (java.util.concurrent.ExecutorService)1 FineGrainDataMap (org.apache.carbondata.core.datamap.dev.fgdatamap.FineGrainDataMap)1 CarbonDataWriterException (org.apache.carbondata.core.datastore.exception.CarbonDataWriterException)1 CarbonRow (org.apache.carbondata.core.datastore.row.CarbonRow)1 BlockletDataMap (org.apache.carbondata.core.indexstore.blockletindex.BlockletDataMap)1 SegmentIndexFileStore (org.apache.carbondata.core.indexstore.blockletindex.SegmentIndexFileStore)1 CarbonThreadFactory (org.apache.carbondata.core.util.CarbonThreadFactory)1 CarbonRowBatch (org.apache.carbondata.processing.loading.row.CarbonRowBatch)1 UnsafeCarbonRowPage (org.apache.carbondata.processing.loading.sort.unsafe.UnsafeCarbonRowPage)1 UnsafeIntermediateMerger (org.apache.carbondata.processing.loading.sort.unsafe.merger.UnsafeIntermediateMerger)1