• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ARR_LBOUND函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ARR_LBOUND函数的典型用法代码示例。如果您正苦于以下问题:C++ ARR_LBOUND函数的具体用法?C++ ARR_LBOUND怎么用?C++ ARR_LBOUND使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ARR_LBOUND函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: array_prepend

/*-----------------------------------------------------------------------------
 * array_prepend :
 *		push an element onto the front of a one-dimensional array
 *----------------------------------------------------------------------------
 */
Datum
array_prepend(PG_FUNCTION_ARGS)
{
	ArrayType  *v;
	Datum		newelem;
	bool		isNull;
	ArrayType  *result;
	int		   *lb;
	int			indx;
	ArrayMetaState *my_extra;

	isNull = PG_ARGISNULL(0);
	if (isNull)
		newelem = (Datum) 0;
	else
		newelem = PG_GETARG_DATUM(0);
	v = fetch_array_arg_replace_nulls(fcinfo, 1);

	if (ARR_NDIM(v) == 1)
	{
		/* prepend newelem */
		lb = ARR_LBOUND(v);
		indx = lb[0] - 1;

		/* overflow? */
		if (indx > lb[0])
			ereport(ERROR,
					(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
					 errmsg("integer out of range")));
	}
	else if (ARR_NDIM(v) == 0)
		indx = 1;
	else
		ereport(ERROR,
				(errcode(ERRCODE_DATA_EXCEPTION),
				 errmsg("argument must be empty or one-dimensional array")));

	/* Perform element insertion */
	my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;

	result = array_set(v, 1, &indx, newelem, isNull,
			   -1, my_extra->typlen, my_extra->typbyval, my_extra->typalign);

	/* Readjust result's LB to match the input's, as expected for prepend */
	if (ARR_NDIM(v) == 1)
		ARR_LBOUND(result)[0] = ARR_LBOUND(v)[0];

	PG_RETURN_ARRAYTYPE_P(result);
}
开发者ID:PJMODOS,项目名称:postgres,代码行数:54,代码来源:array_userfuncs.c


示例2: array_loop

void array_loop(ArrayType *array, int32 start, array_iter *iter)
{
	iter->array = array;
	iter->ptr   = ARR_DATA_PTR(array);
	iter->max   = ARR_DIMS(array)[0];
	get_typlenbyvalalign(ARR_ELEMTYPE(array), 
						 &iter->typlen,
						 &iter->typbyval,
						 &iter->typalign);

	/* If we are starting in the middle of the array, then scan forward */
	start = start - ARR_LBOUND(array)[0];
	if (start <= 0)
		iter->index = start;
	else
	{
		/* 
		 * could probably be more efficient for fixed length arrays, but
		 * they would still require adjustments for nulls.
		 */
		iter->index = 0;
		while (start--)
		{
			Datum d;
			bool  isna;
			array_next(iter, &d, &isna);
		}
	}
}
开发者ID:BALDELab,项目名称:incubator-hawq,代码行数:29,代码来源:pivot.c


示例3: array_get_lowerbounds

static PyObj
array_get_lowerbounds(PyObj self, void *closure)
{
	ArrayType *at;
	PyObj rob;
	int i, ndim, *lbs;

	at = DatumGetArrayTypeP(PyPgObject_GetDatum(self));
	ndim = ARR_NDIM(at);
	lbs = ARR_LBOUND(at);

	rob = PyTuple_New(ndim);

	for (i = 0; i < ndim; ++i)
	{
		PyObj ob;
		ob = PyLong_FromLong(lbs[i]);
		if (ob == NULL)
		{
			Py_DECREF(rob);
			return(NULL);
		}
		PyTuple_SET_ITEM(rob, i, ob);
	}

	return(rob);
}
开发者ID:python-postgres,项目名称:be,代码行数:27,代码来源:array.c


示例4: new_intArrayType

