-
Notifications
You must be signed in to change notification settings - Fork 556
Custom key comparer in version 2.1 failing assertion #5436
Copy link
Copy link
Open
Description
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:
pebble/internal/base/comparer.go
Lines 417 to 425 in d5392e3
| 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
Reactions are currently unavailable