Class AbstractFileAtlasProvider

  • All Implemented Interfaces:
    java.io.Serializable, java.util.function.BiFunction<java.lang.String,​org.openstreetmap.atlas.geography.sharding.Shard,​java.util.Optional<org.openstreetmap.atlas.geography.atlas.Atlas>>, AtlasProvider
    Direct Known Subclasses:
    AtlasFileAtlasProvider, PbfRawAtlasProvider

    public abstract class AbstractFileAtlasProvider
    extends java.lang.Object
    implements AtlasProvider
    Abstract AtlasProvider that focuses on accessing Atlas data from files/resources using ResourceCaches.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<org.openstreetmap.atlas.geography.atlas.Atlas> apply​(java.lang.String country, org.openstreetmap.atlas.geography.sharding.Shard shard)  
      protected java.lang.String getAtlasPath()  
      protected abstract java.util.Optional<org.openstreetmap.atlas.streaming.resource.Resource> getResourceFromCache​(java.lang.String country, org.openstreetmap.atlas.geography.sharding.Shard shard)
      Use a ConcurrentResourceCache to get a remote resource from the country and shard.
      protected java.util.Map<java.lang.String,​java.lang.String> getSparkConfiguration()  
      protected abstract void invalidateCache​(java.lang.String country, org.openstreetmap.atlas.geography.sharding.Shard shard)
      Invalidate the cache for a specific country and shard, allowing for a retry.
      protected abstract java.util.Optional<org.openstreetmap.atlas.geography.atlas.Atlas> resourceToAtlas​(org.openstreetmap.atlas.streaming.resource.Resource resource, java.lang.String country, org.openstreetmap.atlas.geography.sharding.Shard shard)
      The core of the AbstractFileAtlasProvider, in which a provided file becomes a resource which is then translated into an Atlas.
      void setAtlasProviderContext​(java.util.Map<java.lang.String,​java.lang.Object> context)
      Provide more generic runtime context to the AtlasProvider, this method to be used right before running the dependent mutation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.function.BiFunction

        andThen
    • Constructor Detail

      • AbstractFileAtlasProvider

        public AbstractFileAtlasProvider()
    • Method Detail

      • apply

        public java.util.Optional<org.openstreetmap.atlas.geography.atlas.Atlas> apply​(java.lang.String country,
                                                                                       org.openstreetmap.atlas.geography.sharding.Shard shard)
        Specified by:
        apply in interface java.util.function.BiFunction<java.lang.String,​org.openstreetmap.atlas.geography.sharding.Shard,​java.util.Optional<org.openstreetmap.atlas.geography.atlas.Atlas>>
      • setAtlasProviderContext

        public void setAtlasProviderContext​(java.util.Map<java.lang.String,​java.lang.Object> context)
        Description copied from interface: AtlasProvider
        Provide more generic runtime context to the AtlasProvider, this method to be used right before running the dependent mutation.
        Specified by:
        setAtlasProviderContext in interface AtlasProvider
        Parameters:
        context - Generic context that is needed by the provider
      • getAtlasPath

        protected java.lang.String getAtlasPath()
      • getResourceFromCache

        protected abstract java.util.Optional<org.openstreetmap.atlas.streaming.resource.Resource> getResourceFromCache​(java.lang.String country,
                                                                                                                        org.openstreetmap.atlas.geography.sharding.Shard shard)
        Use a ConcurrentResourceCache to get a remote resource from the country and shard.
        Parameters:
        country - The country code
        shard - The provided shard
        Returns:
        If it exists, the resource associated with the country and shard.
      • getSparkConfiguration

        protected java.util.Map<java.lang.String,​java.lang.String> getSparkConfiguration()
      • invalidateCache

        protected abstract void invalidateCache​(java.lang.String country,
                                                org.openstreetmap.atlas.geography.sharding.Shard shard)
        Invalidate the cache for a specific country and shard, allowing for a retry.
        Parameters:
        country - The country code
        shard - The provided shard
      • resourceToAtlas

        protected abstract java.util.Optional<org.openstreetmap.atlas.geography.atlas.Atlas> resourceToAtlas​(org.openstreetmap.atlas.streaming.resource.Resource resource,
                                                                                                             java.lang.String country,
                                                                                                             org.openstreetmap.atlas.geography.sharding.Shard shard)
        The core of the AbstractFileAtlasProvider, in which a provided file becomes a resource which is then translated into an Atlas.
        Parameters:
        resource - The resource to translate
        country - The country code
        shard - The provided shard
        Returns:
        The resulting Atlas.