You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TLDR I found it harder to implement this in the way the spec defines, and found a split between read and write to make things a lot easier
As a pretext to this, I did previously try to implement this based on using async iterables in place of "streams" where the dataset also implemented [Symbol.asyncIterator], however the implementation was messy and didn't cleanly fall into place, it required weird inheritance where a factory was required to create new datasets within DatasetCore.
I hoped that using async iterables would help with the lazy style of reading I wanted to achieve, but it turns out you can achieve this same thing with sync Iterables, which can be seen in a code snippet below
I have had great success implementing dataset using two different concepts
In terms of implementation, this felt a lot more natural and took a lot less time than trying to follow the spec one to one
I've used types specifically for TypeScript here, but I think it shows nicely the how implementation works
Behind the scenes I was able to utilise a Set as the backing collection for quads
The read dataset in this implementation accepts a source Iterable, which the read dataset implements itself, meaning we don't need any intermediate steps in between creating new datasets, a Set also implements this, making everything very seemless.
Chaining using the read dataset is very clean which can be seen in the implementation of the read dataset itself:
I have implemented these datasets as sync as I am only wanting to know whats in memory right now, not whats available in this remote dataset
I did this because if you wanted to import information from a remote dataset, you should utilise import if you have an async iterable (Node.js ReadableStream, MongoDB cursors, etc), or addAll if you have another in memory dataset or an iterable (Arrays, Sets, etc)
The text was updated successfully, but these errors were encountered:
TLDR I found it harder to implement this in the way the spec defines, and found a split between read and write to make things a lot easier
As a pretext to this, I did previously try to implement this based on using async iterables in place of "streams" where the dataset also implemented
[Symbol.asyncIterator]
, however the implementation was messy and didn't cleanly fall into place, it required weird inheritance where a factory was required to create new datasets withinDatasetCore
.I hoped that using async iterables would help with the lazy style of reading I wanted to achieve, but it turns out you can achieve this same thing with sync Iterables, which can be seen in a code snippet below
I have had great success implementing dataset using two different concepts
First, we have all of our "read" dataset
And our write dataset...
If we want an immutable write dataset...
A couple of specific changes...
DatasetCore
is "moved up" to become the write dataset on top,Dataset
is "moved down" to become the read dataset.write functions return writable datasets
read functions return readable datasets
In terms of implementation, this felt a lot more natural and took a lot less time than trying to follow the spec one to one
I've used types specifically for TypeScript here, but I think it shows nicely the how implementation works
Behind the scenes I was able to utilise a Set as the backing collection for quads
The read dataset in this implementation accepts a source Iterable, which the read dataset implements itself, meaning we don't need any intermediate steps in between creating new datasets, a Set also implements this, making everything very seemless.
Chaining using the read dataset is very clean which can be seen in the implementation of the read dataset itself:
https://github.com/opennetwork/rdf-dataset/blob/02f8d19e78b8065cfc0f78691f1af174e8c47425/src/readonly-dataset.ts#L76-L78
Using iterables also enables this kind of usage where the returned read dataset is a "live" view of the write dataset:
This snippet outputs:
I have implemented these datasets as sync as I am only wanting to know whats in memory right now, not whats available in this remote dataset
I did this because if you wanted to import information from a remote dataset, you should utilise
import
if you have an async iterable (Node.js ReadableStream, MongoDB cursors, etc), oraddAll
if you have another in memory dataset or an iterable (Arrays, Sets, etc)The text was updated successfully, but these errors were encountered: