MCPcopy Create free account
hub / github.com/IBM/AssetOpsBench / load_collection

Function load_collection

src/couchdb/loader.py:279–294  ·  view source on GitHub ↗

Load one collection's data into a database named after the key. Returns (db, n).

(key, source, drop=True, base_dir=None)

Source from the content-addressed store, hash-verified

277# Public entry point
278# --------------------------------------------------------------------------- #
279def load_collection(key, source, drop=True, base_dir=None) -> tuple:
280 """Load one collection's data into a database named after the key. Returns (db, n)."""
281 cfg = collection_config(key)
282 transform = _transform_for(key)
283 docs = [
284 _normalise(d, key, cfg, transform)
285 for d in _collect_docs(key, source, cfg, base_dir)
286 ]
287 db = key
288 if docs:
289 _ensure_db(db, drop=drop)
290 if cfg.get("design_doc"):
291 _install_design(db, cfg["design_doc"])
292 _bulk_insert(db, docs)
293 _create_indexes(db, cfg.get("indexes"))
294 return db, len(docs)

Callers

nothing calls this directly

Calls 9

collection_configFunction · 0.85
_transform_forFunction · 0.85
_normaliseFunction · 0.85
_collect_docsFunction · 0.85
_ensure_dbFunction · 0.85
_install_designFunction · 0.85
_bulk_insertFunction · 0.85
_create_indexesFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected