Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for AbstractLevelDown 2 #41

Closed
wants to merge 1 commit into from

Conversation

mcollina
Copy link
Member

@mcollina mcollina commented Jul 5, 2015

This partially solves the problems with AbstractLevelDown 2 (at least the initialization)

Unfortunately, the new feature "support for null values", needs to be implemented in a not-backward compatible way. Basically IDBWrapper returns null if a key is not found, so it is impossible to tell if the specified value is null or if there is no key.

I am not sure if exposing this difference in IDBWrapper is possible, and I had no time to look at this issue further

I recommend:

  1. Release 2.2.1 with the old AbstractLevelDown
  2. Fix the NULL value support and release it as level-js 3.

Also cc @JamesKyburz and @jprichardson @juliangruber

@mcollina mcollina changed the title Call the AbstractLevelDown constructor. Fixes for AbstractLevelDown 2 Jul 5, 2015
@juliangruber
Copy link
Member

lgtm

i guess for the null value problem we could use some special string with escaping

@mcollina
Copy link
Member Author

mcollina commented Jul 5, 2015

Yes. Or wrap everything in a simple object. Would you like to assemble
something?
Il giorno dom 5 lug 2015 alle 16:31 Julian Gruber notifications@github.com
ha scritto:

lgtm

i guess for the null value problem we could use some special string with
escaping


Reply to this email directly or view it on GitHub
#41 (comment).

@max-mapper
Copy link
Contributor

ok 2.2.1 is out with "abstract-leveldown": "~0.12.0". once this is ready we can do a 3.0.0

@juliangruber
Copy link
Member

i started fixing bugs, i'll post my progress later today

@mcollina
Copy link
Member Author

mcollina commented Jul 6, 2015

I've opened an issue against IDBWrapper, maybe we should just add a method/argument there.

@jensarps
Copy link

jensarps commented Jan 4, 2016

@mcollina Going through old IDBWrapper issues, and found this: jensarps/IDBWrapper#63

Feel free to get back to me over there!

timkuijsten pushed a commit to timkuijsten/level.js that referenced this pull request Feb 3, 2016
abstract-level requires differentiation between undefined as a value
and not exists. The IndexedDB API has a note explaining openCursor
can be used for this instead of get.

refs Level#41
@timkuijsten
Copy link

To complement jensarps comment on Chrome, I've noticed Firefox 46.0a2 can return undefined as well, so not only null. See this patch timkuijsten@18965a8

timkuijsten pushed a commit to timkuijsten/level.js that referenced this pull request Feb 3, 2016
abstract-level requires differentiation between undefined as a value
and not exists. The IndexedDB API has a note explaining openCursor
can be used for this instead of get.

refs Level#41
timkuijsten pushed a commit to timkuijsten/level.js that referenced this pull request Feb 5, 2016
abstract-level requires differentiation between undefined as a value
and not exists. The IndexedDB API has a note explaining openCursor
can be used for this instead of get.

refs Level#41
timkuijsten pushed a commit to timkuijsten/level.js that referenced this pull request Feb 5, 2016
abstract-level requires differentiation between undefined as a value
and not exists. The IndexedDB API has a note explaining openCursor
can be used for this instead of get.

refs Level#41
@timkuijsten
Copy link

Based on PR #51 I've started testing with abstract-leveldown2 and found that most tests succeed. I've fixed all remaining failing tests. I cannot reproduce the problems with undefined versus null values, Firefox 46.0a2 does return undefined as well as Chrome, not null for values that do not exist.

Some abstract tests require to differentiate between undefined as a value and not exists. The IndexedDB API has a note explaining openCursor can be used for this instead of get. Therefore I'm using IDB.iterate with a keyRange in _get now.

The work is ready to be merged and lives in https://github.com/timkuijsten/level.js/tree/abstract-level2. I'm currently proceeding with #46 and I'm not sure if I should already open up a PR for bumping the deps to abstract-level2 or wait until #46 is finished?

@mcollina
Copy link
Member Author

mcollina commented Feb 6, 2016

this would be a major anyway, if #46 is close by, let's just jump there.

