Search in sources :

Example 6 with IntermediateSortTempRow

use of org.apache.carbondata.processing.loading.row.IntermediateSortTempRow in project carbondata by apache.

the class IntermediateSortTempRowComparatorTest method comparemixed.

@Test
public void comparemixed() {
    DataType[] noDicDataTypes = { DataTypes.BOOLEAN, DataTypes.INT, DataTypes.LONG };
    boolean[] noDicSortColumnMapping = { true };
    new_comparator = new IntermediateSortTempRowComparator(noDicSortColumnMapping, noDicDataTypes);
    int[] dictSortDims1 = { 1, 2, 3 };
    Object[] noDictSortDims1 = { true, 1, 2L };
    byte[] noSortDimsAndMeasures1 = { 1, 2, 3 };
    IntermediateSortTempRow a1 = new IntermediateSortTempRow(dictSortDims1, noDictSortDims1, noSortDimsAndMeasures1);
    int[] dictSortDims = { 1, 2, 3 };
    Object[] noDictSortDims = { false, 3, 5L };
    byte[] noSortDimsAndMeasures = { 1, 2, 3 };
    IntermediateSortTempRow a = new IntermediateSortTempRow(dictSortDims, noDictSortDims, noSortDimsAndMeasures);
    int res = new_comparator.compare(a1, a);
    Assert.assertTrue(res > 0);
}
Also used : DataType(org.apache.carbondata.core.metadata.datatype.DataType) IntermediateSortTempRow(org.apache.carbondata.processing.loading.row.IntermediateSortTempRow) Test(org.junit.Test)

Example 7 with IntermediateSortTempRow

use of org.apache.carbondata.processing.loading.row.IntermediateSortTempRow in project carbondata by apache.

the class IntermediateSortTempRowComparatorTest method compareint.

@Test
public void compareint() {
    DataType[] noDicDataTypes = { DataTypes.INT };
    boolean[] noDicSortColumnMapping = { true };
    new_comparator = new IntermediateSortTempRowComparator(noDicSortColumnMapping, noDicDataTypes);
    int[] dictSortDims1 = { 1, 2, 3 };
    Object[] noDictSortDims1 = { 1, 2, 3 };
    byte[] noSortDimsAndMeasures1 = { 1, 2, 3 };
    IntermediateSortTempRow a1 = new IntermediateSortTempRow(dictSortDims1, noDictSortDims1, noSortDimsAndMeasures1);
    int[] dictSortDims = { 1, 2, 3 };
    Object[] noDictSortDims = { 4, 5, 6 };
    byte[] noSortDimsAndMeasures = { 1, 2, 3 };
    IntermediateSortTempRow a = new IntermediateSortTempRow(dictSortDims, noDictSortDims, noSortDimsAndMeasures);
    int res = new_comparator.compare(a, a1);
    Assert.assertTrue(res > 0);
}
Also used : DataType(org.apache.carbondata.core.metadata.datatype.DataType) IntermediateSortTempRow(org.apache.carbondata.processing.loading.row.IntermediateSortTempRow) Test(org.junit.Test)

Example 8 with IntermediateSortTempRow

use of org.apache.carbondata.processing.loading.row.IntermediateSortTempRow in project carbondata by apache.

the class UnsafeCarbonRowPage method getRow.

/**
 * get one row from memory address
 * @param address address
 * @return one row
 */
public IntermediateSortTempRow getRow(long address) {
    if (convertNoSortFields) {
        IntermediateSortTempRow intermediateSortTempRow = sortStepRowHandler.readRowFromMemoryWithNoSortFieldConvert(dataBlock.getBaseObject(), address);
        this.sortTempRowUpdater.updateSortTempRow(intermediateSortTempRow);
        return intermediateSortTempRow;
    } else {
        return sortStepRowHandler.readFromMemoryWithoutNoSortFieldConvert(dataBlock.getBaseObject(), address);
    }
}
Also used : IntermediateSortTempRow(org.apache.carbondata.processing.loading.row.IntermediateSortTempRow)

Example 9 with IntermediateSortTempRow

use of org.apache.carbondata.processing.loading.row.IntermediateSortTempRow in project carbondata by apache.

the class UnsafeSortTempFileChunkHolder method readBatchedRowFromStream.

/**
 * get a batch of row, this interface is used in reading compressed sort temp files
 *
 * @param expected expected number in a batch
 * @return a batch of row
 * @throws IOException if error occurs while reading from stream
 */
private IntermediateSortTempRow[] readBatchedRowFromStream(int expected) throws IOException {
    IntermediateSortTempRow[] holders = new IntermediateSortTempRow[expected];
    for (int i = 0; i < expected; i++) {
        if (convertNoSortFields) {
            IntermediateSortTempRow intermediateSortTempRow = sortStepRowHandler.readWithNoSortFieldConvert(stream);
            sortTempRowUpdater.updateSortTempRow(intermediateSortTempRow);
            holders[i] = intermediateSortTempRow;
        } else {
            holders[i] = sortStepRowHandler.readWithoutNoSortFieldConvert(stream);
        }
    }
    this.numberOfObjectRead += expected;
    return holders;
}
Also used : IntermediateSortTempRow(org.apache.carbondata.processing.loading.row.IntermediateSortTempRow)

Example 10 with IntermediateSortTempRow

use of org.apache.carbondata.processing.loading.row.IntermediateSortTempRow in project carbondata by apache.

the class UnsafeSortTempFileChunkHolder method readRow.

/**
 * This method will be used to read new row from file
 *
 * @throws CarbonSortKeyAndGroupByException problem while reading
 */
@Override
public void readRow() throws CarbonSortKeyAndGroupByException {
    if (prefetch) {
        fillDataForPrefetch();
    } else {
        try {
            if (convertNoSortFields) {
                IntermediateSortTempRow intermediateSortTempRow = sortStepRowHandler.readWithNoSortFieldConvert(stream);
                sortTempRowUpdater.updateSortTempRow(intermediateSortTempRow);
                this.returnRow = intermediateSortTempRow;
            } else {
                this.returnRow = sortStepRowHandler.readWithoutNoSortFieldConvert(stream);
            }
            this.numberOfObjectRead++;
        } catch (IOException e) {
            throw new CarbonSortKeyAndGroupByException("Problems while reading row", e);
        }
    }
}
Also used : IntermediateSortTempRow(org.apache.carbondata.processing.loading.row.IntermediateSortTempRow) CarbonSortKeyAndGroupByException(org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException) IOException(java.io.IOException)

Aggregations

IntermediateSortTempRow (org.apache.carbondata.processing.loading.row.IntermediateSortTempRow)20 DataType (org.apache.carbondata.core.metadata.datatype.DataType)9 Test (org.junit.Test)9 CarbonSortKeyAndGroupByException (org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException)3 IOException (java.io.IOException)2 CarbonDataWriterException (org.apache.carbondata.core.datastore.exception.CarbonDataWriterException)2 SortTempChunkHolder (org.apache.carbondata.processing.loading.sort.unsafe.holder.SortTempChunkHolder)2 NoSuchElementException (java.util.NoSuchElementException)1 CarbonRow (org.apache.carbondata.core.datastore.row.CarbonRow)1 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)1