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

        classDiagram
  ABC <|-- TreeBucket
  Collection <|-- Set
  Collection <|-- TreeBucket
  Container <|-- Collection
  Iterable <|-- Collection
  MutableSet <|-- TreeBucket
  Set <|-- MutableSet
  Sized <|-- Collection
    
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:
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