#include "zypp/Pathname.h"
#include "zypp/cache/sqlite3x/sqlite3x.hpp"
-#define ZYPP_CACHE_SCHEMA_VERSION 1000
+#define ZYPP_CACHE_SCHEMA_VERSION 1001
///////////////////////////////////////////////////////////////////
namespace zypp
"insert into patch_packages_baseversions (patch_package_id, version, release, epoch) "
"values (:patch_package_id, :version, :release, :epoch)" ));
-
+ update_disk_usage_cmd.reset( new sqlite3_command (con,
+ "insert or replace into resolvable_disk_usage (resolvable_id, dir_name_id, files, size) "
+ "values (:resolvable_id, :dir_name_id, :files, :size)" ));
+
+
// disable autocommit
con.executenonquery("BEGIN;");
}
sqlite3_command_ptr insert_deltarpm_cmd;
sqlite3_command_ptr append_patch_baseversion_cmd;
+ sqlite3_command_ptr update_disk_usage_cmd;
+
map<string, RecordId> name_cache;
map< pair<string,string>, RecordId> type_cache;
int name_cache_hits;
return id;
}
-RecordId CacheStore::consumeChangelog( const data::RecordId & repository_id,
- const data::Resolvable_Ptr & resolvable,
+RecordId CacheStore::consumeChangelog( const data::RecordId &resolvable_id,
const Changelog & changelog )
{
//! \todo maybe appendChangelog(const data::RecordId & resolvable_id, Changelog changelog) will be needed
return data::noRecordId;
}
-RecordId CacheStore::consumeFilelist( const data::RecordId & repository_id,
- const data::Resolvable_Ptr & resolvable,
+RecordId CacheStore::consumeFilelist( const data::RecordId &resolvable_id,
const data::Filenames & filenames )
{
//! \todo maybe consumeFilelist(const data::RecordId & resolvable_id, data::Filenames &) will be needed
return data::noRecordId;
}
+void CacheStore::consumeDiskUsage( const data::RecordId &resolvable_id,
+ const DiskUsage &disk )
+{
+ // iterate over entries
+ for ( DiskUsage::const_iterator it = disk.begin();
+ it != disk.end();
+ ++it )
+ {
+ data::RecordId dirid = lookupOrAppendDirName( (*it).path );
+ try
+ {
+ _pimpl->update_disk_usage_cmd->bind(":resolvable_id", resolvable_id);
+ _pimpl->update_disk_usage_cmd->bind(":dir_name_id", dirid);
+ _pimpl->update_disk_usage_cmd->bind(":files", (int)(*it)._files );
+ _pimpl->update_disk_usage_cmd->bind(":size", (int)(*it)._size );
+ _pimpl->update_disk_usage_cmd->executenonquery();
+ }
+ catch ( const sqlite3x::database_error &e )
+ {
+ ZYPP_RETHROW(e);
+ }
+ }
+}
+
void CacheStore::updatePackageLang( const data::RecordId & resolvable_id,
const data::Packagebase_Ptr & data_r )
{
* \param changelog the changelog
* \todo see implementation
*/
- virtual data::RecordId consumeChangelog( const data::RecordId & repository_id,
- const data::Resolvable_Ptr & resolvable,
+ virtual data::RecordId consumeChangelog( const data::RecordId & resolvable_id,
const Changelog & changelog );
/**
* \param filenames list of filenames the resolvable contains
* \todo see implementation
*/
- virtual data::RecordId consumeFilelist( const data::RecordId &repository_id,
- const data::Resolvable_Ptr & resolvable,
+ virtual data::RecordId consumeFilelist( const data::RecordId & resolvable_id,
const data::Filenames & filenames );
+
+ /**
+ * Implementation of the \ref ResolvableDataConsumer interface
+ *
+ * Consume disk usage of a resolvable, inserting it in the cache.
+ *
+ * Repeated entries are updated (replaced)
+ *
+ * \param repository_id ownership.
+ * \param resolvable resolvable for which the filelist is to be saved
+ * \param disk Disk usage object
+ * \todo see implementation
+ */
+ virtual void consumeDiskUsage( const data::RecordId &resolvable_id,
+ const DiskUsage &disk );
+
/**
* Implementation of the \ref ResolvableDataConsumer interface
);
CREATE INDEX split_capabilities_resolvable ON split_capabilities(resolvable_id);
--- Auto clean capabilities
+------------------------------------------------
+-- File list
+------------------------------------------------
+
+CREATE TABLE resolvable_files (
+ resolvable_id INTEGER REFERENCES resolvables (id)
+ , file_id INTEGER REFERENCES files (id)
+ , PRIMARY KEY ( resolvable_id, file_id )
+);
+
+------------------------------------------------
+-- Disk usage
+------------------------------------------------
+
+CREATE TABLE resolvable_disk_usage (
+ resolvable_id INTEGER REFERENCES resolvables (id)
+ , dir_name_id INTEGER REFERENCES dir_name (id)
+ , files INTEGER
+ , size INTEGER
+ , PRIMARY KEY ( resolvable_id, dir_name_id )
+);
+CREATE INDEX disk_usage_resolvable_id ON resolvable_disk_usage(resolvable_id);
+CREATE INDEX disk_usage_dir_name_id ON resolvable_disk_usage(dir_name_id);
+
+------------------------------------------------
+-- Cleanup
+------------------------------------------------
+
CREATE TRIGGER remove_resolvables
AFTER DELETE ON resolvables
BEGIN
DELETE FROM text_attributes WHERE weak_resolvable_id = old.id;
DELETE FROM numeric_attributes WHERE weak_resolvable_id = old.id;
+ DELETE FROM resolvable_disk_usage WHERE resolvable_id = old.id;
+ DELETE FROM resolvable_files WHERE resolvable_id = old.id;
END;
+
+
+
------------------------------------------------
-- Associate resolvables and repositories
------------------------------------------------
#define ZYPP_ResolvableDataConsumer_H
+#include "zypp/DiskUsage.h"
#include "zypp/data/RecordId.h"
#include "zypp/data/ResolvableData.h"
virtual data::RecordId consumeScript ( const data::RecordId & repository_id, const data::Script_Ptr & ) = 0;
virtual data::RecordId consumePattern ( const data::RecordId & repository_id, const data::Pattern_Ptr & ) = 0;
- virtual data::RecordId consumeChangelog ( const data::RecordId & repository_id, const data::Resolvable_Ptr &, const Changelog & ) = 0;
- virtual data::RecordId consumeFilelist ( const data::RecordId & repository_id, const data::Resolvable_Ptr &, const data::Filenames & ) = 0;
-
+ virtual data::RecordId consumeChangelog ( const data::RecordId & resolvable_id, const Changelog & ) = 0;
+ virtual data::RecordId consumeFilelist ( const data::RecordId & resolvable_id, const data::Filenames & ) = 0;
+ virtual void consumeDiskUsage ( const data::RecordId &resolvable_id, const DiskUsage &disk ) = 0;
+
virtual void updatePackageLang( const data::RecordId & resolvable_id, const data::Packagebase_Ptr & data_r ) = 0;
+
};
} // namespace parser
bool RepoParser::Impl::other_CB(
const data::Resolvable_Ptr & res_ptr, const Changelog & changelog)
{
- _consumer.consumeChangelog(_repository_id, res_ptr, changelog);
+ //_consumer.consumeChangelog(_repository_id, res_ptr, changelog);
/*
DBG << "got changelog for "
<< res_ptr->name << res_ptr->edition << " "
bool RepoParser::Impl::filelist_CB(
const data::Resolvable_Ptr & res_ptr, const data::Filenames & filenames)
{
- _consumer.consumeFilelist(_repository_id, res_ptr, filenames);
+ //_consumer.consumeFilelist(_repository_id, res_ptr, filenames);
/*
DBG << "got filelist for "
<< res_ptr->name << res_ptr->edition << " "