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

C++ construct_array函数代码示例

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

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



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

示例1: alpine_plda_first

Datum
alpine_plda_first(PG_FUNCTION_ARGS)
{
	ArrayType *assign;
	ArrayType *topiccount;
	int32 * assign_array_data;
	int32 * topiccount_array_data;
	Datum values[2];
	int32 column_size,topicnumber;
	int32 temptopic;
	int32 k;
	bool * isnulls ;
	TupleDesc tuple;
	HeapTuple ret;
	Datum * arr1;
	Datum * arr2;
	if (PG_ARGISNULL(0)){
		 PG_RETURN_NULL();
	}
 
	column_size=PG_GETARG_INT32(0);
	topicnumber=PG_GETARG_INT32(1);
	 
	arr1 = palloc0(column_size * sizeof(Datum));//Datum * 
 
 	assign = construct_array(arr1,column_size,INT4OID,4,true,'i');
 
	assign_array_data = (int32 *)ARR_DATA_PTR(assign);
 
	arr2 = palloc0(topicnumber * sizeof(Datum));//Datum * 
	topiccount = construct_array(arr2,topicnumber,INT4OID,4,true,'i');
	topiccount_array_data = (int32 *)ARR_DATA_PTR(topiccount);
 
	for ( k = 0; k < column_size; k++){
		temptopic = random() % topicnumber + 1;
		assign_array_data[k] = temptopic;
		topiccount_array_data[temptopic-1]++;		 	
	}
 
	values[0] = PointerGetDatum(assign);
	values[1] = PointerGetDatum(topiccount);
 
	if (get_call_result_type(fcinfo, NULL, &tuple) != TYPEFUNC_COMPOSITE)
		ereport(ERROR,
			(errcode( ERRCODE_FEATURE_NOT_SUPPORTED ),
			 errmsg( "function returning record called in context "
				 "that cannot accept type record" )));
	tuple = BlessTupleDesc(tuple);
	isnulls = palloc0(2 * sizeof(bool));
	ret = heap_form_tuple(tuple, values, isnulls);
 
	if (isnulls[0] || isnulls[1])
		ereport(ERROR,
			(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
			 errmsg("function \"%s\" produced null results",
				format_procedure(fcinfo->flinfo->fn_oid))));
 PG_RETURN_DATUM(HeapTupleGetDatum(ret));
      
}	
开发者ID:thyferny,项目名称:indwa-work,代码行数:59,代码来源:alpine_miner_plda.c


示例2: randomTopics

Datum randomTopics(PG_FUNCTION_ARGS)
{
	int32 doclen = PG_GETARG_INT32(0);
	int32 num_topics = PG_GETARG_INT32(1);

	ArrayType * ret_topics_arr, * ret_topic_d_arr;
	int32 * ret_topics, * ret_topic_d;

	Datum * arr1 = palloc0(doclen * sizeof(Datum));
	ret_topics_arr = construct_array(arr1,doclen,INT4OID,4,true,'i');
	ret_topics = (int32 *)ARR_DATA_PTR(ret_topics_arr);

	Datum * arr2 = palloc0(num_topics * sizeof(Datum));
	ret_topic_d_arr = construct_array(arr2,num_topics,INT4OID,4,true,'i');
	ret_topic_d = (int32 *)ARR_DATA_PTR(ret_topic_d_arr);

	/* Sample topics */
	int i, rtopic;
	for (i=0; i!=doclen; i++) {
		rtopic = random() % num_topics + 1;
		ret_topics[i] = rtopic;
		ret_topic_d[rtopic-1]++;
	}
	
	/* Package up the return arrays */
	Datum values[2];
	values[0] = PointerGetDatum(ret_topics_arr);
	values[1] = PointerGetDatum(ret_topic_d_arr);

	TupleDesc tuple;
	if (get_call_result_type(fcinfo, NULL, &tuple) != TYPEFUNC_COMPOSITE)
		ereport(ERROR,
			(errcode( ERRCODE_FEATURE_NOT_SUPPORTED ),
			 errmsg( "function returning record called in context "
				 "that cannot accept type record" )));
	tuple = BlessTupleDesc(tuple);

	bool * isnulls = palloc0(2 * sizeof(bool));
	HeapTuple ret = heap_form_tuple(tuple, values, isnulls);

	if (isnulls[0] || isnulls[1])
		ereport(ERROR,
			(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
			 errmsg("function \"%s\" produced null results",
				format_procedure(fcinfo->flinfo->fn_oid),i)));

	PG_RETURN_DATUM(HeapTupleGetDatum(ret));
}
开发者ID:dcking,项目名称:madlib,代码行数:48,代码来源:plda.c


