Skip to content
Open
Prev Previous commit
Next Next commit
write chivector
  • Loading branch information
Aapo Kyrola committed Aug 14, 2013
commit 2d79519619bc11ff808010fcc30eb7071d575723
11 changes: 9 additions & 2 deletions src/shards/dynamicdata/dynamicblock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,24 @@ namespace graphchi {
// First compute size
size = 0;
for(int i=0; i < nitems; i++) {
size += chivecs[i].capacity() * sizeof(typename ET::element_type_t) + sizeof(typename ET::sizeword_t);
size += chivecs[i].capacity() * sizeof(typename ET::element_type_t) + sizeof(typename ET::sizeword_t) + sizeof(typename ET::header_t);
}

*outdata = (uint8_t *) malloc(size);
uint8_t * ptr = *outdata;
for(int i=0; i < nitems; i++) {
ET & vec = chivecs[i];

/* Write header */
((typename ET::header_t *) ptr)[0] = vec.header();
ptr += sizeof(typename ET::header_t);

/* Write size information */
((uint16_t *) ptr)[0] = vec.size();
((uint16_t *) ptr)[1] = vec.capacity();

ptr += sizeof(typename ET::sizeword_t);

/* Write elements */
vec.write((typename ET::element_type_t *) ptr);
ptr += vec.capacity() * sizeof(typename ET::element_type_t);
}
Expand Down