Callidon / sparql-engine

🚂 A framework for building SPARQL query engines in Javascript/Typescript
https://callidon.github.io/sparql-engine
MIT License
99 stars 14 forks source link

Failing example #27

Closed vhf closed 5 years ago

vhf commented 5 years ago

Thanks for this great project! ❤️

Describe the bug

The levelgraph example doesn't run: https://github.com/Callidon/sparql-engine/blob/2d699c93033d8e9737f19d50395f8c4fb13d2b87/examples/levelgraph.js

To Reproduce Steps to reproduce the behavior:

  1. Copy the above file
  2. NPM Install sparql-engine
  3. node levelgraph.js
  4. See error:
error TypeError: dest.on is not a function
    at FormatterStream.Readable.pipe (_stream_readable.js:669:8)
    at RxjsPipeline.map (/example/node_modules/sparql-engine/dist/engine/pipeline/rxjs-pipeline.js:95:22)
    at MergeMapSubscriber.project (/example/node_modules/sparql-engine/dist/engine/stages/bgp-stage-builder.js:71:23)
    at MergeMapSubscriber._tryNext (/example/node_modules/rxjs/internal/operators/mergeMap.js:69:27)
    at MergeMapSubscriber._next (/example/node_modules/rxjs/internal/operators/mergeMap.js:59:18)
    at MergeMapSubscriber.Subscriber.next (/example/node_modules/rxjs/internal/Subscriber.js:66:18)
    at Observable._subscribe (/example/node_modules/rxjs/internal/util/subscribeToArray.js:5:20)
    at Observable._trySubscribe (/example/node_modules/rxjs/internal/Observable.js:44:25)
    at Observable.subscribe (/example/node_modules/rxjs/internal/Observable.js:30:22)
    at MergeMapOperator.call (/example/node_modules/rxjs/internal/operators/mergeMap.js:39:23)

Expected behavior Example should not crash.

Callidon commented 5 years ago

Hi Thank you :) Well, it appears that the levelgraph example has not been updated after the introduction of major API changes made to the project. I will try to update it as soon as possible.

vhf commented 5 years ago

Nice, thanks in advance!

Callidon commented 5 years ago

I've updated the levelgraph example in commit ff5a024a1152a08f1d6b1a8b702ec865ffeee008. It is working for me, I would be glad if you can retry with your own setup.

vhf commented 5 years ago

Thank you!

I had a few issues with the first two changes here: https://github.com/Callidon/sparql-engine/commit/ff5a024a1152a08f1d6b1a8b702ec865ffeee008#diff-51e908970d27907e5ab4a3e609e1508d

With this, the example runs with node 12 and prints:

Find solutions: { '?name': '"c"' }
Find solutions: { '?name': '"d"' }
Query evaluation complete!

(This require isn't used in the example 😉 https://github.com/Callidon/sparql-engine/blob/ff5a024a1152a08f1d6b1a8b702ec865ffeee008/examples/levelgraph.js#L6 )

Thanks again!

Callidon commented 5 years ago

Hello,

Since I'm have npm installed sparql-engine@0.5.3 in my project, I had to replace

- const { BindingBase, HashMapDataset, Graph, PlanBuilder, Pipeline } = require('../dist/api')
+ const { BindingBase, HashMapDataset, Graph, PlanBuilder, Pipeline } = require('sparql-engine')

I used the relative import for my local, but I forgot to replace it, my bad. This will be fixed.

  • level-browserify cannot be installed by npm@6.11.3 (it's the latest one) with node@12.10.0 (again, the latest one).

About this one, I simply followed the README of levelgraph and it works well for me. Nonetheless, I will update the example with level@5, as you suggested.

(This require isn't used in the example 😉

https://github.com/Callidon/sparql-engine/blob/ff5a024a1152a08f1d6b1a8b702ec865ffeee008/examples/levelgraph.js#L6

Whoops, my bad 😄 Another fix for me.

Callidon commented 5 years ago

And voilà: I've integrated your feedback into the both examples (commit 796b690047d665cd14018f846a8e19e9f494718d). I've also added an implementation for the Graph.insert and Graph.delete method in the levelgraph examples.

Let me know if you have any more suggestions/remarks on this topic!

vhf commented 5 years ago

It works well 👍

Callidon commented 5 years ago

A little update on the subject. In v0.5.5, I've added a new method for using Node.JS streams in the framework. Since levelgraph has a Stream API, I've updated the levelgraph example so it can use it during SPARQL query processing. This should also improve performance!