Ejemplo n.º 1
0
static SERIALIZED_PATCH * 
pc_patch_dimensional_serialize(const PCPATCH *patch_in)
{
    int i;
    uint8_t *buf;
	size_t serpch_size = pc_patch_serialized_size(patch_in);
	SERIALIZED_PATCH *serpch = pcalloc(serpch_size);
    const PCPATCH_DIMENSIONAL *patch = (PCPATCH_DIMENSIONAL*)patch_in;

    assert(patch_in);
    assert(patch_in->type == PC_DIMENSIONAL);

	/* Copy basics */
	serpch->pcid = patch->schema->pcid;
	serpch->npoints = patch->npoints;
	serpch->xmin = patch->xmin;
	serpch->ymin = patch->ymin;
	serpch->xmax = patch->xmax;
	serpch->ymax = patch->ymax;
	
	/* Copy byte buffers, one by one */
    buf = serpch->data;
    for ( i = 0; i < patch->schema->ndims; i++ )
    {
        size_t bsize = 0;
        PCBYTES *pcb = &(patch->bytes[i]);
        pc_bytes_serialize(pcb, buf, &bsize);
        buf += bsize;
    }

	SET_VARSIZE(serpch, serpch_size);
	return serpch;
}
Ejemplo n.º 2
0
static SERIALIZED_PATCH *
pc_patch_dimensional_serialize(const PCPATCH *patch_in)
{
	//  uint32_t size;
	//  uint32_t pcid;
	//  uint32_t compression;
	//  uint32_t npoints;
	//  double xmin, xmax, ymin, ymax;
	//  data:
	//    pcpoint[3] stats;
	//    serialized_pcbytes[ndims] dimensions;

	int i;
	uint8_t *buf;
	size_t serpch_size = pc_patch_serialized_size(patch_in);
	SERIALIZED_PATCH *serpch = pcalloc(serpch_size);
	const PCPATCH_DIMENSIONAL *patch = (PCPATCH_DIMENSIONAL*)patch_in;
	assert(patch_in);
	assert(patch_in->type == PC_DIMENSIONAL);
	/* Copy basics */
	serpch->pcid = patch->schema->pcid;
	serpch->npoints = patch->npoints;
	serpch->bounds = patch->bounds;
	serpch->compression = patch->type;
	//pcinfo("	dim serialisation : just copied basic : pcid : %d, npoints : %d, compression :%d,  bounds\n", serpch->pcid,serpch->npoints,serpch->compression );

	/* Get a pointer to the data area */
	buf = serpch->data;

	/* Write stats into the buffer */
	if ( patch->stats )
	{
		buf += pc_patch_stats_serialize(buf, patch->schema, patch->stats);
	}
	else
	{
		pcerror("%s: stats missing!", __func__);
	}

	/* Write each dimension in after the stats */
	for ( i = 0; i < patch->schema->ndims; i++ )
	{
		size_t bsize = 0;
		PCBYTES *pcb = &(patch->bytes[i]);
		pc_bytes_serialize(pcb, buf, &bsize);
		buf += bsize;
	}
	SET_VARSIZE(serpch, serpch_size);
	return serpch;
}
Ejemplo n.º 3
0
static SERIALIZED_PATCH *
pc_patch_ght_serialize(const PCPATCH *patch_in)
{
	//  uint32_t size;
	//  uint32_t pcid;
	//  uint32_t compression;
	//  uint32_t npoints;
	//  double xmin, xmax, ymin, ymax;
	//  data:
	//    pcpoint[3] stats;
	//    uint32_t ghtsize;
	//    uint8_t ght[];

	size_t serpch_size = pc_patch_serialized_size(patch_in);
	SERIALIZED_PATCH *serpch = pcalloc(serpch_size);
	const PCPATCH_GHT *patch = (PCPATCH_GHT*)patch_in;
	uint32_t ghtsize = patch->ghtsize;
	uint8_t *buf = serpch->data;

	assert(patch);
	assert(patch->type == PC_GHT);

	/* Copy basics */
	serpch->pcid = patch->schema->pcid;
	serpch->npoints = patch->npoints;
	serpch->bounds = patch->bounds;
	serpch->compression = patch->type;

	/* Write stats into the buffer first */
	if ( patch->stats )
	{
		buf += pc_patch_stats_serialize(buf, patch->schema, patch->stats);
	}
	else
	{
		pcerror("%s: stats missing!", __func__);
	}

	/* Write tree buffer size */
	memcpy(buf, &(ghtsize), 4);
	buf += 4;

	/* Write tree buffer */
	memcpy(buf, patch->ght, patch->ghtsize);
	SET_VARSIZE(serpch, serpch_size);
	return serpch;
}
Ejemplo n.º 4
0
static SERIALIZED_PATCH *
pc_patch_uncompressed_serialize(const PCPATCH *patch_in)
{
	//  uint32_t size;
	//  uint32_t pcid;
	//  uint32_t compression;
	//  uint32_t npoints;
	//  double xmin, xmax, ymin, ymax;
	//  data:
	//    pcpoint [];

	uint8_t *buf;
	size_t serpch_size;
	SERIALIZED_PATCH *serpch;
	const PCPATCH_UNCOMPRESSED *patch = (PCPATCH_UNCOMPRESSED *)patch_in;

	serpch_size = pc_patch_serialized_size(patch_in);
	serpch = pcalloc(serpch_size);

	/* Copy basic */
	serpch->compression = patch->type;
	serpch->pcid = patch->schema->pcid;
	serpch->npoints = patch->npoints;
	serpch->bounds = patch->bounds;

	/* Write stats into the buffer first */
	buf = serpch->data;
	if ( patch->stats )
	{
		buf += pc_patch_stats_serialize(buf, patch->schema, patch->stats);
	}
	else
	{
		pcerror("%s: stats missing!", __func__);
	}

	/* Copy point list into data buffer */
	memcpy(buf, patch->data, patch->datasize);
	SET_VARSIZE(serpch, serpch_size);
	return serpch;
}
Ejemplo n.º 5
0
static SERIALIZED_PATCH * 
pc_patch_uncompressed_serialize(const PCPATCH *patch_in)
{
	size_t serpch_size;
	SERIALIZED_PATCH *serpch;
    const PCPATCH_UNCOMPRESSED *patch = (PCPATCH_UNCOMPRESSED *)patch_in;
	
    serpch_size = pc_patch_serialized_size(patch_in);
	serpch = pcalloc(serpch_size);
	
	/* Copy */
	serpch->pcid = patch->schema->pcid;
	serpch->npoints = patch->npoints;
	serpch->xmin = patch->xmin;
	serpch->ymin = patch->ymin;
	serpch->xmax = patch->xmax;
	serpch->ymax = patch->ymax;
	memcpy(serpch->data, patch->data, patch->datasize);
	SET_VARSIZE(serpch, serpch_size);
	return serpch;
}