Skip to content

buildBinaryFuse uses 0 as an empty-slot sentinel in reverseOrder even though mixsplit hash 0 is valid #57

@dain

Description

@dain

I noticed this while reading, so it is possible I'm missing something.

In buildBianryFuse, there is:

for _, key := range keys {
	hash := mixsplit(key, filter.Seed)
	segment_index := hash >> (64 - blockBits)
	for reverseOrder[startPos[segment_index]] != 0 {
		segment_index++
		segment_index &= (1 << blockBits) - 1
	}
	reverseOrder[startPos[segment_index]] = hash
	startPos[segment_index] += 1
}

so if reverseOrder[startPos[segment_index]] == 0 the slot is considered empty and is filled with the hash. But it seems that mixsplit(key, filter.Seed) can return zero, which would mark the slot as empty again.

A work around would be to not allow zero as a hash value or use a different reserved sentinel, or the code would need a sidecar "slot is empty" array.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions