Package org.aksw.limes.core.io.cache
Class MemoryCache
- java.lang.Object
-
- org.aksw.limes.core.io.cache.ACache
-
- org.aksw.limes.core.io.cache.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)
-
-
Field Summary
Fields Modifier and Type Field Description protected Iterator<Instance>instanceIteratorprotected HashMap<String,Instance>instanceMap
-
Constructor Summary
Constructors Constructor Description MemoryCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInstance(Instance i)ACacheaddProperty(String sourcePropertyName, String targetPropertyName, String processingChain)Method to process data of a property into a new property with specific preprocessing.voidaddTriple(String s, String p, String o)Adds a new spo statement to the cacheMemoryCacheclone()Ignores instanceIterator since there is no sane way to test the equality of iteratorsbooleancontainsInstance(Instance i)booleancontainsUri(String uri)booleanequals(Object obj)ArrayList<Instance>getAllInstances()Returns all the instance contained in the cacheSet<String>getAllProperties()Returns a set of properties (most likely) all instances have.ArrayList<String>getAllUris()InstancegetInstance(String uri)InstancegetNextInstance()Returns the next instance in the list of instancesACachegetSample(int size)inthashCode()org.apache.jena.rdf.model.ModelparseCSVtoRDFModel(String baseURI, String IDbaseURI, String rdfType)Basic method to create a JENA Model out of a cache.voidreplaceInstance(String uri, Instance a)voidresetIterator()intsize()StringtoString()
-
-
-
Method Detail
-
getNextInstance
public Instance getNextInstance()
Returns the next instance in the list of instances- Specified by:
getNextInstancein classACache- 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:
getAllInstancesin classACache- Returns:
- ArrayList containing all instances
-
addInstance
public void addInstance(Instance i)
- Specified by:
addInstancein classACache
-
getInstance
public Instance getInstance(String uri)
- Specified by:
getInstancein classACache- Parameters:
uri- URI to look for- Returns:
- The instance with the URI uri if it is in the cache, else null
-
addTriple
public void addTriple(String s, String p, String o)
Adds a new spo statement to the cache
-
containsInstance
public boolean containsInstance(Instance i)
- Specified by:
containsInstancein classACache- 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:
containsUriin classACache- Parameters:
uri- The URI to looks for- Returns:
- True if an instance with the URI uri is found in the cache, else false
-
resetIterator
public void resetIterator()
- Specified by:
resetIteratorin classACache
-
getAllUris
public ArrayList<String> getAllUris()
- Specified by:
getAllUrisin classACache
-
addProperty
public ACache addProperty(String sourcePropertyName, String targetPropertyName, String processingChain)
Description copied from class:ACacheMethod to process data of a property into a new property with specific preprocessing.- Specified by:
addPropertyin classACache- 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:
getAllPropertiesin classACache- Returns:
- set of all properties
-
replaceInstance
public void replaceInstance(String uri, Instance a)
- Specified by:
replaceInstancein classACache
-
parseCSVtoRDFModel
public org.apache.jena.rdf.model.Model parseCSVtoRDFModel(String baseURI, String IDbaseURI, String rdfType)
Description copied from class:ACacheBasic 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:
parseCSVtoRDFModelin classACache- 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
-
-