~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/records.cc

  • Committer: Brian Aker
  • Date: 2010-05-18 20:28:28 UTC
  • mto: This revision was merged to the branch mainline in revision 1540.
  • Revision ID: brian@gaz-20100518202828-rbstjiyauygl6a42
MoreĀ RRĀ encapsulation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
static int rr_unpack_from_buffer(ReadRecord *info);
39
39
static int rr_from_pointers(ReadRecord *info);
40
40
static int rr_from_cache(ReadRecord *info);
41
 
static int init_rr_cache(Session *session, ReadRecord *info);
42
41
static int rr_cmp(unsigned char *a,unsigned char *b);
43
42
static int rr_index_first(ReadRecord *info);
44
43
static int rr_index(ReadRecord *info);
130
129
        !table->s->blob_fields &&
131
130
        ref_length <= MAX_REFLENGTH)
132
131
    {
133
 
      if (! init_rr_cache(session, this))
 
132
      if (init_rr_cache())
134
133
      {
135
134
        read_record=rr_from_cache;
136
135
      }
381
380
}
382
381
 
383
382
/* cacheing of records from a database */
384
 
static int init_rr_cache(Session *session, ReadRecord *info)
 
383
bool ReadRecord::init_rr_cache()
385
384
{
386
 
  uint32_t rec_cache_size;
387
 
 
388
 
  info->struct_length= 3+MAX_REFLENGTH;
389
 
  info->reclength= ALIGN_SIZE(info->table->s->reclength+1);
390
 
  if (info->reclength < info->struct_length)
391
 
    info->reclength= ALIGN_SIZE(info->struct_length);
392
 
 
393
 
  info->error_offset= info->table->s->reclength;
394
 
  info->cache_records= (session->variables.read_rnd_buff_size /
395
 
                        (info->reclength+info->struct_length));
396
 
  rec_cache_size= info->cache_records*info->reclength;
397
 
  info->rec_cache_size= info->cache_records*info->ref_length;
 
385
  uint32_t local_rec_cache_size;
 
386
 
 
387
  struct_length= 3 + MAX_REFLENGTH;
 
388
  reclength= ALIGN_SIZE(table->s->reclength+1);
 
389
  if (reclength < struct_length)
 
390
    reclength= ALIGN_SIZE(struct_length);
 
391
 
 
392
  error_offset= table->s->reclength;
 
393
  cache_records= (session->variables.read_rnd_buff_size /
 
394
                        (reclength+struct_length));
 
395
  local_rec_cache_size= cache_records * reclength;
 
396
  rec_cache_size= cache_records * ref_length;
398
397
 
399
398
  // We have to allocate one more byte to use uint3korr (see comments for it)
400
 
  if (info->cache_records <= 2 ||
401
 
      !(info->cache=(unsigned char*) malloc(rec_cache_size+info->cache_records*
402
 
                                            info->struct_length+1)))
403
 
    return(1);
 
399
  if (cache_records <= 2 ||
 
400
      !(cache=(unsigned char*) malloc(local_rec_cache_size + cache_records * struct_length + 1)))
 
401
  {
 
402
    return false;
 
403
  }
404
404
#ifdef HAVE_purify
405
405
  // Avoid warnings in qsort
406
 
  memset(info->cache, 0,
407
 
         rec_cache_size+info->cache_records* info->struct_length+1);
 
406
  memset(cache, 0, local_rec_cache_size + cache_records * struct_length + 1);
408
407
#endif
409
 
  info->read_positions=info->cache+rec_cache_size;
410
 
  info->cache_pos=info->cache_end=info->cache;
411
 
  return(0);
 
408
  read_positions= cache + local_rec_cache_size;
 
409
  cache_pos= cache_end= cache;
 
410
 
 
411
  return true;
412
412
} /* init_rr_cache */
413
413
 
414
414
static int rr_from_cache(ReadRecord *info)