org.jrdf.graph.index.longindex.mem
Class LongIndexMem

java.lang.Object
  extended by org.jrdf.graph.index.longindex.mem.LongIndexMem
All Implemented Interfaces:
Serializable, LongIndex

public final class LongIndexMem
extends Object
implements LongIndex, Serializable

An in memory version of $LongIndex.

Version:
$Revision: 1055 $
Author:
Andrew Newman
See Also:
Serialized Form

Constructor Summary
LongIndexMem()
           
LongIndexMem(Map<Long,Map<Long,Set<Long>>> newIndex)
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LongIndexMem

public LongIndexMem()

LongIndexMem

public LongIndexMem(Map<Long,Map<Long,Set<Long>>> newIndex)
Method Detail

add

public void add(Long[] triple)
Description copied from interface: LongIndex
Adds a triple to a single index. This method defines the internal structure.

Specified by:
add in interface LongIndex
Parameters:
triple - Consists of three longs.

add

public void add(Long first,
                Long second,
                Long third)
Description copied from interface: LongIndex
Adds a triple to a single index. This method defines the internal structure.

Specified by:
add in interface LongIndex
Parameters:
first - The first node id.
second - The second node id.
third - The last node id.

remove

public void remove(Long[] triple)
            throws GraphException
Description copied from interface: LongIndex
Removes a triple from a single index.

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

remove

public void remove(Long first,
                   Long second,
                   Long third)
            throws GraphException
Description copied from interface: LongIndex
Removes a triple from a single index.

Specified by:
remove in interface LongIndex
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

public Iterator<Map.Entry<Long,Map<Long,Set<Long>>>> iterator()
Description copied from interface: LongIndex
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.

Specified by:
iterator in interface LongIndex
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

public Map<Long,Set<Long>> getSubIndex(Long first)
Description copied from interface: LongIndex
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.

Specified by:
getSubIndex in interface LongIndex
Parameters:
first - the entry set to find.
Returns:
a map containing the list of longs to set of longs.

removeSubIndex

public boolean removeSubIndex(Long first)
Description copied from interface: LongIndex
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.

Specified by:
removeSubIndex in interface LongIndex
Parameters:
first - the entry set to remove.
Returns:
true if the entry set was non-null.

getSize

public long getSize()
Description copied from interface: LongIndex
Returns the number of triples in the index.

Specified by:
getSize in interface LongIndex
Returns:
the number of triples in the index.