Skip to content

Custom key comparer in version 2.1 failing assertion #5436

@merlimat

Description

@merlimat

I'm using a custom comparison function with Pebble (main reason is to have hierarchical friendly sorting, eg. assigning special meaning to / and have filesystem like tree structure).

This worked well in Pebble 1.x (apart from the addition of AbbreviatedKey which silently broker the ordering.. :) ).

In Pebble 2.1 there is an assertion check the custom compare returns the same order as the default compare:

Compare: func(a []byte, b []byte) int {
res := c.Compare(a, b)
// Verify that Compare is consistent with the default implementation.
if expected := defaultCompare(c.Split, c.ComparePointSuffixes, a, b); res != expected {
panic(AssertionFailedf("%s: Compare(%s, %s)=%d, expected %d",
c.Name, c.FormatKey(a), c.FormatKey(b), res, expected))
}
return res
},

Is there anything I'm missing here? Any configuration function to pass in to make it work? How any non-standard compare implementation can work if it needs to be checked against bytewise compare in the end?

Jira issue: PEBBLE-1217

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions