java.lang.Objectcom.chap.memo.memoNodes.MemoNode
public class MemoNode
MemoNode is a graph database, designed to run effectively on the Google App Engine datastore. It features arbitrary length byte values, full history and a self-referencing pattern-matching search facility. Copyright: Ludo Stellingwerff, Almende B.V. License: Apache License Version 2.0
Field Summary | |
---|---|
static UUID |
ROOT
|
Constructor Summary | |
---|---|
MemoNode(UUID uuid)
Find or create node with specified UUID. |
|
MemoNode(UUID uuid,
byte[] value)
Find or create node with specified UUID and value. |
|
MemoNode(UUID uuid,
java.lang.String value)
Find or create node with specified UUID and value. |
Method Summary | |
---|---|
void |
addChild(UUID child)
Add a new child arc between a node with specified child UUID and this node, effectively making the provided node a child of this node. |
void |
addParent(UUID parent)
Add a new parent arc between a node with specified parent UUID and this node, effectively making this node a child of the provided node. |
static void |
compactDB()
Recluster the database for faster access. |
int |
compareTo(MemoNode o)
|
void |
delChild(UUID child)
Remove the child arc between this node and the node with the provided child UUID, effectively making this node no longer a parent of the provided node. |
void |
delete()
Remove this node.(=setting its value to null and removing all arcs) This method will delete entire subgraphs. |
void |
delParent(UUID parent)
Remove the parent arc between the node with specified parent UUID and this node, effectively making this node no longer a child of the provided node. |
static void |
emptyDB()
Dangerous! Empties the entire graph database, irreversible! You will loose data... |
boolean |
equals(java.lang.Object o)
|
static void |
exportDB(java.io.OutputStream out)
Export the entire node database as a byte array |
static void |
flushDB()
Makes sure all graph changes are written to the datastore. |
MemoNode |
getChildByStringValue(java.lang.String value)
Get a single child whose string value equals the given string. |
java.util.ArrayList<MemoNode> |
getChildren()
Returns the list of direct child nodes. |
java.util.ArrayList<MemoNode> |
getChildrenByRange(int lower,
int upper,
int topx)
Returns all children whose integer value falls in the give range. |
java.util.ArrayList<MemoNode> |
getChildrenByRegEx(java.util.regex.Pattern regex,
int topx)
Returns all children whose string value match the given regular expression. |
java.util.ArrayList<MemoNode> |
getChildrenByStringValue(java.lang.String value,
int topx)
Returns all children whose string value equal the given string. |
UUID |
getId()
Returns the UUID of this node. |
java.util.ArrayList<MemoNode> |
getParents()
Returns the list of direct parent nodes. |
java.lang.String |
getPropertyValue(java.lang.String propName)
Convenience method to get a property pattern for this node. |
static MemoNode |
getRootNode()
Get the node that can serve as a tree root, providing at least one anchor for the database. |
java.lang.String |
getStringValue()
Get current value of node as a string. |
long |
getTimestamp()
Returns the timestamp of the latest update (or creation) to this node as the amount of microseconds since midnight 1 Jan 1970. |
byte[] |
getValue()
Get current value of node. |
int |
hashCode()
|
java.util.ArrayList<MemoNode> |
history()
|
static void |
importDB(java.io.InputStream in)
import the given byte array as subgraph, HOW? |
boolean |
isChildOf(MemoNode node)
Checks if given node is a direct parent of this node. |
boolean |
isParentOf(MemoNode node)
Checks if given node is a direct parent of this node. |
static void |
purgeHistory(java.io.OutputStream out)
Export and remove historical nodes, leaving only current values |
java.util.ArrayList<MemoNode> |
search(java.util.ArrayList<MemoNode> preambles,
java.util.ArrayList<MemoNode> patterns,
int topx,
java.util.HashMap<java.lang.String,java.lang.String> arguments)
Search for nodes according to the give Preamble(s) and Pattern(s). |
java.util.ArrayList<MemoNode> |
search(MemoNode algorithm,
int topx,
java.util.HashMap<java.lang.String,java.lang.String> arguments)
Search for nodes according to the give Preamble(s) and Pattern(s). |
java.util.ArrayList<MemoNode> |
search(MemoNode preamble,
MemoNode pattern,
int topx,
java.util.HashMap<java.lang.String,java.lang.String> arguments)
Search for nodes according to the give Preamble(s) and Pattern(s). |
MemoNode |
setChild(MemoNode child)
Add a new child arc between the specified child node and this node, effectively making the provided node a child of this node. |
MemoNode |
setParent(MemoNode parent)
Add a new parent arc between the specified parent node and this node, effectively making this node a child of the provided node. |
MemoNode |
setPropertyValue(java.lang.String propName,
java.lang.String propValue)
Convenience method to store a property pattern for this node. |
java.lang.String |
toJSONString(int depth)
Return the subgraph below this node as a JSON object suitable for the chap network viewer. |
MemoNode |
update(byte[] value)
Update node's value to specified value. |
MemoNode |
update(java.lang.String value)
Update node's value to specified string value. |
byte[] |
valueAt(long timestamp)
|
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static UUID ROOT
Constructor Detail |
---|
public MemoNode(UUID uuid)
public MemoNode(UUID uuid, byte[] value)
public MemoNode(UUID uuid, java.lang.String value)
Method Detail |
---|
public static void flushDB()
public static void emptyDB()
public static void compactDB()
public static void exportDB(java.io.OutputStream out)
public static void purgeHistory(java.io.OutputStream out)
public static void importDB(java.io.InputStream in)
public static MemoNode getRootNode()
public int compareTo(MemoNode o)
compareTo
in interface java.lang.Comparable<MemoNode>
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public MemoNode update(byte[] value)
public MemoNode update(java.lang.String value)
public void addParent(UUID parent)
public void addChild(UUID child)
public void delParent(UUID parent)
public void delChild(UUID child)
public MemoNode setParent(MemoNode parent)
public MemoNode setChild(MemoNode child)
public boolean isChildOf(MemoNode node)
public boolean isParentOf(MemoNode node)
public byte[] getValue()
public java.lang.String getStringValue()
public byte[] valueAt(long timestamp)
public java.util.ArrayList<MemoNode> history()
public UUID getId()
public long getTimestamp()
public java.util.ArrayList<MemoNode> getParents()
public java.util.ArrayList<MemoNode> getChildren()
public java.util.ArrayList<MemoNode> getChildrenByStringValue(java.lang.String value, int topx)
value
- the string value to compare withtopx
- return a maximum of topx children (Set to 0 for all matching children)
public MemoNode getChildByStringValue(java.lang.String value)
value
- the string value to compare with
public java.util.ArrayList<MemoNode> getChildrenByRegEx(java.util.regex.Pattern regex, int topx)
regex
- the regular expression to match againsttopx
- return a maximum of topx children (Set to 0 for all matching children)
Pattern
public java.util.ArrayList<MemoNode> getChildrenByRange(int lower, int upper, int topx)
lower
- the lower bound of the range, value is included in the range.upper
- the upper bound of the range, value is included in the range.topx
- return a maximum of topx children (Set to 0 for all matching children)
public void delete()
public MemoNode setPropertyValue(java.lang.String propName, java.lang.String propValue)
propName
- the name of this property, must be unique for this node.propValue
- the (new) value of this property.getPropertyValue(String propName)
public java.lang.String getPropertyValue(java.lang.String propName)
propName
- the name of the property to retrievesetPropertyValue(String propName,String propValue)
public java.util.ArrayList<MemoNode> search(java.util.ArrayList<MemoNode> preambles, java.util.ArrayList<MemoNode> patterns, int topx, java.util.HashMap<java.lang.String,java.lang.String> arguments)
public java.util.ArrayList<MemoNode> search(MemoNode algorithm, int topx, java.util.HashMap<java.lang.String,java.lang.String> arguments)
public java.util.ArrayList<MemoNode> search(MemoNode preamble, MemoNode pattern, int topx, java.util.HashMap<java.lang.String,java.lang.String> arguments)
public java.lang.String toJSONString(int depth)
depth
- maximum depth of the subgraph to retrieve. (set to 0 for unlimited =dangerous)