Closed plainweaver closed 5 years ago
It's hard to tell which tests you're referring to. Can you link to specific lines in iterator-range-test.js?
It might help to look at other implementations for inspiration, and to read the documentation of levelup
, leveldown
and LevelDB.
And could you share some details about your implementation? It's OK if you can't, but it'll be more difficult to help you.
Thanks for a passionate response. I'm wondering since there are eccentric usages over normal javascript strings and numbers.
What do they mean? Am I missing something?
In a nutshell, they test that the implementation sorts keys lexicographically. Numbers are a good way to do that, because they shouldn't sort "naturally".
Why would '40000' ~ '50000' contains '45' ?
Isn't it correct when it should only contains longer ones? It looks more natural when '40' ~ '50' containing '45555'
If then, looks able to be done with radix tree.
Why would '40000' ~ '50000' contains '45' ?
Keys are compared character by character (or byte by byte), stopping at inquality. Comparing '45'
and '40000'
, '4'
is equal to '4'
and '5'
is greater than '0'
so therefore '45'
comes after '40000'
.
If a consumer of an abstract-leveldown
implementation wants to sort numbers naturally, they can either zero-pad their keys so that '45'
becomes e.g. '00045'
, or to save space, use an encoding like lexicographic-integer.
If then, looks able to be done with radix tree.
Can't say if that's the right choice, without knowing anything about your implementation and its underlying storage.
Is there a recommended way to pass iterator tests passing option as below:
..9999 (midway)
forstart, end, lt, gt, lte, gte
..a
forstart, end, lt, gt, lte, gte