/* Create a new int array with room for "num" elements */
ArrayType *
new_intArrayType(int num)
{
	ArrayType  *r;
	int			nbytes;

	/* if no elements, return a zero-dimensional array */
	if (num <= 0)
	{
		r = construct_empty_array(INT4OID);
		return r;
	}

	nbytes = ARR_OVERHEAD_NONULLS(1) + sizeof(int) * num;

	r = (ArrayType *) palloc0(nbytes);

	SET_VARSIZE(r, nbytes);
	ARR_NDIM(r) = 1;
	r->dataoffset = 0;			/* marker for no null bitmap */
	ARR_ELEMTYPE(r) = INT4OID;
	ARR_DIMS(r)[0] = num;
	ARR_LBOUND(r)[0] = 1;

	return r;
}
开发者ID:Brar,项目名称:postgres,代码行数:27,代码来源:_int_tool.c


示例5: intArrayIdx

static int 
intArrayIdx(ArrayType * array, int const * coord, bool noerror)
{
    int * lbs;
    int * dims;
    int i, res;

    lbs = ARR_LBOUND(array);
    dims = ARR_DIMS(array);

    res = 0;
    for (i = 0; i < array->ndim; i++)
    {
        int c = coord[i] - lbs[i];

        if (c < 0 || c >= dims[i])
        {
            if (noerror)
                return -1;
            else
                elog(ERROR, "array out of bounds");
        }
        res = res * dims[i] + c;
    }

    return res;
}
开发者ID:kikht,项目名称:hvault,代码行数:27,代码来源:table_group.c


示例6: createArrayType

ArrayType* createArrayType(jsize nElems, size_t elemSize, Oid elemType, bool withNulls)
{
	ArrayType* v;
	Size nBytes = elemSize * nElems;
	MemoryContext currCtx = Invocation_switchToUpperContext();

	Size dataoffset;
	if(withNulls)
	{
		dataoffset = ARR_OVERHEAD_WITHNULLS(1, nElems);
		nBytes += dataoffset;
	}
	else
	{
		dataoffset = 0;			/* marker for no null bitmap */
		nBytes += ARR_OVERHEAD_NONULLS(1);
	}
	v = (ArrayType*)palloc0(nBytes);
	AssertVariableIsOfType(v->dataoffset, int32);
	v->dataoffset = (int32)dataoffset;
	MemoryContextSwitchTo(currCtx);

	SET_VARSIZE(v, nBytes);
	ARR_NDIM(v) = 1;
	ARR_ELEMTYPE(v) = elemType;
	*((int*)ARR_DIMS(v)) = nElems;
	*((int*)ARR_LBOUND(v)) = 1;
	return v;
}
开发者ID:greenplum-db,项目名称:pljava,代码行数:29,代码来源:Array.c


示例7: intArrayInit

static ArrayType *
intArrayInit(int ndims, int const * dims, int const * lbs)
{
    ArrayType * res;
    int size;
    int nbytes;

    if (ndims < 0)              /* we do allow zero-dimension arrays */
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                 errmsg("invalid number of dimensions: %d", ndims)));
    if (ndims > MAXDIM)
        ereport(ERROR,
                (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
                 errmsg("number of array dimensions (%d) exceeds the maximum allowed (%d)",
                        ndims, MAXDIM)));
    

    /* fast track for empty array */
    if (ndims == 0)
        return construct_empty_array(INT4OID);
    
    size = ArrayGetNItems(ndims, dims);
    nbytes = ARR_OVERHEAD_NONULLS(ndims);
    nbytes += size * 4;
    res = palloc0(nbytes);
    SET_VARSIZE(res, nbytes);
    res->ndim = ndims;
    res->elemtype = INT4OID;
    res->dataoffset = 0;
    memcpy(ARR_DIMS(res), dims, ndims * sizeof(int));
    memcpy(ARR_LBOUND(res), lbs, ndims * sizeof(int));

    return res;
}
开发者ID:kikht,项目名称:hvault,代码行数:35,代码来源:table_group.c


示例8: hstore_slice_to_array

Datum
hstore_slice_to_array(PG_FUNCTION_ARGS)
{
    HStore	   *hs = PG_GETARG_HS(0);
    HEntry	   *entries = ARRPTR(hs);
    char	   *ptr = STRPTR(hs);
    ArrayType  *key_array = PG_GETARG_ARRAYTYPE_P(1);
    ArrayType  *aout;
    Datum	   *key_datums;
    bool	   *key_nulls;
    Datum	   *out_datums;
    bool	   *out_nulls;
    int			key_count;
    int			i;

    deconstruct_array(key_array,
                      TEXTOID, -1, false, 'i',
                      &key_datums, &key_nulls, &key_count);

    if (key_count == 0)
    {
        aout = construct_empty_array(TEXTOID);
        PG_RETURN_POINTER(aout);
    }

    out_datums = palloc(sizeof(Datum) * key_count);
    out_nulls = palloc(sizeof(bool) * key_count);

    for (i = 0; i < key_count; ++i)
    {
        text	   *key = (text *) DatumGetPointer(key_datums[i]);
        int			idx;

        if (key_nulls[i])
            idx = -1;
        else
            idx = hstoreFindKey(hs, NULL, VARDATA(key), VARSIZE(key) - VARHDRSZ);

        if (idx < 0 || HS_VALISNULL(entries, idx))
        {
            out_nulls[i] = true;
            out_datums[i] = (Datum) 0;
        }
        else
        {
            out_datums[i] = PointerGetDatum(
                                cstring_to_text_with_len(HS_VAL(entries, ptr, idx),
                                        HS_VALLEN(entries, idx)));
            out_nulls[i] = false;
        }
    }

    aout = construct_md_array(out_datums, out_nulls,
                              ARR_NDIM(key_array),
                              ARR_DIMS(key_array),
                              ARR_LBOUND(key_array),
                              TEXTOID, -1, false, 'i');

    PG_RETURN_POINTER(aout);
}
开发者ID:nathanwadhwani,项目名称:recdb-postgresql,代码行数:60,代码来源:hstore_op.c


示例9: pcpoint_from_double_array

Datum pcpoint_from_double_array(PG_FUNCTION_ARGS)
{
	uint32 pcid = PG_GETARG_INT32(0);
	ArrayType *arrptr = PG_GETARG_ARRAYTYPE_P(1);
	int nelems;
	float8 *vals;
	PCPOINT *pt;
	PCSCHEMA *schema = pc_schema_from_pcid(pcid, fcinfo);
	SERIALIZED_POINT *serpt;

	if ( ! schema )
		elog(ERROR, "unable to load schema for pcid = %d", pcid);

	if ( ARR_ELEMTYPE(arrptr) != FLOAT8OID )
		elog(ERROR, "array must be of float8[]");

	if ( ARR_NDIM(arrptr) != 1 )
		elog(ERROR, "float8[] must have only one dimension");

	if ( ARR_HASNULL(arrptr) )
		elog(ERROR, "float8[] must not have null elements");

	nelems = ARR_DIMS(arrptr)[0];
	if ( nelems != schema->ndims || ARR_LBOUND(arrptr)[0] > 1 )
		elog(ERROR, "array dimensions do not match schema dimensions of pcid = %d", pcid);

	vals = (float8*) ARR_DATA_PTR(arrptr);
	pt = pc_point_from_double_array(schema, vals, nelems);

	serpt = pc_point_serialize(pt);
	pc_point_free(pt);
	PG_RETURN_POINTER(serpt);
}
开发者ID:achidlow,项目名称:pointcloud,代码行数:33,代码来源:pc_inout.c


示例10: sizeof

inline
AbstractionLayer::MutableArrayHandle<T>
AbstractionLayer::Allocator::allocateArray(size_t inNumElements) const {    
    /*
     * Check that the size will not exceed addressable memory. Therefore, the
     * following precondition has to hold:
     * ((std::numeric_limits<size_t>::max() - ARR_OVERHEAD_NONULLS(1)) /
     *     inElementSize >= inNumElements)
     */
    if ((std::numeric_limits<size_t>::max() - ARR_OVERHEAD_NONULLS(1)) /
            sizeof(T) < inNumElements)
        throw std::bad_alloc();
    
    size_t		size = sizeof(T) * inNumElements + ARR_OVERHEAD_NONULLS(1);
    ArrayType	*array;

    // Note: Except for the allocate call, the following statements do not call
    // into the PostgreSQL backend. We are only using macros here.
    
    // PostgreSQL requires that all memory is overwritten with zeros. So
    // we ingore ZM here
    array = static_cast<ArrayType*>(allocate<MC, dbal::DoZero, F>(size));
        
    SET_VARSIZE(array, size);
    array->ndim = 1;
    array->dataoffset = 0;
    array->elemtype = TypeTraits<T>::oid;
    ARR_DIMS(array)[0] = inNumElements;
    ARR_LBOUND(array)[0] = 1;
    
    return MutableArrayHandle<T>(array);
}
开发者ID:agorajek,项目名称:madlib,代码行数:32,代码来源:Allocator_impl.hpp


示例11: alpine_miner_lr_ca_derivative

Datum
alpine_miner_lr_ca_derivative(PG_FUNCTION_ARGS)
{

        ArrayType  *beta_arg, *columns_arg, *result;
        float8     *beta_data, *columns_data, *result_data;
	int         beta_count, columns_count, result_count;

	bool add_intercept_arg;
	double weight_arg;
	int y_arg;
        int         size;

	double gx = 0.0;
	double pi = 0.0;
	if (PG_ARGISNULL(0) || PG_ARGISNULL(1) || PG_ARGISNULL(2) || PG_ARGISNULL(3) || PG_ARGISNULL(4) || PG_ARGISNULL(5)){
		PG_RETURN_NULL();
	}
	result = PG_GETARG_ARRAYTYPE_P(0);
        beta_arg = PG_GETARG_ARRAYTYPE_P(1);

        columns_arg = PG_GETARG_ARRAYTYPE_P(2);
	add_intercept_arg = PG_GETARG_BOOL(3);
	weight_arg = PG_GETARG_FLOAT8(4);
	y_arg = PG_GETARG_INT32(5);

	result_data = (float8*) ARR_DATA_PTR(result);
	beta_data = (float8*) ARR_DATA_PTR(beta_arg);
	columns_data = (float8*) ARR_DATA_PTR(columns_arg);
	
	result_count = ARR_DIMS(result)[0];
	beta_count = ARR_DIMS(beta_arg)[0];
	columns_count = ARR_DIMS(columns_arg)[0];
//	float8 * column_array_data = (float8*) ARR_DATA_PTR(column_array);
	if (result_count == 1){
		result_count = beta_count;
       	 	size =  result_count * sizeof(float8) + ARR_OVERHEAD_NONULLS(1);
        	result = (ArrayType *) palloc(size);
	        SET_VARSIZE(result, size);
       	 	result->ndim = 1;
        	result->dataoffset = 0;
        	result->elemtype = FLOAT8OID;
        	ARR_DIMS(result)[0] = result_count;
        	ARR_LBOUND(result)[0] = 1;
		result_data = (float8*) ARR_DATA_PTR(result);
        	memset(result_data, 0,  result_count * sizeof(float8));
	}

	pi = alpine_miner_compute_pi(beta_data,  beta_count, columns_data,  columns_count, add_intercept_arg);

	alpine_miner_compute_derivative(columns_count,columns_data, result_data
		,weight_arg, y_arg, add_intercept_arg,  pi);
        PG_RETURN_ARRAYTYPE_P(result);
}
开发者ID:thyferny,项目名称:indwa-work,代码行数:54,代码来源:alpine_miner_lr_ca.c


示例12: alpine_miner_covar_sam_accum

Datum
alpine_miner_covar_sam_accum(PG_FUNCTION_ARGS)
{
	ArrayType *state;
	float8 * state_array_data;
	ArrayType * column_array;
	int column_size;
	float8 * column_array_data;
	int i;
	int k ;
	int j;

	if (PG_ARGISNULL(0)){
		 PG_RETURN_NULL();
	}
	state = PG_GETARG_ARRAYTYPE_P(0);
	
	state_array_data = (float8*) ARR_DATA_PTR(state);
	
	column_array = PG_GETARG_ARRAYTYPE_P(1);
	column_size = ARR_DIMS(column_array)[0];
	column_array_data = (float8*) ARR_DATA_PTR(column_array);
	if (ARR_DIMS(state)[0] == 1){
			
			int result_size = column_size * ( column_size + 1)/2 + column_size+2;
       	 	int size =  result_size * sizeof(float8) + ARR_OVERHEAD_NONULLS(1);
        	state = (ArrayType *) palloc(size);
	        SET_VARSIZE(state, size);
       	 	state->ndim = 1;
        	state->dataoffset = 0;
        	state->elemtype = FLOAT8OID;
        	ARR_DIMS(state)[0] = result_size;
        	ARR_LBOUND(state)[0] = 1;
			state_array_data = (float8*) ARR_DATA_PTR(state);
	     	memset(state_array_data, 0,  result_size * sizeof(float8));
	}
	
		k	= 0;
        for ( i = 0; i < column_size; i++){
			for(j = i; j < column_size; j++){
                	state_array_data[k] += column_array_data[i] * column_array_data[j];
			k++;
		}
	}
	for( i = 0; i < column_size; i++){
		state_array_data[k + i] += column_array_data[i];
	}
	state_array_data[k+i]++;
	state_array_data[k+i+1]=column_size;
        PG_RETURN_ARRAYTYPE_P(state);
}	
开发者ID:thyferny,项目名称:indwa-work,代码行数:51,代码来源:alpine_miner_covar_sam.c


示例13: array_append

/*-----------------------------------------------------------------------------
 * array_append :
 *		push an element onto the end of a one-dimensional array
 *----------------------------------------------------------------------------
 */
Datum
array_append(PG_FUNCTION_ARGS)
{
	ArrayType  *v;
	Datum		newelem;
	bool		isNull;
	ArrayType  *result;
	int		   *dimv,
			   *lb;
	int			indx;
	ArrayMetaState *my_extra;

	v = fetch_array_arg_replace_nulls(fcinfo, 0);
	isNull = PG_ARGISNULL(1);
	if (isNull)
		newelem = (Datum) 0;
	else
		newelem = PG_GETARG_DATUM(1);

	if (ARR_NDIM(v) == 1)
	{
		/* append newelem */
		int			ub;

		lb = ARR_LBOUND(v);
		dimv = ARR_DIMS(v);
		ub = dimv[0] + lb[0] - 1;
		indx = ub + 1;

		/* overflow? */
		if (indx < ub)
			ereport(ERROR,
					(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
					 errmsg("integer out of range")));
	}
	else if (ARR_NDIM(v) == 0)
		indx = 1;
	else
		ereport(ERROR,
				(errcode(ERRCODE_DATA_EXCEPTION),
				 errmsg("argument must be empty or one-dimensional array")));

	/* Perform element insertion */
	my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;

	result = array_set(v, 1, &indx, newelem, isNull,
			   -1, my_extra->typlen, my_extra->typbyval, my_extra->typalign);

	PG_RETURN_ARRAYTYPE_P(result);
}
开发者ID:PJMODOS,项目名称:postgres,代码行数:55,代码来源:array_userfuncs.c


示例14: internal_get_array_of_close_canopies

