org.neo4j.index.timeline
Interface TimelineIndex

All Known Implementing Classes:
Timeline

public interface TimelineIndex

A utility for ordering nodes in a timeline. You add nodes to the timeline and then you can query for nodes given a time period, w/ or w/o lower/upper bounds, for example "Give me all nodes before this given timestamp" or "Give me all nodes between these two timestamps". Please note that the timestamps don't need to represent actual points in time, any long that identifies the indexed Node and defines its global order is fine.


Method Summary
 void addNode(Node nodeToAdd, long timestamp)
          Adds a node to this timeline with the given timestamp.
 void delete()
          Deletes this timeline.
 Iterable<Node> getAllNodes()
          Returns all added nodes in this timeline ordered by increasing timestamp.
 Iterable<Node> getAllNodes(Long startTimestampOrNull, Long endTimestampOrNull)
          Convenience method which you can use getAllNodes(), getAllNodesAfter(long), getAllNodesBefore(long) and getAllNodesBetween(long, long) in a single method.
 Iterable<Node> getAllNodesAfter(long timestamp)
          Returns all the nodes after (exclusive) timestamp ordered by increasing timestamp.
 Iterable<Node> getAllNodesBefore(long timestamp)
          Returns all the nodes before (exclusive) timestamp ordered by increasing timestamp.
 Iterable<Node> getAllNodesBetween(long startTimestamp, long endTimestamp)
          Returns all the nodes after (exclusive) afterTimestamp and before (exclusive) beforeTimestamp ordered by increasing timestamp.
 Node getFirstNode()
          Returns the first node in the timeline, that is the node with the lowest timestamp or null if there's no nodes in the timeline.
 Node getLastNode()
          Returns the last node in the timeline, that is the node with the highest timestamp or null if there's no nodes in the timeline.
 Iterable<Node> getNodes(long timestamp)
          Returns nodes which were added with the given timestamp.
 long getTimestampForNode(Node node)
          Will return the timestamp for node if it has been added to this timeline.
 void removeNode(Node nodeToRemove)
          Removes a node from the timeline.
 

Method Detail

getLastNode

Node getLastNode()
Returns the last node in the timeline, that is the node with the highest timestamp or null if there's no nodes in the timeline.

Returns:
the last node in the timeline or null if timeline is empty.

getFirstNode

Node getFirstNode()
Returns the first node in the timeline, that is the node with the lowest timestamp or null if there's no nodes in the timeline.

Returns:
the first node in the timeline or null if timeline is empty.

removeNode

void removeNode(Node nodeToRemove)
Removes a node from the timeline. It will throw an exception if nodeToRemove isn't added in this timeline.

Parameters:
nodeToRemove - the node to remove from this timeline
Throws:
IllegalArgumentException - if null node or node not connected to this timeline.

addNode

void addNode(Node nodeToAdd,
             long timestamp)
Adds a node to this timeline with the given timestamp.

Parameters:
nodeToAdd - the node to add to this timeline.
timestamp - the timestamp to use
Throws:
IllegalArgumentException - if already added to this timeline or null node.

getNodes

Iterable<Node> getNodes(long timestamp)
Returns nodes which were added with the given timestamp.

Parameters:
timestamp - the timestamp to get nodes for.
Returns:
nodes which were added with the given timestamp.

getAllNodes

Iterable<Node> getAllNodes()
Returns all added nodes in this timeline ordered by increasing timestamp.

Returns:
all the nodes in the timeline ordered by increasing timestamp.

getAllNodesAfter

Iterable<Node> getAllNodesAfter(long timestamp)
Returns all the nodes after (exclusive) timestamp ordered by increasing timestamp.

Parameters:
timestamp - the timestamp value, nodes with greater timestamp value will be returned.
Returns:
all nodes after (exclusive) timestamp ordered by increasing timestamp.

getAllNodesBefore

Iterable<Node> getAllNodesBefore(long timestamp)
Returns all the nodes before (exclusive) timestamp ordered by increasing timestamp.

Parameters:
timestamp - the timestamp value, nodes with lesser timestamp value will be returned.
Returns:
all nodes before (exclusive) timestamp ordered by increasing timestamp.

getAllNodesBetween

Iterable<Node> getAllNodesBetween(long startTimestamp,
                                  long endTimestamp)
Returns all the nodes after (exclusive) afterTimestamp and before (exclusive) beforeTimestamp ordered by increasing timestamp.

Parameters:
startTimestamp - the start timestamp, nodes with greater timestamp value will be returned.
endTimestamp - the end timestamp, nodes with lesser timestamp value will be returned.
Returns:
all nodes between (exclusive) the specified timestamps ordered by increasing timestamp.

getAllNodes

Iterable<Node> getAllNodes(Long startTimestampOrNull,
                           Long endTimestampOrNull)
Convenience method which you can use getAllNodes(), getAllNodesAfter(long), getAllNodesBefore(long) and getAllNodesBetween(long, long) in a single method.

Parameters:
startTimestampOrNull - the start timestamp, nodes with greater timestamp value will be returned. Will be ignored if null.
endTimestampOrNull - the end timestamp, nodes with lesser timestamp value will be returned. Will be ignored if null.
Returns:
all nodes in this timeline ordered by timestamp. A range can be given with the startTimestampOrNull and/or endTimestampOrNull (where null means no restriction).

getTimestampForNode

long getTimestampForNode(Node node)
Will return the timestamp for node if it has been added to this timeline. If node hasn't been added to this timeline a runtime exception will be thrown.

Parameters:
node - the node to return the timestamp for.
Returns:
the timestamp for node.

delete

void delete()
Deletes this timeline. Nodes added to the timeline will not be deleted, they are just disconnected from this timeline.



Copyright © 2010 Neo4j. All Rights Reserved.