org.jrdf.graph.local.index.graphhandler
Interface GraphHandler

All Known Implementing Classes:
AbstractGraphHandler, GraphHandler012, GraphHandler120, GraphHandler201

public interface GraphHandler

An interface used to make modifications on the internal indexes (012, 120 and 201) of a graph.

Version:
$Revision: 1804 $
Author:
Andrew Newman

Method Summary
 Triple createTriple(Long... nodes)
          Creates the globalized nodes based on the internal representation of the nodes.
 Iterator<Map.Entry<Long,Map<Long,Set<Long>>>> getEntries()
          Returns an iterator over an internal representation of the graph in the fixed order based on the underlying index.
 Map<Long,Set<Long>> getSubIndex(Long first)
          Returns the map of long to set of longs for the given entry of the index.
 void reconstructIndices(LongIndex firstIndex, LongIndex secondIndex, LongIndex thirdIndex)
          As 012, 120 and 201 are symmetrical this can be used to reconstruct either two from any one index.
 void remove(Long... nodes)
          Removes a triple from the other indexes of the graph.
 boolean removeSubIndex(Long first)
          Removes the given entry of long to set of longs with the given entry.
 

Method Detail

reconstructIndices

void reconstructIndices(LongIndex firstIndex,
                        LongIndex secondIndex,
                        LongIndex thirdIndex)
                        throws GraphException
As 012, 120 and 201 are symmetrical this can be used to reconstruct either two from any one index. Using the 012 index it will add entries correctly to 120 (secondIndex) and 201 (thirdIndex), or 120 will make 201 (secondIndex) and 012 (thirdIndex) and 201 will produce 120 and 201.

Parameters:
firstIndex - the first index.
secondIndex - the second index.
thirdIndex - the third index.
Throws:
GraphException - if the adds fail.

getSubIndex

Map<Long,Set<Long>> getSubIndex(Long first)
Returns the map of long to set of longs for the given entry of the index. For example, a given subject id is given and it returns a map of predicates to objects.

Parameters:
first - the entry set to find.
Returns:
a map containing the list of longs to set of longs.

removeSubIndex

boolean removeSubIndex(Long first)
Removes the given entry of long to set of longs with the given entry. For example, a given subject id is given and it will remove all the associated predicate and objects for that subject.

Parameters:
first - the entry set to remove.
Returns:
true if the entry set was non-null.

getEntries

Iterator<Map.Entry<Long,Map<Long,Set<Long>>>> getEntries()
Returns an iterator over an internal representation of the graph in the fixed order based on the underlying index.

Returns:
an iterator over an internal representation of the graph in the fixed order based on the underlying index.

createTriple

Triple createTriple(Long... nodes)
Creates the globalized nodes based on the internal representation of the nodes. This may move to the NodePool interface.

Parameters:
nodes - an array of three triple values to create.
Returns:
an array of three nodes.

remove

void remove(Long... nodes)
            throws GraphException
Removes a triple from the other indexes of the graph. For example, if this is the 012 GraphHandler it will remove the 120 and 201.

Parameters:
nodes - the array of nodes to remove.
Throws:
GraphException - if the nodes do not exist.