Skip to content

Commit dba4df7

Browse files
committed
use compare function in the hash table;
add comments;
1 parent 0d2fc3d commit dba4df7

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

src/kv_fdw.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@
3434
#define DATAAREASIZE sizeof(char)*BUFSIZE
3535

3636

37-
/* Shared memory for function requests */
37+
/* Shared memory for function requests:
38+
* mutex is used for the mutual exclusion of the request buffer;
39+
* full is used to tell whether the request buffer is full;
40+
* agent[2] are used to synchronize the creation of the worker process;
41+
* worker is used to notify the worker process after a request is submitted;
42+
* responseMutexes[RESPONSEQUEUELENGTH] are used for the mutual exclusion of the response buffer;
43+
* responseSync[RESPONSEQUEUELENGTH] are used to notify child processes after the response is ready.
44+
*/
3845
typedef struct SharedMem {
3946
sem_t mutex;
4047
sem_t full;

src/kv_shm.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ void OpenResponseArea() {
168168
/*
169169
* Compare function for KVIterHash
170170
*/
171-
/* int CompareKVIterHashKey(const void *key1, const void *key2, Size keysize) {
172-
KVIterHashKey *k1 = (const KVIterHashKey *)key1;
173-
KVIterHashKey *k2 = (const KVIterHashKey *)key2;
171+
int CompareKVIterHashKey(const void *key1, const void *key2, Size keysize) {
172+
const KVIterHashKey *k1 = (const KVIterHashKey *)key1;
173+
const KVIterHashKey *k2 = (const KVIterHashKey *)key2;
174174

175175
if(k1 == NULL || k2 == NULL) {
176176
return -1;
@@ -181,7 +181,7 @@ void OpenResponseArea() {
181181
}
182182

183183
return -1;
184-
}*/
184+
}
185185

186186
void *KVStorageThreadFun(void *arg) {
187187
PthreadSetCancelState(PTHREAD_CANCEL_ENABLE, NULL, __func__);
@@ -259,13 +259,13 @@ static void KVWorkerMain(int argc, char *argv[]) {
259259
memset(&iterhash_ctl, 0, sizeof(iterhash_ctl));
260260
iterhash_ctl.keysize = sizeof(KVIterHashKey);
261261
iterhash_ctl.entrysize = sizeof(KVIterHashEntry);
262-
//iterhash_ctl.match = CompareKVIterHashKey;
262+
iterhash_ctl.match = CompareKVIterHashKey;
263263
kvIterHash = hash_create("kvIterHash",
264264
HASHSIZE,
265265
&iterhash_ctl,
266-
HASH_ELEM | HASH_BLOBS);
266+
HASH_ELEM | HASH_COMPARE);
267267

268-
char buff[DATAAREASIZE];
268+
char buff[BUFSIZE];
269269
do {
270270
SemWait(&ptr->worker, __func__);
271271

0 commit comments

Comments
 (0)