~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/range.cc

  • Committer: Padraig O'Sullivan
  • Date: 2010-01-26 19:00:26 UTC
  • mto: This revision was merged to the branch mainline in revision 1276.
  • Revision ID: osullivan.padraig@gmail.com-20100126190026-pb5ud5y13av4mvjp
Correcting the case of a number of classes in the optimizer to adhere to the coding standards. Also
removed the use of thr TRP acronym in places and instead replaced it with ReadPlan as TRP stands for
Table Read Plan.

Show diffs side-by-side

added added

removed removed

Lines of Context:
320
320
                                                  double read_time);
321
321
 
322
322
static
323
 
optimizer::TRP_ROR_INTERSECT *get_best_ror_intersect(const optimizer::Parameter *param,
324
 
                                                     SEL_TREE *tree,
325
 
                                                     double read_time,
326
 
                                                     bool *are_all_covering);
 
323
optimizer::RorIntersectReadPlan *get_best_ror_intersect(const optimizer::Parameter *param,
 
324
                                                        SEL_TREE *tree,
 
325
                                                        double read_time,
 
326
                                                        bool *are_all_covering);
327
327
 
328
328
static
329
 
optimizer::TRP_ROR_INTERSECT *get_best_covering_ror_intersect(optimizer::Parameter *param,
330
 
                                                              SEL_TREE *tree,
331
 
                                                              double read_time);
 
329
optimizer::RorIntersectReadPlan *get_best_covering_ror_intersect(optimizer::Parameter *param,
 
330
                                                                 SEL_TREE *tree,
 
331
                                                                 double read_time);
332
332
 
333
333
static
334
334
optimizer::TableReadPlan *get_best_disjunct_quick(optimizer::Parameter *param,
336
336
                                                  double read_time);
337
337
 
338
338
static
339
 
optimizer::TRP_GROUP_MIN_MAX *get_best_group_min_max(optimizer::Parameter *param, SEL_TREE *tree);
 
339
optimizer::GroupMinMaxReadPlan *get_best_group_min_max(optimizer::Parameter *param, SEL_TREE *tree);
340
340
 
341
341
static void print_sel_tree(optimizer::Parameter *param,
342
342
                           SEL_TREE *tree,
1005
1005
    }
1006
1006
 
1007
1007
    optimizer::TableReadPlan *best_trp= NULL;
1008
 
    optimizer::TRP_GROUP_MIN_MAX *group_trp= NULL;
 
1008
    optimizer::GroupMinMaxReadPlan *group_trp= NULL;
1009
1009
    double best_read_time= read_time;
1010
1010
 
1011
1011
    if (cond)
1052
1052
      if (tree->merges.is_empty())
1053
1053
      {
1054
1054
        optimizer::TRP_RANGE *range_trp= NULL;
1055
 
        optimizer::TRP_ROR_INTERSECT *rori_trp= NULL;
 
1055
        optimizer::RorIntersectReadPlan *rori_trp= NULL;
1056
1056
        bool can_build_covering= false;
1057
1057
 
1058
1058
        /* Get best 'range' plan and prepare data for making other plans */
1209
1209
                                                  double read_time)
1210
1210
{
1211
1211
  SEL_TREE **ptree;
1212
 
  optimizer::TRP_INDEX_MERGE *imerge_trp= NULL;
 
1212
  optimizer::IndexMergeReadPlan *imerge_trp= NULL;
1213
1213
  uint32_t n_child_scans= imerge->trees_next - imerge->trees;
1214
1214
  optimizer::TRP_RANGE **range_scans= NULL;
1215
1215
  optimizer::TRP_RANGE **cur_child= NULL;
1323
1323
                         param->session->variables.sortbuff_size);
1324
1324
  if (imerge_cost < read_time)
