-
Notifications
You must be signed in to change notification settings - Fork 42
/
hashtable-lock.h
70 lines (60 loc) · 2.25 KB
/
hashtable-lock.h
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
/*
* File: hashtable-lock.h
* Author: Vincent Gramoli <[email protected]>,
* Vasileios Trigonakis <[email protected]>
* Description: using one lazy linst per bucket
* hashtable-lock.h is part of ASCYLIB
*
* Copyright (c) 2014 Vasileios Trigonakis <[email protected]>,
* Tudor David <[email protected]>
* Distributed Programming Lab (LPD), EPFL
*
* ASCYLIB is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, version 2
* of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include "./lists/intset.h"
#define DEFAULT_MOVE 0
#define DEFAULT_SNAPSHOT 0
#define DEFAULT_LOAD 1
#define DEFAULT_ELASTICITY 1
#define DEFAULT_ALTERNATE 0
#define DEFAULT_EFFECTIVE 1
#define MAXHTLENGTH 65536
/* Hashtable length (# of buckets) */
extern unsigned int maxhtlength, maxbulength;
/* ################################################################### *
* HASH TABLE
* ################################################################### */
typedef struct ht_intset
{
size_t hash;
map_t* buckets;
uint8_t padding[CACHE_LINE_SIZE - sizeof(size_t) - sizeof(map_t*)];
} ht_intset_t;
void ht_delete(ht_intset_t *set);
int ht_size(ht_intset_t *set);
int floor_log_2(unsigned int n);
ht_intset_t *ht_new();
sval_t ht_contains(ht_intset_t* set, skey_t key);
int ht_add(ht_intset_t* set, skey_t key, sval_t val);
sval_t ht_remove(ht_intset_t* set, skey_t key);
/*
* Move an element in the hashtable (from one linked-list to another)
*/
int ht_move(ht_intset_t *set, int val1, int val2);
/*
* Read all elements of the hashtable (parses all linked-lists)
* This cannot be consistent when used with move operation.
* TODO: make a coarse-grain version of the snapshot.
*/
int ht_snapshot(ht_intset_t *set);
void ht_print(ht_intset_t *set);
#define IO_FLUSH fflush(stdout)