Datum gsfp_consistent(PG_FUNCTION_ARGS) { GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); bool *recheck = (bool *) PG_GETARG_POINTER(4); bytea *key = (bytea*)DatumGetPointer(entry->key); bytea *query; MolSparseFingerPrint data; fcinfo->flinfo->fn_extra = SearchSparseFPCache( fcinfo->flinfo->fn_extra, fcinfo->flinfo->fn_mcxt, PG_GETARG_DATUM(1), NULL, &data, &query); *recheck = true; /* we use signature, so it's needed to recheck */ if (ISALLTRUE(key) && !GIST_LEAF(entry)) { PG_RETURN_BOOL(true); } else { int sum, overlapSum, overlapN; countOverlapValues( (ISALLTRUE(key)) ? NULL : key, data, NUMBITS, &sum, &overlapSum, &overlapN ); PG_RETURN_BOOL( calcConsistency( GIST_LEAF(entry), strategy, overlapSum, /* nCommonUp */ overlapN, /* nCommonDown */ (ISALLTRUE(key)) ? NUMBITS : sizebitvec(key), /* nKey */ sum /* nQuery */ ) ); } }
Datum gsfp_consistent(PG_FUNCTION_ARGS) { GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); bool *recheck = (bool *) PG_GETARG_POINTER(4); bytea *key = (bytea*)DatumGetPointer(entry->key); bytea *query; CSfp data; fcinfo->flinfo->fn_extra = searchSfpCache( fcinfo->flinfo->fn_extra, fcinfo->flinfo->fn_mcxt, PG_GETARG_DATUM(1), NULL, &data, &query); *recheck = true; /* we use signature, so it's needed to recheck */ if (ISALLTRUE(key) && !GIST_LEAF(entry)) { PG_RETURN_BOOL(true); } int sum, overlapSum, overlapN; countOverlapValues( (ISALLTRUE(key)) ? NULL : key, data, NUMBITS, &sum, &overlapSum, &overlapN ); int nKey = (ISALLTRUE(key)) ? NUMBITS : bitstringWeight(SIGLEN(key), (uint8 *)VARDATA(key)); PG_RETURN_BOOL(calcConsistency( GIST_LEAF(entry), strategy, overlapSum, /* nCommonUp */ overlapN, /* nCommonDown */ nKey, sum /* nQuery */ )); }