Mailinglist Archive: zypp-commit (149 mails)

< Previous Next >
[zypp-commit] r5413 - in /trunk/libzypp/zypp2: cache/CacheStore.cpp cache/CacheStore.h cache/schema/schema.sql source/cached/CachedSourceImpl.cc
  • From: dmacvicar@xxxxxxxxxxxxxxxx
  • Date: Thu, 19 Apr 2007 13:59:31 -0000
  • Message-id: <20070419135931.314F635597@xxxxxxxxxxxxxxxx>
Author: dmacvicar
Date: Thu Apr 19 15:59:30 2007
New Revision: 5413

URL: http://svn.opensuse.org/viewcvs/zypp?rev=5413&view=rev
Log:
denormalze dependencies one level. one left

Modified:
    trunk/libzypp/zypp2/cache/CacheStore.cpp
    trunk/libzypp/zypp2/cache/CacheStore.h
    trunk/libzypp/zypp2/cache/schema/schema.sql
    trunk/libzypp/zypp2/source/cached/CachedSourceImpl.cc

Modified: trunk/libzypp/zypp2/cache/CacheStore.cpp
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CacheStore.cpp?rev=5413&r1=5412&r2=5413&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/CacheStore.cpp (original)
+++ trunk/libzypp/zypp2/cache/CacheStore.cpp Thu Apr 19 15:59:30 2007
@@ -61,9 +61,7 @@
   sqlite3_command_ptr insert_dependency_entry_cmd;
   
   sqlite3_command_ptr append_file_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_named_dependency_cmd;
   
   sqlite3_command_ptr append_resolvable_cmd;
   
@@ -113,10 +111,8 @@
   _pimpl->insert_file_cmd.reset( new sqlite3_command( _pimpl->con, "insert into files (dir_name_id,file_name_id) values (:dir_name_id,:file_name_id);" ));
 
   _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_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_file_dependency_cmd.reset( new sqlite3_command( _pimpl->con, "insert into file_capabilities ( capability_id, file_id ) values ( :capability_id, :file_id );" ));
+  _pimpl->append_named_dependency_cmd.reset( new sqlite3_command( _pimpl->con, "insert into named_capabilities ( capability_id, name_id, version, release, epoch, relation ) values ( :capability_id, :name_id, :version, :release, :epoch, :relation );" ));
   
   _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 );" ));
   
@@ -209,31 +205,31 @@
   }
 }
 
-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);
-}
+// 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 )
 {
@@ -241,15 +237,17 @@
     ZYPP_THROW(Exception("bad versioned dep"));
   //DBG << "versioned : " << cap << endl;
  
-  data::RecordId dependency_id = appendDependencyEntry( resolvable_id, deptype, cap->refers() );
+  data::RecordId capability_id = appendDependencyEntry( resolvable_id, deptype, cap->refers() );
   data::RecordId name_id = lookupOrAppendName(cap->name());
   
-  data::RecordId named_id = lookupOrAppendNamedDependencyEntry(name_id, cap->edition(), cap->op());
-  
-  _pimpl->insert_named_dependency_cmd->bind( ":capability_id", dependency_id);
-  _pimpl->insert_named_dependency_cmd->bind( ":named_capability_id", named_id);
+  _pimpl->append_named_dependency_cmd->bind( ":capability_id", capability_id);
+  _pimpl->append_named_dependency_cmd->bind( ":name_id", name_id);
+  _pimpl->append_named_dependency_cmd->bind( ":version", cap->edition().version() );
+  _pimpl->append_named_dependency_cmd->bind( ":release", cap->edition().release() );
+  _pimpl->append_named_dependency_cmd->bind( ":epoch", static_cast<int>( cap->edition().epoch() ) );
+  _pimpl->append_named_dependency_cmd->bind( ":relation", zypp_rel2db_rel( cap->op() ) );
+  _pimpl->append_named_dependency_cmd->executenonquery();
 
-  _pimpl->insert_named_dependency_cmd->executenonquery();
   //delete cmd;
 }
 
@@ -258,10 +256,10 @@
   if ( !cap )
     ZYPP_THROW(Exception("bad file cap"));
 
-  data::RecordId dependency_id = appendDependencyEntry( resolvable_id, deptype, cap->refers() );
+  data::RecordId capability_id = appendDependencyEntry( resolvable_id, deptype, cap->refers() );
   data::RecordId file_id = lookupOrAppendFile(cap->filename());
   
-  _pimpl->append_file_dependency_cmd->bind( ":dependency_id", dependency_id);
+  _pimpl->append_file_dependency_cmd->bind( ":capability_id", capability_id);
   _pimpl->append_file_dependency_cmd->bind( ":file_id", file_id);
 
   _pimpl->append_file_dependency_cmd->executenonquery();

Modified: trunk/libzypp/zypp2/cache/CacheStore.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/CacheStore.h?rev=5413&r1=5412&r2=5413&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/CacheStore.h (original)
+++ trunk/libzypp/zypp2/cache/CacheStore.h Thu Apr 19 15:59:30 2007
@@ -241,9 +241,6 @@
       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/schema/schema.sql
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/cache/schema/schema.sql?rev=5413&r1=5412&r2=5413&view=diff
==============================================================================
--- trunk/libzypp/zypp2/cache/schema/schema.sql (original)
+++ trunk/libzypp/zypp2/cache/schema/schema.sql Thu Apr 19 15:59:30 2007
@@ -38,7 +38,7 @@
 DROP TABLE IF EXISTS capabilities;
 DROP INDEX IF EXISTS package_details_resolvable_id;
 DROP INDEX IF EXISTS capability_resolvable;
-DROP INDEX IF EXISTS named_capabilities_dependency_id;
+DROP INDEX IF EXISTS named_capabilities_capability_id;
 
 ------------------------------------------------
 -- version metadata, probably not needed, there
@@ -319,34 +319,26 @@
 
 CREATE TABLE named_capabilities (
    id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL 
---  , dependency_id INTEGER REFERENCES capabilities (id)
+  , capability_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_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 INDEX named_capabilities_capability_id ON named_capabilities (capability_id);
+CREATE INDEX named_capabilities_name ON named_capabilities(name_id);
 
 CREATE TABLE file_capabilities (
    id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL 
-  , dependency_id INTEGER REFERENCES capabilities (id)
+  , capability_id INTEGER REFERENCES capabilities (id)
   , file_id INTEGER REFERENCES files(id)
 );
-CREATE INDEX file_capabilities_dependency_id ON file_capabilities (dependency_id);
+CREATE INDEX file_capabilities_capability_id ON file_capabilities (capability_id);
 
 CREATE TABLE split_capabilities (
    id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL 
-  , dependency_id INTEGER REFERENCES capabilities (id)
+  , capability_id INTEGER REFERENCES capabilities (id)
   , name_id INTEGER REFERENCES names(id)
   , file_id INTEGER REFERENCES files(id)
 );

Modified: trunk/libzypp/zypp2/source/cached/CachedSourceImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp2/source/cached/CachedSourceImpl.cc?rev=5413&r1=5412&r2=5413&view=diff
==============================================================================
--- trunk/libzypp/zypp2/source/cached/CachedSourceImpl.cc (original)
+++ trunk/libzypp/zypp2/source/cached/CachedSourceImpl.cc Thu Apr 19 15:59:30 2007
@@ -91,12 +91,11 @@
       arch = Arch(archstring);
 
       // Collect basic Resolvable data
-      NVRAD dataCollect( reader.getstring(1),
+      nvras[id] = NVRAD( reader.getstring(1),
                        Edition( reader.getstring(2), reader.getstring(3), reader.getint(4) ),
                        arch,
                        deps
                      );
-      nvras[id] = dataCollect;
     }
     
     MIL << "Done reading resolvables nvra" << endl;
@@ -133,8 +132,8 @@
 //       
 //     }
 //   }
-  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;");
+  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, capabilities c where v.name_id=n.id and c.id=v.capability_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.capability_id;");
   
   {
     debug::Measure mnc("read named capabilities");
@@ -173,6 +172,8 @@
       nvras[rid][deptype].insert( capfactory.fromImpl( capability::CapabilityImpl::Ptr(fcap) ) ); 
     }
   }
+  
+  MIL << nvras.size() << " capabilities" << endl;
 }
 
 

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

< Previous Next >
This Thread
  • No further messages