23 #define GETENTRY(vec,pos) ((ltree_gist *) DatumGetPointer((vec)->vector[(pos)].key))
24 #define NEXTVAL(x) ( (ltree*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) )
28 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
29 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
30 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
31 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
32 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
33 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
34 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
35 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
36 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
37 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
38 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
39 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
40 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
41 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
42 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
43 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
46 #define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
81 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
82 errmsg(
"array must be one-dimensional")));
85 (
errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
86 errmsg(
"array must not contain nulls")));
115 if ((sign[i] & 0xff) != 0xff)
189 for (i = 0; i < entryvec->
n; i++)
229 diff = (
unsigned char) (a[i] ^ b[i]);
259 *penalty =
hemdist(origval, newval);
302 maxoff = entryvec->
n - 2;
313 if (size_waste > waste)
327 if (seed_1 == 0 || seed_2 == 0)
366 costvector[j - 1].
pos = j;
368 size_alpha =
hemdist(datum_l, _j);
369 size_beta =
hemdist(datum_r, _j);
370 costvector[j - 1].
cost =
Abs(size_alpha - size_beta);
377 for (k = 0; k < maxoff; k++)
379 j = costvector[k].
pos;
386 else if (j == seed_2)
393 size_alpha =
hemdist(datum_l, _j);
394 size_beta =
hemdist(datum_r, _j);
407 union_l[
i] |= ptr[
i];
423 union_r[
i] |= ptr[
i];
494 bool isexist =
false;
527 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
528 errmsg(
"array must be one-dimensional")));
531 (
errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
532 errmsg(
"array must not contain nulls")));
579 elog(
ERROR,
"unrecognized StrategyNumber: %d", strategy);
PG_FUNCTION_INFO_V1(_ltree_compress)
#define PG_RETURN_POINTER(x)
char name[FLEXIBLE_ARRAY_MEMBER]
static bool gist_qtxt(ltree_gist *key, ltxtquery *query)
static int32 unionkey(BITVECP sbase, ltree_gist *add)
#define GETENTRY(vec, pos)
Datum _ltree_compress(PG_FUNCTION_ARGS)
#define PointerGetDatum(X)
#define PG_GETARG_DATUM(n)
int ArrayGetNItems(int ndim, const int *dims)
int errcode(int sqlerrcode)
#define MemSet(start, val, len)
#define PG_GETARG_POINTER(n)
unsigned int ltree_crc32_sz(char *buf, int size)
bool ltree_execute(ITEM *curitem, void *checkval, bool calcnot, bool(*chkcond)(void *checkval, ITEM *val))
static bool gist_te(ltree_gist *key, ltree *query)
static int hemdist(ltree_gist *a, ltree_gist *b)
static void hashing(BITVECP sign, ltree *t)
static const uint8 number_of_ones[256]
Datum _ltree_same(PG_FUNCTION_ARGS)
#define FirstOffsetNumber
static int hemdistsign(BITVECP a, BITVECP b)
#define ereport(elevel, rest)
Datum _ltree_union(PG_FUNCTION_ARGS)
void * palloc0(Size size)
#define PG_RETURN_BOOL(x)
static bool _arrq_cons(ltree_gist *key, ArrayType *_query)
Datum _ltree_penalty(PG_FUNCTION_ARGS)
unsigned char ABITVEC[ASIGLEN]
#define gistentryinit(e, k, r, pg, o, l)
static bool checkcondition_bit(void *checkval, ITEM *val)
#define OffsetNumberNext(offsetNumber)
static bool gist_qe(ltree_gist *key, lquery *query)
#define PG_FREE_IF_COPY(ptr, n)
#define FLG_CANLOOKSIGN(x)
Datum _ltree_consistent(PG_FUNCTION_ARGS)
#define PG_GETARG_UINT16(n)
#define DatumGetPointer(X)
int errmsg(const char *fmt,...)
#define PG_DETOAST_DATUM(datum)
Datum _ltree_picksplit(PG_FUNCTION_ARGS)
#define SET_VARSIZE(PTR, len)
static int comparecost(const void *a, const void *b)
#define qsort(a, b, c, d)
bool array_contains_nulls(ArrayType *array)
static unsigned hash(unsigned *uv, int n)
static int32 sizebitvec(BITVECP sign)
#define LQL_CANLOOKSIGN(x)
#define DatumGetArrayTypeP(X)