pack differently
This commit is contained in:
parent
1fac779f5f
commit
752b0bac6f
@ -371,6 +371,13 @@ Section creation order:
|
||||
1. ✅ `idx_*`. requires offsets to `groups` and `users`.
|
||||
1. ✅ Header.
|
||||
|
||||
For v2
|
||||
------
|
||||
|
||||
These are desired for the next DB format:
|
||||
- Compress strings with fsst.
|
||||
- Trim first 4 bytes from the cmph headers.
|
||||
|
||||
[git-subtrac]: https://apenwarr.ca/log/20191109
|
||||
[cmph]: http://cmph.sourceforge.net/
|
||||
[id]: https://linux.die.net/man/1/id
|
||||
|
@ -4,13 +4,13 @@ extern fn bdz_search_packed(packed_mphf: [*]const u8, key: [*]const u8, len: c_u
|
||||
|
||||
pub fn search(packed_mphf: []const u8, key: []const u8) u32 {
|
||||
const len = std.math.cast(c_uint, key.len).?;
|
||||
return @as(u32, bdz_search_packed(packed_mphf.ptr, key.ptr, len));
|
||||
return @as(u32, bdz_search_packed(packed_mphf[4..].ptr, key.ptr, len));
|
||||
}
|
||||
|
||||
const u32len = 5;
|
||||
|
||||
pub fn search_u32(packed_mphf: []const u8, key: u32) u32 {
|
||||
return @as(u32, bdz_search_packed(packed_mphf.ptr, &unzero(key), u32len));
|
||||
return @as(u32, bdz_search_packed(packed_mphf[4..].ptr, &unzero(key), u32len));
|
||||
}
|
||||
|
||||
// encode a u32 to 5 bytes so no bytes is a '\0'.
|
||||
|
@ -39,7 +39,7 @@ pub fn pack(allocator: Allocator, input: [][*:0]const u8) error{OutOfMemory}![]c
|
||||
errdefer allocator.free(buf);
|
||||
cmph_pack(mph, buf.ptr);
|
||||
cmph_destroy(mph);
|
||||
return buf[4..];
|
||||
return buf;
|
||||
}
|
||||
|
||||
// perfect-hash a list of numbers and return the packed mphf
|
||||
|
Loading…
Reference in New Issue
Block a user