~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/opt_range.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-04-11 02:32:57 UTC
  • mto: (971.1.63 mordred)
  • mto: This revision was merged to the branch mainline in revision 990.
  • Revision ID: osullivan.padraig@gmail.com-20090411023257-2pz255xvtzfhrart
Added new functions for adding a bitset in a thread-safe way. I created a
class which simply consists of 2 class members: 1) a lock and 2) a
std::bitset.

Also, moved some helper functions to a separate new file (sql_bitmap.cc).

Nearly all instances of My_BITMAP are replaced now. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
    return static_cast<ha_rows>(x);
128
128
}
129
129
 
130
 
/*
131
 
 * This helper function returns true if map1 is a subset of
132
 
 * map2; otherwise it returns false.
133
 
 */
134
 
static bool is_bitmap_subset(const bitset<MAX_FIELDS> *map1, const bitset<MAX_FIELDS> *map2)
135
 
{
136
 
  bitset<MAX_FIELDS> tmp1= *map2;
137
 
  tmp1.flip();
138
 
  bitset<MAX_FIELDS> tmp2= *map1 & tmp1;
139
 
  return (!tmp2.any());
140
 
}
141
 
 
142
 
 
143
130
static int sel_cmp(Field *f,unsigned char *a,unsigned char *b,uint8_t a_flag,uint8_t b_flag);
144
131
 
145
132
static unsigned char is_null_string[2]= {1,0};
3143
3130
    info->index_records += info->param->table->quick_rows[ror_scan->keynr];
3144
3131
    info->index_scan_costs += ror_scan->index_read_cost;
3145
3132
    info->covered_fields |= ror_scan->covered_fields;
3146
 
    if (!info->is_covering && is_bitmap_subset(&info->param->needed_fields,
3147
 
                                               &info->covered_fields))
 
3133
    if (!info->is_covering && isBitmapSubset(&info->param->needed_fields,
 
3134
                                             &info->covered_fields))
3148
3135
    {
3149
3136
      info->is_covering= true;
3150
3137
    }
3380
3367
}
3381
3368
 
3382
3369
/*
3383
 
 * Helper method to find the position of the first bit in the
3384
 
 * given bitset that is set to 1.
3385
 
 * If no bit is set in the given bitset, return MY_BIT_NONE.
3386
 
 */
3387
 
static uint32_t get_first_bit_on_pos(bitset<MAX_FIELDS> &bitmap)
3388
 
{
3389
 
  uint32_t first_bit_on= MY_BIT_NONE;
3390
 
  for (int idx= 0; idx < MAX_FIELDS; idx++)
3391
 
  {
3392
 
    if (bitmap.test(idx))
3393
 
    {
3394
 
      first_bit_on= idx;
3395
 
      break;
3396
 
    }
3397
 
  } 
3398
 
  return first_bit_on;
3399
 
}
3400
 
 
3401
 
/*
3402
3370
  Get best covering ROR-intersection.
3403
3371
  SYNOPSIS
3404
3372
    get_best_covering_ror_intersect()
3475
3443
      (*scan)->covered_fields &= covered_fields->flip();
3476
3444
      covered_fields->flip();
3477
3445
      (*scan)->used_fields_covered= (*scan)->covered_fields.count();
3478
 
      (*scan)->first_uncovered_field= get_first_bit_on_pos((*scan)->covered_fields);
 
3446
      (*scan)->first_uncovered_field= getFirstBitPos((*scan)->covered_fields);
3479
3447
    }
3480
3448
 
3481
3449
    my_qsort(ror_scan_mark, ror_scans_end-ror_scan_mark, sizeof(ROR_SCAN_INFO*),
3492
3460
      return NULL;
3493
3461
    /* F=F-covered by first(I) */
3494
3462
    *covered_fields |= (*ror_scan_mark)->covered_fields;
3495
 
    all_covered= is_bitmap_subset(&param->needed_fields, covered_fields);
 
3463
    all_covered= isBitmapSubset(&param->needed_fields, covered_fields);
3496
3464
  } while ((++ror_scan_mark < ror_scans_end) && !all_covered);
3497
3465
 
3498
3466
  if (!all_covered || (ror_scan_mark - tree->ror_scans) == 1)