示例3: lexize

Datum
lexize(PG_FUNCTION_ARGS)
{
	text	   *in = PG_GETARG_TEXT_P(1);
	DictInfo   *dict;
	TSLexeme   *res,
			   *ptr;
	Datum	   *da;
	ArrayType  *a;

	SET_FUNCOID();
	dict = finddict(PG_GETARG_OID(0));

	ptr = res = (TSLexeme *) DatumGetPointer(
										  FunctionCall3(&(dict->lexize_info),
										   PointerGetDatum(dict->dictionary),
												PointerGetDatum(VARDATA(in)),
										Int32GetDatum(VARSIZE(in) - VARHDRSZ)
														)
		);
	PG_FREE_IF_COPY(in, 1);
	if (!res)
	{
		if (PG_NARGS() > 2)
			PG_RETURN_POINTER(NULL);
		else
			PG_RETURN_NULL();
	}

	while (ptr->lexeme)
		ptr++;
	da = (Datum *) palloc(sizeof(Datum) * (ptr - res + 1));
	ptr = res;
	while (ptr->lexeme)
	{
		da[ptr - res] = PointerGetDatum(char2text(ptr->lexeme));
		ptr++;
	}

	a = construct_array(
						da,
						ptr - res,
						TEXTOID,
						-1,
						false,
						'i'
		);

	ptr = res;
	while (ptr->lexeme)
	{
		pfree(DatumGetPointer(da[ptr - res]));
		pfree(ptr->lexeme);
		ptr++;
	}
	pfree(res);
	pfree(da);

	PG_RETURN_POINTER(a);
}
开发者ID:CraigBryan,项目名称:PostgresqlFun,代码行数:60,代码来源:dict.c


示例4: get_range_by_idx

/*
 * Returns N-th range (in form of array)
 *
 * First argument is the parent relid.
 * Second argument is the index of the range (if it is negative then the last
 * range will be returned).
 */
Datum
get_range_by_idx(PG_FUNCTION_ARGS)
{
	int parent_oid = DatumGetInt32(PG_GETARG_DATUM(0));
	int idx = DatumGetInt32(PG_GETARG_DATUM(1));
	PartRelationInfo *prel;
	RangeRelation	*rangerel;
	RangeEntry		*ranges;
	RangeEntry		*re;
	Datum			*elems;
	TypeCacheEntry	*tce;

	prel = get_pathman_relation_info(parent_oid, NULL);

	rangerel = get_pathman_range_relation(parent_oid, NULL);

	if (!prel || !rangerel || idx >= (int)rangerel->ranges.length)
		PG_RETURN_NULL();

	tce = lookup_type_cache(prel->atttype, 0);
	ranges = dsm_array_get_pointer(&rangerel->ranges);
	if (idx >= 0)
		re = &ranges[idx];
	else
		re = &ranges[rangerel->ranges.length - 1];

	elems = palloc(2 * sizeof(Datum));
	elems[0] = PATHMAN_GET_DATUM(re->min, rangerel->by_val);
	elems[1] = PATHMAN_GET_DATUM(re->max, rangerel->by_val);

	PG_RETURN_ARRAYTYPE_P(
		construct_array(elems, 2, prel->atttype,
						tce->typlen, tce->typbyval, tce->typalign));
}
开发者ID:VladimirMikhailov,项目名称:pg_pathman,代码行数:41,代码来源:pl_funcs.c


示例5: zero_array

Datum zero_array(PG_FUNCTION_ARGS)
{
	int32 len = PG_GETARG_INT32(0);
	Datum * array = palloc0(len * sizeof(Datum));
	ArrayType * pgarray = construct_array(array, len, INT4OID, 4, true, 'i');
	PG_RETURN_ARRAYTYPE_P(pgarray);
}
开发者ID:dcking,项目名称:madlib,代码行数:7,代码来源:plda.c


示例6: stem_token_arr

