Comments (6)
It seems the issue is a lack of caching in ActiveContextBuilder line 244.
On this line new document is requested every time without checking the cache.
There are cache mechanisms in JsonLdOptions, yet they are not used here.
I see several ways to tackle this issue:
- Introduce a custom HttpLoader with another cache. We may be able to do this outside the
titanium-json-ld code base. - Add caching to ActiveContextBuilder.
2.1) We can leverage existing contextCache as we are working with the context here anyway.
The main issue is that contextCache stores JsonValue instead of JsonStructure.
2.2) We can add a third cache importedDocumentCache (to JsonLdOptions) to the existing contextCache, documentCache.
That would not only allow to use of proper type but also when left empty (null) would not change
existing behaviour.
2.3) We can use documentCache, but I would rather avoid it. Using documentCache
would lead to unnecessary parsing of JSON harming performance. This would be equivalent to 1) but in titanium-json-ld code base.
@filip26 Can I get your thoughts, is there a solution you would prefer?
from titanium-json-ld.
HTTP cache must be fully handled by provided HttpLoader
implementation. e.g. native Java 11 HttpClient
. I'm not in favor to start implementing another HTTP cache as a part of the processor.
How to cache parsed and pre-processed context is another thing. In the next major version I would like to see a separate method allowing you to pre-fetch/process a context separatelly.
Something like
var context = JsonLd.getContent(....);
var expanded = JsonLd.expand(input, context);
So you would be able to re-use a context of a set contexts between calls.
from titanium-json-ld.
So that takes 1), and 2.3) out of the question.
From my perspective the difference between 2.1 and 2.2 is backwards compatibility.
As of the
Jsonld.getContext( .... );
That is a neat idea. Yet, I do not see how this would address the issue. I would need to know all contexts used throughout the document tree, which is often not the case.
I see that you do aim on the high-level API (JsonLd object). As I should be able to use re-use cache by sharing the JsonLdOptions
between the calls. Is that correct? If so, we are back to 2.1 or 2.2.
from titanium-json-ld.
@jakubklimek can we close this issue as a shareable cache has been delivered by @skodapetr ?
from titanium-json-ld.
@filip26 I would prefer to close it when the resolution makes its way to a release and we can test it in our tool. But I will understand if you want to close it based on the fact that the corresponding test is passing. We can always raise another issue later.
from titanium-json-ld.
@jakubklimek great, it's easier link an issue to PR and close it together, to keep it trackable, instead of waiting on a release and then do the closing manually. It's part of 1.4.0-SNAPSHOT
now.
Please feel free to re-open or raise a new issue.
from titanium-json-ld.
Related Issues (20)
- Asynchronous Document Loader HOT 1
- Some URI resources are resolving as strings rather than URI HOT 2
- Provide a multi-release jar? HOT 14
- Allow to set custom DocumentResolver HOT 2
- Usage of @reverse breaks scoped contexts HOT 8
- Frame aliasing `@graph` broken when `omitGraph = false` HOT 4
- Add benchmarks HOT 1
- provision of activitypub / activitystreams compatible json-ld HOT 6
- Not handling xsd:float HOT 2
- Allow to prematurely terminate processing when a criteria is met HOT 2
- Force HTTPS on HttpLoader HOT 5
- Allow to pass JsonFactory as a runtime option HOT 2
- Extract RDF interfaces, parser, into a separate artifact HOT 2
- Add support to create RDF* statements HOT 6
- Allow to set an `Accept` header HOT 1
- Use "#" as the vocabulary mapping
- Sync json-ld-test-suite content with the official test repo
- Support for JSON-LD framing widcard matching ? HOT 3
- Type Coercion not working in a @container inside another @container HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from titanium-json-ld.