l.s.d.bulk : module documentation

Part of lp.services.database

Optimized bulk operations against the database.
Function collate Collate the given objects according to a key function.
Function get_type Return the type of the given object.
Function gen_reload_queries Prepare queries to reload the given objects.
Function reload Reload a large number of objects efficiently.
Function load Load a large number of objects efficiently.
Function load_referencing Load objects of object_type that reference owning_objects.
Function load_related Load objects of object_type referred to by owning_objects.
Function dbify_value Convert a value into a form that Storm can compile directly.
Function dbify_column Convert a column into a form that Storm can compile directly.
Function create Create a large number of objects efficiently.
Function _primary_key Get a primary key our helpers can use.
def collate(things, key):
Collate the given objects according to a key function.

Generates (common-key-value, list-of-things) tuples, like groupby, except that the given objects do not need to be sorted.

def get_type(thing):
Return the type of the given object.

If the given object is wrapped by a security proxy, the type returned is that of the wrapped object.

def gen_reload_queries(objects):
Prepare queries to reload the given objects.
def reload(objects):
Reload a large number of objects efficiently.
def _primary_key(object_type, allow_compound=False):
Get a primary key our helpers can use.

:raises AssertionError if the key is missing or unusable.

def load(object_type, primary_keys, store=None):
Load a large number of objects efficiently.
def load_referencing(object_type, owning_objects, reference_keys, extra_conditions=):
Load objects of object_type that reference owning_objects.

Note that complex types like Person are best loaded through dedicated helpers that can eager load other related things (e.g. validity for Person).

Parametersobject_typeThe object type to load - e.g. BranchSubscription.
owning_objectsThe objects which are referenced. E.g. [Branch()] At this point, all the objects should be of the same type, but that constraint could be lifted in future.
reference_keysA list of attributes that should be used to select object_type keys. e.g. ['branchID']
extra_conditionsA list of Storm clauses that will be used in the final query.
ReturnsA list of object_type where any of reference_keys refered to the primary key of any of owning_objects.
def load_related(object_type, owning_objects, foreign_keys):
Load objects of object_type referred to by owning_objects.

Note that complex types like Person are best loaded through dedicated helpers that can eager load other related things (e.g. validity for Person).

Parametersobject_typeThe object type to load - e.g. Person.
owning_objectsThe objects holding the references. E.g. Bug.
foreign_keysA list of attributes that should be inspected for keys. e.g. ['ownerID']
def dbify_value(col, val):
Convert a value into a form that Storm can compile directly.
def dbify_column(col):
Convert a column into a form that Storm can compile directly.
def create(columns, values, get_objects=False, get_primary_keys=False):
Create a large number of objects efficiently.
ParameterscolumnsThe Storm columns to insert values into. Must be from a single class.
valuesA list of lists of values for the columns.
get_objectsReturn the created objects.
get_primary_keysReturn the created primary keys.
ReturnsA list of the created objects if get_created, otherwise None.
API Documentation for Launchpad, generated by pydoctor at 2018-05-23 00:00:09.