~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:23:07 UTC
  • mto: (960.5.2 mordred)
  • mto: This revision was merged to the branch mainline in revision 961.
  • Revision ID: osullivan.padraig@gmail.com-20090321232307-ier1xqflczgp7r1v
Removed all traces of QUEUE from the codebase. We are using
std::priority_queue in MyISAM now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include "myisamdef.h"
22
22
#include <stddef.h>
 
23
#include <queue>
23
24
 
24
25
/* static variables */
25
26
 
33
34
#define MYF_RW  MYF(MY_NABP | MY_WME | MY_WAIT_IF_FULL)
34
35
#define DISK_BUFFER_SIZE (IO_SIZE*16)
35
36
 
 
37
using namespace std;
 
38
 
36
39
 
37
40
/*
38
41
 Pointers of functions for store and read keys from temp file
874
877
  my_off_t to_start_filepos= 0;
875
878
  unsigned char *strpos;
876
879
  BUFFPEK *buffpek,**refpek;
877
 
  QUEUE queue;
 
880
  priority_queue<BUFFPEK *, vector<BUFFPEK *>, info->keycmp> queue;
878
881
  volatile int *killed= killed_ptr(info->sort_info->param);
879
882
 
880
883
  count=error=0;
885
888
  strpos=(unsigned char*) sort_keys;
886
889
  sort_length=info->key_length;
887
890
 
888
 
 
889
 
  if (init_queue(&queue,(uint32_t) (Tb-Fb)+1,(uint32_t) offsetof(BUFFPEK,key),
890
 
                 false,
891
 
                 (queue_compare) info->key_cmp,
892
 
                 (void*) info))
893
 
    return(1); /* purecov: inspected */
894
 
 
895
891
  for (buffpek= Fb ; buffpek <= Tb ; buffpek++)
896
892
  {
897
893
    count+= buffpek->count;
901
897
                                                      sort_length));
902
898
    if (error == -1)
903
899
      goto err; /* purecov: inspected */
904
 
    queue_insert(&queue,(unsigned char*) buffpek);
 
900
    queue.push(buffpek);
905
901
  }
906
902
 
907
 
  while (queue.elements > 1)
 
903
  while (queue.size() > 1)
908
904
  {
909
905
    for (;;)
910
906
    {
912
908
      {
913
909
        error=1; goto err;
914
910
      }
915
 
      buffpek=(BUFFPEK*) queue_top(&queue);
 
911
      buffpek= queue.top();
916
912
      if (to_file)
917
913
      {
918
914
        if (info->write_key(info,to_file,(unsigned char*) buffpek->key,
936
932
          unsigned char *base=buffpek->base;
937
933
          uint32_t max_keys=buffpek->max_keys;
938
934
 
939
 
          queue_remove(&queue,0);
 
935
          queue.pop();
940
936
 
941
937
          /* Put room used by buffer to use in other buffer */
942
938
          for (refpek= (BUFFPEK**) &queue_top(&queue);
961
957
      }
962
958
      else if (error == -1)
963
959
        goto err;               /* purecov: inspected */
964
 
      queue_replaced(&queue);   /* Top element has been replaced */
 
960
      /* Top element has been replaced */
 
961
      queue.pop();
 
962
      queue.push(buffpek);
965
963
    }
966
964
  }
967
 
  buffpek=(BUFFPEK*) queue_top(&queue);
 
965
  buffpek= queue.top();
968
966
  buffpek->base=(unsigned char *) sort_keys;
969
967
  buffpek->max_keys=keys;
970
968
  do
999
997
  if (to_file)
1000
998
    lastbuff->file_pos=to_start_filepos;
1001
999
err:
1002
 
  delete_queue(&queue);
1003
1000
  return(error);
1004
1001
} /* merge_buffers */
1005
1002