org.jrdf.graph.index.longindex
Interface LongIndex

All Known Implementing Classes:
LongIndexDerby, LongIndexMem

public interface LongIndex

Represents an indexed set of longs.

Version:
$Revision: 1045 $
Author:
Andrew Newman

Method Summary
 void add(Long[] triple)
          Adds a triple to a single index.
 void add(Long first, Long second, Long third)
          Adds a triple to a single index.
 long getSize()
          Returns the number of triples in the index.
 Map<Long,Set<Long>> getSubIndex(Long first)
          Returns the map of long to set of longs for the given entry of the index.
 Iterator<Map.Entry<Long,Map<Long,Set<Long>>>> iterator()
          Returns an iterator which contains all the elements in the graph as a collections of distinct longs, contains a map of longs to other longs.
 void remove(Long[] triple)
          Removes a triple from a single index.
 void remove(Long first, Long second, Long third)
          Removes a triple from a single index.
 boolean removeSubIndex(Long first)
          Removes the given entry of long to set of longs with the given entry.
 

Method Detail

add

void add(Long[] triple)
         throws GraphException
Adds a triple to a single index. This method defines the internal structure.

Parameters:
triple - Consists of three longs.
Throws:
GraphException - If there was an error adding the statement.

add

void add(Long first,
         Long second,
         Long third)
         throws GraphException
Adds a triple to a single index. This method defines the internal structure.

Parameters:
first - The first node id.
second - The second node id.
third - The last node id.
Throws:
GraphException - If there was an error adding the statement.

remove

void remove(Long[] triple)
            throws GraphException
Removes a triple from a single index.

Parameters:
triple - Consists of three longs.
Throws:
GraphException - If there was an error revoking the statement, for example if it didn't exist.

remove

void remove(Long first,
            Long second,
            Long third)
            throws GraphException
Removes a triple from a single index.

Parameters:
first - The first node id.
second - The second node id.
third - The last node id.
Throws:
GraphException - If there was an error revoking the statement, for example if it didn't exist.

iterator

Iterator<Map.Entry<Long,Map<Long,Set<Long>>>> iterator()
Returns an iterator which contains all the elements in the graph as a collections of distinct longs, contains a map of longs to other longs. This prevents any duplication.

Returns:
an iterator which contains all the elements in the graph as a collections of distinct longs, contains a map of longs to other longs. This prevents any duplication.

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.

getSize

long getSize()
Returns the number of triples in the index.

Returns:
the number of triples in the index.