1325
1325
  {
1326
 
    if ((imerge_trp= new (param->mem_root) optimizer::TRP_INDEX_MERGE))
 
1326
    if ((imerge_trp= new (param->mem_root) optimizer::IndexMergeReadPlan))
1327
1327
    {
1328
1328
      imerge_trp->read_cost= imerge_cost;
1329
1329
      imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
1386
1386
    }
1387
1387
    else
1388
1388
      roru_index_costs +=
1389
 
        ((optimizer::TRP_ROR_INTERSECT*)(*cur_roru_plan))->index_scan_costs;
 
1389
        ((optimizer::RorIntersectReadPlan*)(*cur_roru_plan))->index_scan_costs;
1390
1390
    roru_total_records += (*cur_roru_plan)->records;
1391
1391
    roru_intersect_part *= (*cur_roru_plan)->records /
1392
1392
                           param->table->cursor->stats.records;
1954
1954
*/
1955
1955
 
1956
1956
static
1957
 
optimizer::TRP_ROR_INTERSECT *get_best_ror_intersect(const optimizer::Parameter *param,
1958
 
                                                     SEL_TREE *tree,
1959
 
                                                     double read_time,
1960
 
                                                     bool *are_all_covering)
 
1957
optimizer::RorIntersectReadPlan *get_best_ror_intersect(const optimizer::Parameter *param,
 
1958
                                                   SEL_TREE *tree,
 
1959
                                                   double read_time,
 
1960
                                                   bool *are_all_covering)
1961
1961
{
1962
1962
  uint32_t idx;
1963
1963
  double min_cost= DBL_MAX;
2080
2080
  }
2081
2081
 
2082
2082
  /* Ok, return ROR-intersect plan if we have found one */
2083
 
  optimizer::TRP_ROR_INTERSECT *trp= NULL;
 
2083
  optimizer::RorIntersectReadPlan *trp= NULL;
2084
2084
  if (min_cost < read_time && (cpk_scan_used || best_num > 1))
2085
2085
  {
2086
 
    if (! (trp= new (param->mem_root) optimizer::TRP_ROR_INTERSECT))
 
2086
    if (! (trp= new (param->mem_root) optimizer::RorIntersectReadPlan))
2087
2087
      return trp;
2088
2088
 
2089
2089
    if (! (trp->first_scan=
2141
2141
*/
2142
2142
 
2143
2143
static
2144
 
optimizer::TRP_ROR_INTERSECT *get_best_covering_ror_intersect(optimizer::Parameter *param,
2145
 
                                                              SEL_TREE *tree,
2146
 
                                                              double read_time)
 
2144
optimizer::RorIntersectReadPlan *get_best_covering_ror_intersect(optimizer::Parameter *param,
 
2145
                                                            SEL_TREE *tree,
 
2146
                                                            double read_time)
2147
2147
{
2148
2148
  ROR_SCAN_INFO **ror_scan_mark;
2149
2149
  ROR_SCAN_INFO **ror_scans_end= tree->ror_scans_end;
2233
2233
  if (total_cost > read_time)
2234
2234
    return NULL;
2235
2235
 
2236
 
  optimizer::TRP_ROR_INTERSECT *trp= NULL;
2237
 
  if (! (trp= new (param->mem_root) optimizer::TRP_ROR_INTERSECT))
 
2236
  optimizer::RorIntersectReadPlan *trp= NULL;
 
2237
  if (! (trp= new (param->mem_root) optimizer::RorIntersectReadPlan))
2238
2238
  {
2239
2239
    return trp;
2240
2240
  }
2358
2358
}
2359
2359
 
2360
2360
 
2361
 
optimizer::QuickSelectInterface *optimizer::TRP_INDEX_MERGE::make_quick(optimizer::Parameter *param, bool, memory::Root *)
 
2361
optimizer::QuickSelectInterface *optimizer::IndexMergeReadPlan::make_quick(optimizer::Parameter *param, bool, memory::Root *)
2362
2362
{
2363
2363
  optimizer::QuickIndexMergeSelect *quick_imerge;
2364
2364
  optimizer::QuickRangeSelect *quick= NULL;
2386
2386
  return quick_imerge;
2387
2387
}
2388
2388
 
2389
 
optimizer::QuickSelectInterface *optimizer::TRP_ROR_INTERSECT::make_quick(optimizer::Parameter *param,
2390
 
                                                                          bool retrieve_full_rows,
2391
 
                                                                          memory::Root *parent_alloc)
 
2389
optimizer::QuickSelectInterface *optimizer::RorIntersectReadPlan::make_quick(optimizer::Parameter *param,
 
2390
                                                                             bool retrieve_full_rows,
 
2391
                                                                             memory::Root *parent_alloc)
2392
2392
{
2393
2393
  optimizer::QuickRorIntersectSelect *quick_intersect= NULL;
2394
2394
  optimizer::QuickRangeSelect *quick= NULL;
5350
5350
 
5351
5351
  RETURN
5352
5352
    If mem_root != NULL
5353
 
    - valid TRP_GROUP_MIN_MAX object if this QUICK class can be used for
 
5353
    - valid GroupMinMaxReadPlan object if this QUICK class can be used for
5354
5354
      the query
5355
5355
    -  NULL o/w.
5356
5356
    If mem_root == NULL
5357
5357
    - NULL
5358
5358
*/
5359
 
static optimizer::TRP_GROUP_MIN_MAX *
 
5359
static optimizer::GroupMinMaxReadPlan *
5360
5360
get_best_group_min_max(optimizer::Parameter *param, SEL_TREE *tree)
5361
5361
{
5362
5362
  Session *session= param->session;
5373
5373
  uint32_t used_key_parts= 0;   /* Number of index key parts used for access. */
5374
5374
  unsigned char key_infix[MAX_KEY_LENGTH]; /* Constants from equality predicates.*/
5375
5375
  uint32_t key_infix_len= 0;          /* Length of key_infix. */
5376
 
  optimizer::TRP_GROUP_MIN_MAX *read_plan= NULL; /* The eventually constructed TRP. */
 
5376
  optimizer::GroupMinMaxReadPlan *read_plan= NULL; /* The eventually constructed TRP. */
5377
5377
  uint32_t key_part_nr;
5378
5378
  order_st *tmp_group= NULL;
5379
5379
  Item *item= NULL;
5772
5772
 
5773
5773
  /* The query passes all tests, so construct a new TRP object. */
5774
5774
  read_plan=
5775
 
    new(param->mem_root) optimizer::TRP_GROUP_MIN_MAX(have_min,
5776
 
                                                      have_max,
5777
 
                                                      min_max_arg_part,
5778
 
                                                      group_prefix_len,
5779
 
                                                      used_key_parts,
5780
 
                                                      group_key_parts,
5781
 
                                                      index_info,
5782
 
                                                      index,
5783
 
                                                      key_infix_len,
5784
 
                                                      (key_infix_len > 0) ? key_infix : NULL,
5785
 
                                                      tree,
5786
 
                                                      best_index_tree,
5787
 
                                                      best_param_idx,
5788
 
                                                      best_quick_prefix_records);
 
5775
    new(param->mem_root) optimizer::GroupMinMaxReadPlan(have_min,
 
5776
                                                        have_max,
 
5777
                                                        min_max_arg_part,
 
5778
                                                        group_prefix_len,
 
5779
                                                        used_key_parts,
 
5780
                                                        group_key_parts,
 
5781
                                                        index_info,
 
5782
                                                        index,
 
5783
                                                        key_infix_len,
 
5784
                                                        (key_infix_len > 0) ? key_infix : NULL,
 
5785
                                                        tree,
 
5786
                                                        best_index_tree,
 
5787
                                                        best_param_idx,
 
5788
                                                        best_quick_prefix_records);
5789
5789
  if (read_plan)
5790
5790
  {
5791
5791
    if (tree && read_plan->quick_prefix_records == 0)
6117
6117
    records             [out] The number of rows retrieved
6118
6118
 
6119
6119
  DESCRIPTION
6120
 
    This method computes the access cost of a TRP_GROUP_MIN_MAX instance and
 
6120
    This method computes the access cost of a GroupMinMaxReadPlan instance and
6121
6121
    the number of rows returned. It updates this->read_cost and this->records.
6122
6122
 
6123
6123
  NOTES
6241
6241
  Construct a new quick select object for queries with group by with min/max.
6242
6242
 
6243
6243
  SYNOPSIS
6244
 
    TRP_GROUP_MIN_MAX::make_quick()
 
6244
    GroupMinMaxReadPlan::make_quick()
6245
6245
    param              Parameter from test_quick_select
6246
6246
    retrieve_full_rows ignored
6247
6247
    parent_alloc       Memory pool to use, if any.
6258
6258
    NULL otherwise.
6259
6259
*/
6260
6260
optimizer::QuickSelectInterface *
6261
 
optimizer::TRP_GROUP_MIN_MAX::make_quick(optimizer::Parameter *param, bool, memory::Root *parent_alloc)
 
6261
optimizer::GroupMinMaxReadPlan::make_quick(optimizer::Parameter *param, bool, memory::Root *parent_alloc)
6262
6262
{
6263
6263
  optimizer::QuickGroupMinMaxSelect *quick= NULL;
6264
6264