/**
 * Appends along the last dimensions.
 */
static hid_t make_dataset(ndio_hdf5_t self,nd_type_id_t type_id,unsigned ndim,size_t *shape, hid_t* filespace)
{ hsize_t *sh=0,*ori=0,*ext=0;
  TRY(self->isw);
  STACK_ALLOC(hsize_t,sh ,ndim);
  STACK_ALLOC(hsize_t,ori,ndim);
  STACK_ALLOC(hsize_t,ext,ndim);
  if(self->dataset>=0) // data set already exists...needs extending, append on slowest dim
  { HTRY(H5Sget_simple_extent_dims(space(self),sh,NULL));
    ZERO(hsize_t,ori,ndim);
    ori[0]=sh[0];
    sh[0]+=shape[ndim-1];
    reverse_hsz_sz(ndim,ext,shape);
    HTRY(H5Dextend(self->dataset,sh));
    HTRY(*filespace=H5Dget_space(self->dataset));
    HTRY(H5Sselect_hyperslab(*filespace,H5S_SELECT_SET,ori,NULL,ext,NULL));
  } else
  { HTRY(self->dataset=H5Dcreate(
                       self->file,name(self),
                       nd_to_hdf5_type(type_id),
                       make_space(self,ndim,shape),
                       H5P_DEFAULT,/*(rare) link creation props*/
                       dataset_creation_properties(
                          /*set_deflate*/(
                          set_chunk(self,ndim,shape))),
                       H5P_DEFAULT /*(rare) dataset access props*/
                       ));
    reverse_hsz_sz(ndim,sh,shape);
    *filespace=H5S_ALL;
  }
  HTRY(H5Dset_extent(self->dataset,sh));
  return self->dataset;
Error:
  return -1;
}
Exemple #2
0
static inline void generate(void *mem, unsigned long len)
{
    unsigned long i, j = 0;

    arr = (struct chunk *)mem;
    for (i = 0; i < len; i++)
        set_chunk(&arr[i], j++ % range);
}
void
add_run(struct text *txt0, unsigned int i0,
	struct text *txt1, unsigned int i1,
	unsigned int size
) {
	/*	Adds the run of given size to our collection.
	*/
	register struct run *r = (struct run *)malloc(sizeof (struct run));

	if (!r) fatal("out of memory");
	set_chunk(&r->rn_cn0, txt0, i0 - txt0->tx_start, size);
	set_chunk(&r->rn_cn1, txt1, i1 - txt1->tx_start, size);
	r->rn_size = size;

	if (option_set('p') ? add_to_percentages(r) : add_to_runs(r)) {
		/* OK */
	}
	else	fatal("out of memory");
}
Exemple #4
0
void
add_run(struct text *txt0, size_t i0,
	struct text *txt1, size_t i1,
	size_t size
) {
	/*	Adds the run of given size to our collection.
	*/
	struct run *r = new(struct run);

	set_chunk(&r->rn_chunk0, txt0, i0 - txt0->tx_start, size);
	set_chunk(&r->rn_chunk1, txt1, i1 - txt1->tx_start, size);
	r->rn_size = size;

#ifdef	DB_RUN
	db_run_info("Added", r, 0);
#endif	/* DB_RUN */

	if (is_set_option('p')) {
		add_to_percentages(r);
	}
	else {
		add_to_runs(r);
	}
}
Exemple #5
0
int main(int argc, char *argv[]) {
		unsigned int i=5;
		unsigned int j;
		chunk c,c2;
		unsigned char *ptr=heap;
		/* Q1 */
		printf("i: %d\n",get_int(&i));
		set_int(&j, i);
		printf("j: %d\n",get_int(&j));
		/* Q2 */
		c.free=0;
		c.size=5;
		c.addr=0;
		c.next_chunk=0;
		c.previous_chunk=0;
		set_chunk(&c, ptr);
		get_chunk(&c2,ptr);
        return 0;
}