CHANGES
+Aug 9, 2002
+ Fixed very stupid but important bug :-)
July 31, 2002
Now works on 64-bit platforms.
Added function lca - lowest common ancestor
TODO
* Testing on 64-bit platforms. There are several known problems with byte
- alignment;
+ alignment; -- RESOLVED
* Better documentation;
* We plan (probably) to improve regular expressions processing using
non-deterministic automata;
int hash;
while(tlen > 0) {
- hash = crc32_sz( cur->name, cur->len );
+ hash = ltree_crc32_sz( cur->name, cur->len );
AHASH( sign, hash );
cur = LEVEL_NEXT(cur);
tlen--;
return true;
while( qlen>0 ) {
- hv = crc32_sz(curq->name,curq->len);
+ hv = ltree_crc32_sz(curq->name,curq->len);
if ( ! GETBIT( sign, AHASHVAL(hv) ) )
return false;
curq = LEVEL_NEXT(curq);
if ( LTG_ISALLTRUE(key) )
return true;
- return execute(
+ return ltree_execute(
GETQUERY(query),
(void*)LTG_SIGN(key), false,
checkcondition_bit
};
unsigned int
-crc32_sz(char *buf, int size)
+ltree_crc32_sz(char *buf, int size)
{
unsigned int crc = ~0;
char *p;
#define _CRC32_H
/* Returns crc32 of data block */
-extern unsigned int crc32_sz(char *buf, int size);
+extern unsigned int ltree_crc32_sz(char *buf, int size);
/* Returns crc32 of null-terminated string */
-#define crc32(buf) crc32_sz((buf),strlen(buf))
+#define crc32(buf) ltree_crc32_sz((buf),strlen(buf))
#endif
/* Util function */
Datum ltree_in(PG_FUNCTION_ARGS);
-bool execute(ITEM * curitem, void *checkval,
+bool ltree_execute(ITEM * curitem, void *checkval,
bool calcnot, bool (*chkcond) (void *checkval, ITEM * val));
int ltree_compare(const ltree *a, const ltree *b);
int hash;
while(tlen > 0) {
- hash = crc32_sz( cur->name, cur->len );
+ hash = ltree_crc32_sz( cur->name, cur->len );
HASH( sign, hash );
cur = LEVEL_NEXT(cur);
tlen--;
if ( LTG_ISALLTRUE(key) )
return true;
- return execute(
+ return ltree_execute(
GETQUERY(query),
(void*)LTG_SIGN(key), false,
checkcondition_bit
cur->totallen += MAXALIGN(LVAR_HDRSIZE + lptr->len);
lrptr->len = lptr->len;
lrptr->flag = lptr->flag;
- lrptr->val = crc32_sz((uint8 *) lptr->start, lptr->len);
+ lrptr->val = ltree_crc32_sz((uint8 *) lptr->start, lptr->len);
memcpy( lrptr->name, lptr->start, lptr->len);
lptr++;
lrptr = LVAR_NEXT( lrptr );
if (lenval > 0xffff)
elog(ERROR, "Word is too long");
- pushquery(state, type, crc32_sz((uint8 *) strval, lenval),
+ pushquery(state, type, ltree_crc32_sz((uint8 *) strval, lenval),
state->curop - state->op, lenval, flag);
while (state->curop - state->op + lenval + 1 >= state->lenop)
* check for boolean condition
*/
bool
-execute(ITEM * curitem, void *checkval, bool calcnot, bool (*chkcond) (void *checkval, ITEM * val)) {
+ltree_execute(ITEM * curitem, void *checkval, bool calcnot, bool (*chkcond) (void *checkval, ITEM * val)) {
if (curitem->type == VAL)
return (*chkcond) (checkval, curitem);
else if (curitem->val == (int4) '!') {
return (calcnot) ?
- ((execute(curitem + 1, checkval, calcnot, chkcond)) ? false : true)
+ ((ltree_execute(curitem + 1, checkval, calcnot, chkcond)) ? false : true)
: true;
} else if (curitem->val == (int4) '&') {
- if (execute(curitem + curitem->left, checkval, calcnot, chkcond))
- return execute(curitem + 1, checkval, calcnot, chkcond);
+ if (ltree_execute(curitem + curitem->left, checkval, calcnot, chkcond))
+ return ltree_execute(curitem + 1, checkval, calcnot, chkcond);
else
return false;
} else { /* |-operator */
- if (execute(curitem + curitem->left, checkval, calcnot, chkcond))
+ if (ltree_execute(curitem + curitem->left, checkval, calcnot, chkcond))
return true;
else
- return execute(curitem + 1, checkval, calcnot, chkcond);
+ return ltree_execute(curitem + 1, checkval, calcnot, chkcond);
}
return false;
}
chkval.node = val;
chkval.operand = GETOPERAND(query);
- result = execute(
+ result = ltree_execute(
GETQUERY(query),
&chkval,
true,