Comments (12)
Here's the patch I've made. It compiles -- I'm not sure if it fixes the problem, as I haven't built any test cases. Want to give it a whirl, srbehera?
from cuckoofilter.
The reason you cannot find the existing items is because you have to clear the char array to make sure the chars behind '\0' are the same.
ex:
char[31] str;
bzero(str, 31);
from cuckoofilter.
It is still not working !
This is my code
CuckooFilter<string, 12> filter(total_items);
string line;
while(getline(inp, line))
{
if(filter.Contain(line) == cuckoofilter::Ok)
cout<<"Found:"<<line<<endl;
else
filter.Add(line);
}
from cuckoofilter.
I think no char* and string now. It needs primative and non-pointer type because there is sizeof(item) in the code. So sizeof(string) will go wrong.
from cuckoofilter.
@bingo4508 you are right. currently the way to calculate hash index is here .
As a result, the string is converted into char*
, getting into problems.
@srbehera for now string is not supported but only primary types (where sizeof(item)
makes sense). I planed to support string
but still not able to find time doing that :(
from cuckoofilter.
@bingo4508 @apc999 Got it !! Thanks !!
from cuckoofilter.
Would a templated function that defaulted to sizeof() for other structs/types with a specialization for std::string (using std::string.c_str() rather than (const char *) and std::string.size() rather than sizeof) be a quick fix?
from cuckoofilter.
yes, I think so.
Deaniel, feel free to submit a patch.
otherwise, I will probably add one later .
best,
On Wed, Apr 27, 2016 at 5:31 PM, Daniel Baker [email protected]
wrote:
Would a templated function that defaulted to sizeof() for other
structs/types with a specialization for std::string (using
std::string.c_str() rather than (const char *) and std::string.size()
rather than sizeof) be a quick fix?—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#2 (comment)
from cuckoofilter.
Daniel, it is not working for string.
Here is the simple code I was testing
int main(int argc, char** argv) {
CuckooFilter<string, 12> filter2(total_items);
srand (time(NULL));
ifstream inp;
inp.open("test.txt");
string line;
int c1 = 0;
int i = 0;
while(getline(inp, line))
{
cout<<line<<endl;
if(filter2.Contain(line) == cuckoofilter::Ok){
cout<<"Found:"<<line<<endl;
c++;
}
else{
filter2.Add(line);
}
i++;
}
cout<< "c = "<< c <<endl;
cout<< "i = "<< i <<endl;
inp.close();
Where test.txt has following entries
AAA
BBB
CCC
AAA
CCC
DDD
XYZ
CCC
XYZ
AAA
from cuckoofilter.
Is there any output? What does it do?
from cuckoofilter.
The program was putting the strings in the filter. If it is already there, it was printing "Found". The following output shows that it only puts the first string and then says "Found" all other strings.
AAA
BBB
Found:BBB
CCC
Found:CCC
AAA
Found:AAA
CCC
Found:CCC
DDD
Found:DDD
XYZ
Found:XYZ
CCC
Found:CCC
XYZ
Found:XYZ
AAA
Found:AAA
c1=9
i=10
from cuckoofilter.
I faced the same issue and it looks like according to the implementation the first parameter can only be uint64_t
.
So I used following code:
std::string mystring = "Hello World";
cuckoofilter::CuckooFilter<size_t, 12> test(1000);
test.Add(CityHash64(mystring.c_str(), mystring.length()));
CitiHash64
can be found in src/City.h
in https://github.com/aappleby/smhasher
from cuckoofilter.
Related Issues (20)
- BFS for Insert path HOT 3
- Please get rid of SuperFastHash
- Test code doesn't seem to work for total_items < 4.
- Broken build: missing openssl include? HOT 6
- APIs to serialize/deserialize data? HOT 10
- [Question] Python Bindings
- Using SipHash ? HOT 2
- __m256i/ _mm256_or_si256/ _mm256_testc_si256 HOT 1
- PackedTable with bits_per_item 5,7,9 does not work HOT 4
- [Question]false positive rate HOT 4
- Problem in Adding __int128 HOT 1
- adding string to cuckoo filter HOT 3
- Does the misjudgment rate equation work?
- [Question]how to test speed of "Contain" by -O3 -march=native?
- Abount “delete item
- Aboun “delete item” HOT 1
- The possible mistake about the unit of the speed in benchmark
- Tests fail for all tested values other than 12 (Single) 13 (Packed) HOT 3
- Mind if I rewrite to use SIPhash and speed-optimize? HOT 2
- Cuckoo filter constructors overestimate insert success probability HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cuckoofilter.