Search in sources :

Example 16 with CarbonSortKeyAndGroupByException

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

the class SingleThreadFinalSortFilesMerger method getSortedRecordFromFile.

/**
 * This method will be used to get the sorted record from file
 *
 * @return sorted record sorted record
 * @throws CarbonSortKeyAndGroupByException
 */
private IntermediateSortTempRow getSortedRecordFromFile() throws CarbonDataWriterException {
    IntermediateSortTempRow row = null;
    // poll the top object from heap
    // heap maintains binary tree which is based on heap condition that will
    // be based on comparator we are passing the heap
    // when will call poll it will always delete root of the tree and then
    // it does trickel down operation complexity is log(n)
    SortTempFileChunkHolder poll = this.recordHolderHeapLocal.poll();
    // get the row from chunk
    row = poll.getRow();
    // check if there no entry present
    if (!poll.hasNext()) {
        // if chunk is empty then close the stream
        poll.closeStream();
        // change the file counter
        --this.fileCounter;
        // reaturn row
        return row;
    }
    // read new row
    try {
        poll.readRow();
    } catch (CarbonSortKeyAndGroupByException e) {
        close();
        throw new CarbonDataWriterException(e.getMessage(), e);
    }
    // add to heap
    this.recordHolderHeapLocal.add(poll);
    // return row
    return row;
}
Also used : IntermediateSortTempRow(org.apache.carbondata.processing.loading.row.IntermediateSortTempRow) CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException) CarbonDataWriterException(org.apache.carbondata.core.datastore.exception.CarbonDataWriterException)

Example 17 with CarbonSortKeyAndGroupByException

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

the class SortDataRows method addRow.

/**
 * This method will be used to add new row
 *
 * @param row new row
 * @throws CarbonSortKeyAndGroupByException problem while writing
 */
public void addRow(Object[] row) throws CarbonSortKeyAndGroupByException {
    // if record holder list size is equal to sort buffer size then it will
    // sort the list and then write current list data to file
    int currentSize = entryCount;
    if (sortBufferSize == currentSize) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("************ Writing to temp file ********** ");
        }
        intermediateFileMerger.startMergingIfPossible();
        Object[][] recordHolderListLocal = recordHolderList;
        try {
            semaphore.acquire();
            dataSorterAndWriterExecutorService.execute(new DataSorterAndWriter(recordHolderListLocal));
        } catch (InterruptedException e) {
            LOGGER.error(e, "exception occurred while trying to acquire a semaphore lock: ");
            throw new CarbonSortKeyAndGroupByException(e);
        }
        // create the new holder Array
        this.recordHolderList = new Object[this.sortBufferSize][];
        this.entryCount = 0;
    }
    recordHolderList[entryCount++] = row;
}
Also used : CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException)

Example 18 with CarbonSortKeyAndGroupByException

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

the class SortDataRows method startFileBasedMerge.

/**
 * Below method will be used to start file based merge
 *
 * @throws CarbonSortKeyAndGroupByException
 */
private void startFileBasedMerge() throws CarbonSortKeyAndGroupByException {
    try {
        dataSorterAndWriterExecutorService.shutdown();
        dataSorterAndWriterExecutorService.awaitTermination(2, TimeUnit.DAYS);
    } catch (InterruptedException e) {
        throw new CarbonSortKeyAndGroupByException("Problem while shutdown the server ", e);
    }
}
Also used : CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException)

Example 19 with CarbonSortKeyAndGroupByException

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

the class SortTempFileChunkHolder method initialise.

private void initialise() throws CarbonSortKeyAndGroupByException {
    try {
        stream = FileFactory.getDataInputStream(tempFile.getPath(), FileFactory.FileType.LOCAL, readBufferSize, compressorName);
        this.entryCount = stream.readInt();
        if (prefetch) {
            new DataFetcher(false).call();
            totalRecordFetch += currentBuffer.length;
            if (totalRecordFetch < this.entryCount) {
                submit = executorService.submit(new DataFetcher(true));
            }
        }
    } catch (FileNotFoundException e) {
        LOGGER.error(e);
        throw new CarbonSortKeyAndGroupByException(tempFile + " No Found", e);
    } catch (IOException e) {
        LOGGER.error(e);
        throw new CarbonSortKeyAndGroupByException(tempFile + " No Found", e);
    } catch (Exception e) {
        LOGGER.error(e);
        throw new CarbonSortKeyAndGroupByException(tempFile + " Problem while reading", e);
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException) IOException(java.io.IOException) CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 20 with CarbonSortKeyAndGroupByException

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

the class SortTempFileChunkHolder method readRow.

/**
 * This method will be used to read new row from file
 *
 * @throws CarbonSortKeyAndGroupByException problem while reading
 */
public void readRow() throws CarbonSortKeyAndGroupByException {
    if (prefetch) {
        fillDataForPrefetch();
    } else {
        try {
            this.returnRow = sortStepRowHandler.readIntermediateSortTempRowFromInputStream(stream);
            this.numberOfObjectRead++;
        } catch (IOException e) {
            throw new CarbonSortKeyAndGroupByException("Problem while reading rows", e);
        }
    }
}
Also used : 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