|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.neo4j.index.timeline.Timeline
public class Timeline
An implementation of TimelineIndex
on top of Neo4j, using
BTree
for indexing. Note: this implementation is not thread-safe
(yet).
Nodes added to a timeline will get a Relationship
created to it so if
you delete such a node later on you'll have to remove it from the timeline
first (or in the same transaction at least).
Constructor Summary | |
---|---|
Timeline(String name,
Node underlyingNode,
boolean indexed,
GraphDatabaseService graphDb)
Creates/loads a timeline. |
|
Timeline(String name,
Node underlyingNode,
GraphDatabaseService graphDb)
Creates/loads an indexed timeline. |
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 afterTimestampOrNull,
Long beforeTimestampOrNull)
Convenience method which you can use TimelineIndex.getAllNodes() ,
TimelineIndex.getAllNodesAfter(long) , TimelineIndex.getAllNodesBefore(long) and
TimelineIndex.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 startTime,
long endTime)
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. |
Node |
getUnderlyingNode()
Returns the underlying node representing this timeline. |
void |
removeNode(Node nodeToRemove)
Removes a node from the timeline. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Timeline(String name, Node underlyingNode, boolean indexed, GraphDatabaseService graphDb)
underlyingNode
can either be a
new (just created) node or a node that already represents a previously
timeline.
name
- The unique name of the timeline or null
if
timeline already existunderlyingNode
- The underlying node representing the timelineindexed
- Set to true
if this timeline is indexedgraphDb
- the GraphDatabaseService
public Timeline(String name, Node underlyingNode, GraphDatabaseService graphDb)
underlyingNode
can
either be a new (just created) node or a node that already represents a
previously timeline.
name
- The unique name of the timeline or null
if
timeline already existunderlyingNode
- The underlying node representing the timelinegraphDb
- The GraphDatabaseService
.Method Detail |
---|
public Node getUnderlyingNode()
public Node getLastNode()
TimelineIndex
null
if there's no nodes in the timeline.
getLastNode
in interface TimelineIndex
null
if timeline is
empty.public Node getFirstNode()
TimelineIndex
null
if there's no nodes in the timeline.
getFirstNode
in interface TimelineIndex
null
if timeline is
empty.public void addNode(Node nodeToAdd, long timestamp)
TimelineIndex
timestamp
.
addNode
in interface TimelineIndex
nodeToAdd
- the node to add to this timeline.timestamp
- the timestamp to usepublic long getTimestampForNode(Node node)
TimelineIndex
node
if it has been added to this
timeline. If node
hasn't been added to this timeline a runtime
exception will be thrown.
getTimestampForNode
in interface TimelineIndex
node
- the node to return the timestamp for.
node
.public void removeNode(Node nodeToRemove)
TimelineIndex
nodeToRemove
isn't added in this timeline.
removeNode
in interface TimelineIndex
nodeToRemove
- the node to remove from this timelinepublic Iterable<Node> getAllNodes(Long afterTimestampOrNull, Long beforeTimestampOrNull)
TimelineIndex
TimelineIndex.getAllNodes()
,
TimelineIndex.getAllNodesAfter(long)
, TimelineIndex.getAllNodesBefore(long)
and
TimelineIndex.getAllNodesBetween(long, long)
in a single method.
getAllNodes
in interface TimelineIndex
afterTimestampOrNull
- the start timestamp, nodes with greater
timestamp value will be returned. Will be ignored if null
.beforeTimestampOrNull
- the end timestamp, nodes with lesser timestamp
value will be returned. Will be ignored if null
.
startTimestampOrNull
and/or endTimestampOrNull
(where null
means no restriction).public Iterable<Node> getAllNodes()
TimelineIndex
getAllNodes
in interface TimelineIndex
public Iterable<Node> getNodes(long timestamp)
TimelineIndex
timestamp
.
getNodes
in interface TimelineIndex
timestamp
- the timestamp to get nodes for.
timestamp
.public Iterable<Node> getAllNodesAfter(long timestamp)
TimelineIndex
timestamp
ordered by
increasing timestamp.
getAllNodesAfter
in interface TimelineIndex
timestamp
- the timestamp value, nodes with greater timestamp value
will be returned.
timestamp
ordered by
increasing timestamp.public Iterable<Node> getAllNodesBefore(long timestamp)
TimelineIndex
timestamp
ordered by
increasing timestamp.
getAllNodesBefore
in interface TimelineIndex
timestamp
- the timestamp value, nodes with lesser timestamp value
will be returned.
timestamp
ordered by
increasing timestamp.public Iterable<Node> getAllNodesBetween(long startTime, long endTime)
TimelineIndex
afterTimestamp
and before
(exclusive) beforeTimestamp
ordered by increasing timestamp.
getAllNodesBetween
in interface TimelineIndex
startTime
- the start timestamp, nodes with greater timestamp
value will be returned.endTime
- the end timestamp, nodes with lesser timestamp value
will be returned.
public void delete()
TimelineIndex
delete
in interface TimelineIndex
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |