forked from microsoft/MSVBASE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.cpp
69 lines (57 loc) · 2.27 KB
/
lib.cpp
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "index.hpp"
#include "hnswindex.hpp"
extern "C"
{
#include <postgres.h>
#include <fmgr.h>
#include <omp.h>
#include <access/reloptions.h>
}
extern "C"
{
PG_MODULE_MAGIC;
PGDLLEXPORT void _PG_init(void);
}
relopt_kind sptag_para_relopt_kind;
relopt_kind hnsw_para_relopt_kind;
relopt_kind pase_hnsw_para_relopt_kind;
relopt_enum_elt_def sptag_DistCalcMethodValues[] =
{
{"inner_product", sptag_Inner_Product},
{"l2_distance", sptag_L2_Distance},
{(const char *) NULL} /* list terminator */
};
relopt_enum_elt_def hnsw_DistCalcMethodValues[] =
{
{"inner_product", hnsw_Inner_Product},
{"l2_distance", hnsw_L2_Distance},
{(const char *) NULL} /* list terminator */
};
void _PG_init(void)
{
int totalCoreNum;
totalCoreNum = omp_get_num_procs();
sptag_para_relopt_kind = add_reloption_kind();
add_int_reloption(sptag_para_relopt_kind, "threads", "Thread Number",
1, 1, totalCoreNum,AccessExclusiveLock);
add_enum_reloption(sptag_para_relopt_kind, "distmethod", "Distance Calculate Method",
sptag_DistCalcMethodValues, sptag_Inner_Product,
"Valid values are \"inner_product\" and \"l2_distance\".",
AccessExclusiveLock);
hnsw_para_relopt_kind = add_reloption_kind();
add_int_reloption(hnsw_para_relopt_kind, "dimension", "Vector Dimension",
1, 1, 4096,AccessExclusiveLock);
add_enum_reloption(hnsw_para_relopt_kind, "distmethod", "Distance Calculate Method",
hnsw_DistCalcMethodValues, hnsw_Inner_Product,
"Valid values are \"inner_product\" and \"l2_distance\".",
AccessExclusiveLock);
pase_hnsw_para_relopt_kind = add_reloption_kind();
add_int_reloption(pase_hnsw_para_relopt_kind, "dimension", "Vector Dimension",
1, 1, 4096,AccessExclusiveLock);
add_enum_reloption(pase_hnsw_para_relopt_kind, "distmethod", "Distance Calculate Method",
hnsw_DistCalcMethodValues, hnsw_Inner_Product,
"Valid values are \"inner_product\" and \"l2_distance\".",
AccessExclusiveLock);
}