-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathSimpleCuckoo.h
113 lines (113 loc) · 2.98 KB
/
SimpleCuckoo.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//#pragma once
//#include "cryptoTools/Common/Defines.h"
//#include "cryptoTools/Common/Log.h"
//#include "cryptoTools/Common/BitVector.h"
//
//#include "cryptoTools/Common/Matrix.h"
////#include <mutex>
//#include <atomic>
////#define THREAD_SAFE_CUCKOO
//#include "cryptoTools/Common/CuckooIndex.h"
//
//namespace osuCrypto
//{
//
// class SimpleCuckoo
// {
// public:
// SimpleCuckoo();
// ~SimpleCuckoo();
//
// struct Bin
// {
// Bin() :mVal(-1) {}
// Bin(u64 idx, u64 hashIdx) : mVal(idx | (hashIdx << 56)) {}
//
// bool isEmpty() const;
// u64 idx() const;
// u64 hashIdx() const;
//
// void swap(u64& idx, u64& hashIdx);
//#ifdef THREAD_SAFE_CUCKOO
// Bin(const Bin& b) : mVal(b.mVal.load(std::memory_order_relaxed)) {}
// Bin(Bin&& b) : mVal(b.mVal.load(std::memory_order_relaxed)) {}
// std::atomic<u64> mVal;
//#else
// Bin(const Bin& b) : mVal(b.mVal) {}
// Bin(Bin&& b) : mVal(b.mVal) {}
// u64 mVal;
//#endif
// };
// struct Workspace
// {
// Workspace(u64 n, u64 h)
// : curAddrs(n)
// , curHashIdxs(n)
// , oldVals(n)
// , findVal(n, h)
// {}
//
// std::vector<u64>
// curAddrs,
// curHashIdxs,
// oldVals;
//
// Matrix<u64> findVal;
// };
//
//
//
// u64 mTotalTries;
//
// bool operator==(const SimpleCuckoo& cmp)const;
// bool operator!=(const SimpleCuckoo& cmp)const;
//
// //std::mutex mStashx;
//
// CuckooParam mParams;
//
// void print() const;
// void init();
//
// void insert(span<u64> itemIdxs, span<block> hashs)
// {
// Workspace ws(itemIdxs.size(), mParams.mNumHashes);
// std::vector<block> bb(mParams.mNumHashes);
// Matrix<u64> hh(hashs.size(), mParams.mNumHashes);
//
// for (i64 i = 0; i < hashs.size(); ++i)
// {
// //AES aes(hashs[i]);
// //aes.ecbEncCounterMode(0, bb.size(), bb.data());
// for (u64 j = 0; j < mParams.mNumHashes; ++j)
// {
// //hh(i, j) = *(u64*)&bb[j];
// hh(i,j) = CuckooIndex<>::getHash(hashs[i], j, mParams.numBins());
// }
// }
//
// insertBatch(itemIdxs, hh, ws);
// }
// void insertBatch(span<u64> itemIdxs, MatrixView<u64> hashs, Workspace& workspace);
//
// u64 findBatch(MatrixView<u64> hashes,
// span<u64> idxs,
// Workspace& wordkspace);
//
//
// u64 stashUtilization();
//
// std::vector<u64> mLocations;
// MatrixView<u64> mHashesView;
//
// std::vector<Bin> mBins;
// std::vector<Bin> mStash;
//
// //std::vector<Bin> mBins;
// //std::vector<Bin> mStash;
//
//
// //void insertItems(std::array<std::vector<block>,4>& hashs);
// };
//
//}