architxt.bucket#

Classes

TreeBucket()

A scalable, persistent, set-like container for Tree.

class architxt.bucket.TreeBucket[source]#

Bases: ABC, MutableSet, Collection

A scalable, persistent, set-like container for Tree.

The TreeBucket behaves like a mutable set and provides persistent storage. It is designed to handle large collections of trees efficiently, supporting standard set operations and transactional updates.

Transaction Management

  • Bucket automatically handles transactions when adding or removing Tree from the bucket.

  • If a Tree is modified after being added to the bucket, you must call commit() to persist those changes.

Available Implementations

digraph inheritance999ed8d026 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "TreeBucket" [URL="#architxt.bucket.TreeBucket",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A scalable, persistent, set-like container for :py:class:`~architxt.tree.Tree`."]; "ZODBTreeBucket" [URL="architxt.bucket.zodb.html#architxt.bucket.zodb.ZODBTreeBucket",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A persistent, scalable container for :py:class:`~architxt.tree.Tree` objects backed by ZODB and RelStorage using SQLite."]; "TreeBucket" -> "ZODBTreeBucket" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
async async_update(trees, batch_size=BATCH_SIZE)[source]#

Asynchronously add multiple Tree to the bucket.

This method mirrors the behavior of update() but supports asynchronous iteration. Internally, it delegates each chunk to a background thread.

Parameters:
  • trees (AsyncIterable[Tree]) – Trees to add to the bucket.

  • batch_size (int) – The number of trees to be added at once.

Return type:

None

abstractmethod close()[source]#

Close the underlying storage and release any associated resources.

Return type:

None

abstractmethod commit()[source]#

Persist any in-memory changes to Tree in the bucket.

Return type:

None

abstractmethod oids()[source]#

Yield the object IDs (OIDs) of all trees stored in the bucket.

Return type:

Generator[UUID, None, None]

abstractmethod transaction()[source]#

Return a context manager for managing a transaction.

Upon exiting the context, the transaction is automatically committed. If an exception occurs within the context, the transaction is rolled back.

Return type:

AbstractContextManager[None]

abstractmethod update(trees, batch_size=BATCH_SIZE)[source]#

Add multiple Tree to the bucket, managing memory via chunked transactions.

Parameters:
  • trees (Iterable[Tree]) – Trees to add to the bucket.

  • batch_size (int) – The number of trees to be added at once.

Return type:

None

Modules