Closed jacoscaz closed 7 years ago
The following guideline contained in the specs
Given the necessity of methods, plain objects (JSON) cannot be used.
introduces potential performance penalties as it requires transforming all plain objects to class instances.
To preserve access to the native interface, we could make the rdf interface available via some method such as const interface = store.getRdfInterface();
that would return a wrapper around a store instance which would take care of adding the necessary transform streams.
@elf-pavlik we welcome all thoughts and suggestions you might have on this.
@RubenVerborgh just mentioned on https://gitter.im/rdfjs/Representation-Task-Force?at=58c011fa1465c46a5602aaa1 switching from very minimalistic plain object N3.js used to those interface had minimal performance impact. I believe he can offer much more feedback on that and possibly soon report his experience in more detail on https://github.com/rdfjs/representation-task-force/issues/67
@jacoscaz There is no performance penalty associated with "transforming plain objects to class instances": plain objects are also class instances (Object), and all modern JavaScript engines are specifically tailored to excel on objects with the same shape (i.e., all property accesses will be translated to machine code).
The small performance penalty that I took with N3.js, as mentioned by @elf-pavlik, is because N3.js used single-level objects.
On the other hand, the "Given the necessity of methods, plain objects (JSON) cannot be used." is misleading in the RDF/JS spec, as these methods are not required for core data tasks (subject/predicate/object/graph) but rather for equality and conversion.
Thanks to @elf-pavlik and @RubenVerborgh for the excellent brainstorming on Gitter. Strategy:
Closing this. Will track bugs and enhancements in dedicated issues.
As suggested by @elf-pavlik in https://github.com/mcollina/levelgraph/issues/43#issuecomment-284721147 .
See specs: https://github.com/rdfjs/representation-task-force/blob/master/interface-spec.md
Status:
.import()
).match()
without regexp support).remove()
,.removeMatches()
,.deleteGraph()
)