Table of Contents

Class: Keyspace oops/core.py

Keyspace manager.

Keyspace's role is to keep track of a container node's persistent members. In the case of a Dict instance, it is to keep track of the dictionary's keys. In the case of an Obj instance, it is to keep track of its data rows.

Keyspace is specially designed to scale for containers with many subnodes. Keyspace instances distribute their contents across many database rows to counter the overhead of pickling large lists. The reason for this is that the keyspace needs to be synced to disk every time it is modified. With this implementation, the keyspace is broken into chunks and only the modified chunks are pickled and saved when new keys are added.

Keyspace is ultra-light on storage size, I/O and processing because it uses what I call the square key distribution algorithm. The rows containing the distributed keyspace are always smaller than the square root of the size of the keyspace. There are usually as many rows as there are elements per row, but when a new square size is reached (len(keyspace)==x**2), new elements are placed in a new row (so rows==row_size+1).

When adding an element, only one row is synced to disk which has at most row_size+1 elements. When removing an element, at most 2 rows are synced to disk while sometimes only one row is synced to disk.

Base Classes   
list
Node
    object
Methods   
__bindto__
__clear__
__copyfrom__
__init__
__moveto__
__nonzero__
add_key
rem_key
  __bindto__ 
__bindto__ (
        self,
        database,
        path=(),
        parent=None,
        )

Bind node to new location.

Overloaded to load reconstitute the keyspace from chunks stored on disk.

  __clear__ 
__clear__ ( self )

Recursively delete all persistent data under `self`.

Overloaded to empty the keyspace.

  __copyfrom__ 
__copyfrom__ ( self,  other )

Make `self` a copy of `other`

Overloaded to copy over all the keyspace's data.

  __init__ 
__init__ ( self,  **keywords )

Constructor.

Overloaded to call list.__init__

  __moveto__ 
__moveto__ (
        self,
        database,
        path=(),
        parent=None,
        )

Move node to new location.

Overloaded to copy the keyspace chunks to the new database location.

  __nonzero__ 
__nonzero__ ( self )

Test for emptiness.

Returns true (1) if the keyspace has one key or more, false (0) otherwise.

  add_key 
add_key ( self,  key )

Insert a key into the keyspace.

If you insert a key that is already in the keyspace, the function returns without doing anything.

  rem_key 
rem_key ( self,  key )

Remove a key from the keyspace.

Raises a KeyError is the key is not in the keyspace.

Exceptions   
KeyError( key )

Table of Contents

This document was automatically generated on Mon Feb 18 01:32:24 2002 by HappyDoc version 2.0.1