~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/filesort.cc

  • Committer: Olaf van der Spek
  • Date: 2011-08-14 12:20:36 UTC
  • mto: This revision was merged to the branch mainline in revision 2407.
  • Revision ID: olafvdspek@gmail.com-20110814122036-ydjayvqjgwixp3o8
Refactor iocache

Show diffs side-by-side

added added

removed removed

Lines of Context:
462
462
 
463
463
/** Read 'count' number of buffer pointers into memory. */
464
464
 
465
 
static unsigned char *read_buffpek_from_file(internal::io_cache_st *buffpek_pointers, uint32_t count,
466
 
                                     unsigned char *buf)
 
465
static unsigned char *read_buffpek_from_file(internal::io_cache_st *buffpek_pointers, uint32_t count, unsigned char *buf)
467
466
{
468
467
  uint32_t length= sizeof(buffpek)*count;
469
468
  unsigned char *tmp= buf;
473
472
    tmp= (unsigned char *)malloc(length);
474
473
  {
475
474
    if (buffpek_pointers->reinit_io_cache(internal::READ_CACHE,0L,0,0) ||
476
 
        my_b_read(buffpek_pointers, (unsigned char*) tmp, length))
 
475
      buffpek_pointers->read(tmp, length))
477
476
    {
478
 
      free((char*) tmp);
479
 
      tmp=0;
 
477
      free(tmp);
 
478
      tmp= 0;
480
479
    }
481
480
  }
482
 
  return(tmp);
 
481
  return tmp;
483
482
}
484
483
 
485
484
 
595
594
    {
596
595
      if (indexfile)
597
596
      {
598
 
        if (my_b_read(indexfile,(unsigned char*) ref_pos,ref_length))
 
597
        if (indexfile->read(ref_pos, ref_length))
599
598
        {
600
599
          error= errno ? errno : -1;            /* Abort */
601
600
          break;
732
731
 
733
732
  for (unsigned char **ptr= sort_keys + count ; sort_keys != ptr ; sort_keys++)
734
733
  {
735
 
    if (my_b_write(tempfile, (unsigned char*) *sort_keys, (uint32_t) rec_length))
 
734
    if (tempfile->write(*sort_keys, rec_length))
736
735
    {
737
736
      return 1;
738
737
    }
739
738
  }
740
739
 
741
 
  if (my_b_write(buffpek_pointers, (unsigned char*) &buffpek, sizeof(buffpek)))
 
740
  if (buffpek_pointers->write(&buffpek, sizeof(buffpek)))
742
741
  {
743
742
    return 1;
744
743
  }
1257
1256
    */
1258
1257
    buffpek_inst= queue.top();
1259
1258
    memcpy(param->unique_buff, buffpek_inst->key, rec_length);
1260
 
    if (my_b_write(to_file, (unsigned char*) buffpek_inst->key, rec_length))
 
1259
    if (to_file->write(buffpek_inst->key, rec_length))
1261
1260
    {
1262
1261
      return 1;
1263
1262
    }
1295
1294
      }
1296
1295
      if (flag == 0)
1297
1296
      {
1298
 
        if (my_b_write(to_file,(unsigned char*) buffpek_inst->key, rec_length))
 
1297
        if (to_file->write(buffpek_inst->key, rec_length))
1299
1298
        {
1300
1299
          return 1;
1301
1300
        }
1302
1301
      }
1303
1302
      else
1304
1303
      {
1305
 
        if (my_b_write(to_file, (unsigned char*) buffpek_inst->key+offset, res_length))
 
1304
        if (to_file->write(buffpek_inst->key+offset, res_length))
1306
1305
        {
1307
1306
          return 1;
1308
1307
        }
1360
1359
    max_rows-= buffpek_inst->mem_count;
1361
1360
    if (flag == 0)
1362
1361
    {
1363
 
      if (my_b_write(to_file,(unsigned char*) buffpek_inst->key,
1364
 
                     (rec_length*buffpek_inst->mem_count)))
 
1362
      if (to_file->write(buffpek_inst->key, (rec_length*buffpek_inst->mem_count)))
1365
1363
      {
1366
1364
        return 1;
1367
1365
      }
1374
1372
           strpos != end ;
1375
1373
           strpos+= rec_length)
1376
1374
      {
1377
 
        if (my_b_write(to_file, (unsigned char *) strpos, res_length))
 
1375
        if (to_file->write(strpos, res_length))
1378
1376
        {
1379
1377
          return 1;
1380
1378
        }