Get Firefox

Firefox 3.5

stopsoftwarepatents.eu petition banner Manifiesto por la liberación de la cultura 
No a la traza privada
Últimos cambios
Últimos Cambios
Vote for Public Maps - Reject INSPIRE! Geocaching
Mi estado actual en Jabber/XMPP: - jabberES - jabber.org

Berkeley DB Backend Storage Engine for DURUS

Última Actualización: 03 de mayo de 2007 - Jueves

This code provides a new storage engine for DURUS, an excellent persistence system for the Python programming language.

The README included in the distribution:

$Id: README 332 2007-02-20 20:23:49Z jcea $

WHAT IS "DURUS-BERKELEYDBSTORAGE"?

"Durus-berkeleydbstorage" is a backend storage module for Durus, a persistence system for Python. As its name indicates,"Durus-berkeleydbstorage" uses Berkeley DB as the storage technology.

Some advantages compared to Durus standard FileStorage:

There are some disadvantages, nevertheless:

You can use this product both as a normal (local) filestorage, or a server (remote) storage system, just like the usual Durus FileStorage.

HOW IS "DURUS-BERKELEYDBSTORAGE" USED?

IMPORTANT: The PATH you specify in the storage MUST BE an already existant directory. The database files will be created inside.

You can use this engine in two ways:

  1. Local access:

    The program is the only user of the storage, since local access is exclusive.

    In your code simply put:

    from berkeleydb_storage import BerkeleyDBStorage
    connection = Connection(BerkeleyDBStorage("PATH"))
    

    where "PATH" is the path to already existant directory. The database will reside inside that directory.

    After doing that, you use the connection like any other Durus connection. See "test3.py" as a reference implementation:

    from durus.btree import BTree
    from durus.connection import Connection
    from berkeleydb_storage import BerkeleyDBStorage
    
    connection = Connection(BerkeleyDBStorage("db"))
    
    root=connection.get_root()
    root[0]=BTree()
    connection.commit()
    
    for i in xrange(65536) :
      root[0][i]=0
    connection.commit()
    
    for i in xrange(0,65536,2) :
      del root[0][i]
    connection.commit()
    
    print len(root[0])
    

  2. Remote access:

    Clients are "normal" Durus clients.

    The Durus server must use this engine. The file "server.py" is a reference implementation. Example:

    import sys
    import socket
    from optparse import OptionParser
    from durus.storage_server import DEFAULT_PORT, DEFAULT_HOST, StorageServer
    from durus.logger import log, logger, direct_output
    
    def start() :
      logfile = sys.stderr
      direct_output(logfile)
    
      from berkeleydb_storage import BerkeleyDBStorage
      storage = BerkeleyDBStorage("db")
      host=DEFAULT_HOST
      port=DEFAULT_PORT
      log(20, 'host=%s port=%s', host, port)
      StorageServer(storage, host=host, port=port).serve()
    
    if __name__=="__main__" :
      start()
    

Additionally, you can specify options when you instanciate a Berkeley DB Storage. The options are passed as optional parameters in the instance constructor:

CHECKPOINT POLICY

Releases since 20061016 allow to specify an object in the storage constructor to set a database checkpointing policy.

Programmers can create new arbitrary policy objects/factories using "berkeleydb_storage.checkpoint_interface" interface-like class as a blueprint. Any future interface change will be documented in the UPGRADING document.

Currently implemented policies are:

GARBAGE COLLECTION POLICY

Releases since 20070220 allow to specify an object in the storage constructor to set a garbage collection policy.

Currently, the interface used as a blueprint is subject to change. DO NOT IMPLEMENT new policy objects. They can break without notice when upgrading this storage backend. When the API be stable enough to freely implement new policies, you will be notified.

Currently implemented policies are:

DATASET MIGRATION

If you already have data in a traditional Durus FileStorage, you can migrate it to this Storage Backend using the standard migration procedure: iterate over the objects in the source storage, send them to the destination storage and do a "commit" when you are done.

This procedure is useable if your dataset fits in RAM, but even if your machine is full of RAM or you have a huge SWAP space, you will hit addressable space limitations, if your machine is 32 bits, in the order of 2^30 bytes.

You can't do "bit sized" commits because this backend does garbage collection in background, and it could free stored but still not referenced objects.

To solve these issues, releases since 20060509 have a "migrate()" method. It has an iterable parameter, giving the original objects.

Example:

from durus.file_storage import FileStorage
from berkeleydb_storage import BerkeleyDBStorage

source=FileStorage("source",readonly=True)
destination=BerkeleyDBStorage("destination")

destination.migrate(source.gen_oid_record())


DOWNLOADS:

"durus-berkeleydbstorage" is released under GNU Public License, version 2.


Procesos a realizar cuando se publica una actualización

Esto es solo útil para mí :-).


Historia



Get Firefox Python Zope ©2006-2007 jcea@jcea.es