Search in sources :

Example 11 with CarbonSortKeyAndGroupByException

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

the class UnsafeIntermediateFileMerger method initialize.

/**
   * This method is responsible for initializing the out stream
   *
   * @throws CarbonSortKeyAndGroupByException
   */
private void initialize() throws CarbonSortKeyAndGroupByException {
    if (!mergerParameters.isSortFileCompressionEnabled() && !mergerParameters.isPrefetch()) {
        try {
            this.stream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(outPutFile), mergerParameters.getFileWriteBufferSize()));
            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);
        }
    } else {
        writer = TempSortFileWriterFactory.getInstance().getTempSortFileWriter(mergerParameters.isSortFileCompressionEnabled(), mergerParameters.getDimColCount(), mergerParameters.getComplexDimColCount(), mergerParameters.getMeasureColCount(), mergerParameters.getNoDictionaryCount(), mergerParameters.getFileWriteBufferSize());
        writer.initiaize(outPutFile, totalNumberOfRecords);
    }
}
Also used : DataOutputStream(java.io.DataOutputStream) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sortandgroupby.exception.CarbonSortKeyAndGroupByException) IOException(java.io.IOException) BufferedOutputStream(java.io.BufferedOutputStream)

Example 12 with CarbonSortKeyAndGroupByException

use of org.apache.carbondata.processing.sortandgroupby.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 {
    if (!mergerParameters.isSortFileCompressionEnabled() && !mergerParameters.isPrefetch()) {
        try {
            this.stream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(outPutFile), mergerParameters.getFileWriteBufferSize()));
            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);
        }
    } else {
        writer = TempSortFileWriterFactory.getInstance().getTempSortFileWriter(mergerParameters.isSortFileCompressionEnabled(), mergerParameters.getDimColCount(), mergerParameters.getComplexDimColCount(), mergerParameters.getMeasureColCount(), mergerParameters.getNoDictionaryCount(), mergerParameters.getFileWriteBufferSize());
        writer.initiaize(outPutFile, totalNumberOfRecords);
        if (mergerParameters.isPrefetch()) {
            totalSize = mergerParameters.getBufferSize();
        } else {
            totalSize = mergerParameters.getSortTempFileNoOFRecordsInCompression();
        }
    }
}
Also used : DataOutputStream(java.io.DataOutputStream) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sortandgroupby.exception.CarbonSortKeyAndGroupByException) IOException(java.io.IOException) BufferedOutputStream(java.io.BufferedOutputStream)

Example 13 with CarbonSortKeyAndGroupByException

use of org.apache.carbondata.processing.sortandgroupby.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.sortandgroupby.exception.CarbonSortKeyAndGroupByException)

Example 14 with CarbonSortKeyAndGroupByException

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

the class AbstractTempSortFileWriter method initiaize.

/**
   * Below method will be used to initialize the stream and write the entry count
   */
@Override
public void initiaize(File file, int entryCount) throws CarbonSortKeyAndGroupByException {
    try {
        stream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file), writeBufferSize));
        stream.writeInt(entryCount);
    } catch (FileNotFoundException e1) {
        throw new CarbonSortKeyAndGroupByException(e1);
    } catch (IOException e) {
        throw new CarbonSortKeyAndGroupByException(e);
    }
}
Also used : DataOutputStream(java.io.DataOutputStream) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sortandgroupby.exception.CarbonSortKeyAndGroupByException) IOException(java.io.IOException) BufferedOutputStream(java.io.BufferedOutputStream)

Example 15 with CarbonSortKeyAndGroupByException

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

the class UnsafeSortDataRows method getMemoryBlock.

public static MemoryBlock getMemoryBlock(long size) throws CarbonSortKeyAndGroupByException {
    MemoryBlock baseBlock = null;
    int tries = 0;
    while (true && tries < 100) {
        baseBlock = UnsafeMemoryManager.INSTANCE.allocateMemory(size);
        if (baseBlock == null) {
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                throw new CarbonSortKeyAndGroupByException(e);
            }
        } else {
            break;
        }
        tries++;
    }
    if (baseBlock == null) {
        throw new CarbonSortKeyAndGroupByException("Not enough memory to create page");
    }
    return baseBlock;
}
Also used : MemoryBlock(org.apache.carbondata.core.memory.MemoryBlock) CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sortandgroupby.exception.CarbonSortKeyAndGroupByException)

Aggregations

CarbonSortKeyAndGroupByException (org.apache.carbondata.processing.sortandgroupby.exception.CarbonSortKeyAndGroupByException)30 IOException (java.io.IOException)17 DataOutputStream (java.io.DataOutputStream)7 CarbonDataWriterException (org.apache.carbondata.processing.store.writer.exception.CarbonDataWriterException)7 CarbonDataLoadingException (org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException)6 BufferedOutputStream (java.io.BufferedOutputStream)5 FileNotFoundException (java.io.FileNotFoundException)5 FileOutputStream (java.io.FileOutputStream)5 Iterator (java.util.Iterator)4 CarbonIterator (org.apache.carbondata.common.CarbonIterator)4 MemoryBlock (org.apache.carbondata.core.memory.MemoryBlock)3 SortDataRows (org.apache.carbondata.processing.sortandgroupby.sortdata.SortDataRows)3 SortParameters (org.apache.carbondata.processing.sortandgroupby.sortdata.SortParameters)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 DataType (org.apache.carbondata.core.metadata.datatype.DataType)2 CarbonRow (org.apache.carbondata.processing.newflow.row.CarbonRow)2 CarbonRowBatch (org.apache.carbondata.processing.newflow.row.CarbonRowBatch)2 UnsafeSortDataRows (org.apache.carbondata.processing.newflow.sort.unsafe.UnsafeSortDataRows)2 SortIntermediateFileMerger (org.apache.carbondata.processing.sortandgroupby.sortdata.SortIntermediateFileMerger)2 SortTempFileChunkHolder (org.apache.carbondata.processing.sortandgroupby.sortdata.SortTempFileChunkHolder)2