Datum stem_token_arr(PG_FUNCTION_ARGS)
{
    if (PG_ARGISNULL(0)) {
        PG_RETURN_NULL();
    }
    /* Prepare elements to receive input text[] */
    ArrayType *arr = PG_GETARG_ARRAYTYPE_P(0);
    Datum *dtum;
    bool *nulls;
    int ndim;
    /* Deconstruct input text[] */
    deconstruct_array(arr, TEXTOID, -1, false, 'i', &dtum, &nulls, &ndim);
    /* Prepare stemmer */
    struct sb_stemmer *stemmer = sb_stemmer_new(
                                     "english" /* language */, NULL /* language encoding NULL for UTF-8 */);
    Assert(stemmer);

    /* Call stemming code */
    text **result = (text **) palloc(ndim * sizeof(text * ));
    for(int i=0; i< ndim; i++) {
        text *token = dtum[i] == 0 ? NULL : DatumGetTextP(dtum[i]);
        char *empty;
        if(token == NULL) {
            empty =  (char *)palloc(sizeof(char));
            empty[0] = '\0';
        }
        result[i] = (token == NULL ?
                     cstring_to_text(empty) :
                     cstring_to_text(stem_token_text(stemmer, token)));
    }
    ArrayType *res = construct_array((Datum*)result, ndim, TEXTOID, -1, false, 'i');
    sb_stemmer_delete(stemmer);
    PG_RETURN_ARRAYTYPE_P(res);
}
开发者ID:leckie711,项目名称:incubator-madlib,代码行数:34,代码来源:porter_stemmer.c


示例7: postal_normalize

Datum postal_normalize(PG_FUNCTION_ARGS)
{
	text *address = PG_GETARG_TEXT_P(0);
	size_t arr_nelems, i;
	libpostal_normalize_options_t options = libpostal_get_default_options();
	char **expansions = libpostal_expand_address(text_to_cstring(address), options, &arr_nelems);
	ArrayType *arr;
	Datum *arr_elems = palloc(sizeof(Datum) * arr_nelems);
	
	Oid elem_type = TEXTOID;
	int16 elem_len;
	char elem_byval;
	char elem_align;
	
	get_typlenbyvalalign(elem_type, &elem_len, &elem_byval, &elem_align);
	
	for (i = 0; i < arr_nelems; i++)
	{
		arr_elems[i] = PointerGetDatum(cstring_to_text(expansions[i]));
	}
	
	/* Array construction takes a full copy of the input */
	arr = construct_array(arr_elems, arr_nelems, elem_type, elem_len, elem_byval, elem_align);
	
	/* Clean up unmanaged memory */
	libpostal_expansion_array_destroy(expansions, arr_nelems);
	
	PG_RETURN_ARRAYTYPE_P(arr); 
}
开发者ID:pramsey,项目名称:pgsql-postal,代码行数:29,代码来源:postal.c


示例8: tsvector2textarray

Datum
tsvector2textarray(PG_FUNCTION_ARGS)
{
	TSVector	ts = PG_GETARG_TSVECTOR(0);
	ArrayType	*a;
	Datum		*words;
	int			i;
	WordEntry	*wptr = ARRPTR(ts);

	words = palloc( sizeof(Datum) * (ts->size+1) );

	for(i=0; i<ts->size; i++)
	{
		text		*t = palloc(VARHDRSZ + wptr->len);

		SET_VARSIZE(t, VARHDRSZ + wptr->len);
		memcpy( VARDATA(t), STRPTR(ts) + wptr->pos, wptr->len);
		words[i] = PointerGetDatum(t);
	
		wptr++;
	}

	a = construct_array( words, ts->size,
							TEXTOID, -1, false, 'i' );

	PG_FREE_IF_COPY(ts, 0);

	PG_RETURN_ARRAYTYPE_P(a);
}
开发者ID:golem131,项目名称:smlar,代码行数:29,代码来源:tsarr.c


示例9: hstore_akeys

Datum
hstore_akeys(PG_FUNCTION_ARGS)
{
    HStore	   *hs = PG_GETARG_HS(0);
    Datum	   *d;
    ArrayType  *a;
    HEntry	   *entries = ARRPTR(hs);
    char	   *base = STRPTR(hs);
    int			count = HS_COUNT(hs);
    int			i;

    if (count == 0)
    {
        a = construct_empty_array(TEXTOID);
        PG_RETURN_POINTER(a);
    }

    d = (Datum *) palloc(sizeof(Datum) * count);

    for (i = 0; i < count; ++i)
    {
        text	   *item = cstring_to_text_with_len(HS_KEY(entries, base, i),
                           HS_KEYLEN(entries, i));

        d[i] = PointerGetDatum(item);
    }

    a = construct_array(d, count,
                        TEXTOID, -1, false, 'i');

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


示例10: build_array

static Datum
build_array(element_set_t * eset, Oid element_type)
{
    Datum * array_of_datums;
    int i;

    int16       typlen;
    bool        typbyval;
    char        typalign;

    /* do the compaction */
    compact_set(eset, false);

#if DEBUG_PROFILE
    print_set_stats(eset);
#endif
    
    /* get detailed type information on the element type */
    get_typlenbyvalalign(element_type, &typlen, &typbyval, &typalign);

    /* Copy data from compact array to array of Datums
     * A bit suboptimal way, spends excessive memory
     */
    array_of_datums = palloc0(eset->nsorted * sizeof(Datum));
    for (i = 0; i < eset->nsorted; i++)
        memcpy(array_of_datums + i, eset->data + (eset->item_size * i), eset->item_size);

    /* build and return the array */
    PG_RETURN_DATUM(PointerGetDatum(construct_array(
        array_of_datums, eset->nsorted, element_type, typlen, typbyval, typalign
    )));
}
开发者ID:bashtanov,项目名称:count_distinct,代码行数:32,代码来源:count_distinct.c


示例11: float4_accum

Datum
float4_accum(PG_FUNCTION_ARGS)
{
	ArrayType  *transarray = PG_GETARG_ARRAYTYPE_P(0);
	float4		newval4 = PG_GETARG_FLOAT4(1);
	float8	   *transvalues;
	float8		N,
				sumX,
				sumX2,
				newval;
	Datum		transdatums[3];
	ArrayType  *result;

	transvalues = check_float8_array(transarray, "float4_accum");
	N = transvalues[0];
	sumX = transvalues[1];
	sumX2 = transvalues[2];

	/* Do arithmetic in float8 for best accuracy */
	newval = newval4;

	N += 1.0;
	sumX += newval;
	sumX2 += newval * newval;

	transdatums[0] = Float8GetDatumFast(N);
	transdatums[1] = Float8GetDatumFast(sumX);
	transdatums[2] = Float8GetDatumFast(sumX2);

	result = construct_array(transdatums, 3,
							 FLOAT8OID,
						 sizeof(float8), false /* float8 byval */ , 'd');

	PG_RETURN_ARRAYTYPE_P(result);
}
开发者ID:sunyangkobe,项目名称:cscd43,代码行数:35,代码来源:float.c


示例12: WeightedNoReplacement

Datum WeightedNoReplacement(PG_FUNCTION_ARGS) {
	int value1 = PG_GETARG_INT32(0);
	int value2 = PG_GETARG_INT32(1);
	int64 *result = (int64*)palloc(sizeof(int64)*value1);
	int32 i = 0;
	int32 k = 0;
	ArrayType *pgarray;
	float to_select = value1;

   	for(;i < value2; i++){
		

		if(rand()%100 < (to_select/(value2 - i))*100){			
			result[k] = i+1;
			k++;
		}

		if(to_select == 0)
			break; 

   	}
   
	pgarray = construct_array((Datum *)result,
		value1, INT8OID,
		sizeof(int64),true,'d');
    PG_RETURN_ARRAYTYPE_P(pgarray);
}
开发者ID:abhigp,项目名称:madlib,代码行数:27,代码来源:decision_tree.c


示例13: rotation3d_explode

Datum rotation3d_explode(PG_FUNCTION_ARGS)
{
    Rotation3D * rotation3d = (Rotation3D*)PG_GETARG_POINTER(0);

    ArrayType * result;
    Datum * result_data;

    result_data = (Datum*)palloc(sizeof(float8)*9);

    if (!result_data)
    {
        PG_RETURN_NULL();
    }

    result_data[0] = Float8GetDatum(rotation3d->r11);
    result_data[1] = Float8GetDatum(rotation3d->r12);
    result_data[2] = Float8GetDatum(rotation3d->r13);
    result_data[3] = Float8GetDatum(rotation3d->r21);
    result_data[4] = Float8GetDatum(rotation3d->r22);
    result_data[5] = Float8GetDatum(rotation3d->r23);
    result_data[6] = Float8GetDatum(rotation3d->r31);
    result_data[7] = Float8GetDatum(rotation3d->r32);
    result_data[8] = Float8GetDatum(rotation3d->r33);
    
    result = construct_array(result_data, 9, FLOAT8OID, sizeof(float8), true, 'd');

    pfree(result_data);

    PG_RETURN_ARRAYTYPE_P(result);
}
开发者ID:icesoar,项目名称:PG_LLA_ECEF,代码行数:30,代码来源:rotation3d.c


示例14: plr_array_create

/*
 * actually does the work for array(), and array_accum() if it is given a null
 * input array.
 *
 * numelems and elem_start allow the function to be shared given the differing
 * arguments accepted by array() and array_accum(). With array(), all function
 * arguments are used for array construction -- therefore elem_start is 0 and
 * numelems is the number of function arguments. With array_accum(), we are
 * always initializing the array with a single element given to us as argument
 * number 1 (i.e. the second argument).
 *
 */
static ArrayType *
plr_array_create(FunctionCallInfo fcinfo, int numelems, int elem_start)
{
	Oid			funcid = fcinfo->flinfo->fn_oid;
	Datum	   *dvalues = (Datum *) palloc(numelems * sizeof(Datum));
	int16		typlen;
	bool		typbyval;
	Oid			typinput;
	Oid			element_type;
	char		typalign;
	int			i;
	HeapTuple	tp;
	Oid			functypeid;
	Oid		   *funcargtypes;
	ArrayType  *result;

	if (numelems == 0)
		ereport(ERROR,
				(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
				 errmsg("at least one value required to construct an array")));

	/*
	 * Get the type metadata for the array return type and its elements
	 */
	tp = SearchSysCache(PROCOID,
						ObjectIdGetDatum(funcid),
						0, 0, 0);
	if (!HeapTupleIsValid(tp))
		/* internal error */
		elog(ERROR, "function OID %u does not exist", funcid);

	functypeid = ((Form_pg_proc) GETSTRUCT(tp))->prorettype;
	getTypeInputInfo(functypeid, &typinput, &element_type);

	get_typlenbyvalalign(element_type, &typlen, &typbyval, &typalign);

	funcargtypes = FUNCARGTYPES(tp);

	/*
	 * the first function argument(s) may not be one of our array elements,
	 * but the caller is responsible to ensure we get nothing but array
	 * elements once they start coming
	 */
	for (i = elem_start; i < elem_start + numelems; i++)
		if (funcargtypes[i] != element_type)
			ereport(ERROR,
					(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
					 errmsg("argument %d datatype not " \
							"compatible with return data type", i + 1)));

	ReleaseSysCache(tp);

	for (i = 0; i < numelems; i++)
		dvalues[i] = PG_GETARG_DATUM(elem_start + i);

	result = construct_array(dvalues, numelems, element_type,
							 typlen, typbyval, typalign);

	return result;
}
开发者ID:bhavinkamani,项目名称:plr,代码行数:72,代码来源:pg_userfuncs.c


示例15: rep_aggr_class_count_ffunc

/*
 * The final function for aggregating the class counts for REP. It takes the class
 * count array produced by the sfunc and produces a two-element array. The first
 * element is the ID of the class that has the maximum number of cases represented by
 * the root node of the subtree being processed. The second element is the number of
 * reduced misclassified cases if the leave nodes of the subtree are pruned.
 *
 * Parameters:
 *      class_count_data:   The array containing all the information for the 
 *                          calculation of Reduced-Error pruning. 
 * Return:
 *      A two element array.
 */
Datum rep_aggr_class_count_ffunc(PG_FUNCTION_ARGS)
{
    ArrayType *class_count_array    = PG_GETARG_ARRAYTYPE_P(0);
    int array_dim                   = ARR_NDIM(class_count_array);

    check_error_value
		(
			array_dim == 1,
			"invalid array dimension: %d. The dimension of class count array must be equal to 1",
			array_dim
		);

    int *p_array_dim                = ARR_DIMS(class_count_array);
    int array_length                = ArrayGetNItems(array_dim,p_array_dim);
    int64 *class_count_data         = (int64 *)ARR_DATA_PTR(class_count_array);
    int64 *result                   = palloc(sizeof(int64)*2);

    check_error
		(
			result,
			"memory allocation failure"
		);

    int64 max = class_count_data[1];
    int64 sum = max;
    int maxid = 1;
    for(int i = 2; i < array_length; ++i)
    {
        if(max < class_count_data[i])
        {
            max = class_count_data[i];
            maxid = i;
        }

        sum += class_count_data[i];
    }

    /* maxid is the id of the class, which has the most cases */
    result[0] = maxid;

    /*
     * (sum - max) is the number of mis-classified cases represented by
     * the root node of the subtree being processed
     * class_count_data[0] the total number of mis-classified cases
     */
    result[1] = class_count_data[0] - (sum - max);

    ArrayType* result_array =
    	construct_array(
         (Datum *)result,
         2,
         INT8OID,
         sizeof(int64),
         true,
         'd'
        );

    PG_RETURN_ARRAYTYPE_P(result_array);
}
开发者ID:agorajek,项目名称:madlib,代码行数:72,代码来源:decision_tree.c


示例16: GpPolicyStore

/*
 * Sets the policy of a table into the gp_distribution_policy table
 * from a GpPolicy structure.
 */
void
GpPolicyStore(Oid tbloid, const GpPolicy *policy)
{
	Relation	gp_policy_rel;
	HeapTuple	gp_policy_tuple = NULL;

	ArrayType  *attrnums;

	bool		nulls[2];
	Datum		values[2];

	Insist(policy->ptype == POLICYTYPE_PARTITIONED);

    /*
     * Open and lock the gp_distribution_policy catalog.
     */
	gp_policy_rel = heap_open(GpPolicyRelationId, RowExclusiveLock);

	/*
	 * Convert C arrays into Postgres arrays.
	 */
	if (policy->nattrs > 0)
	{
		int			i;
		Datum	   *akey;

		akey = (Datum *) palloc(policy->nattrs * sizeof(Datum));
		for (i = 0; i < policy->nattrs; i++)
			akey[i] = Int16GetDatum(policy->attrs[i]);
		attrnums = construct_array(akey, policy->nattrs,
								   INT2OID, 2, true, 's');
	}
	else
	{
		attrnums = NULL;
	}

	nulls[0] = false;
	nulls[1] = false;
	values[0] = ObjectIdGetDatum(tbloid);

	if (attrnums)
		values[1] = PointerGetDatum(attrnums);
	else
		nulls[1] = true;

	gp_policy_tuple = heap_form_tuple(RelationGetDescr(gp_policy_rel), values, nulls);

	/* Insert tuple into the relation */
	simple_heap_insert(gp_policy_rel, gp_policy_tuple);
	CatalogUpdateIndexes(gp_policy_rel, gp_policy_tuple);

	/*
     * Close the gp_distribution_policy relcache entry without unlocking.
     * We have updated the catalog: consequently the lock must be held until
     * end of transaction.
     */
    heap_close(gp_policy_rel, NoLock);
}                               /* GpPolicyStore */
开发者ID:LJoNe,项目名称:gpdb,代码行数:63,代码来源:cdbcat.c


示例17: spherepoint_xyz

Datum  spherepoint_xyz(PG_FUNCTION_ARGS)
{
    SPoint  * p =  ( SPoint * ) PG_GETARG_POINTER ( 0 ) ;
    Datum    dret[3];
    ArrayType  *result;
    static Vector3D  v ;
    spoint_vector3d ( &v , p );
    dret[0] = Float8GetDatumFast(v.x);
    dret[1] = Float8GetDatumFast(v.y);
    dret[2] = Float8GetDatumFast(v.z);
#ifdef FLOAT8PASSBYVAL
    result = construct_array ( dret , 3, FLOAT8OID, sizeof(float8), FLOAT8PASSBYVAL, 'd');
#else
    result = construct_array ( dret , 3, FLOAT8OID, sizeof(float8), false /* float8 byval */ , 'd' );
#endif
    PG_RETURN_ARRAYTYPE_P(result);
}
开发者ID:mnullmei,项目名称:pgsphere,代码行数:17,代码来源:point.c


示例18: gp_statistics_estimate_reltuples_relpages_oid

/**
 * Given the oid of a relation, this method calculates reltuples, relpages. This only looks up
 * local information (on master or segments). It produces meaningful values for AO and
 * heap tables and returns [0.0,0.0] for all other relations.
 * Input: 
 * 	relationoid
 * Output:
 * 	array of two values [reltuples,relpages]
 */
Datum
gp_statistics_estimate_reltuples_relpages_oid(PG_FUNCTION_ARGS)
{
	
	float4		relpages = 0.0;		
	float4		reltuples = 0.0;			
	Oid			relOid = PG_GETARG_OID(0);
	Datum		values[2];
	ArrayType   *result;
	
	Relation rel = try_relation_open(relOid, AccessShareLock, false);

	if (rel != NULL)
	{
		if (rel->rd_rel->relkind == RELKIND_RELATION)
		{
			if (RelationIsHeap(rel))
			{
				gp_statistics_estimate_reltuples_relpages_heap(rel, &reltuples, &relpages);
			}
			else if (RelationIsAoRows(rel))
			{
				gp_statistics_estimate_reltuples_relpages_ao_rows(rel, &reltuples, &relpages);
			}
			else if	(RelationIsAoCols(rel))
			{
				gp_statistics_estimate_reltuples_relpages_ao_cs(rel, &reltuples, &relpages);
			}
		}
		else if (rel->rd_rel->relkind == RELKIND_INDEX)
		{
			reltuples = 1.0;
			relpages = RelationGetNumberOfBlocks(rel);
		}
		else
		{
			/**
			 * Should we silently return [0.0,0.0] or error out? Currently, we choose option 1.
			 */
		}
		relation_close(rel, AccessShareLock);
	}
	else
	{
		/**
		 * Should we silently return [0.0,0.0] or error out? Currently, we choose option 1.
		 */
	}
	
	values[0] = Float4GetDatum(reltuples);
	values[1] = Float4GetDatum(relpages);

	result = construct_array(values, 2,
					FLOAT4OID,
					sizeof(float4), true, 'i');

	PG_RETURN_ARRAYTYPE_P(result);
}
开发者ID:AnLingm,项目名称:gpdb,代码行数:67,代码来源:analyzefuncs.c


示例19: malloc

Sen_board *construct_board(int len) {
    Sen_board *ret = malloc(sizeof(Sen_board));
    ret->len   = len;
    ret->bound = false;
    ret->data  = construct_array(len);
    ret->print_sep = ' ';
    printf("hi\n");
    return ret;
}
开发者ID:rmunoz12,项目名称:senet,代码行数:9,代码来源:sen_board.c


示例20: xmlnode_children

Datum
xmlnode_children(PG_FUNCTION_ARGS)
{
	xmlnode		nodeRaw = (xmlnode) PG_GETARG_VARLENA_P(0);
	char	   *data = (char *) VARDATA(nodeRaw);
	XMLNodeOffset rootNdOff = XNODE_ROOT_OFFSET(nodeRaw);
	XMLNodeHdr	node = (XMLNodeHdr) (data + rootNdOff);
	TypeInfo	nodeType;
	ArrayType  *result;

	/*
	 * Unfortunately the type info has to be retrieved every time again. If
	 * the backend used global variable to remember the values, all backends
	 * would have to invalidate the values whenever the extension gets dropped
	 * / created.
	 */

	Assert(fcinfo->flinfo != NULL);
	initXNodeTypeInfo(fcinfo->flinfo->fn_oid, 0, &nodeType);

	if (node->kind == XMLNODE_DOC || node->kind == XMLNODE_ELEMENT || node->kind == XMLNODE_DOC_FRAGMENT)
	{
		XMLCompNodeHdr root = (XMLCompNodeHdr) node;
		unsigned short children = root->children;
		Datum	   *elems;
		char	   *childOffPtr;
		unsigned short i;

		if (children == 0)
		{
			result = construct_empty_array(nodeType.oid);
			PG_RETURN_POINTER(result);
		}

		elems = (Datum *) palloc(children * sizeof(Datum));

		childOffPtr = XNODE_FIRST_REF(root);
		for (i = 0; i < children; i++)
		{
			XMLNodeOffset childOff = readXMLNodeOffset(&childOffPtr, XNODE_GET_REF_BWIDTH(root), true);
			XMLNodeHdr	childNode = (XMLNodeHdr) (data + rootNdOff - childOff);
			char	   *childNodeCopy = copyXMLNode(childNode, NULL, true, NULL);

			elems[i] = PointerGetDatum(childNodeCopy);
		}

		result = construct_array(elems, children, nodeType.oid, nodeType.elmlen, nodeType.elmbyval,
								 nodeType.elmalign);
		PG_RETURN_POINTER(result);
	}
	else
	{
		result = construct_empty_array(nodeType.oid);
		PG_RETURN_POINTER(result);
	}
}
开发者ID:andreypopp,项目名称:pg_xnode,代码行数:56,代码来源:xmlnode.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ constructor函数代码示例发布时间:2022-05-30
下一篇:
C++ constructTextRun函数代码示例发布时间: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