Giter VIP home page Giter VIP logo

Comments (6)

skodapetr avatar skodapetr commented on August 19, 2024

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:

  1. Introduce a custom HttpLoader with another cache. We may be able to do this outside the
    titanium-json-ld code base.
  2. 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.

filip26 avatar filip26 commented on August 19, 2024

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.

skodapetr avatar skodapetr commented on August 19, 2024

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.

filip26 avatar filip26 commented on August 19, 2024

@jakubklimek can we close this issue as a shareable cache has been delivered by @skodapetr ?

from titanium-json-ld.

jakubklimek avatar jakubklimek commented on August 19, 2024

@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.

filip26 avatar filip26 commented on August 19, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.