mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-20 10:35:50 +00:00
add delete to snug
This commit is contained in:
@@ -287,9 +287,15 @@ private:
|
|||||||
uint8_t* start = data + offset;
|
uint8_t* start = data + offset;
|
||||||
for (int i = 0; i < 256 * 1024; i += 1024)
|
for (int i = 0; i < 256 * 1024; i += 1024)
|
||||||
{
|
{
|
||||||
if (!IS_ENTRY(start + i, key) && !IS_ZERO_ENTRY(start + i))
|
bool const found = IS_ENTRY(start + i, key);
|
||||||
|
if (!found && !IS_ZERO_ENTRY(start + i))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// special edge case: the key doesn't exist and they're trying to
|
||||||
|
// delete it
|
||||||
|
if (!found && len == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
// read flags
|
// read flags
|
||||||
uint64_t flags = *((uint64_t*)(start + i + 32));
|
uint64_t flags = *((uint64_t*)(start + i + 32));
|
||||||
|
|
||||||
@@ -323,9 +329,17 @@ private:
|
|||||||
if (!new_big)
|
if (!new_big)
|
||||||
flags = len;
|
flags = len;
|
||||||
|
|
||||||
|
if (len == 0)
|
||||||
|
{
|
||||||
|
// deletion requests are written as zero keys
|
||||||
|
memset(start + i, 0, 1024);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/// write entry
|
/// write entry
|
||||||
WRITE_KEY(start + i, key, flags);
|
WRITE_KEY(start + i, key, flags);
|
||||||
memcpy(start + i + 40, val, (len > 984 ? 984 : len));
|
memcpy(start + i + 40, val, (len > 984 ? 984 : len));
|
||||||
|
}
|
||||||
|
|
||||||
// sort the bucket backwards so 0's appear at the end
|
// sort the bucket backwards so 0's appear at the end
|
||||||
qsort(start, 256, 1024, compare_entries_reverse);
|
qsort(start, 256, 1024, compare_entries_reverse);
|
||||||
|
|||||||
Reference in New Issue
Block a user