Datum
internal_get_array_of_close_canopies(PG_FUNCTION_ARGS)
{
    SvecType       *svec;
    Datum          *all_canopies;
    int             num_all_canopies;
    float8          threshold;
    PGFunction      metric_fn;
    
    ArrayType      *close_canopies_arr;
    int4           *close_canopies;
    int             num_close_canopies;
    size_t          bytes;
    MemoryContext   mem_context_for_function_calls;
    
    svec = PG_GETARG_SVECTYPE_P(verify_arg_nonnull(fcinfo, 0));
    get_svec_array_elms(PG_GETARG_ARRAYTYPE_P(verify_arg_nonnull(fcinfo, 1)),
        &all_canopies, &num_all_canopies);
    threshold = PG_GETARG_FLOAT8(verify_arg_nonnull(fcinfo, 2));
    metric_fn = get_metric_fn(PG_GETARG_INT32(verify_arg_nonnull(fcinfo, 3)));
    
    mem_context_for_function_calls = setup_mem_context_for_functional_calls();
    close_canopies = (int4 *) palloc(sizeof(int4) * num_all_canopies);
    num_close_canopies = 0;
    for (int i = 0; i < num_all_canopies; i++) {
        if (compute_metric(metric_fn, mem_context_for_function_calls,
                PointerGetDatum(svec), all_canopies[i]) < threshold)
            close_canopies[num_close_canopies++] = i + 1 /* lower bound */;
    }
    MemoryContextDelete(mem_context_for_function_calls);

    /* If we cannot find any close canopy, return NULL. Note that the result
     * we return will be passed to internal_kmeans_closest_centroid() and if the
     * array of close canopies is NULL, then internal_kmeans_closest_centroid()
     * will consider and compute the distance to all centroids. */
    if (num_close_canopies == 0)
        PG_RETURN_NULL();

    bytes = ARR_OVERHEAD_NONULLS(1) + sizeof(int4) * num_close_canopies;
    close_canopies_arr = (ArrayType *) palloc0(bytes);
    SET_VARSIZE(close_canopies_arr, bytes);
    ARR_ELEMTYPE(close_canopies_arr) = INT4OID;
    ARR_NDIM(close_canopies_arr) = 1;
    ARR_DIMS(close_canopies_arr)[0] = num_close_canopies;
    ARR_LBOUND(close_canopies_arr)[0] = 1;
    memcpy(ARR_DATA_PTR(close_canopies_arr), close_canopies,
        sizeof(int4) * num_close_canopies);

    PG_RETURN_ARRAYTYPE_P(close_canopies_arr);
}
开发者ID:0x0all,项目名称:madlib,代码行数:50,代码来源:kmeans.c


示例15: alpine_miner_covar_sam_final

Datum
alpine_miner_covar_sam_final(PG_FUNCTION_ARGS){
		ArrayType *state ;
		ArrayType *result;
		float8 * resultData;
		float8 * state_array_data;
		int total_length;
		int column_size;
		float8 row_size;
		int result_size;
		int size;
		int k=0;
		int i,j;
		int sam_row_size;

		if (PG_ARGISNULL(0))
			PG_RETURN_NULL();
		state = PG_GETARG_ARRAYTYPE_P(0);

		state_array_data = (float8*) ARR_DATA_PTR(state);
		total_length=ARR_DIMS(state)[0];


		column_size=state_array_data[total_length-1];
		row_size=state_array_data[total_length-2];
		result_size=column_size*(column_size+1)/2;
		size = result_size * sizeof(float8) + ARR_OVERHEAD_NONULLS(1);
		result = (ArrayType *) palloc(size);
		SET_VARSIZE(result, size);
		result->ndim = 1;
		result->dataoffset = 0;
		result->elemtype = FLOAT8OID;
		ARR_DIMS(result)[0] = result_size;
		ARR_LBOUND(result)[0] = 1;
		resultData = (float8*) ARR_DATA_PTR(result);
		memset(resultData, 0, result_size * sizeof(float8));

		 sam_row_size=row_size-1;
		 if(sam_row_size<=0)
		sam_row_size=1;
		  k=0;
		for (  i = 0; i < column_size; i++){
				for(  j = i; j < column_size; j++){
		         	resultData[k] =state_array_data[k]/sam_row_size- state_array_data[result_size+i] * state_array_data[result_size+j]/row_size/sam_row_size;
				k++;
			}
		}
		PG_RETURN_ARRAYTYPE_P(result);

}
开发者ID:thyferny,项目名称:indwa-work,代码行数:50,代码来源:alpine_miner_covar_sam.c


示例16: _ReadChunkArray1El

/*------------------------------------------------------------------------
 * _ReadChunkArray1El --
 *       returns one element of the chunked array as specified by the index "st"
 *       the chunked file descriptor is "fp"
 *-------------------------------------------------------------------------
 */
