Mailinglist Archive: zypp-commit (149 mails)

< Previous Next >
[zypp-commit] r5407 - in /trunk/libzypp: devel/devel.dmacvicar/ zypp2/cache/ zypp2/cache/schema/ zypp2/cache/sqlite_detail/ zypp2/source/cached/
  • From: dmacvicar@xxxxxxxxxxxxxxxx
  • Date: Wed, 18 Apr 2007 15:52:29 -0000
  • Message-id: <20070418155229.6DDC835582@xxxxxxxxxxxxxxxx>
Author: dmacvicar
Date: Wed Apr 18 17:52:28 2007
New Revision: 5407

URL: http://svn.opensuse.org/viewcvs/zypp?rev=5407&view=rev
Log:

normalize named dependencies


Modified:
    trunk/libzypp/devel/devel.dmacvicar/CacheQuery_test.cc
    trunk/libzypp/devel/devel.dmacvicar/SUSETagsParser.cc
    trunk/libzypp/devel/devel.dmacvicar/SUSETagsParser.h
    trunk/libzypp/zypp2/cache/CacheStore.cpp
    trunk/libzypp/zypp2/cache/CacheStore.h
    trunk/libzypp/zypp2/cache/CapabilityQuery.cc
    trunk/libzypp/zypp2/cache/CapabilityQuery.h
    trunk/libzypp/zypp2/cache/QueryFactory.cc
    trunk/libzypp/zypp2/cache/QueryFactory.h
    trunk/libzypp/zypp2/cache/schema/schema.sql
    trunk/libzypp/zypp2/cache/sqlite_detail/CacheSqlite.h
    trunk/libzypp/zypp2/cache/sqlite_detail/CapabilityQueryImpl.cc
    trunk/libzypp/zypp2/cache/sqlite_detail/CapabilityQueryImpl.h
    trunk/libzypp/zypp2/cache/sqlite_detail/QueryFactoryImpl.cc
    trunk/libzypp/zypp2/source/cached/CachedSourceImpl.cc

Modified: trunk/libzypp/devel/devel.dmacvicar/CacheQuery_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.dmacvicar/CacheQuery_test.cc?rev=5407&r1=5406&r2=5407&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.dmacvicar/CacheQuery_test.cc (original)
+++ trunk/libzypp/devel/devel.dmacvicar/CacheQuery_test.cc Wed Apr 18 17:52:28 2007
@@ -45,8 +45,8 @@
       //zypp::cache::CacheInitializer init( "/", dbfile );
       //t.tick("init sqlite database");
       int i = 1;
-      for ( ; i < 19000; i++ ) {
-        zypp::cache::CapabilityQuery capquery = query.createCapabilityQuery( i );
+      //for ( ; i < 19000; i++ ) {
+        zypp::cache::CapabilityQuery capquery = query.createCapabilityQuery( );
         //cout << capquery.value() << endl;
         //cout << 2 << endl;
         while ( capquery.read() )
@@ -54,7 +54,7 @@
           //cout << 3 << endl;
           //cout << capquery.value() << endl;
         }
-      }
+      //}
     }
     catch ( const Exception &e )
     {

Modified: trunk/libzypp/devel/devel.dmacvicar/SUSETagsParser.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.dmacvicar/SUSETagsParser.cc?rev=5407&r1=5406&r2=5407&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.dmacvicar/SUSETagsParser.cc (original)
+++ trunk/libzypp/devel/devel.dmacvicar/SUSETagsParser.cc Wed Apr 18 17:52:28 2007
@@ -73,7 +73,7 @@
   Pathname _descr_dir;
 };
 
-PackagesParser::PackagesParser( const data::RecordId &catalog_id, zypp::cache::CacheStore consumer )
+PackagesParser::PackagesParser( const data::RecordId &catalog_id, zypp::cache::CacheStore &consumer )
     : _consumer(consumer), _catalog_id(catalog_id)
 {
   ZYpp::Ptr z = getZYpp();

Modified: trunk/libzypp/devel/devel.dmacvicar/SUSETagsParser.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.dmacvicar/SUSETagsParser.h?rev=5407&r1=5406&r2=5407&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.dmacvicar/SUSETagsParser.h (original)
+++ trunk/libzypp/devel/devel.dmacvicar/SUSETagsParser.h Wed Apr 18 17:52:28 2007
@@ -58,7 +58,7 @@
       NUM_TAGS
     };
   
