Coder Social home page Coder Social logo

level-js's Issues

del problems

@jez0990 and me are trying to make LevelGraph run in the browser on top of Level.js.

However we have a couple of failing tests on del support: stuff do not get deleted.

Any ideas in how to debug them?

snapshots seem not to work

this test (simplified for this issue):

test('iterator create snapshot correctly', function (t) {
    db.put('foobatch1', 'bar1', function(err){
      t.error(err)
      var iterator = db.iterator()
      db.del('foobatch1', function () {
        iterator.next(function (err, key, value) {
          t.notOk(err, 'no error')
          t.ok(key, 'got a key')
          t.equal(key.toString(), 'foobatch1', 'correct key')
          t.equal(value.toString(), 'bar1', 'correct value')
          iterator.end(t.end.bind(t))
        })
      })
    })
  })

is failing:

# iterator create snapshot correctly
default_stream.js:27 ok 419 no error
default_stream.js:27 not ok 420 got a key
default_stream.js:27   ---
default_stream.js:27     operator: ok
default_stream.js:27     expected: true
default_stream.js:27     actual:   undefined
default_stream.js:27     at: Test.assert (http://localhost:9966/test.js:12977:17)
default_stream.js:27   ...
iterator-test.js:467 Uncaught TypeError: Cannot read property 'toString' of undefined

@maxogden do you know what's going on here?

TypeError: value.toArrayBuffer is not a function

I'm running into the exception that toArrayBuffer is not a method of value on line #68. I wonder if this code in #L67-L68 is correct and what the purpose of it is? I really have no clue, for now I just disabled #L67-L69 and "It works for me".

'json' encoding stringifies data before being inserted into db

Since JSON is the native encoding to IndexedDB, it shouldn't be necessary to stringify data before storing it. Is it AbstractLevelDOWN that does the conversion? Does it make sense to replace 'json' encoding with raw:true when the database is opened?

I'm using the following to make sure I can cleanly work with JSON in both node and browser environments, but it feels like a hack:

package.json:

  ...
  "browser": {
    "leveldown": "level-js",
  }
  ...

index.js:

var levelup = require('levelup');
var leveldown = require('leveldown');
var leveljs = require('level-js');

var options = {
  db: leveldown
};
if (leveljs !== leveldown) {
  options.valueEncoding = 'json';
}
var db = levelup(name, options);

leveldown dep missing?

Not sure if this is something missing from the dependencies in this or maybe just my browserify inexperience, but it seems to want leveldown even if it isn't really using it.

Installing leveldown made browserify happy. If it's not just user error on my part it might help to put it in the package.json as a dep.

asBuffer = false by default?

Why is everything returned as an ArrayBuffer by default?
I expected the json that I put in to come out as json, and passing {asBuffer: false} to db.get gave me what I expected, but why not do that by default?

npm based install on windows failing

C:_data\leveljs>npm install level-js
npm http GET https://registry.npmjs.org/level-js
npm http 304 https://registry.npmjs.org/level-js
npm http GET https://registry.npmjs.org/abstract-leveldown
npm http GET https://registry.npmjs.org/isbuffer/0.0.0
npm ERR! not found: git
npm ERR!
npm ERR! Failed using git.
npm ERR! This is most likely not a problem with npm itself.
npm ERR! Please check if you have git installed and in your PATH.

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "level-js"
npm ERR! cwd C:_data\leveljs
npm ERR! node -v v0.10.7
npm ERR! npm -v 1.2.21
npm ERR! code ENOGIT
npm http 304 https://registry.npmjs.org/isbuffer/0.0.0
npm http 304 https://registry.npmjs.org/abstract-leveldown
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:_data\leveljs\npm-debug.log
npm ERR! not ok code 0

Get current tests passing

Without updating anything yet.

It doesn't pass the iterator snapshot test currently, because level.js creates the IDB cursor lazily (on next). It should create it in the Iterator constructor instead.

Array Buffers

If I try to put array buffer into a db that has valueEncoding set to 'binary' I get an error about

message: "value cannot be an empty ArrayBuffer"
name: "WriteError"

as far as I can tell this is due to it being improperly turned into a Uint8 at some point, I managed to trace it to here where the array Buffer failed the Buffer.isBuffer test, but then when new Buffer(ArrayBuffer) is called it uses ArrayBuffer.prototype.length instead of ArrayBuffer.prototype.byteLength, so I'll likely have to open an issue there as well

binary keyEncoding fails indirectly

Guys,

I've been trying to port my application from Node to the browser using level-browserify. My code depends heavily on binary keys but unfortunately all write operations fail with the error "DataError: Data provided to an operation does not meet requirements." (Fx 45.0a2). When looking up the specs binary keys are not part of IndexedDB 1.0 but they are going to be part of IndexedDB Second Edition.

I've patched IDBWrapper to map Uint8Array keys to plain arrays in the meantime, but I think the level-js package is a better place to do this, especially considering issue #46. I was wondering if a patch that handles binary keys would be welcome. Otherwise I would suggest at least a patch that throws if keyEncoding is binary. Or maybe if idb-blob-store is the future I better open this issue there?

Safari not supported

Seems that Safari is not supported here.

I am trying to run the tests and I got these kind of errors:

TypeError: 'undefined' is not an object (evaluating 'this.db.iterate')
TypeError: 'undefined' is not an object (evaluating 'this.idb.put')

abstract-leveldown tests aren't all passing anymore

right now the tests don't pass in latest chrome. Not sure if it was something in chrome, idb-wrapper, or abstract-leveldown that changed but if someone has some time to dig in and try and make the tests pass it would be much appreciated

Add a cache to Iterator

From #60 (comment):

Iterators should by default keep reading from the underlying IDB cursor, to fulfill the snapshot guarantee

  • Have the IDB cursor fill a cache (similar to how leveldown works with highWaterMark)
  • Have Iterator.prototype._next() read from the cache.

This cleanly separates the two mechanisms (IDB pushes, Iterator pulls).

Where do we stand?

I feel it's time to start focusing on this repository now. I'd really like to get this done and then ship level as one package to rule them all 😄

But first, lets breath some air into it.

However, I'm unsure of where we stand, like what should be done to make this work well.

Some links:

Lets use this issue to summarize what's needed and which direction we want to take it.

@vweevers @timkuijsten I feel you guys have have been digging around the most in this code and most likely have the most valuable input.

Some questions:

  • what is the big problem with the current implementation?
  • what are we fixing, except for using latest abstract-leveldown?

Support binary keys

  • Have the abstract-leveldown test suite assume binary keys are supported (remove process.browser checks) (Level/abstract-leveldown#121) Remove process.browser checks and move binary key tests to isolated test file(s) that can be skipped by implementations.
  • Or until then, add a custom test to level-js
  • Assume use of modern browserify (where Buffer is a subclass of Uint8Array)
  • Feature-detect binary key support
  • Update to latest abstract-leveldown and implement _serializeKey as (simplified):
var supportsBinaryKeys = true;

Level.prototype._serializeKey = function (key) {
  return !supportsBinaryKeys && this._isBuffer(key)
    ? String(key)
    : key
}

This means the test suite can pass in browsers that support binary keys as well as those that don't (IE, Edge, Chrome 49).

swap out idbwrapper with straight indexeddb code

idbwrapper has outlived its usefulness to us, and has performance issues

fastest throughput I can get with idbwrapper is 60KB/s. Without it I can get 1MB/s (using substacks idb-blob-store module which uses the IDB API directly)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.