-
Notifications
You must be signed in to change notification settings - Fork 0
/
anyarray_guc.c
84 lines (73 loc) · 1.48 KB
/
anyarray_guc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*-------------------------------------------------------------------------
*
* anyarray_guc.c
* GUC management
*
* Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
*
* Copyright (c) 2023, Postgres Professional
*
* Author: Teodor Sigaev <[email protected]>,
* Oleg Bartunov <[email protected]>
*
* IDENTIFICATION
* contrib/anyarray/anyarray_gud.c
*
*-------------------------------------------------------------------------
*/
#include "anyarray.h"
#include <utils/guc.h>
SimilarityType SmlType = AA_Cosine;
double SmlLimit = 0.6;
static bool AnyArrayInited = false;
static const struct config_enum_entry SmlTypeOptions[] = {
{"cosine", AA_Cosine, false},
{"jaccard", AA_Jaccard, false},
{"overlap", AA_Overlap, false},
{NULL, 0, false}
};
static void
initAnyArray()
{
if (AnyArrayInited)
return;
DefineCustomRealVariable(
"anyarray.similarity_threshold",
"Lower threshold of array's similarity",
"Array's with similarity lower than threshold are not similar by % operation",
&SmlLimit,
SmlLimit,
0.0,
1e10,
PGC_USERSET,
0,
NULL,
NULL,
NULL
);
DefineCustomEnumVariable(
"anyarray.similarity_type",
"Type of similarity formula",
"Type of similarity formula: cosine(default), jaccard, overlap",
(int*)&SmlType,
SmlType,
SmlTypeOptions,
PGC_SUSET,
0,
NULL,
NULL,
NULL
);
}
void _PG_init(void);
void
_PG_init(void)
{
initAnyArray();
}
void _PG_fini(void);
void
_PG_fini(void)
{
return;
}