-    PackagesParser( const data::RecordId &catalog_id, zypp::cache::CacheStore consumer );
+    PackagesParser( const data::RecordId &catalog_id, zypp::cache::CacheStore &consumer );
     void start( const zypp::Pathname &path, Progress progress_fnc );
     void fromCache ( TagCacheRetrieval_Ptr pkgcache);
     void collectDeps( zypp::Dep deptype, const std::list<std::string> &depstrlist, data::Dependencies &deps );
@@ -73,7 +73,7 @@
     zypp::Arch _system_arch;
     typedef std::map <std::string, PackageDataProviderPtr> pkgmaptype;
     pkgmaptype _pkgmap;
-    zypp::cache::CacheStore _consumer;
+    zypp::cache::CacheStore &_consumer;
     std::map<std::string, data::RecordId> _idmap;
     data::RecordId _catalog_id;
   };

Modified: trunk/libzypp/zypp2/cache/CacheStore.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CacheStore.cpp?rev=5407&r1=5406&r2=5407&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/CacheStore.cpp (original)
+++ trunk/libzypp/zypp2/cache/CacheStore.cpp Wed Apr 18 17:52:28 2007
@@ -61,7 +61,9 @@
   sqlite3_command_ptr insert_dependency_entry_cmd;
   
   sqlite3_command_ptr append_file_dependency_cmd;
-  sqlite3_command_ptr append_versioned_dependency_cmd;
+  sqlite3_command_ptr append_named_dependency_entry_cmd;
+  sqlite3_command_ptr select_named_dependency_cmd;
+  sqlite3_command_ptr insert_named_dependency_cmd;
   
   sqlite3_command_ptr append_resolvable_cmd;
   
@@ -112,7 +114,9 @@
 
   _pimpl->insert_dependency_entry_cmd.reset( new sqlite3_command( _pimpl->con, "insert into capabilities ( resolvable_id, dependency_type, refers_kind ) values ( :resolvable_id, :dependency_type, :refers_kind );" ));
   _pimpl->append_file_dependency_cmd.reset( new sqlite3_command( _pimpl->con, "insert into file_capabilities ( dependency_id, file_id ) values ( :dependency_id, :file_id );" ));
-  _pimpl->append_versioned_dependency_cmd.reset( new sqlite3_command( _pimpl->con, "insert into named_capabilities ( dependency_id, name_id, version, release, epoch, relation ) values ( :dependency_id, :name_id, :version, :release, :epoch, :relation );" ));
+  _pimpl->append_named_dependency_entry_cmd.reset( new sqlite3_command( _pimpl->con, "insert into named_capabilities ( name_id, version, release, epoch, relation ) values ( :name_id, :version, :release, :epoch, :relation );" ));
+  _pimpl->select_named_dependency_cmd.reset( new sqlite3_command( _pimpl->con, "select id from named_capabilities where name_id=:name_id and version= :version and release=:release and epoch=:epoch and relation=:relation;" ));
+  _pimpl->insert_named_dependency_cmd.reset( new sqlite3_command( _pimpl->con, "insert into named_capabilities_capabilities ( capability_id, named_capability_id )values ( :capability_id, :named_capability_id );" ));
   
   _pimpl->append_resolvable_cmd.reset( new sqlite3_command( _pimpl->con, "insert into resolvables ( name, version, release, epoch, arch, kind, catalog_id ) values ( :name, :version, :release, :epoch, :arch, :kind, :catalog_id );" ));
   
@@ -205,6 +209,32 @@
   }
 }
 
