Recsplit: collision typed error (#150)

This commit is contained in:
Alex Sharov 2021-11-07 09:54:48 +07:00 committed by GitHub
parent 138a208431
commit f6b0a0c969
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,6 +30,8 @@ import (
"github.com/spaolacci/murmur3"
)
var ErrCollision = fmt.Errorf("duplicate key")
const RecSplitLogPrefix = "recsplit"
const MaxLeafSize = 24
@ -298,7 +300,7 @@ func (rs *RecSplit) recsplitCurrentBucket() error {
for i, key := range rs.currentBucket[1:] {
if key == rs.currentBucket[i] {
rs.collision = true
return fmt.Errorf("duplicate key %x", key)
return fmt.Errorf("%w: %x", ErrCollision, key)
}
}
bitPos := rs.gr.bitCount