Class DataServiceBBoxCache<C,T>

java.lang.Object
org.aksw.jena_sparql_api.sparql.ext.geosparql.DataServiceBBoxCache<C,T>

public class DataServiceBBoxCache<C,T> extends Object
Adds a quad tree cache to the lookup service. If there are only few items, then the 'global' workflow fetches them all. The 'tiled' workflow starts from the current viewport.
  • Field Details

    • listServiceBBox

      protected org.aksw.commons.rx.lookup.MapService<org.locationtech.jts.geom.Envelope,T,T> listServiceBBox
    • quadTree

      protected LooseQuadTree<T> quadTree
    • checkedGlobalCount

      protected io.reactivex.rxjava3.core.Single<Boolean> checkedGlobalCount
    • maxGlobalItemCount

      protected long maxGlobalItemCount
    • maxItemsPerTileCount

      protected long maxItemsPerTileCount
    • acquireDepth

      protected int acquireDepth
    • runningTasks

      protected Map<Object,io.reactivex.rxjava3.core.Single<QuadTreeNode<T>>> runningTasks
    • checkedFetchAllAtOnce

      protected CompletableFuture<Boolean> checkedFetchAllAtOnce
      Future whether there are few enough items to fetch them all at once
  • Constructor Details

    • DataServiceBBoxCache

      public DataServiceBBoxCache(org.aksw.commons.rx.lookup.MapService<org.locationtech.jts.geom.Envelope,T,T> listServiceBBox, long maxGlobalItemCount, long maxItemsPerTileCount, int acquireDepth)
  • Method Details

    • resetGlobalCount

      protected void resetGlobalCount()
      Sets checkedGlobalCount to a fresh cold single that upon subscription counts items
    • fetchData

      public io.reactivex.rxjava3.core.Flowable<org.apache.jena.rdf.model.Resource> fetchData(org.locationtech.jts.geom.Envelope bounds)
    • runWorkflow

      public io.reactivex.rxjava3.core.Flowable<QuadTreeNode<T>> runWorkflow(org.locationtech.jts.geom.Envelope bounds)
    • runGlobalWorkflow

      public io.reactivex.rxjava3.core.Single<QuadTreeNode<T>> runGlobalWorkflow(QuadTreeNode<T> node)
    • runTiledWorkflow

      public io.reactivex.rxjava3.core.Flowable<QuadTreeNode<T>> runTiledWorkflow(org.locationtech.jts.geom.Envelope bounds)
      This method implements the primary workflow for tile-based fetching data. globalGeomCount = number of geoms - facets enabled, bounds disabled. if(globalGeomCount > threshold) { nodes = aquire nodes. foreach(node in nodes) { fetchGeomCount in the node - facets TODO enabled or disabled? nonFullNodes = nodes where geomCount < threshold foreach(node in nonFullNodes) { fetch geomToFeatureCount - facets enabled fetch all positions of geometries in that area -- Optionally: fetchGeomToFeatureCount - facets disabled - this can be cached per type of interest!! } } }
    • createCountTask

      public io.reactivex.rxjava3.core.Single<QuadTreeNode<T>> createCountTask(QuadTreeNode<T> node)
      For a given node, this method returns a single that upon completion has the item count set
    • isCountingNeeded

      public boolean isCountingNeeded(QuadTreeNode<T> node)
      If either the minimum number of items in the node is above the threshold or all children have been counted, then there is NO need for counting
    • isTooManyGeoms

      public boolean isTooManyGeoms(QuadTreeNode<T> node)
    • loadTaskAction

      public void loadTaskAction(QuadTreeNode<T> node, Map<T,T> items)
      Sets the node's state to loaded, attaches the geomToFeatureCount to it.
    • finalizeLoading

      public List<QuadTreeNode<T>> finalizeLoading(Collection<QuadTreeNode<T>> leafNodes)
      TODO tryMergeNode is not yet implemented! This method checks whether there are leafNodes that can be merged into their parents. The collection passed as the argument is left unchanged, however the nodes in it may become detached.
    • tryMergeNode

      public boolean tryMergeNode(QuadTreeNode<T> node)
      If all child nodes are loaded and the num of all items is less than the threshold then copy all items to this node and remove the children.