+data::RecordId CacheStore::lookupOrAppendNamedDependencyEntry( const data::RecordId name_id, const Edition &edition, const zypp::Rel &rel )
+{
+  _pimpl->select_named_dependency_cmd->bind( ":name_id", name_id);
+  _pimpl->select_named_dependency_cmd->bind( ":version", edition.version() );
+  _pimpl->select_named_dependency_cmd->bind( ":release", edition.release() );
+  _pimpl->select_named_dependency_cmd->bind( ":epoch", static_cast<int>( edition.epoch() ) );
+  _pimpl->select_named_dependency_cmd->bind( ":relation", zypp_rel2db_rel( rel ) );
+  long long id = 0;
+  try {
+    id = _pimpl->select_named_dependency_cmd->executeint64();
+  }
+  catch ( const sqlite3x::database_error &e )
+  {
+    // does not exist
+    _pimpl->append_named_dependency_entry_cmd->bind( ":name_id", name_id);
+    _pimpl->append_named_dependency_entry_cmd->bind( ":version", edition.version() );
+    _pimpl->append_named_dependency_entry_cmd->bind( ":release", edition.release() );
+    _pimpl->append_named_dependency_entry_cmd->bind( ":epoch", static_cast<int>( edition.epoch() ) );
+    _pimpl->append_named_dependency_entry_cmd->bind( ":relation", zypp_rel2db_rel( rel ) );
+    _pimpl->append_named_dependency_entry_cmd->executenonquery();
+    id = _pimpl->con.insertid();
+    return static_cast<data::RecordId>(id);
+  }
+  return static_cast<data::RecordId>(id);
+}
+
 void CacheStore::appendNamedDependency( const data::RecordId &resolvable_id, zypp::Dep deptype, capability::NamedCap::Ptr cap )
 {
   if ( !cap )
@@ -214,15 +244,12 @@
   data::RecordId dependency_id = appendDependencyEntry( resolvable_id, deptype, cap->refers() );
   data::RecordId name_id = lookupOrAppendName(cap->name());
   
-  _pimpl->append_versioned_dependency_cmd->bind( ":dependency_id", dependency_id);
-  _pimpl->append_versioned_dependency_cmd->bind( ":name_id", name_id);
-  
-  _pimpl->append_versioned_dependency_cmd->bind( ":version", cap->edition().version() );
-  _pimpl->append_versioned_dependency_cmd->bind( ":release", cap->edition().release() );
-  _pimpl->append_versioned_dependency_cmd->bind( ":epoch", static_cast<int>( cap->edition().epoch() ) );
-  _pimpl->append_versioned_dependency_cmd->bind( ":relation", zypp_rel2db_rel( cap->op() ) );
+  data::RecordId named_id = lookupOrAppendNamedDependencyEntry(name_id, cap->edition(), cap->op());
   
-  _pimpl->append_versioned_dependency_cmd->executenonquery();
+  _pimpl->insert_named_dependency_cmd->bind( ":capability_id", dependency_id);
+  _pimpl->insert_named_dependency_cmd->bind( ":named_capability_id", named_id);
+
+  _pimpl->insert_named_dependency_cmd->executenonquery();
   //delete cmd;
 }
 

Modified: trunk/libzypp/zypp2/cache/CacheStore.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CacheStore.h?rev=5407&r1=5406&r2=5407&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/CacheStore.h (original)
+++ trunk/libzypp/zypp2/cache/CacheStore.h Wed Apr 18 17:52:28 2007
@@ -240,6 +240,10 @@
        */
       data::RecordId appendDependencyEntry( const data::RecordId &, 
                                             zypp::Dep, const Resolvable::Kind & );
+      
+      data::RecordId lookupOrAppendNamedDependencyEntry( const data::RecordId name_id,
+                                                    const Edition &edition,
+                                                    const zypp::Rel &rel );
     private:
       /** Implementation. */
       class Impl;

Modified: trunk/libzypp/zypp2/cache/CapabilityQuery.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CapabilityQuery.cc?rev=5407&r1=5406&r2=5407&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/CapabilityQuery.cc (original)
+++ trunk/libzypp/zypp2/cache/CapabilityQuery.cc Wed Apr 18 17:52:28 2007
@@ -34,11 +34,11 @@
   : _pimpl( impl)
 {
      //int deptype = static_cast<int>(zypp_deptype2db_deptype(_pimpl->_deptype));
-    _pimpl->context->select_versionedcap_cmd->bind(":rid", _pimpl->_resolvable_id);
-    _pimpl->_versioned_reader.reset( new sqlite3_reader(_pimpl->context->select_versionedcap_cmd->executereader()));
+    //_pimpl->context->select_namedcap_cmd->bind(":rid", _pimpl->_resolvable_id);
+    _pimpl->_named_reader.reset( new sqlite3_reader(_pimpl->context->select_named_cmd->executereader()));
     
-    _pimpl->context->select_filecap_cmd->bind(":rid", _pimpl->_resolvable_id);
-    _pimpl->_file_reader.reset( new sqlite3_reader(_pimpl->context->select_filecap_cmd->executereader()));
+    //_pimpl->context->select_filecap_cmd->bind(":rid", _pimpl->_resolvable_id);
+    _pimpl->_file_reader.reset( new sqlite3_reader(_pimpl->context->select_file_cmd->executereader()));
     
     //MIL << "Done setup query" << endl;
     read();
@@ -49,19 +49,19 @@
 {
   //MIL << endl;
   // it has to be disposed before the commands
-  //_pimpl->_versioned_reader.reset();
+  //_pimpl->_named_reader.reset();
   //_pimpl->_named_reader.reset();
   //_pimpl->_file_reader.reset();
 }
 
 bool CapabilityQuery::read()
 {
-  if (!_pimpl->_vercap_done)
+  if (!_pimpl->_namedcap_done)
   {
-    if ( _pimpl->_vercap_read = _pimpl->_versioned_reader->read() )
+    if ( _pimpl->_namedcap_read = _pimpl->_named_reader->read() )
       return true;
     else
-      _pimpl->_vercap_done = true;
+      _pimpl->_namedcap_done = true;
   }
   
   if (!_pimpl->_filecap_done)
@@ -77,7 +77,7 @@
   
 bool CapabilityQuery::valid() const
 {
- if ( _pimpl->_vercap_read )
+ if ( _pimpl->_namedcap_read )
     return true;
     
   if ( _pimpl->_filecap_read )
@@ -86,25 +86,25 @@
   return false;
 }
 
-std::pair<zypp::Dep, capability::CapabilityImpl::Ptr> CapabilityQuery::value()
+CapabilityQuery::Result CapabilityQuery::value()
 {
-  if ( _pimpl->_vercap_read )
+  if ( _pimpl->_namedcap_read )
   {
-    Resolvable::Kind refer = db_kind2zypp_kind( static_cast<db::Kind>(_pimpl->_versioned_reader->getint(0)) );
-    zypp::Rel rel = db_rel2zypp_rel( static_cast<db::Rel>(_pimpl->_versioned_reader->getint(5)) );
+    Resolvable::Kind refer = db_kind2zypp_kind( static_cast<db::Kind>(_pimpl->_named_reader->getint(0)) );
+    zypp::Rel rel = db_rel2zypp_rel( static_cast<db::Rel>(_pimpl->_named_reader->getint(5)) );
+    data::RecordId rid = _pimpl->_named_reader->getint64(7);
     
     if ( rel == zypp::Rel::NONE )
     {
-      capability::NamedCap *ncap = new capability::NamedCap( refer, _pimpl->_versioned_reader->getstring(1) );
-      zypp::Dep deptype = db_deptype2zypp_deptype( static_cast<db::DependencyType>(_pimpl->_versioned_reader->getint(5)) );
-      return make_pair( deptype, capability::NamedCap::Ptr(ncap) );
+      capability::NamedCap *ncap = new capability::NamedCap( refer, _pimpl->_named_reader->getstring(1) );
+      zypp::Dep deptype = db_deptype2zypp_deptype( static_cast<db::DependencyType>(_pimpl->_named_reader->getint(5)) );  
+      return Result( rid, deptype, capability::NamedCap::Ptr(ncap) );
     }
     else
     {
-      capability::VersionedCap *vcap = new capability::VersionedCap( refer, _pimpl->_versioned_reader->getstring(1), /* rel */ rel, Edition( _pimpl->_versioned_reader->getstring(2), _pimpl->_versioned_reader->getstring(3), _pimpl->_versioned_reader->getint(4) ) );
-      zypp::Dep deptype = db_deptype2zypp_deptype( static_cast<db::DependencyType>(_pimpl->_versioned_reader->getint(5)) );
-      return make_pair( deptype, capability::VersionedCap::Ptr(vcap) );
-      
+      capability::VersionedCap *vcap = new capability::VersionedCap( refer, _pimpl->_named_reader->getstring(1), /* rel */ rel, Edition( _pimpl->_named_reader->getstring(2), _pimpl->_named_reader->getstring(3), _pimpl->_named_reader->getint(4) ) );
+      zypp::Dep deptype = db_deptype2zypp_deptype( static_cast<db::DependencyType>(_pimpl->_named_reader->getint(5)) );
+      return Result( rid, deptype, capability::VersionedCap::Ptr(vcap) );
     }
   }
   if ( _pimpl->_filecap_read )
@@ -112,7 +112,8 @@
     Resolvable::Kind refer = db_kind2zypp_kind( static_cast<db::Kind>(_pimpl->_file_reader->getint(0)) );
     capability::FileCap *fcap = new capability::FileCap( refer, _pimpl->_file_reader->getstring(1) + "/" + _pimpl->_file_reader->getstring(2) );
     zypp::Dep deptype = db_deptype2zypp_deptype( static_cast<db::DependencyType>(_pimpl->_file_reader->getint(3)) );
-    return make_pair( deptype, capability::FileCap::Ptr(fcap));
+    data::RecordId rid = _pimpl->_named_reader->getint64(4);
+    return Result( rid, deptype, capability::FileCap::Ptr(fcap) );
   }
   ZYPP_THROW(Exception("Invalid value"));
 }

Modified: trunk/libzypp/zypp2/cache/CapabilityQuery.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CapabilityQuery.h?rev=5407&r1=5406&r2=5407&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/CapabilityQuery.h (original)
+++ trunk/libzypp/zypp2/cache/CapabilityQuery.h Wed Apr 18 17:52:28 2007
@@ -54,9 +54,19 @@
     struct CapabilityQuery
     {
     public:
-      class Result
+      struct Result
       {
-        data::RecordId id;
+        Result( const data::RecordId &p_resolvable_id,
+            //    const data::RecordId &p_id,
+                const zypp::Dep &p_dep,
+                capability::CapabilityImpl::Ptr p_cap )
+        : resolvable_id(p_resolvable_id),
+          //id(p_id),
+          dep(p_dep),
+          cap(p_cap)
+        {}
+        data::RecordId resolvable_id;
+        //data::RecordId id;
         zypp::Dep dep;
         capability::CapabilityImpl::Ptr cap;
       };
@@ -75,7 +85,7 @@
       * Return a \ref CapabilityImpl::Ptr
       * from the current result.
       */
-      std::pair<zypp::Dep, capability::CapabilityImpl::Ptr> value();
+      Result value();
       
       /** Implementation. */
       class Impl;

Modified: trunk/libzypp/zypp2/cache/QueryFactory.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/QueryFactory.cc?rev=5407&r1=5406&r2=5407&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/QueryFactory.cc (original)
+++ trunk/libzypp/zypp2/cache/QueryFactory.cc Wed Apr 18 17:52:28 2007
@@ -42,9 +42,9 @@
 {
 }
 
-CapabilityQuery QueryFactory::createCapabilityQuery( const data::RecordId &resolvable_id  )
+CapabilityQuery QueryFactory::createCapabilityQuery()
 {
-  return CapabilityQuery( new CapabilityQuery::Impl( _pimpl->context, resolvable_id) );
+  return CapabilityQuery( new CapabilityQuery::Impl( _pimpl->context ) );
 }
 
 QueryFactory::~QueryFactory()

Modified: trunk/libzypp/zypp2/cache/QueryFactory.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/QueryFactory.h?rev=5407&r1=5406&r2=5407&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/QueryFactory.h (original)
+++ trunk/libzypp/zypp2/cache/QueryFactory.h Wed Apr 18 17:52:28 2007
@@ -42,7 +42,7 @@
       QueryFactory( Impl * );
       QueryFactory( const Pathname &dbdir );
       ~QueryFactory();
-      CapabilityQuery createCapabilityQuery( const data::RecordId &id  );
+      CapabilityQuery createCapabilityQuery();
     private:
       /** Pointer to implementation. */
       RW_pointer<Impl> _pimpl;

Modified: trunk/libzypp/zypp2/cache/schema/schema.sql
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/schema/schema.sql?rev=5407&r1=5406&r2=5407&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/schema/schema.sql (original)
+++ trunk/libzypp/zypp2/cache/schema/schema.sql Wed Apr 18 17:52:28 2007
@@ -319,14 +319,23 @@
 
 CREATE TABLE named_capabilities (
    id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL 
-  , dependency_id INTEGER REFERENCES capabilities (id)
+--  , dependency_id INTEGER REFERENCES capabilities (id)
   , name_id INTEGER REFERENCES names(id)
   , version TEXT
   , release TEXT
   , epoch INTEGER
   , relation INTEGER
 );
-CREATE INDEX named_capabilities_dependency_id ON named_capabilities (dependency_id);
+--CREATE INDEX named_capabilities_dependency_id ON named_capabilities (dependency_id);
+CREATE INDEX named_capabilities_attributes ON named_capabilities(name_id, version, release, epoch, release);
+
+CREATE TABLE named_capabilities_capabilities (
+   capability_id INTEGER REFERENCES capabilities (id)
+  , named_capability_id  INTEGER REFERENCES named_capabilities(id)
+  , PRIMARY KEY(capability_id, named_capability_id)
+);
+CREATE INDEX named_capabilities_capabilities_capability_id ON named_capabilities_capabilities(capability_id);
+CREATE INDEX named_capabilities_capabilities_named_capability_id ON named_capabilities_capabilities(named_capability_id);
 
 CREATE TABLE file_capabilities (
    id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL 

Modified: trunk/libzypp/zypp2/cache/sqlite_detail/CacheSqlite.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/sqlite_detail/CacheSqlite.h?rev=5407&r1=5406&r2=5407&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/sqlite_detail/CacheSqlite.h (original)
+++ trunk/libzypp/zypp2/cache/sqlite_detail/CacheSqlite.h Wed Apr 18 17:52:28 2007
@@ -18,9 +18,8 @@
 struct DatabaseContext
 {
   sqlite3x::sqlite3_connection_ptr con;
-  sqlite3x::sqlite3_command_ptr select_versionedcap_cmd;
-  sqlite3x::sqlite3_command_ptr select_namedcap_cmd;
-  sqlite3x::sqlite3_command_ptr select_filecap_cmd;
+  sqlite3x::sqlite3_command_ptr select_named_cmd;
+  sqlite3x::sqlite3_command_ptr select_file_cmd;
   Pathname dbdir;
 };
 

Modified: trunk/libzypp/zypp2/cache/sqlite_detail/CapabilityQueryImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/sqlite_detail/CapabilityQueryImpl.cc?rev=5407&r1=5406&r2=5407&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/sqlite_detail/CapabilityQueryImpl.cc (original)
+++ trunk/libzypp/zypp2/cache/sqlite_detail/CapabilityQueryImpl.cc Wed Apr 18 17:52:28 2007
@@ -26,10 +26,10 @@
 // CAPABILITY QUERY                                         //
 //////////////////////////////////////////////////////////////
 
-CapabilityQuery::Impl::Impl( DatabaseContext_Ptr p_context, const data::RecordId &resolvable_id  )
-  : context(p_context), _resolvable_id(resolvable_id)
-    , _vercap_read(false), _filecap_read(false)
-    , _vercap_done(false), _filecap_done(false)
+CapabilityQuery::Impl::Impl( DatabaseContext_Ptr p_context )
+  : context(p_context)
+    , _namedcap_read(false), _filecap_read(false)
+    , _namedcap_done(false), _filecap_done(false)
 {}
 
 CapabilityQuery::Impl::~Impl()

Modified: trunk/libzypp/zypp2/cache/sqlite_detail/CapabilityQueryImpl.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/sqlite_detail/CapabilityQueryImpl.h?rev=5407&r1=5406&r2=5407&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/sqlite_detail/CapabilityQueryImpl.h (original)
+++ trunk/libzypp/zypp2/cache/sqlite_detail/CapabilityQueryImpl.h Wed Apr 18 17:52:28 2007
@@ -35,19 +35,16 @@
     class CapabilityQuery::Impl
     {
       public:
-      Impl( DatabaseContext_Ptr p_context, const data::RecordId &resolvable_id  );
+      Impl( DatabaseContext_Ptr p_context );
       ~Impl();
       
       DatabaseContext_Ptr context;
-      sqlite3x::sqlite3_reader_ptr _versioned_reader;
       sqlite3x::sqlite3_reader_ptr _named_reader;
       sqlite3x::sqlite3_reader_ptr _file_reader;
       data::RecordId _resolvable_id;
-      bool _vercap_read;
       bool _namedcap_read;
       bool _filecap_read;
       
-      bool _vercap_done;
       bool _namedcap_done;
       bool _filecap_done;
     };

Modified: trunk/libzypp/zypp2/cache/sqlite_detail/QueryFactoryImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/sqlite_detail/QueryFactoryImpl.cc?rev=5407&r1=5406&r2=5407&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/sqlite_detail/QueryFactoryImpl.cc (original)
+++ trunk/libzypp/zypp2/cache/sqlite_detail/QueryFactoryImpl.cc Wed Apr 18 17:52:28 2007
@@ -69,9 +69,8 @@
   try
   {
     // precompile statements
-    context->select_versionedcap_cmd.reset( new sqlite3_command( *context->con, "select c.refers_kind, n.name, v.version, v.release, v.epoch, v.relation, c.dependency_type from names n, capabilities c, named_capabilities v where v.name_id=n.id and c.id=v.dependency_id and c.resolvable_id=:rid;"));
-    context->select_namedcap_cmd.reset( new sqlite3_command( *context->con, "select c.refers_kind, n.name, c.dependency_type from names n, capabilities c, named_capabilities nc where nc.name_id=n.id and c.id=nc.dependency_id and c.resolvable_id=:rid;"));
-    context->select_filecap_cmd.reset( new sqlite3_command( *context->con, "select c.refers_kind, dn.name, fn.name, c.dependency_type from file_names fn, dir_names dn, capabilities c, file_capabilities fc, files f  where f.id=fc.file_id and f.dir_name_id=dn.id and f.file_name_id=fn.id and c.id=fc.dependency_id and c.resolvable_id=:rid;"));
+    context->select_named_cmd.reset( new sqlite3_command( *context->con, "select c.refers_kind, n.name, v.version, v.release, v.epoch, v.relation, c.dependency_type, c.resolvable_id from names n, capabilities c, named_capabilities v where v.name_id=n.id and c.id=v.dependency_id"));
+    context->select_file_cmd.reset( new sqlite3_command( *context->con, "select c.refers_kind, dn.name, fn.name, c.dependency_type, c.resolvable_id from file_names fn, dir_names dn, capabilities c, file_capabilities fc, files f  where f.id=fc.file_id and f.dir_name_id=dn.id and f.file_name_id=fn.id and c.id=fc.dependency_id"));
     
     // disable autocommit
     context->con->executenonquery("PRAGMA cache_size=8000;");

Modified: trunk/libzypp/zypp2/source/cached/CachedSourceImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/source/cached/CachedSourceImpl.cc?rev=5407&r1=5406&r2=5407&view=diff
==============================================================================
--- trunk/libzypp/zypp2/source/cached/CachedSourceImpl.cc (original)
+++ trunk/libzypp/zypp2/source/cached/CachedSourceImpl.cc Wed Apr 18 17:52:28 2007
@@ -9,11 +9,15 @@
 
 #include <iostream>
 #include "zypp/base/Logger.h"
+#include "zypp/base/Measure.h"
+#include <sqlite3.h>
 #include "zypp2/cache/sqlite3x/sqlite3x.hpp"
 #include "zypp2/source/cached/CachedSourceImpl.h"
 #include "zypp2/cache/QueryFactory.h"
 #include "zypp2/cache/CapabilityQuery.h"
 #include "zypp2/cache/sqlite_detail/CacheSqlite.h"
+#include "zypp2/cache/DatabaseTypes.h"
+#include "zypp2/cache/CacheCommon.h"
 #include "zypp2/cache/sqlite_detail/QueryFactoryImpl.h"
 
 #include "zypp2/source/cached/CachedSourcePackageImpl.h"
@@ -21,6 +25,7 @@
 #include "zypp/CapFactory.h"
 
 using namespace zypp::detail;
+using namespace zypp::cache;
 using std::endl;
 using namespace std;
 using namespace sqlite3x;
@@ -59,34 +64,27 @@
   MIL << "   Path     : " << path() << std::endl;
 }
 
+void read_capabilities( sqlite3_connection &con, map<data::RecordId, NVRAD> &nvras );
+
 void CachedSourceImpl::createResolvables(Source_Ref source_r)
 {
+  debug::Measure m("create resolvables");
   Pathname thePath = Pathname(url().getPathName()) + path();
   MIL << "Going to read dir " << thePath << std::endl;
   CapFactory capfactory;
   try {
-    sqlite3_connection_ptr con;
-    con.reset( new sqlite3_connection((_dbdir + "zypp.db").asString().c_str()));
-    sqlite3_command cmd( *con, "select id,name,version,release,epoch,arch,kind from resolvables;");
-    
-    cache::QueryFactory cachequery( new cache::QueryFactory::Impl( _dbdir, con ) );
+    sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
+    con.executenonquery("PRAGMA cache_size=8000;");
+    con.executenonquery("BEGIN;");
+    sqlite3_command cmd( con, "select id,name,version,release,epoch,arch,kind from resolvables;");
+    map<data::RecordId, NVRAD> nvras;
     
     sqlite3_reader reader = cmd.executereader();
     while(reader.read())
     {
       long long id = reader.getint64(0);
-      cache::CapabilityQuery capquery = cachequery.createCapabilityQuery(id);
       Dependencies deps;
-          
-      while ( capquery.read() )
-      {
-        Dependencies deps;
-        std::pair<zypp::Dep, capability::CapabilityImpl::Ptr> d(capquery.value());
-        zypp::Dep dep(d.first);
-        Capability thecap = capfactory.fromImpl( capability::CapabilityImpl::Ptr(d.second) );
-        deps[dep].insert(thecap);
-      }
-
+      
       Arch arch;
       string archstring = reader.getstring(5);
       if (!archstring.empty())
@@ -98,23 +96,98 @@
                        arch,
                        deps
                      );
+      nvras[id] = dataCollect;
+    }
+    
+    MIL << "Done reading resolvables nvra" << endl;
+    
+    read_capabilities( con, nvras);
+    
+    for ( map<data::RecordId, NVRAD>::const_iterator it = nvras.begin(); it != nvras.end(); ++it )
+    {
       ResImplTraits<CachedSourcePackageImpl>::Ptr impl = new CachedSourcePackageImpl(selfSourceRef());
-      Package::Ptr package = detail::makeResolvableFromImpl( dataCollect, impl );
+      Package::Ptr package = detail::makeResolvableFromImpl( it->second, impl );
       _store.insert (package);
     }
+    con.executenonquery("COMMIT;");
   }
   catch(exception &ex) {
       cerr << "Exception Occured: " << ex.what() << endl;
    }
   //extract_packages_from_directory( _store, thePath, selfSourceRef(), true );
+   
 }
 
-      /////////////////////////////////////////////////////////////////
-    } // namespace plaindir
-    ///////////////////////////////////////////////////////////////////
-    /////////////////////////////////////////////////////////////////
-  } // namespace source
-  ///////////////////////////////////////////////////////////////////
-  /////////////////////////////////////////////////////////////////
+void read_capabilities( sqlite3_connection &con, map<data::RecordId, NVRAD> &nvras )
+{
+  CapFactory capfactory;
+  // precompile statements
+  
+//   map<data::RecordId, capability::CapabilityImpl::Ptr> named_caps;
+//   sqlite3_command select_named_cmd( con, "select v.id, c.refers_kind, n.name, v.version, v.release, v.epoch, v.relation named_capabilities v, capabilities c, names n where v.name_id=n.id and c.id=ncc.capability_id and ncc.named_capability_id=v.id;");
+//   {
+//     debug::Measure mnc("read named capabilities");
+//     sqlite3_reader reader = select_named_cmd.executereader();
+//     while  ( reader.read() )
+//     {
+//       
+//     }
+//   }
+  sqlite3_command select_named_cmd( con, "select c.refers_kind, n.name, v.version, v.release, v.epoch, v.relation, c.dependency_type, c.resolvable_id from  names n , named_capabilities v, named_capabilities_capabilities ncc, capabilities c where v.name_id=n.id and c.id=ncc.capability_id and ncc.named_capability_id=v.id;");
+  sqlite3_command select_file_cmd( con, "select c.refers_kind, dn.name, fn.name, c.dependency_type, c.resolvable_id from file_capabilities fc, capabilities c, files f, dir_names dn, file_names fn where f.id=fc.file_id and f.dir_name_id=dn.id and f.file_name_id=fn.id and c.id=fc.dependency_id;");
+  
+  {
+    debug::Measure mnc("read named capabilities");
+    sqlite3_reader reader = select_named_cmd.executereader();
+    while  ( reader.read() )
+    {
+      Resolvable::Kind refer = db_kind2zypp_kind( static_cast<db::Kind>(reader.getint(0)) );
+      zypp::Rel rel = db_rel2zypp_rel( static_cast<db::Rel>(reader.getint(5)) );
+      data::RecordId rid = reader.getint64(7);
+  
+      if ( rel == zypp::Rel::NONE )
+      {
+        capability::NamedCap *ncap = new capability::NamedCap( refer, reader.getstring(1) );
+        zypp::Dep deptype = db_deptype2zypp_deptype( static_cast<db::DependencyType>(reader.getint(5)) );
+        
+        nvras[rid][deptype].insert( capfactory.fromImpl( capability::CapabilityImpl::Ptr(ncap) ) ); 
+      }
+      else
+      {
+        capability::VersionedCap *vcap = new capability::VersionedCap( refer, reader.getstring(1), /* rel */ rel, Edition( reader.getstring(2), reader.getstring(3), reader.getint(4) ) );
+        zypp::Dep deptype = db_deptype2zypp_deptype( static_cast<db::DependencyType>(reader.getint(5)) );
+        nvras[rid][deptype].insert( capfactory.fromImpl( capability::CapabilityImpl::Ptr(vcap) ) ); 
+      }
+    }
+  }
+  
+  {
+    debug::Measure mnf("read file capabilities");
+    sqlite3_reader reader = select_file_cmd.executereader();
+    while  ( reader.read() )
+    {
+      Resolvable::Kind refer = db_kind2zypp_kind( static_cast<db::Kind>(reader.getint(0)) );
+      capability::FileCap *fcap = new capability::FileCap( refer, reader.getstring(1) + "/" + reader.getstring(2) );
+      zypp::Dep deptype = db_deptype2zypp_deptype( static_cast<db::DependencyType>(reader.getint(3)) );
+      data::RecordId rid = reader.getint64(4);
+      nvras[rid][deptype].insert( capfactory.fromImpl( capability::CapabilityImpl::Ptr(fcap) ) ); 
+    }
+  }
+}
+
+
+
+
+
+
+
+
+/////////////////////////////////////////////////////////////////
+} // namespace plaindir
+///////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////
+} // namespace source
+///////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages