~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/opt_range.cc

  • Committer: Brian Aker
  • Date: 2009-02-21 00:18:15 UTC
  • Revision ID: brian@tangent.org-20090221001815-x20e8h71e984lvs1
Completion (?) of uint conversion.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1911
1911
 
1912
1912
  /* Table read plans are allocated on MEM_ROOT and are never deleted */
1913
1913
  static void *operator new(size_t size, MEM_ROOT *mem_root)
1914
 
  { return (void*) alloc_root(mem_root, (uint) size); }
 
1914
  { return (void*) alloc_root(mem_root, (uint32_t) size); }
1915
1915
  static void operator delete(void *, size_t)
1916
1916
    { TRASH(ptr, size); }
1917
1917
  static void operator delete(void *, MEM_ROOT *)
2594
2594
  }
2595
2595
 
2596
2596
  imerge_cost +=
2597
 
    Unique::get_use_cost(param->imerge_cost_buff, (uint)non_cpk_scan_records,
 
2597
    Unique::get_use_cost(param->imerge_cost_buff, (uint32_t)non_cpk_scan_records,
2598
2598
                         param->table->file->ref_length,
2599
2599
                         param->session->variables.sortbuff_size);
2600
2600
  if (imerge_cost < read_time)
4331
4331
get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field,
4332
4332
            KEY_PART *key_part, Item_func::Functype type,Item *value)
4333
4333
{
4334
 
  uint32_t maybe_null=(uint) field->real_maybe_null();
 
4334
  uint32_t maybe_null=(uint32_t) field->real_maybe_null();
4335
4335
  bool optimize_range;
4336
4336
  SEL_ARG *tree= 0;
4337
4337
  MEM_ROOT *alloc= param->mem_root;
6126
6126
    range->end_key.keypart_map= make_prev_keypart_map(cur->max_key_parts);
6127
6127
 
6128
6128
    if (!(cur->min_key_flag & ~NULL_RANGE) && !cur->max_key_flag &&
6129
 
        (uint)key_tree->part+1 == seq->param->table->key_info[seq->real_keyno].key_parts &&
 
6129
        (uint32_t)key_tree->part+1 == seq->param->table->key_info[seq->real_keyno].key_parts &&
6130
6130
        (seq->param->table->key_info[seq->real_keyno].flags & (HA_NOSAME)) ==
6131
6131
        HA_NOSAME &&
6132
6132
        range->start_key.length == range->end_key.length &&
6152
6152
    }
6153
6153
  }
6154
6154
  seq->param->range_count++;
6155
 
  seq->param->max_key_part=cmax(seq->param->max_key_part,(uint)key_tree->part);
 
6155
  seq->param->max_key_part=cmax(seq->param->max_key_part,(uint32_t)key_tree->part);
6156
6156
  return 0;
6157
6157
}
6158
6158
 
6427
6427
      key_tree->next_key_part->type == SEL_ARG::KEY_RANGE)
6428
6428
  {                                               // const key as prefix
6429
6429
    if ((tmp_min_key - min_key) == (tmp_max_key - max_key) &&
6430
 
         memcmp(min_key, max_key, (uint)(tmp_max_key - max_key))==0 &&
 
6430
         memcmp(min_key, max_key, (uint32_t)(tmp_max_key - max_key))==0 &&
6431
6431
         key_tree->min_flag==0 && key_tree->max_flag==0)
6432
6432
    {
6433
6433
      if (get_quick_keys(param,quick,key,key_tree->next_key_part,
6468
6468
  }
6469
6469
  if (flag == 0)
6470
6470
  {
6471
 
    uint32_t length= (uint) (tmp_min_key - param->min_key);
6472
 
    if (length == (uint) (tmp_max_key - param->max_key) &&
 
6471
    uint32_t length= (uint32_t) (tmp_min_key - param->min_key);
 
6472
    if (length == (uint32_t) (tmp_max_key - param->max_key) &&
6473
6473
        !memcmp(param->min_key,param->max_key,length))
6474
6474
    {
6475
6475
      KEY *table_key=quick->head->key_info+quick->index;
6480
6480
        if (!(table_key->flags & HA_NULL_PART_KEY) ||
6481
6481
            !null_part_in_key(key,
6482
6482
                              param->min_key,
6483
 
                              (uint) (tmp_min_key - param->min_key)))
 
6483
                              (uint32_t) (tmp_min_key - param->min_key)))
6484
6484
          flag|= UNIQUE_RANGE;
6485
6485
        else
6486
6486
          flag|= NULL_RANGE;
6490
6490
 
6491
6491
  /* Get range for retrieving rows in QUICK_SELECT::get_next */
6492
6492
  if (!(range= new QUICK_RANGE(param->min_key,
6493
 
                               (uint) (tmp_min_key - param->min_key),
 
6493
                               (uint32_t) (tmp_min_key - param->min_key),
6494
6494
                               min_part >=0 ? make_keypart_map(min_part) : 0,
6495
6495
                               param->max_key,
6496
 
                               (uint) (tmp_max_key - param->max_key),
 
6496
                               (uint32_t) (tmp_max_key - param->max_key),
6497
6497
                               max_part >=0 ? make_keypart_map(max_part) : 0,
6498
6498
                               flag)))
6499
6499
    return 1;                   // out of memory
6500
6500
 
6501
6501
  set_if_bigger(quick->max_used_key_length, range->min_length);
6502
6502
  set_if_bigger(quick->max_used_key_length, range->max_length);
6503
 
  set_if_bigger(quick->used_key_parts, (uint) key_tree->part+1);
 
6503
  set_if_bigger(quick->used_key_parts, (uint32_t) key_tree->part+1);
6504
6504
  if (insert_dynamic(&quick->ranges, (unsigned char*) &range))
6505
6505
    return 1;
6506
6506
 
6706
6706
    quick->mrr_flags |= HA_MRR_USE_DEFAULT_IMPL;
6707
6707
 
6708
6708
  quick->mrr_buf_size= session->variables.read_rnd_buff_size;
6709
 
  if (table->file->multi_range_read_info(quick->index, 1, (uint)records,
 
6709
  if (table->file->multi_range_read_info(quick->index, 1, (uint32_t)records,
6710
6710
                                         &quick->mrr_buf_size,
6711
6711
                                         &quick->mrr_flags, &cost))
6712
6712
    goto err;
8625
8625
  keys_per_block= (table->file->stats.block_size / 2 /
8626
8626
                   (index_info->key_length + table->file->ref_length)
8627
8627
                        + 1);
8628
 
  num_blocks= (uint)(table_records / keys_per_block) + 1;
 
8628
  num_blocks= (uint32_t)(table_records / keys_per_block) + 1;
8629
8629
 
8630
8630
  /* Compute the number of keys in a group. */
8631
8631
  keys_per_group= index_info->rec_per_key[group_key_parts - 1];
8632
8632
  if (keys_per_group == 0) /* If there is no statistics try to guess */
8633
8633
    /* each group contains 10% of all records */
8634
 
    keys_per_group= (uint)(table_records / 10) + 1;
8635
 
  num_groups= (uint)(table_records / keys_per_group) + 1;
 
8634
    keys_per_group= (uint32_t)(table_records / 10) + 1;
 
8635
  num_groups= (uint32_t)(table_records / keys_per_group) + 1;
8636
8636
 
8637
8637
  /* Apply the selectivity of the quick select for group prefixes. */
8638
8638
  if (range_tree && (quick_prefix_records != HA_POS_ERROR))
8639
8639
  {
8640
8640
    quick_prefix_selectivity= (double) quick_prefix_records /
8641
8641
                              (double) table_records;
8642
 
    num_groups= (uint) rint(num_groups * quick_prefix_selectivity);
 
8642
    num_groups= (uint32_t) rint(num_groups * quick_prefix_selectivity);
8643
8643
    set_if_bigger(num_groups, 1);
8644
8644
  }
8645
8645