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

Improve datastore interface #211

Merged
merged 18 commits into from
Feb 25, 2022
Merged

Improve datastore interface #211

merged 18 commits into from
Feb 25, 2022

Conversation

abeforgit
Copy link
Member

@abeforgit abeforgit commented Feb 8, 2022

Adds new node query methods which return a more workable response
Changes:

  • as___NodeMapping methods return a TermMapping object
  • the asQuadsResultSet method returns a ResultSet

Both of these remain iterable (with for...of), but both offer some convenienve methods over normal sets.

  • single(): takes the only element and returns it. Errors if there are more elements in the iterator. Useful in situations where you know there can only be one result.
  • map(mappingFunc): normal "apply this func to each item in the iterator" stuff

TermMapping also has a get(termSpec) method, for when you've matched multiple terms, but you need the nodes for a specific term. Takes the same kind of arguments as datastore.match (so concise term syntax, or RDFjs term objects)

Another improvement is that the nodes per term are now an array instead of a set, and they are guaranteed to be in document order, and contain no duplicates. The ordering was a piece of information we already had, but was destroyed by using sets to ensure no duplicates.

Also adds a minor improvement to the RangeFactory, setting default offset values for the fromInNode method.

Lastly, splits up the datastore file into several files, it was starting to become a little too long since it contained 4 class definitions and a bunch of types.

@abeforgit abeforgit added the enhancement New feature or request label Feb 8, 2022
@abeforgit abeforgit added the breaking Breaking api changes label Feb 8, 2022
@abeforgit abeforgit marked this pull request as draft February 10, 2022 08:52
@abeforgit
Copy link
Member Author

Made draft until its made non-breaking

@abeforgit abeforgit force-pushed the feature/better-datastore branch from 4cfbccf to e1a7e54 Compare February 16, 2022 13:25
@abeforgit abeforgit marked this pull request as ready for review February 16, 2022 13:34
@abeforgit abeforgit removed the breaking Breaking api changes label Feb 16, 2022
Copy link
Contributor

@lagartoverde lagartoverde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I think maybe we will have to change some of the range strategies in the future but we will see that when using them what makes sense now it may not make sense in a few months. Good job :)

@abeforgit abeforgit merged commit 9bf14e5 into development Feb 25, 2022
@abeforgit abeforgit deleted the feature/better-datastore branch February 25, 2022 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants