OpenQuizz
Une application de gestion des contenus pédagogiques
MemoryDB Class Reference
Inheritance diagram for MemoryDB:
Collaboration diagram for MemoryDB:

Public Member Functions

def __init__ (self)
 
def set_ostream (self, stream)
 
def store (self, istream)
 
def has_object (self, sha)
 
def info (self, sha)
 
def stream (self, sha)
 
def size (self)
 
def sha_iter (self)
 
def stream_copy (self, sha_iter, odb)
 
- Public Member Functions inherited from ObjectDBR
def __contains__ (self, sha)
 
- Public Member Functions inherited from ObjectDBW
def __init__ (self, *args, **kwargs)
 
def ostream (self)
 

Detailed Description

A memory database stores everything to memory, providing fast IO and object
retrieval. It should be used to buffer results and obtain SHAs before writing
it to the actual physical storage, as it allows to query whether object already
exists in the target storage before introducing actual IO

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)

Member Function Documentation

◆ has_object()

def has_object (   self,
  sha 
)
:return: True if the object identified by the given 20 bytes
    binary sha is contained in the database

Reimplemented from ObjectDBR.

◆ info()

def info (   self,
  sha 
)
:return: OInfo instance
:param sha: bytes binary sha
:raise BadObject:

Reimplemented from ObjectDBR.

◆ set_ostream()

def set_ostream (   self,
  stream 
)
Adjusts the stream to which all data should be sent when storing new objects

:param stream: if not None, the stream to use, if None the default stream
    will be used.
:return: previously installed stream, or None if there was no override
:raise TypeError: if the stream doesn't have the supported functionality

Reimplemented from ObjectDBW.

◆ sha_iter()

def sha_iter (   self)
Return iterator yielding 20 byte shas for all objects in this data base

Reimplemented from ObjectDBR.

◆ size()

def size (   self)
:return: amount of objects in this database

Reimplemented from ObjectDBR.

◆ store()

def store (   self,
  istream 
)
Create a new object in the database
:return: the input istream object with its sha set to its corresponding value

:param istream: IStream compatible instance. If its sha is already set
    to a value, the object will just be stored in the our database format,
    in which case the input stream is expected to be in object format ( header + contents ).
:raise IOError: if data could not be written

Reimplemented from ObjectDBW.

◆ stream()

def stream (   self,
  sha 
)
:return: OStream instance
:param sha: 20 bytes binary sha
:raise BadObject:

Reimplemented from ObjectDBR.

◆ stream_copy()

def stream_copy (   self,
  sha_iter,
  odb 
)
Copy the streams as identified by sha's yielded by sha_iter into the given odb
The streams will be copied directly
**Note:** the object will only be written if it did not exist in the target db
:return: amount of streams actually copied into odb. If smaller than the amount
    of input shas, one or more objects did already exist in odb

The documentation for this class was generated from the following file: