static rc_t pacbio_meta_entry( ld_context *lctx, const char * toolname ) { KMetadata* meta = NULL; rc_t rc = VDatabaseOpenMetadataUpdate( lctx->database, &meta ); if ( rc != 0 ) { LOGERR( klogErr, rc, "Cannot open database-metadata" ); } else { KMDataNode *node = NULL; rc = KMetadataOpenNodeUpdate( meta, &node, "/" ); if ( rc != 0 ) { LOGERR( klogErr, rc, "Cannot open database-metadata-root" ); } else { rc = KLoaderMeta_Write( node, toolname, __DATE__, "PacBio HDF5", PACBIO_LOAD_VERS ); if ( rc != 0 ) { LOGERR( klogErr, rc, "Cannot write pacbio metadata node" ); } KMDataNodeRelease( node ); } KMetadataRelease( meta ); } return rc; }
rc_t copy_database_meta ( const VDatabase *src_db, VDatabase *dst_db, const char * excluded_nodes, const bool show_meta ) { const KMetadata *src_meta; rc_t rc; if ( src_db == NULL || dst_db == NULL ) return RC( rcExe, rcNoTarg, rcCopying, rcParam, rcNull ); /* it is OK if excluded_nodes is NULL */ rc = VDatabaseOpenMetadataRead ( src_db, & src_meta ); DISP_RC( rc, "copy_database_meta:VDatabaseOpenMetadataRead() failed" ); if ( rc == 0 ) { KMetadata *dst_meta; rc = VDatabaseOpenMetadataUpdate ( dst_db, & dst_meta ); DISP_RC( rc, "copy_database_meta:VDatabaseOpenMetadataUpdate() failed" ); if ( rc == 0 ) { if ( show_meta ) KOutMsg( "+++copy current db-metadata\n" ); rc = copy_stray_metadata ( src_meta, dst_meta, excluded_nodes, show_meta ); if ( show_meta ) KOutMsg( "+++end of copy db-current metadata\n" ); KMetadataRelease ( dst_meta ); } KMetadataRelease ( src_meta ); } return rc; }
static rc_t DB_Fini(const SParam* p, DB_Handle* h, bool drop) { rc_t rc = 0, rc2; /* THIS FUNCTION MAKES NO ATTEMPT TO PRESERVE INITIAL ERROR CODES EACH SUCCESSIVE ERROR OVERWRITES THE PREVIOUS CODE */ if( h != NULL ) { PLOGMSG(klogInfo, (klogInfo, "Fini SEQUENCE", "severity=status")); if( (rc2 = CGWriterSeq_Whack(h->wseq, !drop, NULL)) != 0 && !drop ) { drop = true; rc = rc2; } h->wseq = NULL; h->reads = NULL; PLOGMSG(klogInfo, (klogInfo, "Fini (PRI&SEC)_ALIGNMENT", "severity=status")); if( (rc2 = CGWriterAlgn_Whack(h->walgn, !drop, NULL, NULL)) != 0 && !drop ) { drop = true; rc = rc2; } h->walgn = NULL; h->mappings = NULL; PLOGMSG(klogInfo, (klogInfo, "Fini EVIDENCE_INTERVAL", "severity=status")); if( (rc2 = CGWriterEvdInt_Whack(h->wev_int, !drop, NULL)) != 0 && !drop ) { drop = true; rc = rc2; } h->wev_int = NULL; h->ev_int = NULL; PLOGMSG(klogInfo, (klogInfo, "Fini EVIDENCE_ALIGNMENT", "severity=status")); if( (rc2 = CGWriterEvdDnbs_Whack(h->wev_dnb, !drop, NULL)) != 0 && !drop ) { drop = true; rc = rc2; } h->wev_dnb = NULL; h->ev_dnb = NULL; PLOGMSG(klogInfo, (klogInfo, "Fini calculating reference coverage", "severity=status")); if( (rc2 = ReferenceMgr_Release(h->rmgr, !drop, NULL, drop ? false : true)) != 0 && !drop ) { drop = true; rc = rc2; LOGERR(klogErr, rc, "Failed calculating reference coverage"); } h->rmgr = NULL; if( rc == 0 ) { KMetadata* meta; if( (rc = VDatabaseOpenMetadataUpdate(h->db, &meta)) == 0 ) { KMDataNode *node; if( (rc = KMetadataOpenNodeUpdate(meta, &node, "/")) == 0 ) { if( (rc = KLoaderMeta_Write(node, p->argv0, __DATE__, "Complete Genomics", KAppVersion())) != 0 ) { LOGERR(klogErr, rc, "Cannot update loader meta"); } KMDataNodeRelease(node); } KMetadataRelease(meta); } } PLOGMSG(klogInfo, (klogInfo, "Fini VDatabaseRelease", "severity=status")); VDatabaseRelease(h->db); h->db = NULL; VSchemaRelease(h->schema); h->schema = NULL; if( drop || rc != 0 ) { rc2 = VDBManagerDrop(h->mgr, kptDatabase, p->out); if( GetRCState(rc2) == rcNotFound ) { /* WHAT WOULD BE THE POINT OF RESETTING "rc" TO ZERO? */ rc = 0; } else if( rc2 != 0 ) { if ( rc == 0 ) rc = rc2; PLOGERR(klogErr, (klogErr, rc2, "cannot drop db at '$(path)'", PLOG_S(path), p->out)); } } VDBManagerRelease(h->mgr); h->mgr = NULL; } return rc; }
inline rc_t OpenMetadata ( KMetadata **meta ) throw () { return VDatabaseOpenMetadataUpdate ( this, meta ); }