~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/opt_range.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-03-21 01:02:23 UTC
  • mto: (960.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 961.
  • Revision ID: osullivan.padraig@gmail.com-20090321010223-j8cph7eeyt1u3xol
Fixed function object to ensure it correctly returns a boolean type since
memcmp returns an integer. Added some more comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1485
1485
  session_param->mem_root= &alloc;
1486
1486
}
1487
1487
 
 
1488
/*
 
1489
 * Function object that is used as the comparison function
 
1490
 * for the priority queue in the QUICK_ROR_UNION_SELECT
 
1491
 * class.
 
1492
 */
 
1493
class compare_functor
 
1494
{
 
1495
  QUICK_ROR_UNION_SELECT *self;
 
1496
  public:
 
1497
  compare_functor(QUICK_ROR_UNION_SELECT *in_arg)
 
1498
    : self(in_arg) { }
 
1499
  inline bool operator()(const QUICK_SELECT_I *i, const QUICK_SELECT_I *j) const
 
1500
  {
 
1501
    int val= self->head->file->cmp_ref(i->last_rowid,
 
1502
                                       j->last_rowid);
 
1503
    return (val >= 0);
 
1504
  }
 
1505
};
1488
1506
 
1489
1507
/*
1490
1508
  Do post-constructor initialization.
1498
1516
 
1499
1517
int QUICK_ROR_UNION_SELECT::init()
1500
1518
{
 
1519
  queue= 
 
1520
    new priority_queue<QUICK_SELECT_I *, vector<QUICK_SELECT_I *>, compare_functor >(compare_functor(this));
1501
1521
  if (!(cur_rowid= (unsigned char*) alloc_root(&alloc, 2*head->file->ref_length)))
1502
1522
    return 0;
1503
1523
  prev_rowid= cur_rowid + head->file->ref_length;
1549
1569
    }
1550
1570
    scans_inited= true;
1551
1571
  }
1552
 
  while (!queue.empty())
1553
 
    queue.pop();
 
1572
  while (!queue->empty())
 
1573
    queue->pop();
1554
1574
  /*
1555
1575
    Initialize scans for merged quick selects and put all merged quick
1556
1576
    selects into the queue.
1567
1587
      return(error);
1568
1588
    }
1569
1589
    quick->save_last_pos();
1570
 
    queue.insert(quick);
 
1590
    queue->push(quick);
1571
1591
  }
1572
1592
 
1573
1593
  if (head->file->ha_rnd_init(1))
1587
1607
 
1588
1608
QUICK_ROR_UNION_SELECT::~QUICK_ROR_UNION_SELECT()
1589
1609
{
1590
 
  while (!queue.empty())
1591
 
    queue.pop();
 
1610
  while (!queue->empty())
 
1611
    queue->pop();
 
1612
  delete queue;
1592
1613
  quick_selects.delete_elements();
1593
1614
  if (head->file->inited != handler::NONE)
1594
1615
    head->file->ha_rnd_end();
7053
7074
  {
7054
7075
    do
7055
7076
    {
7056
 
      if (queue.empty())
 
7077
      if (queue->empty())
7057
7078
        return(HA_ERR_END_OF_FILE);
7058
7079
      /* Ok, we have a queue with >= 1 scans */
7059
7080
 
7060
 
      quick= queue.top();
 
7081
      quick= queue->top();
7061
7082
      memcpy(cur_rowid, quick->last_rowid, rowid_length);
7062
7083
 
7063
7084
      /* put into queue rowid from the same stream as top element */
7065
7086
      {
7066
7087
        if (error != HA_ERR_END_OF_FILE)
7067
7088
          return(error);
7068
 
        queue.pop();
 
7089
        queue->pop();
7069
7090
      }
7070
7091
      else
7071
7092
      {
7072
7093
        quick->save_last_pos();
7073
 
        queue.pop();
7074
 
        queue.push(quick);
 
7094
        queue->pop();
 
7095
        queue->push(quick);
7075
7096
      }
7076
7097
 
7077
7098
      if (!have_prev_rowid)