The neoads Memory Manager

Establishes the memory manager object.

At the moment, the memory manager handles a very limited amount of operations but ultimately, every operation in the future will be passing via the MemoryManager in the form of CYPHER (or augmented CYPHER) queries.

author:

Athanasios Anastasiou

date:

Mar 2019

class neoads.memmanager.MemoryManager(connection_uri=None, uname=None, pword=None, host='localhost', port=7687, reset_connection=True)

A memory manager object that handles abstract data structure CRUD operations.

Note

This should be thought of like a memory context object within which, all neoads variables live. It is basically bounded only by the capacity of the server and network latencies.

fsck(recover=False, deep=False)

Returns some basic stats associated with this instance and potentiallly fixes any problems

Parameters:
  • repair – Determines whether fsck should attempt to correct / recover any errors with the layout of the entities in the DBMS.

  • deep (bool) – Determines whether to perform a deep recover or not. In deep recover, “orphaned” data structures will be attempted to be matched to entities in the database based on their HASH value. Obviously this will have to be used with care as it can be a slow operation.

Returns:

dict

Note

  • Reports counts of:
    • “Stray” data structure items

    • “Stray” items WITH a “value” attached to them

    • “Stray” items possibly recoverable either as Lists or Sets.

    • All variables in the system

    • “Unnamed” variables

    • “RECOVERED_[]_UID” named entities

  • Tries to recover:
    • Sets (As RECOVERED_[flat_datetime]_UID)

    • Lists (Named similarly to the way Sets are named)

  • Tries to pair:
    • Stray struct items with a given hash, to items that have that hash in the database.

  • Erases:
    • Stray unrecoverable struct items.

garbage_collect()

Detects “orphan” elements and deletes them.

“Orphan” elements are:

DLListItems that are not bound to a list SetElements that are not linked to a set Unnamed elements that are not refernced by any other data structure

Returns:

get_object(an_object_name)

Returns a properly instantiated reference to a top level neoads object from the DBMS.

Parameters:

an_object_name (str) – The name of the object to get a reference to.

Returns:

ElementVariable

list_objects()

Obtains a list of top level objects from the server.

Note

Similar in functionality to a dir

Returns:

list[str]

query(a_query)

Runs a (potentially augmented) CYPHER query on the DBMS and returns any results.

Parameters:

a_query (str) – A CYPHER or augmented CYPHER query.

Returns:

neomodel.db.cypher_query(), properly instantiated results