本文整理汇总了C++中FunctionCall2函数的典型用法代码示例。如果您正苦于以下问题:C++ FunctionCall2函数的具体用法?C++ FunctionCall2怎么用?C++ FunctionCall2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FunctionCall2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: genericPickSplit
/*
* Trivial picksplit implementaion. Function called only
* if user-defined picksplit puts all keys to the one page.
* That is a bug of user-defined picksplit but we'd like
* to "fix" that.
*/
static void
genericPickSplit(GISTSTATE *giststate, GistEntryVector *entryvec, GIST_SPLITVEC *v, int attno)
{
OffsetNumber i,
maxoff;
int nbytes;
GistEntryVector *evec;
maxoff = entryvec->n - 1;
nbytes = (maxoff + 2) * sizeof(OffsetNumber);
v->spl_left = (OffsetNumber *) palloc(nbytes);
v->spl_right = (OffsetNumber *) palloc(nbytes);
v->spl_nleft = v->spl_nright = 0;
for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
{
if (i <= (maxoff - FirstOffsetNumber + 1) / 2)
{
v->spl_left[v->spl_nleft] = i;
v->spl_nleft++;
}
else
{
v->spl_right[v->spl_nright] = i;
v->spl_nright++;
}
}
/*
* Form unions of each page
*/
evec = palloc( sizeof(GISTENTRY) * entryvec->n + GEVHDRSZ );
evec->n = v->spl_nleft;
memcpy(evec->vector, entryvec->vector + FirstOffsetNumber,
sizeof(GISTENTRY) * evec->n);
v->spl_ldatum = FunctionCall2(&giststate->unionFn[attno],
PointerGetDatum(evec),
PointerGetDatum(&nbytes));
evec->n = v->spl_nright;
memcpy(evec->vector, entryvec->vector + FirstOffsetNumber + v->spl_nleft,
sizeof(GISTENTRY) * evec->n);
v->spl_rdatum = FunctionCall2(&giststate->unionFn[attno],
PointerGetDatum(evec),
PointerGetDatum(&nbytes));
}
示例2: inet_semi_join_sel
/*
* Inet semi join selectivity estimation for one value
*
* The function calculates the probability that there is at least one row
* in the RHS table that satisfies the "lhs_value op column" condition.
* It is used in semi join estimation to check a sample from the left hand
* side table.
*
* The MCV and histogram from the right hand side table should be provided as
* arguments with the lhs_value from the left hand side table for the join.
* hist_weight is the total number of rows represented by the histogram.
* For example, if the table has 1000 rows, and 10% of the rows are in the MCV
* list, and another 10% are NULLs, hist_weight would be 800.
*
* First, the lhs_value will be matched to the most common values. If it
* matches any of them, 1.0 will be returned, because then there is surely
* a match.
*
* Otherwise, the histogram will be used to estimate the number of rows in
* the second table that match the condition. If the estimate is greater
* than 1.0, 1.0 will be returned, because it means there is a greater chance
* that the lhs_value will match more than one row in the table. If it is
* between 0.0 and 1.0, it will be returned as the probability.
*/
static Selectivity
inet_semi_join_sel(Datum lhs_value,
bool mcv_exists, Datum *mcv_values, int mcv_nvalues,
bool hist_exists, Datum *hist_values, int hist_nvalues,
double hist_weight,
FmgrInfo *proc, int opr_codenum)
{
if (mcv_exists)
{
int i;
for (i = 0; i < mcv_nvalues; i++)
{
if (DatumGetBool(FunctionCall2(proc,
lhs_value,
mcv_values[i])))
return 1.0;
}
}
if (hist_exists && hist_weight > 0)
{
Selectivity hist_selec;
/* Commute operator, since we're passing lhs_value on the right */
hist_selec = inet_hist_value_sel(hist_values, hist_nvalues,
lhs_value, -opr_codenum);
if (hist_selec > 0)
return Min(1.0, hist_weight * hist_selec);
}
return 0.0;
}
示例3: cmpEntries
static int
cmpEntries(const void *a, const void *b, void *arg)
{
const keyEntryData *aa = (const keyEntryData *) a;
const keyEntryData *bb = (const keyEntryData *) b;
cmpEntriesArg *data = (cmpEntriesArg *) arg;
int res;
if (aa->isnull)
{
if (bb->isnull)
res = 0; /* NULL "=" NULL */
else
res = 1; /* NULL ">" not-NULL */
}
else if (bb->isnull)
res = -1; /* not-NULL "<" NULL */
else
res = DatumGetInt32(FunctionCall2(data->cmpDatumFunc,
aa->datum, bb->datum));
/*
* Detect if we have any duplicates. If there are equal keys, qsort
* must compare them at some point, else it wouldn't know whether one
* should go before or after the other.
*/
if (res == 0)
data->haveDups = true;
return res;
}
示例4: extractEntriesS
Datum *
extractEntriesS(GinState *ginstate, OffsetNumber attnum, Datum value, int32 *nentries,
bool *needUnique)
{
Datum *entries;
entries = (Datum *) DatumGetPointer(FunctionCall2(
&ginstate->extractValueFn[attnum - 1],
value,
PointerGetDatum(nentries)
));
if (entries == NULL)
*nentries = 0;
*needUnique = FALSE;
if (*nentries > 1)
{
cmpEntriesData arg;
arg.cmpDatumFunc = &ginstate->compareFn[attnum - 1];
arg.needUnique = needUnique;
qsort_arg(entries, *nentries, sizeof(Datum),
(qsort_arg_comparator) cmpEntries, (void *) &arg);
}
return entries;
}
示例5: FunctionCall
globle int FunctionCall(
char *name,
char *args,
DATA_OBJECT *result)
{
FUNCTION_REFERENCE theReference;
/*=======================================*/
/* Call the function if it can be found. */
/*=======================================*/
if (GetFunctionReference(name,&theReference))
{ return(FunctionCall2(&theReference,args,result)); }
/*=========================================================*/
/* Otherwise signal an error if a deffunction, defgeneric, */
/* or user defined function doesn't exist that matches */
/* the specified function name. */
/*=========================================================*/
PrintErrorID("EVALUATN",2,FALSE);
PrintRouter(WERROR,"No function, generic function or deffunction of name ");
PrintRouter(WERROR,name);
PrintRouter(WERROR," exists for external call.\n");
return(TRUE);
}
示例6: index_getbitmap
/* ----------------
* index_getbitmap - get all tuples at once from an index scan
*
* Adds the TIDs of all heap tuples satisfying the scan keys to a bitmap.
* Since there's no interlock between the index scan and the eventual heap
* access, this is only safe to use with MVCC-based snapshots: the heap
* item slot could have been replaced by a newer tuple by the time we get
* to it.
*
* Returns the number of matching tuples found. (Note: this might be only
* approximate, so it should only be used for statistical purposes.)
* ----------------
*/
int64
index_getbitmap(IndexScanDesc scan, TIDBitmap *bitmap)
{
FmgrInfo *procedure;
int64 ntids;
Datum d;
SCAN_CHECKS;
GET_SCAN_PROCEDURE(amgetbitmap);
/* just make sure this is false... */
scan->kill_prior_tuple = false;
/*
* have the am's getbitmap proc do all the work.
*/
d = FunctionCall2(procedure,
PointerGetDatum(scan),
PointerGetDatum(bitmap));
ntids = DatumGetInt64(d);
/* If int8 is pass-by-ref, must free the result to avoid memory leak */
#ifndef USE_FLOAT8_BYVAL
pfree(DatumGetPointer(d));
#endif
pgstat_count_index_tuples(scan->indexRelation, ntids);
return ntids;
}
示例7: hlparsetext
void
hlparsetext(TSCfgInfo * cfg, HLPRSTEXT * prs, QUERYTYPE * query, char *buf, int4 buflen)
{
int type,
lenlemm;
char *lemm = NULL;
WParserInfo *prsobj = findprs(cfg->prs_id);
LexizeData ldata;
TSLexeme *norms;
ParsedLex *lexs;
prsobj->prs = (void *) DatumGetPointer(
FunctionCall2(
&(prsobj->start_info),
PointerGetDatum(buf),
Int32GetDatum(buflen)
)
);
LexizeInit(&ldata, cfg);
do
{
type = DatumGetInt32(FunctionCall3(
&(prsobj->getlexeme_info),
PointerGetDatum(prsobj->prs),
PointerGetDatum(&lemm),
PointerGetDatum(&lenlemm)));
if (type > 0 && lenlemm >= MAXSTRLEN)
{
#ifdef IGNORE_LONGLEXEME
ereport(NOTICE,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("A word you are indexing is too long. It will be ignored.")));
continue;
#else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("A word you are indexing is too long")));
#endif
}
LexizeAddLemm(&ldata, type, lemm, lenlemm);
do
{
if ((norms = LexizeExec(&ldata, &lexs)) != NULL)
addHLParsedLex(prs, query, lexs, norms);
else
addHLParsedLex(prs, query, lexs, NULL);
} while (norms);
} while (type > 0);
FunctionCall1(
&(prsobj->end_info),
PointerGetDatum(prsobj->prs)
);
}
示例8: execTuplesMatch
/*
* execTuplesMatch
* Return true if two tuples match in all the indicated fields.
*
* This actually implements SQL's notion of "not distinct". Two nulls
* match, a null and a not-null don't match.
*
* slot1, slot2: the tuples to compare (must have same columns!)
* numCols: the number of attributes to be examined
* matchColIdx: array of attribute column numbers
* eqFunctions: array of fmgr lookup info for the equality functions to use
* evalContext: short-term memory context for executing the functions
*
* NB: evalContext is reset each time!
*/
bool
execTuplesMatch(TupleTableSlot *slot1,
TupleTableSlot *slot2,
int numCols,
AttrNumber *matchColIdx,
FmgrInfo *eqfunctions,
MemoryContext evalContext)
{
MemoryContext oldContext;
bool result;
int i;
/* Reset and switch into the temp context. */
MemoryContextReset(evalContext);
oldContext = MemoryContextSwitchTo(evalContext);
/*
* We cannot report a match without checking all the fields, but we can
* report a non-match as soon as we find unequal fields. So, start
* comparing at the last field (least significant sort key). That's the
* most likely to be different if we are dealing with sorted input.
*/
result = true;
for (i = numCols; --i >= 0;)
{
AttrNumber att = matchColIdx[i];
Datum attr1,
attr2;
bool isNull1,
isNull2;
attr1 = slot_getattr(slot1, att, &isNull1);
attr2 = slot_getattr(slot2, att, &isNull2);
if (isNull1 != isNull2)
{
result = false; /* one null and one not; they aren't equal */
break;
}
if (isNull1)
continue; /* both are null, treat as equal */
/* Apply the type-specific equality function */
if (!DatumGetBool(FunctionCall2(&eqfunctions[i],
attr1, attr2)))
{
result = false; /* they aren't equal */
break;
}
}
MemoryContextSwitchTo(oldContext);
return result;
}
示例9: compare_indextuple
static int
compare_indextuple(const IndexTuple itup1, const IndexTuple itup2,
ScanKey entry, int keysz, TupleDesc tupdes, bool *hasnull)
{
int i;
int32 compare;
*hasnull = false;
for (i = 1; i <= keysz; i++, entry++)
{
Datum attrDatum1,
attrDatum2;
bool isNull1,
isNull2;
attrDatum1 = index_getattr(itup1, i, tupdes, &isNull1);
attrDatum2 = index_getattr(itup2, i, tupdes, &isNull2);
if (isNull1)
{
*hasnull = true;
if (isNull2)
compare = 0; /* NULL "=" NULL */
else if (entry->sk_flags & SK_BT_NULLS_FIRST)
compare = -1; /* NULL "<" NOT_NULL */
else
compare = 1; /* NULL ">" NOT_NULL */
}
else if (isNull2)
{
*hasnull = true;
if (entry->sk_flags & SK_BT_NULLS_FIRST)
compare = 1; /* NOT_NULL ">" NULL */
else
compare = -1; /* NOT_NULL "<" NULL */
}
else
{
compare =
#if PG_VERSION_NUM >= 90100
DatumGetInt32(FunctionCall2Coll(&entry->sk_func,
entry->sk_collation,
attrDatum1,
attrDatum2));
#else
DatumGetInt32(FunctionCall2(&entry->sk_func,
attrDatum1,
attrDatum2));
#endif
if (entry->sk_flags & SK_BT_DESC)
compare = -compare;
}
if (compare != 0)
return compare;
}
return 0;
}
示例10: compareEntries
int
compareEntries(GinState *ginstate, OffsetNumber attnum, Datum a, Datum b)
{
return DatumGetInt32(
FunctionCall2(
&ginstate->compareFn[attnum - 1],
a, b
)
);
}
示例11: prs_setup_firstcall
static void
prs_setup_firstcall(FuncCallContext *funcctx, Oid prsid, text *txt)
{
TupleDesc tupdesc;
MemoryContext oldcontext;
PrsStorage *st;
TSParserCacheEntry *prs = lookup_ts_parser_cache(prsid);
char *lex = NULL;
int llen = 0,
type = 0;
void *prsdata;
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
st = (PrsStorage *) palloc(sizeof(PrsStorage));
st->cur = 0;
st->len = 16;
st->list = (LexemeEntry *) palloc(sizeof(LexemeEntry) * st->len);
prsdata = (void *) DatumGetPointer(FunctionCall2(&prs->prsstart,
PointerGetDatum(VARDATA(txt)),
Int32GetDatum(VARSIZE(txt) - VARHDRSZ)));
while ((type = DatumGetInt32(FunctionCall3(&prs->prstoken,
PointerGetDatum(prsdata),
PointerGetDatum(&lex),
PointerGetDatum(&llen)))) != 0)
{
if (st->cur >= st->len)
{
st->len = 2 * st->len;
st->list = (LexemeEntry *) repalloc(st->list, sizeof(LexemeEntry) * st->len);
}
st->list[st->cur].lexeme = palloc(llen + 1);
memcpy(st->list[st->cur].lexeme, lex, llen);
st->list[st->cur].lexeme[llen] = '\0';
st->list[st->cur].type = type;
st->cur++;
}
FunctionCall1(&prs->prsend, PointerGetDatum(prsdata));
st->len = st->cur;
st->cur = 0;
funcctx->user_fctx = (void *) st;
tupdesc = CreateTemplateTupleDesc(2, false);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "tokid",
INT4OID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "token",
TEXTOID, -1, 0);
funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
MemoryContextSwitchTo(oldcontext);
}
示例12: reestimateParameters
void
reestimateParameters(ModelInfo *modelInfo, Node *whereExpr)
{
//increment the commandCounter so ALL tuples (also the new INSERTED) can be accessed
CommandCounterIncrement();
if(sdf==2||sdf==4){
modelInfo->disAggKeyDenominator = 0;
}
FunctionCall2(&(modelInfo->algInfo)->algReestimateUpdate,PointerGetDatum(modelInfo), PointerGetDatum(whereExpr));
}
示例13: cmpEntries
static int
cmpEntries(const Datum *a, const Datum *b, cmpEntriesData *arg)
{
int res = DatumGetInt32(FunctionCall2(arg->cmpDatumFunc,
*a, *b));
if (res == 0)
*(arg->needUnique) = TRUE;
return res;
}
示例14: check_overlap
/*
* Checks if range overlaps with existing partitions.
* Returns TRUE if overlaps and FALSE otherwise.
*/
Datum
check_overlap(PG_FUNCTION_ARGS)
{
int parent_oid = DatumGetInt32(PG_GETARG_DATUM(0));
Datum p1 = PG_GETARG_DATUM(1);
Oid p1_type = get_fn_expr_argtype(fcinfo->flinfo, 1);
Datum p2 = PG_GETARG_DATUM(2);
Oid p2_type = get_fn_expr_argtype(fcinfo->flinfo, 2);
PartRelationInfo *prel;
RangeRelation *rangerel;
RangeEntry *ranges;
FmgrInfo cmp_func_1;
FmgrInfo cmp_func_2;
int i;
bool byVal;
prel = get_pathman_relation_info(parent_oid, NULL);
rangerel = get_pathman_range_relation(parent_oid, NULL);
if (!prel || !rangerel || prel->parttype != PT_RANGE)
PG_RETURN_NULL();
/* comparison functions */
cmp_func_1 = *get_cmp_func(p1_type, prel->atttype);
cmp_func_2 = *get_cmp_func(p2_type, prel->atttype);
byVal = rangerel->by_val;
ranges = (RangeEntry *) dsm_array_get_pointer(&rangerel->ranges);
for (i=0; i<rangerel->ranges.length; i++)
{
int c1 = FunctionCall2(&cmp_func_1, p1,
PATHMAN_GET_DATUM(ranges[i].max, byVal));
int c2 = FunctionCall2(&cmp_func_2, p2,
PATHMAN_GET_DATUM(ranges[i].min, byVal));
if (c1 < 0 && c2 > 0)
PG_RETURN_BOOL(true);
}
PG_RETURN_BOOL(false);
}
示例15: processForecastModel
/*
* processForecastModel
*
* gets called every time an input tuple is processed
*/
void
processForecastModel(ModelInfo *model, Datum value)
{
// process value internally as double
double fValue = GetDatumAsDouble(exprType((Node*) model->measure->expr), value);
if((sdf==2||sdf==4)){
model->disAggKeyDenominator += fValue;
}
// call algorithm specific method
FunctionCall2(&(model->algInfo->algProcessForecast),PointerGetDatum(model->model),Float8GetDatum(fValue));
}