org.mulgara.mrg
Class IndexedGraph

java.lang.Object
  extended by org.mulgara.mrg.AbstractGraphExt
      extended by org.mulgara.mrg.AbstractGraph
          extended by org.mulgara.mrg.IndexedGraph
All Implemented Interfaces:
AppendableGraph, Graph, GraphExt, WritableGraph
Direct Known Subclasses:
PackedIndexedGraph

public class IndexedGraph
extends AbstractGraph

A graph with three indexes for complete searchability. Indexes are hash-based, giving constant time lookups. This graph operates the same as other implementations of graph, but is fully indexed.


Field Summary
 
Fields inherited from interface org.mulgara.mrg.Graph
X
 
Constructor Summary
IndexedGraph()
          Default constructor for an empty graph.
IndexedGraph(Collection<Triple> triples)
          Builds a graph with a collection of triples.
 
Method Summary
protected
<X> Collection<X>
createCollection()
          Use a HashSet for efficient lookups.
protected
<X,Y> Map<X,Y>
createMap()
          Use hashmaps for efficient lookups.
 boolean delete(SubjectNode s, PredicateNode p, ObjectNode o)
          Remove a triple from the graph.
 Collection<ObjectNode> getObjects()
          Gets all the objects in the graph.
 Collection<PredicateNode> getPredicates()
          Gets all the predicates in the graph.
 boolean insert(SubjectNode s, PredicateNode p, ObjectNode o)
          Add a new triple to the graph.
 Iterator<Triple> match(SubjectNode s, PredicateNode p, ObjectNode o)
          Find all triples that match a given pattern.
 
Methods inherited from class org.mulgara.mrg.AbstractGraph
delete, doesResourceExist, exportN3, exportN3, exportXML, exportXML, getProperties, getRawProperties, getRdfList, getSubjects, getSubjects, getTriples, getValue, getValues, insert, isAsserted, isAsserted, isEmpty, matchSubgraph, mergeInto, size, unionInto
 
Methods inherited from class org.mulgara.mrg.AbstractGraphExt
doesResourceExist, doesResourceExist, getProperties, getProperties, getRdfList, getRdfList, getRdfList, getRdfList, getRdfList, getRdfList, getRdfList, getRdfList, getSubjects, getSubjects, getSubjects, getSubjects, getSubjects, getSubjects, getSubjects, getSubjects, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, getValues, getValues, getValues, getValues, getValues, getValues, getValues, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mulgara.mrg.GraphExt
doesResourceExist, doesResourceExist, getProperties, getProperties, getRdfList, getRdfList, getRdfList, getRdfList, getRdfList, getRdfList, getRdfList, getRdfList, getSubjects, getSubjects, getSubjects, getSubjects, getSubjects, getSubjects, getSubjects, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, getValues, getValues, getValues, getValues, getValues, getValues, getValues, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, isAsserted, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchSubgraphX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX, matchX
 

Constructor Detail

IndexedGraph

public IndexedGraph()
Default constructor for an empty graph.


IndexedGraph

public IndexedGraph(Collection<Triple> triples)
Builds a graph with a collection of triples.

Parameters:
triples - The initial triples for the graph.
Method Detail

createMap

protected <X,Y> Map<X,Y> createMap()
Use hashmaps for efficient lookups.

Specified by:
createMap in class AbstractGraph
Returns:
an instance of a HashMap.

createCollection

protected <X> Collection<X> createCollection()
Use a HashSet for efficient lookups.

Specified by:
createCollection in class AbstractGraph
Returns:
an instance of a HashSet.

insert

public boolean insert(SubjectNode s,
                      PredicateNode p,
                      ObjectNode o)
Add a new triple to the graph.

Specified by:
insert in interface AppendableGraph
Overrides:
insert in class AbstractGraph
Parameters:
s - The subject of the triple.
p - The predicate of the triple.
o - The object of the triple.
Returns:
true if the triple was already in the graph.

delete

public boolean delete(SubjectNode s,
                      PredicateNode p,
                      ObjectNode o)
Remove a triple from the graph.

Specified by:
delete in interface WritableGraph
Overrides:
delete in class AbstractGraph
Parameters:
s - The subject of the triple.
p - The predicate of the triple.
o - The object of the triple.
Returns:
true if the triple was already in the graph.

match

public Iterator<Triple> match(SubjectNode s,
                              PredicateNode p,
                              ObjectNode o)
Find all triples that match a given pattern.

Specified by:
match in interface Graph
Overrides:
match in class AbstractGraph
Parameters:
s - The subject of the triples to match. If null or Graph.X then all subjects match.
p - The predicate of the triple to add. If null or Graph.X then all predicates match.
o - The object of the triple to add. If null or Graph.X then all objects match.
Returns:
A Collection of the matching triples.

getPredicates

public Collection<PredicateNode> getPredicates()
Gets all the predicates in the graph.

Specified by:
getPredicates in interface Graph
Overrides:
getPredicates in class AbstractGraph
Returns:
All the predicatess in the graph.

getObjects

public Collection<ObjectNode> getObjects()
Gets all the objects in the graph.

Specified by:
getObjects in interface Graph
Overrides:
getObjects in class AbstractGraph
Returns:
All the objects in the graph.


Copyright © 2011. All Rights Reserved.