b.r.p._DirectPackAccess(object) : class documentation

Part of bzrlib.repofmt.pack_repo View In Hierarchy

Access to data in one or more packs with less translation.
Method __init__ Create a _DirectPackAccess object.
Method add_raw_records Add raw knit bytes to a storage area.
Method flush Flush pending writes on this access object.
Method get_raw_records Get the raw bytes for a records.
Method set_writer Set a writer to use for adding data.
Method reload_or_raise Try calling the reload function, or re-raise the original exception.
def __init__(self, index_to_packs, reload_func=None, flush_func=None):
Create a _DirectPackAccess object.
Parametersindex_to_packsA dict mapping index objects to the transport and file names for obtaining data.
reload_funcA function to call if we determine that the pack files have moved and we need to reload our caches. See bzrlib.repo_fmt.pack_repo.AggregateIndex for more details.
def add_raw_records(self, key_sizes, raw_data):
Add raw knit bytes to a storage area.

The data is spooled to the container writer in one bytes-record per raw data item.

ParameterssizesAn iterable of tuples containing the key and size of each raw data segment.
raw_dataA bytestring containing the data.
ReturnsA list of memos to retrieve the record later. Each memo is an opaque index memo. For _DirectPackAccess the memo is (index, pos, length), where the index field is the write_index object supplied to the PackAccess object.
def flush(self):
Flush pending writes on this access object.

This will flush any buffered writes to a NewPack.

def get_raw_records(self, memos_for_retrieval):
Get the raw bytes for a records.
Parametersmemos_for_retrievalAn iterable containing the (index, pos, length) memo for retrieving the bytes. The Pack access method looks up the pack to use for a given record in its index_to_pack map.
ReturnsAn iterator over the bytes of the records.
def set_writer(self, writer, index, transport_packname):
Set a writer to use for adding data.
def reload_or_raise(self, retry_exc):
Try calling the reload function, or re-raise the original exception.

This should be called after _DirectPackAccess raises a RetryWithNewPacks exception. This function will handle the common logic of determining when the error is fatal versus being temporary. It will also make sure that the original exception is raised, rather than the RetryWithNewPacks exception.

If this function returns, then the calling function should retry whatever operation was being performed. Otherwise an exception will be raised.

Parametersretry_excA RetryWithNewPacks exception.
API Documentation for Bazaar, generated by pydoctor at 2019-10-20 00:34:54.