Ejemplo n.º 1
0
/**
 * @param schema we want to partially clone
 * @param an array with the position of the dimension we want to *keep*
 * @param the total number of dimension we want to keep
 * @return a cloned schema with only the dimension whose position are provided, the new position of dimension is there index+1 in provided array, NULL if something wen wrong
 * */
PCSCHEMA * 
pc_schema_clone_subset(  PCSCHEMA *s, uint32_t * dimensions_position_array, uint32_t dimensions_number)
{
	
	int i;
	PCDIMENSION* temp_dim;
	PCSCHEMA *pcs = pc_schema_new(dimensions_number);
	pcs->pcid = s->pcid;
	pcs->srid = s->srid;
	
	pcs->compression = s->compression;
	
	//printf("\n for loop \n");
	for ( i = 0; i < dimensions_number; i++ )
	{
		if ( s->dims[dimensions_position_array[i]] )
		{
				temp_dim = pc_dimension_clone(s->dims[dimensions_position_array[i]]);//cloning the dimension
				temp_dim->position=i ; //changing the position so to have continuous dimension position
				
			pc_schema_set_dimension(pcs,temp_dim);
			//printf("cloning the dimension %s in new position %d",temp_dim->name,i);
		}
	}
	
	//the new x_position and y_position should be found according to where X and Y dimension are
		//looking for X and Y in dimension, to get the dimension position
	pcs->x_position=pc_schema_get_dimension_position_by_name(pcs,"x");
	pcs->y_position=pc_schema_get_dimension_position_by_name(pcs,"y");

	//pcinfo("updating schema : x_position : %d, y_position : %d",pcs->x_position,pcs->y_position);
	pc_schema_calculate_byteoffsets(pcs);

	return pcs;
}
Ejemplo n.º 2
0
PCSCHEMA*
pc_schema_clone(const PCSCHEMA *s)
{
    int i;
    PCSCHEMA *pcs = pc_schema_new(s->ndims);
    pcs->pcid = s->pcid;
    pcs->srid = s->srid;
    pcs->x_position = s->x_position;
    pcs->y_position = s->y_position;
    pcs->compression = s->compression;
    for ( i = 0; i < pcs->ndims; i++ )
    {
        if ( s->dims[i] )
        {
            pc_schema_set_dimension(pcs, pc_dimension_clone(s->dims[i]));
        }
    }
	pc_schema_calculate_byteoffsets(pcs);
    return pcs;
}