~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/sort.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:
214
214
      goto err;
215
215
    }
216
216
 
217
 
    while (!my_b_read(&tempfile_for_exceptions,(unsigned char*)&key_length,
218
 
                      sizeof(key_length))
219
 
        && !my_b_read(&tempfile_for_exceptions,(unsigned char*)sort_keys,
220
 
                      (uint) key_length))
 
217
    while (not tempfile_for_exceptions.read(&key_length, sizeof(key_length))
 
218
        && not tempfile_for_exceptions.read(sort_keys, key_length))
221
219
    {
222
 
        if (_mi_ck_write(idx,keyno,(unsigned char*) sort_keys,key_length-ref_length))
223
 
          goto err;
 
220
      if (_mi_ck_write(idx,keyno,(unsigned char*) sort_keys,key_length-ref_length))
 
221
        goto err;
224
222
    }
225
223
  }
226
224
 
412
410
        continue;
413
411
      }
414
412
 
415
 
      while (!got_error &&
416
 
             !my_b_read(&sinfo->tempfile_for_exceptions,(unsigned char*)&key_length,
417
 
                        sizeof(key_length)))
 
413
      while (!got_error && not sinfo->tempfile_for_exceptions.read(&key_length, sizeof(key_length)))
418
414
      {
419
415
        unsigned char ft_buf[10];
420
 
        if (key_length > sizeof(ft_buf) ||
421
 
            my_b_read(&sinfo->tempfile_for_exceptions, (unsigned char*)ft_buf,
422
 
                      (uint)key_length) ||
423
 
            _mi_ck_write(info, sinfo->key, (unsigned char*)ft_buf,
424
 
                         key_length - info->s->rec_reflength))
425
 
          got_error=1;
 
416
        if (key_length > sizeof(ft_buf) || sinfo->tempfile_for_exceptions.read(ft_buf, (uint)key_length) 
 
417
          || _mi_ck_write(info, sinfo->key, (unsigned char*)ft_buf, key_length - info->s->rec_reflength))
 
418
          got_error= 1;
426
419
      }
427
420
    }
428
421
  }
447
440
 
448
441
  for (end=sort_keys+count ; sort_keys != end ; sort_keys++)
449
442
  {
450
 
    if (my_b_write(tempfile,(unsigned char*) *sort_keys,(uint) sort_length))
 
443
    if (tempfile->write(*sort_keys, sort_length))
451
444
      return(1);
452
445
  }
453
446
  return(0);
461
454
  uint16_t len = _mi_keylength(info->keyinfo, (unsigned char*) bufs);
462
455
 
463
456
  /* The following is safe as this is a local file */
464
 
  if ((err= my_b_write(to_file, (unsigned char*)&len, sizeof(len))))
 
457
  if ((err= to_file->write(&len, sizeof(len))))
465
458
    return (err);
466
 
  if ((err= my_b_write(to_file,bufs, (uint) len)))
 
459
  if ((err= to_file->write(bufs, len)))
467
460
    return (err);
468
461
  return (0);
469
462
}
500
493
  if (not tempfile->inited() && tempfile->open_cached_file(P_tmpdir, "ST", DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
501
494
    return(1);
502
495
 
503
 
  if (my_b_write(tempfile,(unsigned char*)&key_length,sizeof(key_length)) ||
504
 
      my_b_write(tempfile,(unsigned char*)key,(uint) key_length))
 
496
  if (tempfile->write(&key_length, sizeof(key_length)) ||
 
497
      tempfile->write(key, key_length))
505
498
    return(1);
506
499
  return(0);
507
500
} /* write_key */
649
642
}
650
643
 
651
644
 
652
 
static int  write_merge_key(MI_SORT_PARAM *info,
 
645
static int  write_merge_key(MI_SORT_PARAM*,
653
646
                                  internal::io_cache_st *to_file, unsigned char *key,
654
647
                                  uint32_t sort_length, uint32_t count)
655
648
{
656
 
  (void)info;
657
 
  return my_b_write(to_file, key, (size_t) sort_length*count);
 
649
  return to_file->write(key, sort_length*count);
658
650
}
659
651
 
660
652
/*