Implementations¶
Graphs¶
-
class
ruruki.graphs.PersistentGraph(path, auto_create=True)¶ Persistent Graph database storing data to a file system.
See
IGraphfor doco.Note
Verices and Edges ID’s are retained when the path is loaded.
Warning
Use this persistent graph if performance is not important. There is a performance hit due to the extra disk I/O overhead when doing many writing/updating operations.
path |_ vertices | |_ constraints.json (file) | |_ label | | |_ 0 | | |_ properties.json (file) | | |_ in-edges | | | |_ 0 -> ../../../../edges/label/0 (symlink) | | |_ out-edges | | |_ | | | |_ label | | |_ 1 | | |_ properties.json (file) | | |_ in-edges | | | |_ | | |_ out-edges | | |_ 0 -> ../../../../edges/label/0 (symlink) | |_ edges |_ label | |_0 |_ properties.json (file) |_ head | |_ 0 -> ../../../vertices/0 (symlink) |_ tail |_ 1 -> ../../../vertices/1 (symlink)
Parameters: - path (
str) – Path to ruruki graph data on disk. - auto_create (
bool) – If True, then missingverticesoredgesdirectories will be created.
Raises: DatabasePathLocked – If the path is already locked by another persistence graph instance.
- path (
Entities¶
-
class
ruruki.entities.EntitySet(entities=None)¶ EntitySet used for storing, filtering, and iterating over
IEntityobjects.Note
See
IEntitySetfor documenation.Parameters: entities (Iterable of IEntity) – Entities being added to the set.-
clear()¶ This is slow (creates N new iterators!) but effective.
-
discard(entity)¶ Remove a entity from the current set.
Parameters: entity ( IEntity) – Entity to be removed from the set.Raises: KeyError – KeyError is raised if the entity being discared does not exists in the set.
-
isdisjoint(other)¶ Return True if two sets have a null intersection.
-
pop()¶ Return the popped value. Raise KeyError if empty.
-
-
class
ruruki.entities.Entity(label=None, **kwargs)¶ Base class for containing the common methods used for the other entities like vertices and edges.
Note
See
IEntityfor doco.Note
The properties can be accessed as if they are attributes directly by prepending
prop__to the key.>>> e = Entity("Entity", name="Example") >>> e.prop__name 'Example'
Parameters:
-
class
ruruki.entities.Vertex(label=None, **kwargs)¶ Vertex/Node is the representation of a entity. It can be anything and contains properties for additional information.
Note
See
IVertexfor doco.Note
The properties can be accessed as if they are attributes directly by prepending
prop__to the key.>>> v = Vertex("Person", name="Foo") >>> v.prop__name 'Foo'
Parameters:
-
class
ruruki.entities.PersistentVertex(*args, **kwargs)¶ Persistent Vertex behaves exactly the same as a
Vertexbut has an additional path attribute which is the disk location.
-
class
ruruki.entities.Edge(head, label, tail, **kwargs)¶ Edge/Relationship is the representation of a relationship between two entities. A edge has properties for additional information.
Note
See
IEdgefor doco.Note
The properties can be accessed as if they are attributes directly by prepending
prop__to the key.>>> v1 = Vertex("Person", name="Foo") >>> v2 = Vertex("Person", name="Bar") >>> e = Edge(v1, "knows", v2, since="school") >>> e.prop__since 'school'
Parameters:
Locks¶
-
class
ruruki.locks.Lock¶ Base locking class.
See
ILockfor doco.-
locked¶ Return the status of the lock.
Returns: True if the lock is acquired. Return type: bool
-