feature/bloom_filter #55
@@ -104,6 +104,9 @@ uses
|
|||||||
driver.storage.vfs,
|
driver.storage.vfs,
|
||||||
driver.video,
|
driver.video,
|
||||||
arch.x86.memory.virtual,
|
arch.x86.memory.virtual,
|
||||||
|
core.enc.fnv1a,
|
||||||
|
core.enc.djb2,
|
||||||
|
core.ds.bloom,
|
||||||
app.volcmd,
|
app.volcmd,
|
||||||
driver.storage.vol.mgr,
|
driver.storage.vol.mgr,
|
||||||
app.vterminal,
|
app.vterminal,
|
||||||
@@ -344,6 +347,9 @@ begin
|
|||||||
core.ds.prio.UnitTest;
|
core.ds.prio.UnitTest;
|
||||||
driver.storage.vfs.UnitTest;
|
driver.storage.vfs.UnitTest;
|
||||||
driver.storage.test.UnitTest;
|
driver.storage.test.UnitTest;
|
||||||
|
core.enc.fnv1a.UnitTest;
|
||||||
|
core.enc.djb2.UnitTest;
|
||||||
|
core.ds.bloom.UnitTest;
|
||||||
|
|
||||||
{ Initialize driver.video.desktop environment }
|
{ Initialize driver.video.desktop environment }
|
||||||
boot.splash.update(100, 'Booting desktop...');
|
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.
|
Include->Hashmap - Basic Hashmap Implementation.
|
||||||
|
|
||||||
@author(Kieron Morris <[email protected]>)
|
@author(Kieron Morris <[email protected]>)
|
||||||
|
@author(Aaron Hance <[email protected]>)
|
||||||
}
|
}
|
||||||
unit core.ds.hashmap;
|
unit core.ds.hashmap;
|
||||||
|
|
||||||
@@ -23,7 +24,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
memory.heap,
|
memory.heap,
|
||||||
core.enc.md5,
|
core.enc.fnv1a,
|
||||||
core.strings,
|
core.strings,
|
||||||
io.syslog,
|
io.syslog,
|
||||||
debug.tracer,
|
debug.tracer,
|
||||||
@@ -64,19 +65,8 @@ procedure forEach(map : PHashMap; cb : THashForEachCb; ud : void);
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
function KeyHash(key : pchar) : uint32;
|
function KeyHash(key : pchar) : uint32;
|
||||||
var
|
|
||||||
KeyLength : uint32;
|
|
||||||
MD5_Hash : PMD5Digest;
|
|
||||||
Hash128 : puint128;
|
|
||||||
Hash32 : uint32;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
KeyLength:= StringSize(key);
|
KeyHash := Hash_FNV1a32(void(uint32(key)), StringSize(key));
|
||||||
MD5_Hash:= MD5Buffer(puint8(key), KeyLength);
|
|
||||||
Hash128:= puint128(MD5_Hash);
|
|
||||||
Hash32:= MD5To32(Hash128);
|
|
||||||
KeyHash:= Hash32;
|
|
||||||
kfree(void(MD5_Hash));
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function hashIndex(size : uint32; hash : uint32) : uint32;
|
function hashIndex(size : uint32; hash : uint32) : uint32;
|
||||||
|
|||||||
@@ -195,6 +195,32 @@ type
|
|||||||
IsMinHeap : boolean;
|
IsMinHeap : boolean;
|
||||||
end;
|
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
|
implementation
|
||||||
|
|
||||||
end.
|
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