uint32 PaletteFaderProcess::I_fadeToPaletteTransform(const uint8* args, unsigned int /*argsize*/) { ARG_UINT16(transform); ARG_UINT16(priority); // If current fader has higher priority, we do nothing if (fader && fader->priority > priority) return 0; else if (fader) fader->terminate(); fader = new PaletteFaderProcess(static_cast<Pentagram::PalTransforms>(transform), priority, 45); return Kernel::get_instance()->addProcess(fader); }
/* * The GiST Consistent method for circles */ datum_t gist_circle_consistent(PG_FUNC_ARGS) { struct gist_entry *entry = (struct gist_entry *)ARG_POINTER(0); CIRCLE *query = ARG_CIRCLE_P(1); strat_nr_t strategy = (strat_nr_t) ARG_UINT16(2); /* oid_t subtype = ARG_OID(3); */ bool *recheck = (bool *) ARG_POINTER(4); BOX bbox; bool result; /* All cases served by this function are inexact */ *recheck = true; if (D_TO_BOX_P(entry->key) == NULL || query == NULL) RET_BOOL(FALSE); /* * Since the operators require recheck anyway, we can just use * rtree_internal_consistent even at leaf nodes. (This works in part * because the index entries are bounding boxes not circles.) */ bbox.high.x = query->center.x + query->radius; bbox.low.x = query->center.x - query->radius; bbox.high.y = query->center.y + query->radius; bbox.low.y = query->center.y - query->radius; result = rtree_internal_consistent(D_TO_BOX_P(entry->key), &bbox, strategy); RET_BOOL(result); }
/* * The GiST Consistent method for polygons */ datum_t gist_poly_consistent(PG_FUNC_ARGS) { struct gist_entry *entry = (struct gist_entry *)ARG_POINTER(0); POLYGON *query = ARG_POLYGON_P(1); strat_nr_t strategy = (strat_nr_t) ARG_UINT16(2); /* oid_t subtype = ARG_OID(3); */ bool *recheck = (bool*) ARG_POINTER(4); bool result; /* All cases served by this function are inexact */ *recheck = true; if (D_TO_BOX_P(entry->key) == NULL || query == NULL) RET_BOOL(FALSE); /* * Since the operators require recheck anyway, we can just use * rtree_internal_consistent even at leaf nodes. (This works in part * because the index entries are bounding boxes not polygons.) */ result = rtree_internal_consistent(D_TO_BOX_P(entry->key), &(query->boundbox), strategy); /* Avoid memory leak if supplied poly is toasted */ PG_FREE_IF_COPY(query, 1); RET_BOOL(result); }
uint32 HealProcess::I_feedAvatar(const uint8* args, unsigned int /*argsize*/) { ARG_UINT16(food); Process* p = Kernel::get_instance()->findProcess(0, 0x222); // CONSTANT! HealProcess* hp = p_dynamic_cast<HealProcess*>(p); if (!hp) { perr << "I_feedAvatar: unable to find HealProcess!" << std::endl; return 0; } hp->feedAvatar(food); return 0; }
datum_t gin_cmp_prefix(PG_FUNC_ARGS) { text *a = ARG_TEXT_PP(0); text *b = ARG_TEXT_PP(1); #ifdef NOT_USED strat_nr_t strategy = ARG_UINT16(2); pointer_p extra_data = ARG_POINTER(3); #endif int cmp; cmp = tsCompareString(VLA_DATA_ANY(a), VLA_SZ_ANY_EXHDR(a), VLA_DATA_ANY(b), VLA_SZ_ANY_EXHDR(b), true); if (cmp < 0) cmp = 1; /* prevent continue scan */ PG_FREE_IF_COPY(a, 0); PG_FREE_IF_COPY(b, 1); RET_INT32(cmp); }
datum_t gist_point_distance(PG_FUNC_ARGS) { struct gist_entry *entry = (struct gist_entry *)ARG_POINTER(0); strat_nr_t strategy = (strat_nr_t) ARG_UINT16(2); double distance; strat_nr_t strategyGroup = strategy / GeoStrategyNumberOffset; switch (strategyGroup) { case PointStrategyNumberGroup: distance = computeDistance( GIST_LEAF(entry), D_TO_BOX_P(entry->key), ARG_POINT_P(1)); break; default: elog(ERROR, "unknown strategy number: %d", strategy); distance = 0.0; /* keep compiler quiet */ } RET_FLOAT8(distance); }
datum_t gbt_cash_consistent(PG_FUNC_ARGS) { struct gist_entry *entry = (struct gist_entry *) ARG_POINTER(0); Cash query = ARG_CASH(1); strat_nr_t strategy = (strat_nr_t) ARG_UINT16(2); /* oid_t subtype = ARG_OID(3); */ bool *recheck = (bool *) ARG_POINTER(4); cashKEY *kkk = (cashKEY *) D_TO_PTR(entry->key); GBT_NUMKEY_R key; /* All cases served by this function are exact */ *recheck = false; key.lower = (GBT_NUMKEY *) &kkk->lower; key.upper = (GBT_NUMKEY *) &kkk->upper; RET_BOOL( gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo) ); }
/* * The GiST Consistent method for boxes * * Should return false if for all data items x below entry, * the predicate x op query must be FALSE, where op is the oper * corresponding to strategy in the pg_amop table. */ datum_t gist_box_consistent(PG_FUNC_ARGS) { struct gist_entry* entry = (struct gist_entry *)ARG_POINTER(0); BOX* query = ARG_BOX_P(1); strat_nr_t strategy = (strat_nr_t) ARG_UINT16(2); /* oid_t subtype = ARG_OID(3); */ bool* recheck = (bool*) ARG_POINTER(4); /* All cases served by this function are exact */ *recheck = false; if (D_TO_BOX_P(entry->key) == NULL || query == NULL) RET_BOOL(FALSE); /* * if entry is not leaf, use rtree_internal_consistent, else use * gist_box_leaf_consistent */ if (GIST_LEAF(entry)) RET_BOOL(gist_box_leaf_consistent(D_TO_BOX_P(entry->key), query, strategy)); else RET_BOOL(rtree_internal_consistent(D_TO_BOX_P(entry->key), query, strategy)); }
datum_t ginint4_queryextract(PG_FUNC_ARGS) { int32 *nentries = (int32 *) ARG_POINTER(1); strat_nr_t strategy = ARG_UINT16(2); int32 *searchMode = (int32 *) ARG_POINTER(6); datum_t *res = NULL; *nentries = 0; if (strategy == BooleanSearchStrategy) { QUERYTYPE *query = ARG_QUERYTYPE_P(0); ITEM *items = GETQUERY(query); int i; /* empty query must fail */ if (query->size <= 0) RET_POINTER(NULL); /* * If the query doesn't have any required primitive values (for * instance, it's something like '! 42'), we have to do a full index * scan. */ if (query_has_required_values(query)) *searchMode = GIN_SEARCH_MODE_DEFAULT; else *searchMode = GIN_SEARCH_MODE_ALL; /* * Extract all the VAL items as things we want GIN to check for. */ res = (datum_t *) palloc(sizeof(datum_t) * query->size); *nentries = 0; for (i = 0; i < query->size; i++) { if (items[i].type == VAL) { res[*nentries] = INT32_TO_D(items[i].val); (*nentries)++; } } } else { array_s *query = ARG_ARRAY_P(0); CHECKARRVALID(query); *nentries = ARRNELEMS(query); if (*nentries > 0) { int4 *arr; int32 i; res = (datum_t *) palloc(sizeof(datum_t) * (*nentries)); arr = ARRPTR(query); for (i = 0; i < *nentries; i++) res[i] = INT32_TO_D(arr[i]); } switch (strategy) { case RTOverlapStrategyNumber: *searchMode = GIN_SEARCH_MODE_DEFAULT; break; case RTContainedByStrategyNumber: case RTOldContainedByStrategyNumber: /* empty set is contained in everything */ *searchMode = GIN_SEARCH_MODE_INCLUDE_EMPTY; break; case RTSameStrategyNumber: if (*nentries > 0) *searchMode = GIN_SEARCH_MODE_DEFAULT; else *searchMode = GIN_SEARCH_MODE_INCLUDE_EMPTY; break; case RTContainsStrategyNumber: case RTOldContainsStrategyNumber: if (*nentries > 0) *searchMode = GIN_SEARCH_MODE_DEFAULT; else /* everything contains the empty set */ *searchMode = GIN_SEARCH_MODE_ALL; break; default: elog(ERROR, "ginint4_queryextract: unknown strategy number: %d", strategy); } } RET_POINTER(res); }
datum_t ginint4_consistent(PG_FUNC_ARGS) { bool *check = (bool *) ARG_POINTER(0); strat_nr_t strategy = ARG_UINT16(1); int32 nkeys = ARG_INT32(3); /* pointer_p *extra_data = (pointer_p *) ARG_POINTER(4); */ bool *recheck = (bool *) ARG_POINTER(5); bool res = FALSE; int32 i; switch (strategy) { case RTOverlapStrategyNumber: /* result is not lossy */ *recheck = false; /* at least one element in check[] is true, so result = true */ res = TRUE; break; case RTContainedByStrategyNumber: case RTOldContainedByStrategyNumber: /* we will need recheck */ *recheck = true; /* at least one element in check[] is true, so result = true */ res = TRUE; break; case RTSameStrategyNumber: /* we will need recheck */ *recheck = true; /* Must have all elements in check[] true */ res = TRUE; for (i = 0; i < nkeys; i++) { if (!check[i]) { res = FALSE; break; } } break; case RTContainsStrategyNumber: case RTOldContainsStrategyNumber: /* result is not lossy */ *recheck = false; /* Must have all elements in check[] true */ res = TRUE; for (i = 0; i < nkeys; i++) { if (!check[i]) { res = FALSE; break; } } break; case BooleanSearchStrategy: { QUERYTYPE *query = ARG_QUERYTYPE_P(2); /* result is not lossy */ *recheck = false; res = gin_bool_consistent(query, check); } break; default: elog(ERROR, "ginint4_consistent: unknown strategy number: %d", strategy); } RET_BOOL(res); }
datum_t gist_point_consistent(PG_FUNC_ARGS) { struct gist_entry *entry = (struct gist_entry*) ARG_POINTER(0); strat_nr_t strategy = (strat_nr_t) ARG_UINT16(2); bool *recheck = (bool*) ARG_POINTER(4); bool result; strat_nr_t strategyGroup = strategy / GeoStrategyNumberOffset; switch (strategyGroup) { case PointStrategyNumberGroup: result = gist_point_consistent_internal( strategy % GeoStrategyNumberOffset, GIST_LEAF(entry), D_TO_BOX_P(entry->key), ARG_POINT_P(1)); *recheck = false; break; case BoxStrategyNumberGroup: result = D_TO_BOOL(DIRECT_FC5( gist_box_consistent, PTR_TO_D(entry), ARG_DATUM(1), INT16_TO_D(RTOverlapStrategyNumber), 0, PTR_TO_D(recheck))); break; case PolygonStrategyNumberGroup: { POLYGON *query = ARG_POLYGON_P(1); result = D_TO_BOOL(DIRECT_FC5( gist_poly_consistent, PTR_TO_D(entry), POLYGON_P_TO_D(query), INT16_TO_D(RTOverlapStrategyNumber), 0, PTR_TO_D(recheck))); if (GIST_LEAF(entry) && result) { /* * We are on leaf page and quick check shows overlapping * of polygon's bounding box and point */ BOX *box; box = D_TO_BOX_P(entry->key); ASSERT(box->high.x == box->low.x && box->high.y == box->low.y); result = D_TO_BOOL(DIRECT_FC2( poly_contain_pt, POLYGON_P_TO_D(query), POINT_P_TO_D(&box->high))); *recheck = false; } } break; case CircleStrategyNumberGroup: { CIRCLE *query = ARG_CIRCLE_P(1); result = D_TO_BOOL(DIRECT_FC5( gist_circle_consistent, PTR_TO_D(entry), CIRCLE_P_TO_D(query), INT16_TO_D(RTOverlapStrategyNumber), 0, PTR_TO_D(recheck))); if (GIST_LEAF(entry) && result) { /* * We are on leaf page and quick check shows overlapping * of polygon's bounding box and point */ BOX *box; box = D_TO_BOX_P(entry->key); ASSERT(box->high.x == box->low.x && box->high.y == box->low.y); result = D_TO_BOOL(DIRECT_FC2( circle_contain_pt, CIRCLE_P_TO_D(query), POINT_P_TO_D(&box->high))); *recheck = false; } } break; default: elog(ERROR, "unknown strategy number: %d", strategy); result = false; /* keep compiler quiet */ } RET_BOOL(result); }