Class MSortTemplate

java.lang.Object
org.apache.drill.exec.physical.impl.xsort.MSortTemplate
All Implemented Interfaces:
MSorter, org.apache.hadoop.util.IndexedSortable

public abstract class MSortTemplate extends Object implements MSorter, org.apache.hadoop.util.IndexedSortable
  • Constructor Details

    • MSortTemplate

      public MSortTemplate()
  • Method Details

    • setup

      public void setup(FragmentContext context, BufferAllocator allocator, SelectionVector4 vector4, VectorContainer hyperBatch, int outputBatchSize, int desiredBatchSize) throws SchemaChangeException
      Specified by:
      setup in interface MSorter
      Throws:
      SchemaChangeException
    • memoryNeeded

      public static long memoryNeeded(int recordCount)
      For given recordCount how much memory does MSorter needs for its own purpose. This is used in ExternalSortBatch to make decisions about whether to spill or not.
    • merge

      protected int merge(int leftStart, int rightStart, int rightEnd, int outStart)
      Given two regions within the selection vector 4 (a left and a right), merge the two regions to produce a combined output region in the auxiliary selection vector.
    • getSV4

      public SelectionVector4 getSV4()
      Specified by:
      getSV4 in interface MSorter
    • sort

      public void sort()
      Merge a set of pre-sorted runs to produce a combined result set. Merging is done in the selection vector, record data does not move.

      Runs are merge pairwise in multiple passes, providing performance of O(n * m * log(n)), where n = number of runs, m = number of records per run.

      Specified by:
      sort in interface MSorter
    • swap

      public void swap(int sv0, int sv1)
      Specified by:
      swap in interface org.apache.hadoop.util.IndexedSortable
    • compare

      public int compare(int leftIndex, int rightIndex)
      Specified by:
      compare in interface org.apache.hadoop.util.IndexedSortable
    • clear

      public void clear()
      Specified by:
      clear in interface MSorter
    • doSetup

      public abstract void doSetup(@Named("context") FragmentContext context, @Named("incoming") VectorContainer incoming, @Named("outgoing") RecordBatch outgoing) throws SchemaChangeException
      Throws:
      SchemaChangeException
    • doEval

      public abstract int doEval(@Named("leftIndex") int leftIndex, @Named("rightIndex") int rightIndex) throws SchemaChangeException
      Throws:
      SchemaChangeException