~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/sort.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-03-21 23:37:41 UTC
  • mto: (960.5.2 mordred)
  • mto: This revision was merged to the branch mainline in revision 961.
  • Revision ID: osullivan.padraig@gmail.com-20090321233741-vi96ytbnmc69hjq8
Adding a function object to be used as the comparison parameter for the
priority queue.

Show diffs side-by-side

added added

removed removed

Lines of Context:
861
861
  return my_b_write(to_file, key, (size_t) sort_length*count);
862
862
}
863
863
 
 
864
class compare_functor
 
865
{
 
866
  qsort2_cmp key_compare;
 
867
  void *key_compare_arg;
 
868
  public:
 
869
  compare_functor(qsort2_cmp in_key_compare, void *in_compare_arg)
 
870
    : key_compare(in_key_compare), key_compare_arg(in_compare_arg) { }
 
871
  inline bool operator()(const BUFFPEK *i, const BUFFPEK *j) const
 
872
  {
 
873
    int val= key_compare(key_compare_arg,
 
874
                      &i->key, &j->key);
 
875
    return (val >= 0);
 
876
  }
 
877
};
 
878
 
864
879
/*
865
880
  Merge buffers to one buffer
866
881
  If to_file == 0 then use info->key_write
877
892
  my_off_t to_start_filepos= 0;
878
893
  unsigned char *strpos;
879
894
  BUFFPEK *buffpek,**refpek;
880
 
  priority_queue<BUFFPEK *, vector<BUFFPEK *>, info->keycmp> queue;
 
895
  priority_queue<BUFFPEK *, vector<BUFFPEK *>, compare_functor > 
 
896
    queue(compare_functor(info->key_cmp, info));
881
897
  volatile int *killed= killed_ptr(info->sort_info->param);
882
898
 
883
899
  count=error=0;