2 * Sherlock: Data structures used in indices
4 * (c) 2001--2002 Martin Mares <mj@ucw.cz>
9 #define MAX_WORD_LEN 64
11 /* Word and string types are defined in lib/custom.h */
13 /* Global index parameters */
16 sh_time_t ref_time; /* Reference time (for document ages etc.) */
19 /* Index card attributes */
22 u32 card; /* Reference to card description (either oid or filepos) */
24 #define INT_ATTR(t,i,o,k,g,p) t i;
25 CUSTOM_ATTRS /* Include all custom attributes */
29 byte age; /* Document age in pseudo-logarithmic units wrt. reference time */
30 // byte rfu[1]; /* If no custom attributes are defined */
34 CARD_FLAG_EMPTY = 1, /* Empty document (redirect, robot file etc.) [scanner] */
35 CARD_FLAG_ACCENTED = 2, /* Document contains accented characters [scanner] */
36 CARD_FLAG_DUP = 4, /* Removed as a duplicate [merger] */
37 CARD_FLAG_MERGED = 8, /* Destination of a merge [merger] */
40 #define CARD_POS_SHIFT 5 /* Card positions are shifted this # of bytes to the right */
42 /* String fingerprints */
48 void fingerprint(byte *string, struct fingerprint *fp);
51 fp_hash(struct fingerprint *fp)
53 return (fp->hash[0] << 24) | (fp->hash[1] << 16) | (fp->hash[2] << 8) | fp->hash[3];
56 /* Reading of tagged text (Unicode values, tags mapped to 0x80000000 and higher) */
58 #define GET_TAGGED_CHAR(p,u) do { \
73 ASSERT(*p >= 0x80 && *p <= 0xbf); \
74 u = 0x80010000 + ((u & 0x0f) << 6) + (*p++ & 0x3f); \
83 /* Conversion of document age from seconds to our internal units */
86 convert_age(sh_time_t lastmod, sh_time_t reftime)
89 if (reftime < lastmod) /* past times */
91 age = (reftime - lastmod) / 3600;
92 if (age < 48) /* last 2 days: 1 hour resolution */
95 if (age < 64) /* next 64 days: 1 day resolution */
98 if (age < 135) /* next 135 weeks: 1 week resolution */
100 age = (age-135) / 52;
101 if (age < 8) /* next 8 years: 1 year resolution */
103 return 255; /* then just "infinite future" */