struct varlena *
_ReadChunkArray1El(int st[],
		   int bsize,
		   int fp,
		   ArrayType *array,
		   bool *isNull)
{
    int i, j, n, temp, srcOff;
    int chunk_st[MAXDIM];
    
    int  *C, csize, *dim, *lb;
    int PCHUNK[MAXDIM], PC[MAXDIM];
    
    CHUNK_INFO *A = (CHUNK_INFO *) ARR_DATA_PTR(array);
    
    n = ARR_NDIM(array); 
    lb = ARR_LBOUND(array); 
    C = A->C;
    dim = ARR_DIMS(array);
    
    csize = C[n-1];
    PC[n-1] = 1;
    temp = dim[n - 1]/C[n-1];
    for (i = n-2; i >= 0; i--){
        PC[i] = PC[i+1] * temp;
        temp = dim[i] / C[i];
        csize *= C[i];
    }
    
    for (i = 0; i < n; st[i] -= lb[i], i++);
    mda_get_prod(n, C, PCHUNK);
    
    array2chunk_coord(n, C, st, chunk_st);
    
    for (i = j = 0; i < n; i++)
        j+= chunk_st[i]*PC[i];
    srcOff = j * csize;
    
    for(i = 0; i < n; i++)
        srcOff += (st[i]-chunk_st[i]*C[i])*PCHUNK[i];
    
    srcOff *= bsize;
    if (lo_lseek(fp, srcOff, SEEK_SET) < 0)
	RETURN_NULL;
#ifdef LOARRAY
    return (struct varlena *) LOread(fp, bsize);
#endif
    return (struct varlena *) 0;
}
开发者ID:jarulraj,项目名称:postgres95,代码行数:55,代码来源:chunk.c


示例17: alpine_plda_count_accum

Datum
alpine_plda_count_accum(PG_FUNCTION_ARGS)
{
	ArrayType *state;
	int32 * state_array_data;
	ArrayType * column_array;
	ArrayType * assign_array;
	int32 column_size,assign_size,topicnumber,wordnumber;
	int32 result_size;
	int32 size;
	int32 * column_array_data;
	int32 * assign_array_data;
	int32 k;
	if (PG_ARGISNULL(0)){
		 PG_RETURN_NULL();
	}
	state = PG_GETARG_ARRAYTYPE_P(0);
	
	state_array_data = (int32*) ARR_DATA_PTR(state);
	
	column_array = PG_GETARG_ARRAYTYPE_P(1);
	column_size = ARR_DIMS(column_array)[0];
	column_array_data = (int32*) ARR_DATA_PTR(column_array);
	assign_array=PG_GETARG_ARRAYTYPE_P(2);
	assign_size = ARR_DIMS(assign_array)[0];
	assign_array_data = (int32*) ARR_DATA_PTR(assign_array);
	topicnumber=PG_GETARG_INT32(3);
	wordnumber =PG_GETARG_INT32(4);
	if (ARR_DIMS(state)[0] == 1){
			result_size = topicnumber*wordnumber;
       	 	size =  result_size * sizeof(int32) + ARR_OVERHEAD_NONULLS(1);
         	state = (ArrayType *) palloc(size);
   	        SET_VARSIZE(state, size);
       	 	state->ndim = 1;
        	state->dataoffset = 0;
        	state->elemtype = INT4OID;
        	ARR_DIMS(state)[0] = result_size;
        	ARR_LBOUND(state)[0] = 1;
			state_array_data = (int32*) ARR_DATA_PTR(state);
	     	memset(state_array_data, 0,  result_size * sizeof(int32));
	}

	for ( k = 0; k < column_size; k++){
		state_array_data[topicnumber*(column_array_data[k]-1)+assign_array_data[k]-1]=state_array_data[topicnumber*(column_array_data[k]-1)+assign_array_data[k]-1]+1;
 	}
    PG_RETURN_ARRAYTYPE_P(state);
}	
开发者ID:thyferny,项目名称:indwa-work,代码行数:47,代码来源:alpine_miner_plda.c


示例18: EA_flatten_into

/*
 * flatten_into method for expanded arrays
 */
