OPIC
Object Persistence In C
op_hash.h
Go to the documentation of this file.
1 
8 /* This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as
10  * published by the Free Software Foundation, either version 3 of the
11  * License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this program. If not, see
20  * <http://www.gnu.org/licenses/>.
21  */
22 
23 /* Code: */
24 
25 #ifndef OPIC_HASH_OP_HASH_H
26 #define OPIC_HASH_OP_HASH_H 1
27 
28 #include "opic/common/op_macros.h"
29 #include "cityhash.h"
30 
31 OP_BEGIN_DECLS
32 
45 typedef uint64_t(*OPHash)(void* key, size_t size);
46 
59 typedef void(*OPHashIterator)(void* key, void* value,
60  size_t keysize, size_t valsize,
61  void* context);
62 
69 static inline
70 uint64_t OPDefaultHash(void* key, size_t size)
71 {
72  return cityhash64((const uint8_t*)key, size);
73 }
74 
89 typedef void(*OPFunnelUpsertCB)(void* key,
90  void* table_value,
91  void* funnel_value,
92  void* ctx,
93  size_t keysize, size_t valsize,
94  size_t ctxsize, bool is_duplicate);
95 
107 typedef void(*OPFunnelGetCB)(void* key, void* value, void* ctx,
108  size_t keysize, size_t valsize,
109  size_t ctxsize);
110 
122 typedef void(*OPFunnelDeleteCB)(void* key, void* value, void* ctx,
123  size_t keysize, size_t valsize,
124  size_t ctxsize);
125 
126 #ifndef DOXYGEN_SKIP
127 
128 typedef union FunnelCB
129 {
130  OPFunnelUpsertCB upsertcb;
131  OPFunnelGetCB getcb;
132  OPFunnelDeleteCB deletecb;
133 } FunnelCB __attribute__((__transparent_union__));
134 
135 #endif
136 
137 OP_END_DECLS
138 
139 #endif
140 /* op_hash.h ends here */
void(* OPFunnelDeleteCB)(void *key, void *value, void *ctx, size_t keysize, size_t valsize, size_t ctxsize)
Callback type for doing delete operation with funnel.
Definition: op_hash.h:122
static uint64_t OPDefaultHash(void *key, size_t size)
Default hash function.
Definition: op_hash.h:70
void(* OPFunnelUpsertCB)(void *key, void *table_value, void *funnel_value, void *ctx, size_t keysize, size_t valsize, size_t ctxsize, bool is_duplicate)
Callback type for doing upsert operation with funnel.
Definition: op_hash.h:89
void(* OPFunnelGetCB)(void *key, void *value, void *ctx, size_t keysize, size_t valsize, size_t ctxsize)
Callback type for doing get operation with funnel.
Definition: op_hash.h:107
void(* OPHashIterator)(void *key, void *value, size_t keysize, size_t valsize, void *context)
HashTable iterator interface.
Definition: op_hash.h:59
uint64_t(* OPHash)(void *key, size_t size)
Hash function interface.
Definition: op_hash.h:45