Mailinglist Archive: zypp-commit (606 mails)

< Previous Next >
[zypp-commit] r9521 - in /trunk/sat-solver/src: pool.c pool.h solver.c solver.h
  • From: mlschroe@xxxxxxxxxxxxxxxx
  • Date: Fri, 11 Apr 2008 08:50:10 -0000
  • Message-id: <20080411085011.18F9E262E5@xxxxxxxxxxxxxxxx>
Author: mlschroe
Date: Fri Apr 11 10:50:10 2008
New Revision: 9521

URL: http://svn.opensuse.org/viewcvs/zypp?rev=9521&view=rev
Log:
- change DU interface to use installedmap, like the trivial functions

Modified:
trunk/sat-solver/src/pool.c
trunk/sat-solver/src/pool.h
trunk/sat-solver/src/solver.c
trunk/sat-solver/src/solver.h

Modified: trunk/sat-solver/src/pool.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/pool.c?rev=9521&r1=9520&r2=9521&view=diff
==============================================================================
--- trunk/sat-solver/src/pool.c (original)
+++ trunk/sat-solver/src/pool.c Fri Apr 11 10:50:10 2008
@@ -965,6 +965,7 @@
DUChanges *mps;
struct mptree *mptree;
int addsub;
+ int hasdu;

Id *dirmap;
int nmap;
@@ -1030,6 +1031,7 @@
cbd->nmap = data->dirpool.ndirs;
cbd->olddata = data;
}
+ cbd->hasdu = 1;
if (value->id < 0 || value->id >= cbd->nmap)
return 0;
mp = cbd->dirmap[value->id];
@@ -1063,7 +1065,7 @@
#define MPTREE_BLOCK 15

void
-pool_calc_duchanges(Pool *pool, Queue *pkgs, DUChanges *mps, int nmps)
+pool_calc_duchanges(Pool *pool, Repo *oldinstalled, Map *installedmap,
DUChanges *mps, int nmps)
{
char *p;
const char *path, *compstr;
@@ -1072,7 +1074,11 @@
int pos, compl;
int mp;
struct ducbdata cbd;
+ Solvable *s;
+ Id sp;
+ Map ignoredu;

+ memset(&ignoredu, 0, sizeof(ignoredu));
cbd.mps = mps;
cbd.addsub = 0;
cbd.dirmap = 0;
@@ -1149,36 +1155,76 @@

cbd.mptree = mptree;
cbd.addsub = 1;
- for (i = 0; i < pkgs->count; i++)
+ for (sp = 1, s = pool->solvables + sp; sp < pool->nsolvables; sp++, s++)
{
- Id sp = pkgs->elements[i];
- if (sp > 0)
- repo_search(pool->solvables[sp].repo, sp, SOLVABLE_DISKUSAGE, 0, 0,
solver_fill_DU_cb, &cbd);
+ if (!s->repo || (oldinstalled && s->repo == oldinstalled))
+ continue;
+ if (!MAPTST(installedmap, sp))
+ continue;
+ cbd.hasdu = 0;
+ repo_search(s->repo, sp, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb,
&cbd);
+ if (!cbd.hasdu && oldinstalled)
+ {
+ Id op, *opp;
+ /* no du data available, ignore data of all installed solvables we
obsolete */
+ if (!ignoredu.map)
+ map_init(&ignoredu, oldinstalled->end - oldinstalled->start);
+ if (s->obsoletes)
+ {
+ Id obs, *obsp = s->repo->idarraydata + s->obsoletes;
+ while ((obs = *obsp++) != 0)
+ FOR_PROVIDES(op, opp, obs)
+ if (op >= oldinstalled->start && op < oldinstalled->end)
+ MAPSET(&ignoredu, op - oldinstalled->start);
+ }
+ FOR_PROVIDES(op, opp, s->name)
+ if (pool->solvables[op].name == s->name)
+ if (op >= oldinstalled->start && op < oldinstalled->end)
+ MAPSET(&ignoredu, op - oldinstalled->start);
+ }
}
cbd.addsub = -1;
- for (i = 0; i < pkgs->count; i++)
+ if (oldinstalled)
{
- Id sp = pkgs->elements[i];
- if (sp < 0)
- repo_search(pool->solvables[-sp].repo, -sp, SOLVABLE_DISKUSAGE, 0, 0,
solver_fill_DU_cb, &cbd);
+ /* assumes we allways have du data for installed solvables */
+ FOR_REPO_SOLVABLES(oldinstalled, sp, s)
+ {
+ if (MAPTST(installedmap, sp))
+ continue;
+ if (ignoredu.map && MAPTST(&ignoredu, sp - oldinstalled->start))
+ continue;
+ repo_search(oldinstalled, sp, SOLVABLE_DISKUSAGE, 0, 0,
solver_fill_DU_cb, &cbd);
+ }
}
+ if (ignoredu.map)
+ map_free(&ignoredu);
sat_free(cbd.dirmap);
sat_free(mptree);
}

int
-pool_calc_installsizechange(Pool *pool, Queue *pkgs)
+pool_calc_installsizechange(Pool *pool, Repo *oldinstalled, Map *installedmap)
{
- int i, change;
+ Id sp;
+ Solvable *s;
+ int change = 0;

- change = 0;
- for (i = 0; i < pkgs->count; i++)
+ for (sp = 1, s = pool->solvables + sp; sp < pool->nsolvables; sp++, s++)
+ {
+ if (!s->repo || (oldinstalled && s->repo == oldinstalled))
+ continue;
+ if (!MAPTST(installedmap, sp))
+ continue;
+ change += repo_lookup_num(s, SOLVABLE_INSTALLSIZE);
+ }
+ if (oldinstalled)
{
- Id sp = pkgs->elements[i];
- if (sp > 0)
- change += repo_lookup_num(pool->solvables + sp, SOLVABLE_INSTALLSIZE);
- else if (sp < 0)
- change -= repo_lookup_num(pool->solvables - sp, SOLVABLE_INSTALLSIZE);
+ FOR_REPO_SOLVABLES(oldinstalled, sp, s)
+ {
+ if (MAPTST(installedmap, sp))
+ continue;
+ change -= repo_lookup_num(s, SOLVABLE_INSTALLSIZE);
+ }
}
return change;
}

Modified: trunk/sat-solver/src/pool.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/pool.h?rev=9521&r1=9520&r2=9521&view=diff
==============================================================================
--- trunk/sat-solver/src/pool.h (original)
+++ trunk/sat-solver/src/pool.h Fri Apr 11 10:50:10 2008
@@ -253,8 +253,8 @@
int files;
} DUChanges;

-void pool_calc_duchanges(Pool *pool, Queue *pkgs, DUChanges *mps, int nmps);
-int pool_calc_installsizechange(Pool *pool, Queue *pkgs);
+void pool_calc_duchanges(Pool *pool, struct _Repo *oldinstalled, Map
*installedmap, DUChanges *mps, int nmps);
+int pool_calc_installsizechange(Pool *pool, struct _Repo *oldinstalled, Map
*installedmap);

/* loop over all providers of d */
#define FOR_PROVIDES(v, vp, d)
\

Modified: trunk/sat-solver/src/solver.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/solver.c?rev=9521&r1=9520&r2=9521&view=diff
==============================================================================
--- trunk/sat-solver/src/solver.c (original)
+++ trunk/sat-solver/src/solver.c Fri Apr 11 10:50:10 2008
@@ -4150,63 +4150,35 @@
/***********************************************************************/

void
-solver_calc_changed_pkgs(Solver *solv, Queue *pkgs)
+solver_calc_duchanges(Solver *solv, DUChanges *mps, int nmps)
{
Pool *pool = solv->pool;
- Map installmap;
- Solvable *s;
- int i;
+ Map installedmap;
Id p;
+ int i;

- /* create list of solvables that have to be installed */
- /* (this is actually just a simple sort) */
- map_init(&installmap, pool->nsolvables);
+ map_init(&installedmap, pool->nsolvables);
for (i = 1; i < solv->decisionq.count; i++)
- {
- Id p = solv->decisionq.elements[i];
- if (p < 0)
- continue;
- s = pool->solvables + p;
- if (!s->repo)
- continue;
- if (solv->installed && s->repo == solv->installed)
- continue;
- MAPSET(&installmap, p);
- }
- for (p = 1; p < pool->nsolvables; p++)
- if (MAPTST(&installmap, p))
- queue_push(pkgs, p);
- map_free(&installmap);
- /* run through erase solvable dudata */
- if (solv->installed)
- {
- FOR_REPO_SOLVABLES(solv->installed, p, s)
- {
- if (solv->decisionmap[p] < 0)
- queue_push(pkgs, -p);
- }
- }
-}
-
-void
-solver_calc_duchanges(Solver *solv, DUChanges *mps, int nmps)
-{
- Queue pkgs;
- queue_init(&pkgs);
- solver_calc_changed_pkgs(solv, &pkgs);
- pool_calc_duchanges(solv->pool, &pkgs, mps, nmps);
- queue_free(&pkgs);
+ if ((p = solv->decisionq.elements[i]) > 0)
+ MAPSET(&installedmap, p);
+ pool_calc_duchanges(pool, solv->installed, &installedmap, mps, nmps);
+ map_free(&installedmap);
}

int
solver_calc_installsizechange(Solver *solv)
{
- int change;
- Queue pkgs;
- queue_init(&pkgs);
- solver_calc_changed_pkgs(solv, &pkgs);
- change = pool_calc_installsizechange(solv->pool, &pkgs);
- queue_free(&pkgs);
+ Pool *pool = solv->pool;
+ Map installedmap;
+ Id p;
+ int i, change;
+
+ map_init(&installedmap, pool->nsolvables);
+ for (i = 1; i < solv->decisionq.count; i++)
+ if ((p = solv->decisionq.elements[i]) > 0)
+ MAPSET(&installedmap, p);
+ change = pool_calc_installsizechange(solv->pool, solv->installed,
&installedmap);
+ map_free(&installedmap);
return change;
}


Modified: trunk/sat-solver/src/solver.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/solver.h?rev=9521&r1=9520&r2=9521&view=diff
==============================================================================
--- trunk/sat-solver/src/solver.h (original)
+++ trunk/sat-solver/src/solver.h Fri Apr 11 10:50:10 2008
@@ -284,7 +284,6 @@
return 0;
}

-void solver_calc_changed_pkgs(Solver *solv, Queue *pkgs);
void solver_calc_duchanges(Solver *solv, DUChanges *mps, int nmps);
int solver_calc_installsizechange(Solver *solv);


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

< Previous Next >
This Thread
  • No further messages