5 #include "utils/array.h"
6 #include "access/tupdesc.h"
7 #include "catalog/pg_collation.h"
9 typedef struct ProcTypeInfoData *ProcTypeInfo;
11 typedef struct ProcTypeInfoData {
19 /* support of composite type */
24 * Following member can become invalid,
25 * so fill it just before using
33 ProcTypeInfo findProcs(Oid typid);
34 void getFmgrInfoHash(ProcTypeInfo info);
35 void getFmgrInfoCmp(ProcTypeInfo info);
38 /* reject arrays we can't handle; but allow a NULL or empty array */
39 #define CHECKARRVALID(x) \
42 if (ARR_NDIM(x) != NDIM && ARR_NDIM(x) != 0) \
44 (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), \
45 errmsg("array must be one-dimensional"))); \
48 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), \
49 errmsg("array must not contain nulls"))); \
53 #define ARRISVOID(x) ((x) == NULL || ARRNELEMS(x) == 0)
54 #define ARRNELEMS(x) ArrayGetNItems(ARR_NDIM(x), ARR_DIMS(x))
57 typedef struct SimpleArray {
59 double *df; /* frequency in current doc */
65 SimpleArray * Array2SimpleArray(ProcTypeInfo info, ArrayType *a);
66 SimpleArray * Array2SimpleArrayS(ProcTypeInfo info, ArrayType *a);
67 SimpleArray * Array2SimpleArrayU(ProcTypeInfo info, ArrayType *a, void *cache);
68 void allocateHash(void *cache, SimpleArray *a);
73 double GetSmlarLimit(void);
74 const char* GetSmlarTable(void);
75 bool GetSmlarUsePersistent(void);
76 double getOneAdd(void);
77 int getTFMethod(void);
83 #define SmlarOverlapStrategy 1
84 #define SmlarSimilarityStrategy 2
87 struct SmlSign* Array2HashedArray(ProcTypeInfo info, ArrayType *a);
91 void* SearchArrayCache( void *cache, MemoryContext ctx, Datum a, ArrayType **da, SimpleArray **sa, struct SmlSign **ss );
93 typedef struct StatElem {
95 double idf; /* log(d/df) */
98 typedef struct HashedElem {
104 typedef struct SignedElem {
109 typedef struct StatCache {
119 StatCache *initStatCache(MemoryContext ctx);
120 void getHashStatCache(StatCache *stat, MemoryContext ctx, size_t n);
122 void resetStatCache(void);
123 StatElem *findStat(StatCache *stat, Datum query, StatElem *low);
124 StatElem *fingArrayStat(void *cache, Oid typoid, Datum query, StatElem *low);
125 StatCache *getStat(void *cache, size_t n);
128 * Formula's type of similarity
140 #define FCall2(f, x1, x2) FunctionCall2Coll((f), C_COLLATION_OID, (x1), (x2))