pyvgx.Graph Management Methods Description

pyvgx.Graph.Order()

Number of vertices in graph

pyvgx.Graph.Size()

Number of arcs in graph

pyvgx.Graph.Save()

Persist graph to disk

pyvgx.Graph.Sync()

Send all VGX source data to attached destination(s)

pyvgx.Graph.Truncate()

Remove vertices

pyvgx.Graph.Lock()

Acquire and return a graph lock object

pyvgx.Graph.Synchronized()

Call a function while synchronized on a mutex

pyvgx.Graph.Close()

Close graph instance

pyvgx.Graph.Erase()

Erase graph from memory and disk

pyvgx.Graph.ResetSerial()

Change graph serial number

pyvgx.Graph.SetGraphReadonly()

Make the graph readonly

pyvgx.Graph.IsGraphReadonly()

Check if graph is readonly

pyvgx.Graph.ClearGraphReadonly()

Make graph writable

pyvgx.Graph.Status()

Misc. information, counters, resource usage

pyvgx.Graph.ResetCounters()

Reset query counters to zero

pyvgx.Graph.GetMemoryUsage()

Graph memory usage information

1. pyvgx.Graph.Order()

pyvgx.Graph.Order( [ type ] )

Return the number of vertices in the graph, optionally restricted to vertices of the specified type.

2. pyvgx.Graph.Size()

pyvgx.Graph.Size()

Return the number of explicit connections in the graph.

3. pyvgx.Graph.Save()

pyvgx.Graph.Save( [ timeout[, force ] ] )

Persist the graph to disk. An optional timeout (in milliseconds) allows blocking while waiting for the entire graph to become idle in order for the operation to proceed. The default is nonblocking. Data is normally saved incrementally, i.e. only modified structures are written to disk. To perform a complete serialization set force to True.

4. pyvgx.Graph.Sync()

pyvgx.Graph.Sync( [ hard ] )

Update data on all attached destinations to match this VGX source instance. When the optional parameter hard (bool) is True the destination VGX instances are truncated before they are re-populated with data from the source. The default is hard=False, which means the destinations are not truncated prior to receiving the source data.

5. pyvgx.Graph.Truncate()

pyvgx.Graph.Truncate( [ type ] )

Remove all vertices in graph, or if type is specified remove all vertices of that type. All arcs incident on the removed vertices will also be removed.

6. pyvgx.Graph.Lock()

pyvgx.Graph.Lock( [ id[, linger[, timeout ] ] ] )

Acquire and return a mutex lock object with an optional id string. The lock object is a special vertex instance of type _lock and with a namespaced identifier lock_::<graphname>::<id>.

In addition to providing standard mutex functionality a graph lock is useful for preventing graph operations from being emitted to an attached operation stream while the lock is acquired. Graph operations performed after lock acquisition are queued up and emitted in bulk as a single transaction once the lock is released. A lock is released when the lock object goes out of scope, or by invoking pyvgx.Vertex.Close() on the lock object.

Locks without id are anonymous and will always be acquired without blocking.

When lock id is given the acquisition and release operations are transferred to remote subscriber destinations in the order applied. This allows plugins running on remote destinations to synchronize on the same lock id in situations where plugin queries and graph updates cannot be allowed to run concurrently.

The optional linger (in seconds) value specifies how long the lock object should continue to exist after the lock is released. By default linger is 0, causing the lock to be destroyed immediately after release. Set linger to -1 to disable deletion, or to any positive integer to delay deletion by that number of seconds.

An optional timeout (in milliseconds) may be specified to wait for lock access. The default timeout is 0 (nonblocking).

If a large number of graph operations are performed while a lock is held the system will consume more memory. It is possible to run out of memory once the lock is released due to internal activities resuming and now being faced with a large backlog of operations that all need to be fitted into a single transaction.
Manually controlling the contents of a transaction is useful when manipulating several parts of a graph that all need to be in a consistent state for queries to return correct results. This is an important consideration when using a source VGX instance to build a graph to be consumed by destination VGX instances. The time delay between separate transactions arriving at a destination is unspecified. A set of graph updates which must occur atomically (to ensure consistent query results) therefore needs to be confined to a single transaction.

7. pyvgx.Graph.Synchronized()

pyvgx.Graph.Synchronized( function, *args, **kwds )

Call function( *args, **kwds ) in a synchronized context and return its returned value. Only one thread of execution will be allowed to perform a synchronized call at a time, even if the called functions are different.

This is a shorthand for:

def Synchronized( graph, function, *args, **kwds ):
    mutex = graph.Lock( "_SYN", 0, 5000 )
    try:
        return function( *args, **kwds )
    finally:
        mutex.Close()

8. pyvgx.Graph.Close()

pyvgx.Graph.Close()

Close the graph instance. This has the same effect as using the Python del operator on the graph instance. Attempting to use a closed graph will raise pyvgx.AccessError.

9. pyvgx.Graph.Erase()

pyvgx.Graph.Erase()

Erase the graph instance from memory and remove its data from disk. This has the same effect as pyvgx.Graph.Truncate() followed by pyvgx.Graph.Save() followed by system.DeleteGraph(). The graph instance is also closed after this call resulting in pyvgx.AccessError if used.

All vertices (and therefore arcs and properties) will be lost forever after erasing the graph. Only a basic file structure for the graph will remain on disk.

10. pyvgx.Graph.ResetSerial()

pyvgx.Graph.ResetSerial( [ sn ] )

Force the graph input serial number to 0, or to sn if provided. This allows already consumed operation data to be re-submitted.

This should only be performed as part of testing and debugging, and never in a live production system unless part of a carefully designed recovery procedure.

11. pyvgx.Graph.SetGraphReadonly()

pyvgx.Graph.SetGraphReadonly( [ timeout ] )

Make the graph readonly. An optional timeout (in milliseconds) allows blocking while waiting for graph to become idle. The default is nonblocking. No vertices can be acquired writable when a graph is readonly. However, queries are still allowed.

12. pyvgx.Graph.IsGraphReadonly()

pyvgx.Graph.IsGraphReadonly()

Return True if the graph is currently readonly, otherwise False.

13. pyvgx.Graph.ClearGraphReadonly()

pyvgx.Graph.ClearGraphReadonly()

Make a readonly graph writable.

14. pyvgx.Graph.Status()

pyvgx.Graph.Status()

Return a dictionary of various information, counters, and resource usage for the graph.

15. pyvgx.Graph.ResetCounters()

pyvgx.Graph.ResetCounters()

Reset all query counters to zero.

16. pyvgx.Graph.GetMemoryUsage()

pyvgx.Graph.GetMemoryUsage( [ metric ] )

Return memory usage information. By default return a dictionary of memory usage details. If metric is specified, return an integer value. All memory values are in bytes.

The table below show available metric keys.

Table 1. Memory usage metrics
Metric Description

vgx.vertex.object

Vertex object allocator memory pool

vgx.vertex.arcvector

Arc object allocator memory pool

vgx.vertex.property

Allocator memory pool for vertex properties

vgx.string

Internal string data memory pool

vgx.index.global

Global vertex index memory usage

vgx.index.type

Vertex type index memory usage

vgx.codec.vertextype

Memory used by vertex type enumerator

vgx.codec.relationship

Memory used by relationship type enumerator

vgx.codec.vertexprop

Memory used by vertex property enumerator

vgx.codec.dimension

Memory used by vector dimension enumerator

vgx.vector.internal

Internal vector allocator memory pool

vgx.vector.external

External vector allocator memory pool

vgx.vector.dimension

Vector dimension allocator memory pool

vgx.event.schedule

Memory used for storing object expiration schedules

vgx.ephemeral.string

Various non-persistable string objects

vgx.ephemeral.vector

Various non-persistable vector objects

vgx.ephemeral.vertexmap

Memory used for tracking vertex acquisition status

vgx.runtime

All other runtime memory used (including other graph objects)

system.process

Memory used by current process

system.available

Available physical memory

system.global

Total physical memory installed on machine


PYVGX