本文整理汇总了C++中PG_GETARG_FLOAT8函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_GETARG_FLOAT8函数的具体用法?C++ PG_GETARG_FLOAT8怎么用?C++ PG_GETARG_FLOAT8使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PG_GETARG_FLOAT8函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
int32 *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 = (int32 *) palloc(sizeof(int32) * 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(int32) * 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(int32) * num_close_canopies);
PG_RETURN_ARRAYTYPE_P(close_canopies_arr);
}
示例2: dsign
/*
* dsign - returns -1 if the argument is less than 0, 0
* if the argument is equal to 0, and 1 if the
* argument is greater than zero.
*/
Datum
dsign(PG_FUNCTION_ARGS)
{
float8 arg1 = PG_GETARG_FLOAT8(0);
float8 result;
if (arg1 > 0)
result = 1.0;
else if (arg1 < 0)
result = -1.0;
else
result = 0.0;
PG_RETURN_FLOAT8(result);
}
示例3: hashfloat8
Datum
hashfloat8(PG_FUNCTION_ARGS)
{
float8 key = PG_GETARG_FLOAT8(0);
/*
* On IEEE-float machines, minus zero and zero have different bit
* patterns but should compare as equal. We must ensure that they
* have the same hash value, which is most easily done this way:
*/
if (key == (float8) 0)
PG_RETURN_UINT32(0);
return hash_any((unsigned char *) &key, sizeof(key));
}
示例4: earth_get_square
Datum earth_get_square(PG_FUNCTION_ARGS)
{
Point *pt = PG_GETARG_POINT_P(0);
double dist = PG_GETARG_FLOAT8(1);
BOX *box;
if(!( (earth_check_point(pt) == 0) && (earth_check_dist(dist) == 0)))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("attempt to get a box form a dist:%.10f rad for a point:(lat=%.10f, lon=%.10f) out of range",dist,pt->x,pt->y)));
box = earth_get_box_internal(pt, dist);
PG_RETURN_BOX_P(box);
}
示例5: cash_div_flt8
/* cash_div_flt8()
* Divide cash by float8.
*
* XXX Don't know if rounding or truncating is correct behavior.
* Round for now. - tgl 97/04/15
*/
Datum
cash_div_flt8(PG_FUNCTION_ARGS)
{
Cash c = PG_GETARG_CASH(0);
float8 f = PG_GETARG_FLOAT8(1);
Cash result;
if (f == 0.0)
ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
result = rint(c / f);
PG_RETURN_CASH(result);
}
示例6: aggr_InfoGain
Datum aggr_InfoGain(PG_FUNCTION_ARGS) {
ArrayType *state = PG_GETARG_ARRAYTYPE_P(0);
int dimstate = ARR_NDIM(state);
int *dimsstate = ARR_DIMS(state);
int numstate = ArrayGetNItems(dimstate,dimsstate);
float8 *vals_state=(float8 *)ARR_DATA_PTR(state);
float8 truevalue = PG_GETARG_FLOAT8(1);
float8 trueweight = PG_GETARG_FLOAT8(2);
int32 posclasses = PG_GETARG_INT32(3);
int32 trueclass = PG_GETARG_INT32(5);
ArrayType *pgarray;
vals_state[0] += trueweight;
vals_state[trueclass] += trueweight;
vals_state[(int)(truevalue*(posclasses+1))] += trueweight;
vals_state[(int)(truevalue*(posclasses+1) + trueclass)] += trueweight;
pgarray = construct_array((Datum *)vals_state,
numstate,FLOAT8OID,
sizeof(float8),true,'d');
PG_RETURN_ARRAYTYPE_P(pgarray);
}
示例7: cube_f8
/* Create a one dimensional box with identical upper and lower coordinates */
Datum
cube_f8(PG_FUNCTION_ARGS)
{
double x = PG_GETARG_FLOAT8(0);
NDBOX *result;
int size;
size = offsetof(NDBOX, x[0]) +sizeof(double) * 2;
result = (NDBOX *) palloc0(size);
SET_VARSIZE(result, size);
result->dim = 1;
result->x[0] = result->x[1] = x;
PG_RETURN_NDBOX(result);
}
示例8: cube_f8
/* Create a one dimensional box with identical upper and lower coordinates */
Datum
cube_f8(PG_FUNCTION_ARGS)
{
NDBOX *result;
int size;
size = offsetof(NDBOX, x[0]) + sizeof(double) * 2;
result = (NDBOX *) palloc(size);
memset(result, 0, size);
result->size = size;
result->dim = 1;
result->x[0] = PG_GETARG_FLOAT8(0);
result->x[1] = result->x[0];
PG_RETURN_NDBOX(result);
}
示例9: dsqrt
/*
* dsqrt - returns square root of arg1
*/
Datum
dsqrt(PG_FUNCTION_ARGS)
{
float8 arg1 = PG_GETARG_FLOAT8(0);
float8 result;
if (arg1 < 0)
ereport(ERROR,
(errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
errmsg("cannot take square root of a negative number")));
result = sqrt(arg1);
CheckFloat8Val(result);
PG_RETURN_FLOAT8(result);
}
示例10: orafce_to_char_float8
Datum
orafce_to_char_float8(PG_FUNCTION_ARGS)
{
float8 arg0 = PG_GETARG_FLOAT8(0);
StringInfo buf = makeStringInfo();
struct lconv *lconv = PGLC_localeconv();
char *p;
appendStringInfo(buf, "%f", arg0);
for (p = buf->data; *p; p++)
if (*p == '.')
*p = lconv->decimal_point[0];
PG_RETURN_TEXT_P(cstring_to_text(buf->data));
}
示例11: float48div
Datum
float48div(PG_FUNCTION_ARGS)
{
float4 arg1 = PG_GETARG_FLOAT4(0);
float8 arg2 = PG_GETARG_FLOAT8(1);
float8 result;
if (arg2 == 0.0)
ereport(ERROR,
(errcode(ERRCODE_DIVISION_BY_ZERO),
errmsg("division by zero")));
result = arg1 / arg2;
CheckFloat8Val(result);
PG_RETURN_FLOAT8(result);
}
示例12: cube_f8
/* Create a one dimensional box with identical upper and lower coordinates */
Datum
cube_f8(PG_FUNCTION_ARGS)
{
double x = PG_GETARG_FLOAT8(0);
NDBOX *result;
int size;
size = POINT_SIZE(1);
result = (NDBOX *) palloc0(size);
SET_VARSIZE(result, size);
SET_DIM(result, 1);
SET_POINT_BIT(result);
result->x[0] = x;
PG_RETURN_NDBOX(result);
}
示例13: delta_e_cmc_full
Datum
delta_e_cmc_full(PG_FUNCTION_ARGS)
{
float8 result;
float8 l1 = PG_GETARG_FLOAT8(0);
float8 a1 = PG_GETARG_FLOAT8(1);
float8 b1 = PG_GETARG_FLOAT8(2);
float8 l2 = PG_GETARG_FLOAT8(3);
float8 a2 = PG_GETARG_FLOAT8(4);
float8 b2 = PG_GETARG_FLOAT8(5);
float8 pl = PG_GETARG_FLOAT8(6);
float8 pc = PG_GETARG_FLOAT8(7);
result = colors_delta_e_cmc(l1, a1, b1, l2, a2, b2, pl, pc);
PG_RETURN_FLOAT8(result);
}
示例14: dbms_alert_waitany
Datum
dbms_alert_waitany(PG_FUNCTION_ARGS)
{
float8 timeout;
TupleDesc tupdesc;
AttInMetadata *attinmeta;
HeapTuple tuple;
Datum result;
char *str[3] = {NULL, NULL, "1"};
int cycle = 0;
float8 endtime;
TupleDesc btupdesc;
if (PG_ARGISNULL(0))
timeout = TDAYS;
else
timeout = PG_GETARG_FLOAT8(0);
WATCH_PRE(timeout, endtime, cycle);
if (ora_lock_shmem(SHMEMMSGSZ, MAX_PIPES, MAX_EVENTS, MAX_LOCKS, false))
{
str[1] = find_and_remove_message_item(-1, sid,
true, false, false, NULL, &str[0]);
if (str[0])
{
str[2] = "0";
LWLockRelease(shmem_lock);
break;
}
LWLockRelease(shmem_lock);
}
WATCH_POST(timeout, endtime, cycle);
get_call_result_type(fcinfo, NULL, &tupdesc);
btupdesc = BlessTupleDesc(tupdesc);
attinmeta = TupleDescGetAttInMetadata(btupdesc);
tuple = BuildTupleFromCStrings(attinmeta, str);
result = HeapTupleGetDatum(tuple);
if (str[0])
pfree(str[0]);
if (str[1])
pfree(str[1]);
return result;
}
示例15: gbt_float8_distance
Datum
gbt_float8_distance(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
float8 query = PG_GETARG_FLOAT8(1);
/* Oid subtype = PG_GETARG_OID(3); */
float8KEY *kkk = (float8KEY *) DatumGetPointer(entry->key);
GBT_NUMKEY_R key;
key.lower = (GBT_NUMKEY *) &kkk->lower;
key.upper = (GBT_NUMKEY *) &kkk->upper;
PG_RETURN_FLOAT8(
gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
);
}