Class MemoryCache

  • All Implemented Interfaces:
    ICache
    Direct Known Subclasses:
    HybridCache

    public class MemoryCache
    extends ACache
    Implements a cache that is exclusively in memory. Fastest cache as it does not need to read from the hard drive.
    Version:
    Jul 8, 2015
    Author:
    Axel-C. Ngonga Ngomo (ngonga@informatik.uni-leipzig.de), Klaus Lyko, Mohamed Sherif (sherif@informatik.uni-leipzig.de)
    • Constructor Detail

      • MemoryCache

        public MemoryCache()
    • Method Detail

      • getNextInstance

        public Instance getNextInstance()
        Returns the next instance in the list of instances
        Specified by:
        getNextInstance in class ACache
        Returns:
        null if no next instance, else the next instance
      • getAllInstances

        public ArrayList<Instance> getAllInstances()
        Returns all the instance contained in the cache
        Specified by:
        getAllInstances in class ACache
        Returns:
        ArrayList containing all instances
      • getInstance

        public Instance getInstance​(String uri)
        Specified by:
        getInstance in class ACache
        Parameters:
        uri - URI to look for
        Returns:
        The instance with the URI uri if it is in the cache, else null
      • size

        public int size()
        Specified by:
        size in class ACache
        Returns:
        The size of the cache
      • addTriple

        public void addTriple​(String s,
                              String p,
                              String o)
        Adds a new spo statement to the cache
        Specified by:
        addTriple in class ACache
        Parameters:
        s - The URI of the instance linked to o via p
        p - The property which links s and o
        o - The value of the property of p for the entity s
      • containsInstance

        public boolean containsInstance​(Instance i)
        Specified by:
        containsInstance in class ACache
        Parameters:
        i - The instance to look for
        Returns:
        true if the URI of the instance is found in the cache
      • containsUri

        public boolean containsUri​(String uri)
        Specified by:
        containsUri in class ACache
        Parameters:
        uri - The URI to looks for
        Returns:
        True if an instance with the URI uri is found in the cache, else false
      • addProperty

        public ACache addProperty​(String sourcePropertyName,
                                  String targetPropertyName,
                                  String processingChain)
        Description copied from class: ACache
        Method to process data of a property into a new property with specific preprocessing.
        Specified by:
        addProperty in class ACache
        Parameters:
        sourcePropertyName - Name of the property to process.
        targetPropertyName - Name of the new property to process data into.
        processingChain - Preprocessing Expression.
        Returns:
        Cache after property add
      • getAllProperties

        public Set<String> getAllProperties()
        Returns a set of properties (most likely) all instances have.
        Specified by:
        getAllProperties in class ACache
        Returns:
        set of all properties
      • parseCSVtoRDFModel

        public org.apache.jena.rdf.model.Model parseCSVtoRDFModel​(String baseURI,
                                                                  String IDbaseURI,
                                                                  String rdfType)
        Description copied from class: ACache
        Basic method to create a JENA Model out of a cache. Restriction 1: Assumes all objects are literal values. Thus, resource URIs are represented as Strings. Restriction 2: Adds a rdf:Type statement for all instances.
        Specified by:
        parseCSVtoRDFModel in class ACache
        Parameters:
        baseURI - Base URI of properties, could be empty.
        IDbaseURI - Base URI for id of resources: URI(instance) := IDbaseURI+instance.getID(). Could be empty.
        rdfType - rdf:Type of the instances.
        Returns:
        JENA RDF Model
      • clone

        public MemoryCache clone()
        Ignores instanceIterator since there is no sane way to test the equality of iterators
        Specified by:
        clone in class ACache
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in class ACache