5 #include "utils/array.h"
6 #include "access/tupdesc.h"
7 #include "catalog/pg_collation.h"
11 typedef struct ProcTypeInfoData *ProcTypeInfo;
13 typedef struct ProcTypeInfoData {
21 /* support of composite type */
26 * Following member can become invalid,
27 * so fill it just before using
35 ProcTypeInfo findProcs(Oid typid);
36 void getFmgrInfoHash(ProcTypeInfo info);
37 void getFmgrInfoCmp(ProcTypeInfo info);
40 /* reject arrays we can't handle; but allow a NULL or empty array */
41 #define CHECKARRVALID(x) \
44 if (ARR_NDIM(x) != NDIM && ARR_NDIM(x) != 0) \
46 (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), \
47 errmsg("array must be one-dimensional"))); \
50 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), \
51 errmsg("array must not contain nulls"))); \
55 #define ARRISVOID(x) ((x) == NULL || ARRNELEMS(x) == 0)
56 #define ARRNELEMS(x) ArrayGetNItems(ARR_NDIM(x), ARR_DIMS(x))
59 typedef struct SimpleArray {
61 double *df; /* frequency in current doc */
67 SimpleArray * Array2SimpleArray(ProcTypeInfo info, ArrayType *a);
68 SimpleArray * Array2SimpleArrayS(ProcTypeInfo info, ArrayType *a);
69 SimpleArray * Array2SimpleArrayU(ProcTypeInfo info, ArrayType *a, void *cache);
70 void allocateHash(void *cache, SimpleArray *a);
75 double GetSmlarLimit(void);
76 const char* GetSmlarTable(void);
77 bool GetSmlarUsePersistent(void);
78 double getOneAdd(void);
79 int getTFMethod(void);
85 #define SmlarOverlapStrategy 1
86 #define SmlarSimilarityStrategy 2
89 struct SmlSign* Array2HashedArray(ProcTypeInfo info, ArrayType *a);
93 void* SearchArrayCache( void *cache, MemoryContext ctx, Datum a, ArrayType **da, SimpleArray **sa, struct SmlSign **ss );
95 typedef struct StatElem {
97 double idf; /* log(d/df) */
100 typedef struct HashedElem {
106 typedef struct SignedElem {
111 typedef struct StatCache {
121 StatCache *initStatCache(MemoryContext ctx);
122 void getHashStatCache(StatCache *stat, MemoryContext ctx, size_t n);
124 void resetStatCache(void);
125 StatElem *findStat(StatCache *stat, Datum query, StatElem *low);
126 StatElem *fingArrayStat(void *cache, Oid typoid, Datum query, StatElem *low);
127 StatCache *getStat(void *cache, size_t n);
130 * Formula's type of similarity
142 #define FCall2(f, x1, x2) FunctionCall2Coll((f), C_COLLATION_OID, (x1), (x2))