Search in sources :

Example 1 with UnsafeCarbonRowForMerge

use of org.apache.carbondata.processing.loading.sort.unsafe.holder.UnsafeCarbonRowForMerge in project carbondata by apache.

the class UnsafeInMemoryIntermediateDataMerger method getSortedRecordFromMemory.

/**
 * This method will be used to get the sorted record from file
 *
 * @return sorted record sorted record
 */
private UnsafeCarbonRowForMerge getSortedRecordFromMemory() {
    UnsafeCarbonRowForMerge 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)
    UnsafeInmemoryMergeHolder poll = this.recordHolderHeap.peek();
    // get the row from chunk
    row = poll.getRow();
    // check if there no entry present
    if (!poll.hasNext()) {
        // do not close the poll to free the memory of rowPage here
        // because data in memory will be used in final merge sort
        // and close in `UnsafeFinalMergePageHolder` in case of `spillDisk`
        // is false. Please refer method `writeDataToMemory` in this class
        this.recordHolderHeap.poll();
        // change the file counter
        --this.holderCounter;
        // return row
        return row;
    }
    // read new row
    poll.readRow();
    // maintain heap
    this.recordHolderHeap.siftTopDown();
    // return row
    return row;
}
Also used : UnsafeCarbonRowForMerge(org.apache.carbondata.processing.loading.sort.unsafe.holder.UnsafeCarbonRowForMerge) UnsafeInmemoryMergeHolder(org.apache.carbondata.processing.loading.sort.unsafe.holder.UnsafeInmemoryMergeHolder)

Aggregations

UnsafeCarbonRowForMerge (org.apache.carbondata.processing.loading.sort.unsafe.holder.UnsafeCarbonRowForMerge)1 UnsafeInmemoryMergeHolder (org.apache.carbondata.processing.loading.sort.unsafe.holder.UnsafeInmemoryMergeHolder)1