org.jrdf.graph.local.index.longindex.bdb
Class LongIndexBdb

java.lang.Object
  extended by org.jrdf.graph.local.index.longindex.bdb.LongIndexBdb
All Implemented Interfaces:
Serializable, Index<Long>, LongIndex

public final class LongIndexBdb
extends Object
implements LongIndex, Serializable

See Also:
Serialized Form

Constructor Summary
LongIndexBdb(MapFactory newCreator)
           
 
Method Summary
 void add(Long... triple)
          Adds a triple to a single index.
 void clear()
          Removes all triples from this index.
 void close()
           
 boolean contains(Long first)
          Returns true if the value given exists in the 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... node)
          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.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LongIndexBdb

public LongIndexBdb(MapFactory newCreator)
Method Detail

add

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

Specified by:
add in interface Index<Long>
Parameters:
triple - The nodes to add.

remove

public void remove(Long... node)
            throws GraphException
Description copied from interface: Index
Removes a triple from a single index.

Specified by:
remove in interface Index<Long>
Parameters:
node - the nodes to remove.
Throws:
GraphException - If there was an error revoking the statement, for example if it didn't exist.

clear

public void clear()
Description copied from interface: Index
Removes all triples from this index.

Specified by:
clear in interface Index<Long>

iterator

public Iterator<Map.Entry<Long,Map<Long,Set<Long>>>> iterator()
Description copied from interface: Index
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 Index<Long>
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: Index
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 Index<Long>
Parameters:
first - the entry set to find.
Returns:
a map containing the list of longs to set of longs.

contains

public boolean contains(Long first)
Description copied from interface: Index
Returns true if the value given exists in the index.

Specified by:
contains in interface Index<Long>
Parameters:
first - the key to search for.
Returns:
true if the key exsts.

removeSubIndex

public boolean removeSubIndex(Long first)
Description copied from interface: Index
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 Index<Long>
Parameters:
first - the entry set to remove.
Returns:
true if the entry set was non-null.

getSize

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

Specified by:
getSize in interface Index<Long>
Returns:
the number of triples in the index.

close

public void close()
Specified by:
close in interface Index<Long>

toString

public String toString()
Overrides:
toString in class Object