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

perf: Missing caching per cube iri for some queries #1651

Merged
merged 4 commits into from
Jul 3, 2024

Conversation

bprusinowski
Copy link
Collaborator

@bprusinowski bprusinowski requested a review from ptbrowne as a code owner July 3, 2024 07:01
Copy link

vercel bot commented Jul 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
visualization-tool ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 3, 2024 7:22am

@bprusinowski
Copy link
Collaborator Author

@Rdataflow this PR should hopefully fix the missing caching by cube iri queries 👍

@bprusinowski bprusinowski merged commit dba7038 into main Jul 3, 2024
5 of 6 checks passed
@bprusinowski bprusinowski deleted the perf/missing-caching-per-cube branch July 3, 2024 07:33
@Rdataflow
Copy link
Contributor

@bprusinowski there still some cases left... IIUC it occurs with maps

thanks for fixing this soon 👍

  • query for dimension including geo (possibly geoshape?)
PREFIX cube: <https://cube.link/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX schema: <http://schema.org/>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

CONSTRUCT {
  ?dimensionIri rdf:first ?unversionedValue .
  ?unversionedValue
    schema:name ?name ;
    schema:alternateName ?alternateName ;
    schema:description ?description ;
    schema:identifier ?identifier ;
    schema:position ?position ;
    schema:color ?color ;
    geo:hasGeometry ?geometry ;
    schema:latitude ?latitude ;
    schema:longitude ?longitude .
} WHERE {
  { #pragma evaluate on
      SELECT ?dimensionIri ?versionedValue ?unversionedValue WHERE {
        VALUES ?dimensionIri { <https://environment.ld.admin.ch/foen/nfi/unitOfReference> }
        <https://environment.ld.admin.ch/foen/nfi/nfi_T-changes/cube/2024-1> cube:observationConstraint/sh:property ?dimension .
        ?dimension sh:path ?dimensionIri .
        ?dimension schema:version ?version .
        ?dimension sh:in/rdf:rest*/rdf:first ?versionedValue .
        ?versionedValue schema:sameAs ?unversionedValue .
      }
    } UNION { #pragma evaluate on
      SELECT ?dimensionIri ?versionedValue ?unversionedValue WHERE {
        VALUES ?dimensionIri { <https://environment.ld.admin.ch/foen/nfi/unitOfReference> }
        <https://environment.ld.admin.ch/foen/nfi/nfi_T-changes/cube/2024-1> cube:observationConstraint/sh:property ?dimension .
        ?dimension sh:path ?dimensionIri .
        FILTER NOT EXISTS { ?dimension schema:version ?version . }
        ?dimension sh:in/rdf:rest*/rdf:first ?versionedValue .
        BIND(?versionedValue as ?unversionedValue)
      }
    } UNION {
      {
        SELECT DISTINCT ?dimensionIri ?versionedValue ?unversionedValue WHERE {
          { #pragma evaluate on
            SELECT ?observation WHERE {
              VALUES ?dimensionIri { <https://environment.ld.admin.ch/foen/nfi/unitOfReference> }
                  <https://environment.ld.admin.ch/foen/nfi/nfi_T-changes/cube/2024-1> cube:observationConstraint/sh:property ?dimension .
                  ?dimension sh:path ?dimensionIri .
                  ?dimension schema:version ?version .
                  FILTER NOT EXISTS { ?dimension sh:in ?in . }
              <https://environment.ld.admin.ch/foen/nfi/nfi_T-changes/cube/2024-1> cube:observationSet/cube:observation ?observation .
              
            }
          }
          VALUES ?dimensionIri { <https://environment.ld.admin.ch/foen/nfi/unitOfReference> }
          ?observation ?dimensionIri ?versionedValue .
          ?versionedValue schema:sameAs ?unversionedValue .
        }
      }
    } UNION {
      {
        SELECT DISTINCT ?dimensionIri ?versionedValue ?unversionedValue WHERE {
          { #pragma evaluate on
            SELECT ?observation WHERE {
              VALUES ?dimensionIri { <https://environment.ld.admin.ch/foen/nfi/unitOfReference> }
                  <https://environment.ld.admin.ch/foen/nfi/nfi_T-changes/cube/2024-1> cube:observationConstraint/sh:property ?dimension .
                  ?dimension sh:path ?dimensionIri .
                  FILTER NOT EXISTS { ?dimension schema:version ?version . }
                  FILTER NOT EXISTS { ?dimension sh:in ?in . }
              <https://environment.ld.admin.ch/foen/nfi/nfi_T-changes/cube/2024-1> cube:observationSet/cube:observation ?observation .
              
            }
          }
          VALUES ?dimensionIri { <https://environment.ld.admin.ch/foen/nfi/unitOfReference> }
          ?observation ?dimensionIri ?versionedValue .
          BIND(?versionedValue as ?unversionedValue)
        }
      }
    }
  OPTIONAL { ?versionedValue schema:name ?name_de . FILTER(LANG(?name_de) = "de") }
OPTIONAL { ?versionedValue schema:name ?name_fr . FILTER(LANG(?name_fr) = "fr") }
OPTIONAL { ?versionedValue schema:name ?name_it . FILTER(LANG(?name_it) = "it") }
OPTIONAL { ?versionedValue schema:name ?name_en . FILTER(LANG(?name_en) = "en") }
OPTIONAL { ?versionedValue schema:name ?name_ . FILTER(LANG(?name_) = "") }
BIND(COALESCE(?name_de, ?name_fr, ?name_it, ?name_en, ?name_) AS ?name)
  OPTIONAL { ?versionedValue schema:description ?description_de . FILTER(LANG(?description_de) = "de") }
OPTIONAL { ?versionedValue schema:description ?description_fr . FILTER(LANG(?description_fr) = "fr") }
OPTIONAL { ?versionedValue schema:description ?description_it . FILTER(LANG(?description_it) = "it") }
OPTIONAL { ?versionedValue schema:description ?description_en . FILTER(LANG(?description_en) = "en") }
OPTIONAL { ?versionedValue schema:description ?description_ . FILTER(LANG(?description_) = "") }
BIND(COALESCE(?description_de, ?description_fr, ?description_it, ?description_en, ?description_) AS ?description)
  OPTIONAL { ?versionedValue schema:alternateName ?alternateName_de . FILTER(LANG(?alternateName_de) = "de") }
OPTIONAL { ?versionedValue schema:alternateName ?alternateName_fr . FILTER(LANG(?alternateName_fr) = "fr") }
OPTIONAL { ?versionedValue schema:alternateName ?alternateName_it . FILTER(LANG(?alternateName_it) = "it") }
OPTIONAL { ?versionedValue schema:alternateName ?alternateName_en . FILTER(LANG(?alternateName_en) = "en") }
OPTIONAL { ?versionedValue schema:alternateName ?alternateName_ . FILTER(LANG(?alternateName_) = "") }
BIND(COALESCE(?alternateName_de, ?alternateName_fr, ?alternateName_it, ?alternateName_en, ?alternateName_) AS ?alternateName)
  OPTIONAL { ?versionedValue schema:identifier ?identifier . }
  OPTIONAL { ?versionedValue schema:position ?position . }
  OPTIONAL { ?versionedValue schema:color ?color . }
  OPTIONAL { ?versionedValue geo:hasGeometry ?geometry . }
  OPTIONAL { ?versionedValue schema:latitude ?latitude . }
  OPTIONAL { ?versionedValue schema:longitude ?longitude . }
}
  • query 2
#pragma describe.strategy cbd
#pragma join.hash off

DESCRIBE ?subject WHERE {
  {
    BIND(<https://environment.ld.admin.ch/foen/gefahren-waldbrand-warnung/1> AS ?subject)
  }
  UNION
  {
    ?subject <http://schema.org/hasPart> <https://environment.ld.admin.ch/foen/gefahren-waldbrand-warnung/1> .
  }
}
  • query 3
#pragma describe.strategy cbd
#pragma join.hash off

DESCRIBE <https://environment.ld.admin.ch/foen/gefahren-waldbrand-warnung/1/shape/>

@bprusinowski
Copy link
Collaborator Author

bprusinowski commented Jul 3, 2024

Hi @Rdataflow, thanks again for catching this 💯 I am off for the end of this week and will tackle this once I am back on Monday ⛰️

@Rdataflow
Copy link
Contributor

@adintegra please coordinate this fix makes it into the upcoming release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants