Author: mlandres
Date: Thu Dec 18 13:05:46 2008
New Revision: 11949
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11949&view=rev
Log:
- Add Package::filelist, faster and less memory consuming
implementation of Package::filenames (now deprecated).
Modified:
trunk/libzypp/devel/devel.ma/Test.cc
trunk/libzypp/package/libzypp.changes
trunk/libzypp/zypp/Package.cc
trunk/libzypp/zypp/Package.h
trunk/libzypp/zypp/sat/LookupAttrTools.h
Modified: trunk/libzypp/devel/devel.ma/Test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/Test.cc?rev=11949&r1=11948&r2=11949&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/Test.cc (original)
+++ trunk/libzypp/devel/devel.ma/Test.cc Thu Dec 18 13:05:46 2008
@@ -2,23 +2,45 @@
#include
#include
+#include
- static std::string pidAndAppname()
+static std::string pidAndAppname()
+{
+ static std::string _val;
+ if ( _val.empty() )
{
- static std::string _val;
- if ( _val.empty() )
- {
- pid_t mypid = getpid();
- Pathname p( "/proc/"+str::numstring(mypid)+"/exe" );
- Pathname myname( filesystem::readlink( p ) );
-
- _val += str::numstring(mypid);
- _val += ":";
- _val += myname.basename();
- }
- return _val;
+ pid_t mypid = getpid();
+ Pathname p( "/proc/"+str::numstring(mypid)+"/exe" );
+ Pathname myname( filesystem::readlink( p ) );
+
+ _val += str::numstring(mypid);
+ _val += ":";
+ _val += myname.basename();
+ }
+ return _val;
+}
+
+bool solve()
+{
+ static unsigned run = 0;
+ USR << "Solve " << run++ << endl;
+ bool rres = false;
+ {
+ zypp::base::LogControl::TmpLineWriter shutUp;
+ rres = getZYpp()->resolver()->resolvePool();
+ }
+ if ( ! rres )
+ {
+ ERR << "resolve " << rres << endl;
+ getZYpp()->resolver()->problems();
+ return false;
}
+ return true;
+}
+
+typedef sat::ArrayAttrstd::string,std::string FileList;
+
/******************************************************************
**
** FUNCTION NAME : main
@@ -28,37 +50,60 @@
{
INT << "===[START]==========================================" << endl;
- SEC << pidAndAppname() << endl;
-
-
- INT << "===[END]============================================" << endl << endl;
- return 0;
- Pathname mroot( "/tmp/Bb" );
+ Pathname mroot( "/tmp/ToolScanRepos" );
TestSetup test( mroot, Arch_x86_64 );
- test.loadRepo( "/Local/ROOT/cache/raw/11.1-update" );
- test.loadRepo( "/Local/ROOT/cache/raw/11.0-update" );
+ test.loadRepo("/Local/ROOT/cache/solv/@System/solv");
- sat::Pool satpool( test.satpool() );
- for_( it, satpool.reposBegin(), satpool.reposEnd() )
+ ResPool pool( test.pool() );
+ {
+ Measure x("filelist");
+ unsigned p = 0;
+ unsigned f = 0;
+ std::string a;
+ for_( it, pool.byKindBegin<Package>(), pool.byKindEnd<Package>() )
+ {
+ ++p;
+ f += (*it)->asKind<Package>()->filelist().size();
+ for_( i, (*it)->asKind<Package>()->filelist().begin(), (*it)->asKind<Package>()->filelist().end() )
+ a = *i;
+ }
+ SEC << p << " : " << f << endl;
+ }
{
- MIL << *it << endl;
- DBG << it->generatedTimestamp() << endl;
- DBG << it->suggestedExpirationTimestamp() << endl;
+ Measure x("filenames");
+ unsigned p = 0;
+ unsigned f = 0;
+ std::string a;
+ for_( it, pool.byKindBegin<Package>(), pool.byKindEnd<Package>() )
+ {
+ ++p;
+ std::liststd::string l( (*it)->asKind<Package>()->filenames() );
+ f += l.size();
+ for_( i, l.begin(), l.end() )
+ a = *i;
+ }
+ SEC << p << " : " << f << endl;
}
INT << "===[END]============================================" << endl << endl;
return 0;
- sat::LookupRepoAttr q( sat::SolvAttr::repositoryAddedFileProvides );
- USR << q << endl;
- USR << dump(q) << endl;
- for_( it, q.begin(), q.end() )
- {
- MIL << it << endl;
- }
+ //ui::Selectable::Ptr getSel( const std::string & name_r )
+ getSel<Package>( "gcompris" )->setToInstall();
+ vdumpPoolStats( USR << "Transacting:"<< endl,
+ make_filter_beginresfilter::ByTransact(pool),
+ make_filter_endresfilter::ByTransact(pool) ) << endl;
+
+ if ( solve() )
+ {
+ vdumpPoolStats( USR << "Transacting:"<< endl,
+ make_filter_beginresfilter::ByTransact(pool),
+ make_filter_endresfilter::ByTransact(pool) ) << endl;
+ SEC << getSel<Package>( "librsvg" ) << endl;
+ }
INT << "===[END]============================================" << endl << endl;
return 0;
}
Modified: trunk/libzypp/package/libzypp.changes
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=11949&r1=11948&r2=11949&view=diff
==============================================================================
--- trunk/libzypp/package/libzypp.changes (original)
+++ trunk/libzypp/package/libzypp.changes Thu Dec 18 13:05:46 2008
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Thu Dec 18 13:02:27 CET 2008 - ma@suse.de
+
+- Add Package::filelist, faster and less memory consuming
+ implementation of Package::filenames (now deprecated).
+- revision 11949
+
+-------------------------------------------------------------------
Thu Dec 11 21:39:50 CET 2008 - ma@suse.de
- Add str::hexencode and str::hexdecode to encode special characters
Modified: trunk/libzypp/zypp/Package.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Package.cc?rev=11949&r1=11948&r2=11949&view=diff
==============================================================================
--- trunk/libzypp/zypp/Package.cc (original)
+++ trunk/libzypp/zypp/Package.cc Thu Dec 18 13:05:46 2008
@@ -122,15 +122,13 @@
return ret;
}
+ Package::FileList Package::filelist() const
+ { return FileList( sat::SolvAttr::filelist, satSolvable() ); }
+
std::liststd::string Package::filenames() const
{
- std::liststd::string files;
- sat::LookupAttr q( sat::SolvAttr::filelist, *this );
- for_( it, q.begin(), q.end() )
- {
- files.push_back(it.asString());
- }
- return files;
+ FileList f( filelist() );
+ return std::liststd::string( f.begin(), f.end() );
}
CheckSum Package::checksum() const
Modified: trunk/libzypp/zypp/Package.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Package.h?rev=11949&r1=11948&r2=11949&view=diff
==============================================================================
--- trunk/libzypp/zypp/Package.h (original)
+++ trunk/libzypp/zypp/Package.h Thu Dec 18 13:05:46 2008
@@ -39,13 +39,14 @@
public:
typedef sat::ArrayAttr Keywords;
+ typedef sat::ArrayAttrstd::string,std::string FileList;
public:
/**
* Returns the level of supportability the vendor
* gives to this package.
- *
+ *
* This is one value from \ref VendorSupportOption
*/
VendorSupportOption vendorSupport() const;
@@ -77,8 +78,15 @@
ByteCount sourcesize() const;
/** */
std::liststd::string authors() const;
- /** */
- std::liststd::string filenames() const;
+
+ /** Return the packages filelist (if available).
+ * The returned \ref FileList appears to be a container of
+ * \c std::string. In fact it is a query, so it does not
+ * consume much memory.
+ */
+ FileList filelist() const;
+ /** \deprecated Use filelist, it's faster and saves memeory. */
+ std::liststd::string filenames() const ZYPP_DEPRECATED;
/** Name of the source rpm this package was built from.
*/
Modified: trunk/libzypp/zypp/sat/LookupAttrTools.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/LookupAttrTools.h?rev=11949&r1=11948&r2=11949&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/LookupAttrTools.h (original)
+++ trunk/libzypp/zypp/sat/LookupAttrTools.h Thu Dec 18 13:05:46 2008
@@ -172,7 +172,8 @@
{}
public:
- typedef sat::LookupAttr::transformIterator<_ResultT,_AttrT> iterator;
+ typedef LookupAttr::transformIterator<_ResultT,_AttrT> iterator;
+ typedef LookupAttr::size_type size_type;
iterator begin() const
{ return iterator( _q.begin() ); }
@@ -183,6 +184,14 @@
bool empty() const
{ return _q.empty(); }
+ size_type size() const
+ {
+ size_type count = 0;
+ for_( it, begin(), end() )
+ ++count;
+ return count;
+ }
+
public:
iterator find( const _ResultT & key_r ) const
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org