static void
EA_flatten_into(ExpandedObjectHeader *eohptr,
				void *result, Size allocated_size)
{
	ExpandedArrayHeader *eah = (ExpandedArrayHeader *) eohptr;
	ArrayType  *aresult = (ArrayType *) result;
	int			nelems;
	int			ndims;
	int32		dataoffset;

	Assert(eah->ea_magic == EA_MAGIC);

	/* Easy if we have a valid flattened value */
	if (eah->fvalue)
	{
		Assert(allocated_size == ARR_SIZE(eah->fvalue));
		memcpy(result, eah->fvalue, allocated_size);
		return;
	}

	/* Else allocation should match previous get_flat_size result */
	Assert(allocated_size == eah->flat_size);

	/* Fill result array from dvalues/dnulls */
	nelems = eah->nelems;
	ndims = eah->ndims;

	if (eah->dnulls)
		dataoffset = ARR_OVERHEAD_WITHNULLS(ndims, nelems);
	else
		dataoffset = 0;			/* marker for no null bitmap */

	/* We must ensure that any pad space is zero-filled */
	memset(aresult, 0, allocated_size);

	SET_VARSIZE(aresult, allocated_size);
	aresult->ndim = ndims;
	aresult->dataoffset = dataoffset;
	aresult->elemtype = eah->element_type;
	memcpy(ARR_DIMS(aresult), eah->dims, ndims * sizeof(int));
	memcpy(ARR_LBOUND(aresult), eah->lbound, ndims * sizeof(int));

	CopyArrayEls(aresult,
				 eah->dvalues, eah->dnulls, nelems,
				 eah->typlen, eah->typbyval, eah->typalign,
				 false);
}
开发者ID:MasahikoSawada,项目名称:postgresql,代码行数:50,代码来源:array_expanded.c


示例19: extract_INT2OID_array

/*
 * Extract len and pointer to buffer from an int16[] (vector) Datum
 * representing a PostgreSQL INT2OID type.
 */
static void
extract_INT2OID_array(Datum array_datum, int *lenp, int16 **vecp)
{
	ArrayType  *array_type;

	Assert(lenp != NULL);
	Assert(vecp != NULL);

	array_type = DatumGetArrayTypeP(array_datum);
	Assert(ARR_NDIM(array_type) == 1);
	Assert(ARR_ELEMTYPE(array_type) == INT2OID);
	Assert(ARR_LBOUND(array_type)[0] == 1);
	*lenp = ARR_DIMS(array_type)[0];
	*vecp = (int16 *) ARR_DATA_PTR(array_type);

	return;
}
开发者ID:BenjaminYu,项目名称:gpdb,代码行数:21,代码来源:cdbcat.c


示例20: PLyList_FromArray

static PyObject *
PLyList_FromArray(PLyDatumToOb *arg, Datum d)
{
	ArrayType  *array = DatumGetArrayTypeP(d);
	PLyDatumToOb *elm = arg->elm;
	PyObject   *list;
	int			length;
	int			lbound;
	int			i;

	if (ARR_NDIM(array) == 0)
		return PyList_New(0);

	if (ARR_NDIM(array) != 1)
		ereport(ERROR,
				(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
			  errmsg("cannot convert multidimensional array to Python list"),
			  errdetail("PL/Python only supports one-dimensional arrays.")));

	length = ARR_DIMS(array)[0];
	lbound = ARR_LBOUND(array)[0];
	list = PyList_New(length);
	if (list == NULL)
		PLy_elog(ERROR, "could not create new Python list");

	for (i = 0; i < length; i++)
	{
		Datum		elem;
		bool		isnull;
		int			offset;

		offset = lbound + i;
		elem = array_ref(array, 1, &offset, arg->typlen,
						 elm->typlen, elm->typbyval, elm->typalign,
						 &isnull);
		if (isnull)
		{
			Py_INCREF(Py_None);
			PyList_SET_ITEM(list, i, Py_None);
		}
		else
			PyList_SET_ITEM(list, i, elm->func(elm, elem));
	}

	return list;
}
开发者ID:AllenDou,项目名称:postgresql,代码行数:46,代码来源:plpy_typeio.c



注:本文中的ARR_LBOUND函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ARR_NDIM函数代码示例发布时间:2022-05-30
下一篇:
C++ ARR_HASNULL函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap