Comments (20)
okaydoky I'll test if that fixes my unit-test locally then do the pr.
from subleveldown.
fixed - still failing. I've also made sure that my local version of level-codec with your suggested change (Level/codec@master...MeirionHughes:master) is defiantly being loaded.
... anyway I can use charwise and keep all my keys as strings for now.
from subleveldown.
No issue if I switch to charwise
- so I suspect the mix of string + buffer and its screwing with the ! delimiter checking.
from subleveldown.
You're likely hitting a known issue with memdown
, when mixing buffers and strings in the same db, see Level/level-ttl#68 (comment) (different context, same underlying issue). Might be fixable by reverting Level/codec#23.
from subleveldown.
To confirm it's that, could you try replacing memdown
with leveldown
?
from subleveldown.
Yes - leveldown works.
from subleveldown.
Great. So, reverting Level/codec#23 should fix this, the level-ttl
issue and a multileveldown
issue (Level/community#71). I can't think of any reasons not to revert it. Feel up to making a PR?
from subleveldown.
So, you want to revert #23, which was a revert itself?
from subleveldown.
Yes :)
from subleveldown.
okay I've cherry-picked the original commit and resolved the linting errors: https://github.com/MeirionHughes/codec/commit/9f6686a390b96200a93103e6672d96569a388a2a
doesn't seem to fix it unfortunately.
I yarn link
and yarn link level-codec
locally, and added a console.log during the export just to make sure it was being used.
from subleveldown.
I'll see if I can make a basic failing test on here
from subleveldown.
Okay I've managed to get it to trigger the race condition. At least for me and its consistent: https://github.com/Level/subleveldown/compare/tests/buffer-race-issue
it very odd because you can change subdb(db, 'logs')
to subdb(db, 'AAAA')
and it works...
from subleveldown.
{ keyEncoding: 'buffer' }
should be { keyEncoding: 'binary' }
from subleveldown.
I had a closer look. Thanks for providing a clean subleveldown
test! The problem is that memdown
, when comparing two keys, and one key is a buffer while the other key is a string, does not compare them bytewise. Essentially it compares buf[index]
to str[index]
.
from subleveldown.
We have a few options:
- Support comparing buffers to strings in
memdown
(bringing its behavior closer toleveldown
) (but it's not compatible with IDB-style sort order, which sorts by type first and then content - i.e. string data is never equal to binary data) (bytewise
is also IDB-style but sorts string and binary the other way around...) - Have
memdown
sort by type, then content - Have
subleveldown
always use buffers internally
I hate encodings right now :)
from subleveldown.
I think I prefer 2. Because although it is not the same behavior as leveldown
, it is the least surprising and it's fairly reasonable to expect a consumer to be consistent in their usage of key/value types - i.e. don't mix buffers and strings in the same (sub)db.
@ralphtheninja WDYT?
Edit: I forgot I already wrote code for 2! To deal with other surprising cases, all arising from the fact that memdown
does not compare by type. For example it considers 'a'
and 0
to be equal (because JavaScript attempts to convert the left- and right-hand sides of greater-than and less-than operators to numbers, unless both sides are strings. In the case of 'a'
and 0
, 'a'
becomes NaN
, which is never greater or less than a number.)
from subleveldown.
Thanks for investigating, on a Sunday no-less! - Perhaps no.1 via an option so that it behaves just like leveldown? Non-breaking, but allows memdown to behave like leveldown during unit tests. I guess if you're code for no.2 already solves it then that is the way to go.
from subleveldown.
Perhaps no.1 via an option so that it behaves just like leveldown?
Although it's easy to add a comparator
option to memdown
to make it sort however you want, IMO the default behavior should cover common use cases like these, and not require configuration.
Somewhere this week, I'll try to clean up and push the code that I have. It will make memdown
sort the same as IDB and level-js
, and almost the same as bytewise
.
Side note: are you using memdown
purely to speed up tests? You might like level-test
which defaults to leveldown
in node, but is quite fast because it uses temporary directories without cleaning them up (leaving that to the OS).
from subleveldown.
Opened a PR for level-codec
(Level/codec#51, thanks!); memdown
discussion is to be continued in Level/memdown#186.
Keeping this open though, as a reminder to test everything together once ready.
from subleveldown.
Fixed in [email protected]
.
from subleveldown.
Related Issues (20)
- How to get the exception `Inner database is not open`? HOT 2
- Support buffer/Uint8Array prefixes HOT 7
- A way to get a deeply nested sublevel in one-go HOT 5
- Release v3.0.0 HOT 1
- Streams are ignoring fillCache option HOT 2
- Segfault with subleveldown HOT 27
- Adding _seek to SubIterator HOT 4
- Disable `clear()` HOT 2
- Take advantage of manifests and the squash down HOT 1
- An in-range update of abstract-leveldown is breaking the build 🚨 HOT 3
- Applies prefix twice on nested sublevel HOT 12
- An in-range update of levelup is breaking the build 🚨 HOT 2
- Remove unnecessary condition HOT 1
- Drop support of memdb
- Require deferredOpen support HOT 1
- Support "deep" option in clear() & iterator() HOT 10
- Possible issue with buffer keys HOT 10
- Decoder Err ! HOT 3
- Should the `createReadStream` method be scoped to the subs? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from subleveldown.