org.aksw.commons.graph
Class TripleCacheIndexImpl

java.lang.Object
  extended by org.aksw.commons.graph.TripleCacheIndexImpl
All Implemented Interfaces:
ITripleCacheIndex

public class TripleCacheIndexImpl
extends Object
implements ITripleCacheIndex

FIXME The index could be used with either LRUMaps or Maps for keeping track of the data. So these indexes could be used both as cache or as full indexes.

Author:
raven

Method Summary
 void addSeen(Collection<com.hp.hpl.jena.graph.Triple> triples)
          Addes triples to the cache.
 void clear()
           
static TripleCacheIndexImpl create(IGraph graph, Integer fullMaxSize, Integer partialMaxSize, Integer emptyMaxSize, int... indexColumns)
           
 List<Object> extractKey(com.hp.hpl.jena.rdf.model.Statement stmt)
           
static
<T> void
fill(T[] array, Iterable<T> items, int[] map)
           
 IndexCompatibilityLevel getCompatibilityLevel(int[] columnIds)
           
 IndexCompatibilityLevel getCompatibilityLevel(com.hp.hpl.jena.graph.Triple pattern)
          Returns the compatibility level for a given pattern
 IGraph getGraph()
           
 int[] getIndexColumns()
           
static com.hp.hpl.jena.rdf.model.RDFNode getItemAt(com.hp.hpl.jena.rdf.model.Statement stmt, int index)
           
 int[] getKeyColumns()
          Returns the "columns" that are indexed - columns correspond to 0 = subject, 1 = predicate, 2 = object
static
<T> IndexTable
getOrCreate(org.apache.commons.collections15.map.LRUMap<List<? super T>,IndexTable> map, List<T> key)
           
static
<T> IndexTable
getOrCreate(Map<List<T>,IndexTable> map, List<T> key)
           
 CacheState getState()
           
 int[] getValueColumns()
          Returns the "columns" for which values are provided by this index
 void index(Collection<com.hp.hpl.jena.graph.Triple> triples)
          Note: When indexing too many triples, the LRU map might be full.
 Collection<com.hp.hpl.jena.graph.Triple> lookup(List<Object> key)
          lookup: returns a possible empty set of triples or null - if no Does not track cache misses.
 void registerMisses(Set<List<Object>> keys)
           
 void removeSeen(Collection<com.hp.hpl.jena.graph.Triple> triples)
          Methods which are used to notify the index about new triples
 String toString()
           
static com.hp.hpl.jena.graph.Triple toTriple(Object[] array)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getIndexColumns

public int[] getIndexColumns()

create

public static TripleCacheIndexImpl create(IGraph graph,
                                          Integer fullMaxSize,
                                          Integer partialMaxSize,
                                          Integer emptyMaxSize,
                                          int... indexColumns)
                                   throws Exception
Throws:
Exception

getItemAt

public static com.hp.hpl.jena.rdf.model.RDFNode getItemAt(com.hp.hpl.jena.rdf.model.Statement stmt,
                                                          int index)

extractKey

public List<Object> extractKey(com.hp.hpl.jena.rdf.model.Statement stmt)

getOrCreate

public static <T> IndexTable getOrCreate(Map<List<T>,IndexTable> map,
                                         List<T> key)

getOrCreate

public static <T> IndexTable getOrCreate(org.apache.commons.collections15.map.LRUMap<List<? super T>,IndexTable> map,
                                         List<T> key)

fill

public static <T> void fill(T[] array,
                            Iterable<T> items,
                            int[] map)

toTriple

public static com.hp.hpl.jena.graph.Triple toTriple(Object[] array)

lookup

public Collection<com.hp.hpl.jena.graph.Triple> lookup(List<Object> key)
lookup: returns a possible empty set of triples or null - if no Does not track cache misses.

Specified by:
lookup in interface ITripleCacheIndex
Parameters:
key -
Returns:

getGraph

public IGraph getGraph()
Specified by:
getGraph in interface ITripleCacheIndex

getCompatibilityLevel

public IndexCompatibilityLevel getCompatibilityLevel(com.hp.hpl.jena.graph.Triple pattern)
Description copied from interface: ITripleCacheIndex
Returns the compatibility level for a given pattern

Specified by:
getCompatibilityLevel in interface ITripleCacheIndex
Returns:

index

public void index(Collection<com.hp.hpl.jena.graph.Triple> triples)
Note: When indexing too many triples, the LRU map might be full. We therefore

Specified by:
index in interface ITripleCacheIndex

removeSeen

public void removeSeen(Collection<com.hp.hpl.jena.graph.Triple> triples)
Description copied from interface: ITripleCacheIndex
Methods which are used to notify the index about new triples

Specified by:
removeSeen in interface ITripleCacheIndex

getKeyColumns

public int[] getKeyColumns()
Description copied from interface: ITripleCacheIndex
Returns the "columns" that are indexed - columns correspond to 0 = subject, 1 = predicate, 2 = object

Specified by:
getKeyColumns in interface ITripleCacheIndex
Returns:

getValueColumns

public int[] getValueColumns()
Description copied from interface: ITripleCacheIndex
Returns the "columns" for which values are provided by this index

Specified by:
getValueColumns in interface ITripleCacheIndex
Returns:

getCompatibilityLevel

public IndexCompatibilityLevel getCompatibilityLevel(int[] columnIds)
Specified by:
getCompatibilityLevel in interface ITripleCacheIndex

addSeen

public void addSeen(Collection<com.hp.hpl.jena.graph.Triple> triples)
Description copied from interface: ITripleCacheIndex
Addes triples to the cache. The level indicates whether new index partitions created from these triples are incomplete (so there might be more triples in the underlying graph, which have not been touched so far), or complete.

Specified by:
addSeen in interface ITripleCacheIndex

clear

public void clear()
Specified by:
clear in interface ITripleCacheIndex

toString

public String toString()
Overrides:
toString in class Object

registerMisses

public void registerMisses(Set<List<Object>> keys)
Specified by:
registerMisses in interface ITripleCacheIndex

getState

public CacheState getState()
Specified by:
getState in interface ITripleCacheIndex


Copyright © 2012. All Rights Reserved.