Also, it would be really good to have zuul+saucelabs to run tests on all
browsers.
Il giorno sab 6 feb 2016 alle 17:30 Tim Kuijsten notifications@github.com
ha scritto:

Based on PR #51 #51 I've
started testing with abstract-leveldown2 and found that most tests succeed.
I've fixed all remaining failing tests. I cannot reproduce the problems
with undefined versus null values, Firefox 46.0a2 does return undefined as
well as Chrome, not null for values that do not exist.

Some abstract tests require
https://github.com/Level/abstract-leveldown/blob/master/abstract/put-get-del-test.js#L141
to differentiate between undefined as a value and not exists. The IndexedDB
API has a note explaining openCursor can be used for this instead of get.
Therefore I'm using IDB.iterate with a keyRange in _get now
timkuijsten@7ee8b6c
.

The work is ready to be merged and lives in
https://github.com/timkuijsten/level.js/tree/abstract-level2. I'm
currently proceeding with #46
#46 and I'm not sure if I
should already open up a PR for bumping the deps to abstract-level2 or wait
until #46 #46 is finished?


Reply to this email directly or view it on GitHub
#41 (comment).

timkuijsten pushed a commit to timkuijsten/level.js that referenced this pull request Feb 10, 2016
abstract-level requires differentiation between undefined as a value
and not exists. The IndexedDB API has a note explaining openCursor
can be used for this instead of get.

refs Level#41
timkuijsten pushed a commit to timkuijsten/level.js that referenced this pull request Feb 12, 2016
abstract-level requires differentiation between undefined as a value
and not exists. The IndexedDB API has a note explaining openCursor
can be used for this instead of get.

refs Level#41
mvayngrib pushed a commit to mvayngrib/level.js that referenced this pull request Aug 21, 2016
abstract-level requires differentiation between undefined as a value
and not exists. The IndexedDB API has a note explaining openCursor
can be used for this instead of get.

refs Level#41
@mvayngrib
Copy link

mvayngrib commented Aug 21, 2016

@timkuijsten i'm playing with your branch, and though the tests do pass, levelup's createReadStream never gets past the first value (and never emits 'end'). Could you take a look? I added the test to this fork https://github.com/mvayngrib/level.js/tree/al2:

  tape.only('read stream', function (t) {
    var level = levelup('read-stream-test', {db: leveljs})
    var batch = new Array(2).fill(null).map(function (whatever, i) {
      return {
        type: 'put',
        key: '' + i,
        value: '' + i
      }
    })

    level.batch(batch, function (err) {
      if (err) throw err

      const data = []
      level.createReadStream()
        .on('data', function (item) {
          data.push(item)
        })
        .on('error', t.error)
        .on('end', function () {
          t.same(data, batch.map(function (row) {
            return {
              key: row.key,
              value: row.value
            }
          }))

          t.end()
        })
    })
  })

@timkuijsten
Copy link

Hi @mvayngrib, I can reproduce that your test doesn't finish on the abstract-leveldown2 branch. However, it should be noted that most of my effort went into the idbunwrapper branch. I've tested your test on that branch and it does pass successfully.

I'm starting to use the idunwrapper code more and more, so far so good. Maybe you can try out that branch? https://github.com/timkuijsten/level.js/tree/idbunwrapper

@mvayngrib
Copy link

@timkuijsten actually i tried the idbunwrapper branch first :) The problem I had there was unsupported Buffer keys.

@mvayngrib
Copy link

mvayngrib commented Aug 21, 2016

@timkuijsten scratch that, i don't experience that issue (with Buffer keys) anymore, must have been a bug on my side. Will get back to you if something doesn't work for me

@timkuijsten
Copy link

@mvayngrib just pushed a big update into my idbunwrapper branch that could use some extra testing if you'd like.

@mvayngrib
Copy link

@timkuijsten great, i'll give it a try!

@ralphtheninja
Copy link
Member

@vweevers Can we close this as is or do you want to supersede it by something first?

@vweevers
Copy link
Member

Yeah, we'll get to this "automatically".

@vweevers vweevers closed this May 23, 2018
@vweevers vweevers deleted the update-to-abstract-leveldown-2 branch May 23, 2018 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants