コード例 #1
0
ファイル: adaptive_merge.c プロジェクト: Ravikumarmaddi/jitd
cog *partition_cog(cog *c) {
  int records = cog_length(c);
  
  if(c->type == COG_ARRAY && records < BLOCK_SIZE) {
    record_sort(c->data.array.records->data, c->data.array.start, c->data.array.start + c->data.array.len);
    convert_to_sortedarray(c);
    return c;
  }
  
  iterator iter = scan_full_array(c);
  int count=0;

  cog *ret = NULL;
  while(records > 0) {
    count++;
    cog *store = array_load(iter, math_min(records, BLOCK_SIZE));
    records -= store->data.array.len;
    record_sort(store->data.array.records->data, 0, store->data.array.len);
    convert_to_sortedarray(store);
   
    if(ret == NULL) {
      ret = store;
    } else {
      ret = make_concat(ret, store);
    }
  }

  if(ret == NULL) {
    ret = make_sortedarray(0, 0, NULL);
  }
  cleanup(c);
  iter_cleanup(iter);
  return ret;
}
コード例 #2
0
inline void test_serialize_type(const T *dummy = 0)
{
  T t1, t2;
  const unsigned N = 27;
  const unsigned BUF_SIZE = N*N*1000;
  char buf[BUF_SIZE];
  array_stream as(buf, BUF_SIZE);
  for (unsigned i = 0; i<N; ++i) {
    set_randomly(t1, i);
    array_save(as, t1);
    as.reset_read();
    array_load(as, t2);
    BOOST_CHECK(t1 == t2);
  }
}