-
Notifications
You must be signed in to change notification settings - Fork 25
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
Make 'Term' a trait #55
Comments
I'm waiting to see your POC, but I'm not sure exactly what benefit you would gain from such a trait, especially if Iri, Literal and BlankNode are still constrained to be concrete types... Note that nothing forces implementations of Sophia's traits (Graph, Dataset, Parser, Serializer...) to use Term internally. For example, Rio parsers do not, but still interoperate with Sophia. All that is required is to provide easy ways to convert internal "terms" to and from Sophia's Term. For that matter, thanks to the TermData parameter, Term is already rather flexible:
That being said, as I wrote, I'm curious to see your POC, and I remain open to discussion on this issue. |
A part of this comment from @MattesWhite on #62 is more relavant to this topic:
Thanks, this helps me understand the benefit you expect from a I had already given some thoughts (although not as much as you) to N3 and Sophia, and my idea was that N3 could be encoded in the generalized model provided by Sophia. Namely:
So rather than forcing some May be you have already explored this lead and found it unfeasible or suboptimal... It is very possible that I am overlooking some problems of this approach. But what you propose seems to extend Sophia's scope much beyond RDF. Granted, the current generalized model already extends it... but this is even much more. For example, what you suggest is that not all implementations of the |
Granted your suggestion for a In summary I'll close this issue as this (as you mentioned) exceeds the intended implementation of RDF to far. Problems with A short list of problems of your suggestion for the record:
As mentioned above, I imagine a performance optimized N3-engine. Accordingly, an optimized implementation of a |
Again, I am thrilled by your project of an N3 implementation in Rust. And I sympathize entirely with your concerns about performances. Actually, thinking a little more about that, I beleive this should be the opposite: |
While thinking on a graph implementation and the In a bunch of cases terms are passed as read-only references, e.g. the filter methods of The described use-case is similar to I haven't flashed out this thought entirely but I think we could use this to simplify some of |
If I understand trait objects correctly, But yes, we could consider simplifying the API, and requiring
This is already the case. Any iterator of sophia_rs/sophia/src/triple/stream/_iterator.rs Lines 8 to 13 in f8f0304
|
Okay I agree with you the use of
Well, your understanding is mostly true. Maybe it is better to show the impact of an trait object when we look at the size of different
As you can see on my 64bit machine each |
Makes sense. I stand corrected, then. The point your raise about the size of Regarding monoporphization of |
Thought: a good point about a Other thought: if we want to be able to use |
Yet another thought: currently the Of course, we could define a function |
@MattesWhite I created a branch Have a look at 9e878ad. If that's a kind of things you had in mind, we can try to propagate it into the rest of the API and see how it fits... |
I think 9e878ad is a good point to start I added some comments to the commit. TL;DR: The idea to downcast |
At last, this is implemented by 91bbb99. @MattesWhite (or anyone else): if you struggle updating your code to this new version, contact me and I'll to help. |
First of all big respect for this major refactoring of the whole crate 👏 . I see the huge amount of work that has gone into it 👍 and the trait really integrates well. But with such a large change there are some points I'd like to address which could further improve
|
Thanks for the appreciation ;-)
|
With the latest commit 9464afa the new trait |
Proposed first in #35 I suggest to introduce a trait
Term
.Objective
sophia
's aim is to become a central API for RDF in Rust (#23). As such it would be nice if third party terms could smoothly interoperate withsophia
's ecosystem, e.g.rio
's terms could be stored insophia
'sHashGraph
, N3 terms frommetis
could use theSerializer
interface or another crate could provide compatible, ASCII-based terms that are based on&[u8]
(maybe even going towardsno_std
-RDF 😊).Required changes
With the latest effort to turn each kind of term (IRI, literal, blank node and variable) into an own type with an aligned API the step to create a trait is no longer that much work. A problem could be that this could turn advanced traits, such as
Graph
, in a mess of trait bounds. I'd like to commit a PoC-PR to see how it goes.Suggestion
Here a suggestion how a trait may look like:
The focus should be to keep the
Term
trait as small as possible while other behaviour is kept separate in other traits, e.g.Resolve
.The text was updated successfully, but these errors were encountered: