Back to index

obnam  1.1
Public Member Functions | Public Attributes
obnamlib.checksumtree.ChecksumTree Class Reference
Inheritance diagram for obnamlib.checksumtree.ChecksumTree:
Inheritance graph
[legend]
Collaboration diagram for obnamlib.checksumtree.ChecksumTree:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def key
def unkey
def add
def find
def remove
def chunk_is_used

Public Attributes

 fmt
 keep_just_one_tree

Detailed Description

Repository map of checksum to integer id.

The checksum might be, for example, an MD5 one (as returned by
hashlib.md5().digest()). The id would be a chunk id.

Definition at line 23 of file checksumtree.py.


Constructor & Destructor Documentation

def obnamlib.checksumtree.ChecksumTree.__init__ (   self,
  fs,
  name,
  checksum_length,
  node_size,
  upload_queue_size,
  lru_size,
  hooks 
)

Definition at line 33 of file checksumtree.py.

00033 
00034                  upload_queue_size, lru_size, hooks):
00035         tracing.trace('new ChecksumTree name=%s' % name)
00036         self.fmt = '!%dsQQ' % checksum_length
00037         key_bytes = len(self.key('', 0, 0))
00038         obnamlib.RepositoryTree.__init__(self, fs, name, key_bytes, node_size, 
00039                                          upload_queue_size, lru_size, hooks)
00040         self.keep_just_one_tree = True


Member Function Documentation

def obnamlib.checksumtree.ChecksumTree.add (   self,
  checksum,
  chunk_id,
  client_id 
)

Definition at line 47 of file checksumtree.py.

00047 
00048     def add(self, checksum, chunk_id, client_id):
00049         tracing.trace('checksum=%s', repr(checksum))
00050         tracing.trace('chunk_id=%s', chunk_id)
00051         tracing.trace('client_id=%s', client_id)
00052         self.start_changes()
00053         key = self.key(checksum, chunk_id, client_id)
00054         self.tree.insert(key, '')

Here is the call graph for this function:

def obnamlib.checksumtree.ChecksumTree.chunk_is_used (   self,
  checksum,
  chunk_id 
)
Is a given chunk used by anyone?

Definition at line 73 of file checksumtree.py.

00073 
00074     def chunk_is_used(self, checksum, chunk_id):
00075         '''Is a given chunk used by anyone?'''
00076         if self.init_forest() and self.forest.trees:
00077             minkey = self.key(checksum, chunk_id, 0)
00078             maxkey = self.key(checksum, chunk_id, obnamlib.MAX_ID)
00079             t = self.forest.trees[-1]
00080             return not t.range_is_empty(minkey, maxkey)
00081         else:
00082             return False
00083 

Here is the call graph for this function:

def obnamlib.checksumtree.ChecksumTree.find (   self,
  checksum 
)

Definition at line 55 of file checksumtree.py.

00055 
00056     def find(self, checksum):
00057         if self.init_forest() and self.forest.trees:
00058             minkey = self.key(checksum, 0, 0)
00059             maxkey = self.key(checksum, obnamlib.MAX_ID, obnamlib.MAX_ID)
00060             t = self.forest.trees[-1]
00061             pairs = t.lookup_range(minkey, maxkey)
00062             return [self.unkey(key)[1] for key, value in pairs]
00063         else:
00064             return []

Here is the call graph for this function:

def obnamlib.checksumtree.ChecksumTree.key (   self,
  checksum,
  chunk_id,
  client_id 
)

Definition at line 41 of file checksumtree.py.

00041 
00042     def key(self, checksum, chunk_id, client_id):
00043         return struct.pack(self.fmt, checksum, chunk_id, client_id)

Here is the caller graph for this function:

def obnamlib.checksumtree.ChecksumTree.remove (   self,
  checksum,
  chunk_id,
  client_id 
)

Definition at line 65 of file checksumtree.py.

00065 
00066     def remove(self, checksum, chunk_id, client_id):
00067         tracing.trace('checksum=%s', repr(checksum))
00068         tracing.trace('chunk_id=%s', chunk_id)
00069         tracing.trace('client_id=%s', client_id)
00070         self.start_changes()
00071         key = self.key(checksum, chunk_id, client_id)
00072         self.tree.remove_range(key, key)

Here is the call graph for this function:

Here is the caller graph for this function:

def obnamlib.checksumtree.ChecksumTree.unkey (   self,
  key 
)

Definition at line 44 of file checksumtree.py.

00044 
00045     def unkey(self, key):
00046         return struct.unpack(self.fmt, key)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 35 of file checksumtree.py.

Definition at line 39 of file checksumtree.py.


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