1 | /* |
2 | * thr_sindex.h |
3 | * |
4 | * Copyright (C) 2013-2014 Aerospike, Inc. |
5 | * |
6 | * Portions may be licensed to Aerospike, Inc. under one or more contributor |
7 | * license agreements. |
8 | * |
9 | * This program is free software: you can redistribute it and/or modify it under |
10 | * the terms of the GNU Affero General Public License as published by the Free |
11 | * Software Foundation, either version 3 of the License, or (at your option) any |
12 | * later version. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
16 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
17 | * details. |
18 | * |
19 | * You should have received a copy of the GNU Affero General Public License |
20 | * along with this program. If not, see http://www.gnu.org/licenses/ |
21 | */ |
22 | |
23 | /* |
24 | * secondary index function declarations |
25 | */ |
26 | |
27 | #pragma once |
28 | |
29 | #include <pthread.h> |
30 | #include <stdbool.h> |
31 | #include <stdint.h> |
32 | |
33 | #include "citrusleaf/cf_digest.h" |
34 | #include "citrusleaf/cf_queue.h" |
35 | |
36 | #include "ai_obj.h" |
37 | #include "dynbuf.h" |
38 | #include "hist.h" |
39 | |
40 | #include "base/datamodel.h" |
41 | #include "base/monitor.h" |
42 | |
43 | #define SINDEX_GC_QUEUE_HIGHWATER 10 |
44 | #define SINDEX_GC_NUM_OBJS_PER_ARR 20 |
45 | |
46 | typedef struct acol_digest_t { |
47 | cf_digest dig; |
48 | ai_obj acol; |
49 | } acol_digest; |
50 | |
51 | typedef struct objs_to_defrag_arr_t { |
52 | acol_digest acol_digs[SINDEX_GC_NUM_OBJS_PER_ARR]; |
53 | uint32_t num; |
54 | } objs_to_defrag_arr; |
55 | |
56 | typedef struct ll_sindex_gc_element_s { |
57 | cf_ll_element ele; |
58 | objs_to_defrag_arr * objs_to_defrag; |
59 | } ll_sindex_gc_element; |
60 | |
61 | extern pthread_rwlock_t sindex_rwlock; |
62 | extern cf_queue *g_sindex_populate_q; |
63 | extern cf_queue *g_sindex_destroy_q; |
64 | extern cf_queue *g_sindex_populateall_done_q; |
65 | extern bool g_sindex_boot_done; |
66 | |
67 | void as_sindex_thr_init(); |
68 | objs_to_defrag_arr * as_sindex_gc_get_defrag_arr(void); |
69 | |
70 | #define MAX_SINDEX_BUILDER_THREADS 32 |
71 | |
72 | void as_sbld_init(); |
73 | void as_sbld_build_all(as_namespace* ns); |
74 | void as_sbld_resize_thread_pool(uint32_t n_threads); |
75 | int as_sbld_list(char* name, cf_dyn_buf* db); |
76 | as_mon_jobstat* as_sbld_get_jobstat(uint64_t trid); |
77 | as_mon_jobstat* as_sbld_get_jobstat_all(int* size); |
78 | int as_sbld_abort(uint64_t trid); |
79 | |