feature/bloom_filter #55
@@ -104,6 +104,9 @@ uses
|
||||
driver.storage.vfs,
|
||||
driver.video,
|
||||
arch.x86.memory.virtual,
|
||||
core.enc.fnv1a,
|
||||
core.enc.djb2,
|
||||
core.ds.bloom,
|
||||
app.volcmd,
|
||||
driver.storage.vol.mgr,
|
||||
app.vterminal,
|
||||
@@ -344,6 +347,9 @@ begin
|
||||
core.ds.prio.UnitTest;
|
||||
driver.storage.vfs.UnitTest;
|
||||
driver.storage.test.UnitTest;
|
||||
core.enc.fnv1a.UnitTest;
|
||||
core.enc.djb2.UnitTest;
|
||||
core.ds.bloom.UnitTest;
|
||||
|
||||
{ Initialize driver.video.desktop environment }
|
||||
boot.splash.update(100, 'Booting desktop...');
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,6 +16,7 @@
|
||||
Include->Hashmap - Basic Hashmap Implementation.
|
||||
|
||||
@author(Kieron Morris <[email protected]>)
|
||||
@author(Aaron Hance <[email protected]>)
|
||||
}
|
||||
unit core.ds.hashmap;
|
||||
|
||||
@@ -23,7 +24,7 @@ interface
|
||||
|
||||
uses
|
||||
memory.heap,
|
||||
core.enc.md5,
|
||||
core.enc.fnv1a,
|
||||
core.strings,
|
||||
io.syslog,
|
||||
debug.tracer,
|
||||
@@ -64,19 +65,8 @@ procedure forEach(map : PHashMap; cb : THashForEachCb; ud : void);
|
||||
implementation
|
||||
|
||||
function KeyHash(key : pchar) : uint32;
|
||||
var
|
||||
KeyLength : uint32;
|
||||
MD5_Hash : PMD5Digest;
|
||||
Hash128 : puint128;
|
||||
Hash32 : uint32;
|
||||
|
||||
begin
|
||||
KeyLength:= StringSize(key);
|
||||
MD5_Hash:= MD5Buffer(puint8(key), KeyLength);
|
||||
Hash128:= puint128(MD5_Hash);
|
||||
Hash32:= MD5To32(Hash128);
|
||||
KeyHash:= Hash32;
|
||||
kfree(void(MD5_Hash));
|
||||
KeyHash := Hash_FNV1a32(void(uint32(key)), StringSize(key));
|
||||
end;
|
||||
|
||||
function hashIndex(size : uint32; hash : uint32) : uint32;
|
||||
|
||||
@@ -195,6 +195,32 @@ type
|
||||
IsMinHeap : boolean;
|
||||
end;
|
||||
|
||||
{ ------ Bloom Filter ------ }
|
||||
|
||||
{**
|
||||
@abstract Pointer to a bloom filter.
|
||||
**}
|
||||
PBloomFilter = ^TBloomFilter;
|
||||
|
||||
{**
|
||||
@abstract Probabilistic set-membership filter using double hashing.
|
||||
@discussion The bit array is a flat kalloc'd byte buffer of
|
||||
ceil(BitCount / 8) bytes. Membership tests use k independent
|
||||
hash positions derived from two base hashes (FNV-1a + DJB2)
|
||||
via double hashing: h_i(x) = (h1(x) + i * h2(x)) mod BitCount.
|
||||
False positives are possible; false negatives are not.
|
||||
@field Bits Pointer to the flat bit-array buffer.
|
||||
@field BitCount Total number of bits in the filter (m).
|
||||
@field HashCount Number of hash functions applied per element (k).
|
||||
@field Count Number of elements inserted.
|
||||
**}
|
||||
TBloomFilter = record
|
||||
Bits : void;
|
||||
BitCount : uint32;
|
||||
HashCount : uint32;
|
||||
Count : uint32;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user