Author: mlschroe
Date: Tue Dec 4 18:44:31 2007
New Revision: 8024
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8024&view=rev
Log:
- switch to new solv format using schemata
please regenerate all solv files...
- split whatprovides array into whatprovides and whatprovides_rel so
that we can add new ids while keeping the whatprovides information
- start to implement some search/lookup functions in repo.c
needs quite a bit more love...
Modified:
trunk/sat-solver/doc/README.format
trunk/sat-solver/src/pool.c
trunk/sat-solver/src/pool.h
trunk/sat-solver/src/poolid.c
trunk/sat-solver/src/poolid_private.h
trunk/sat-solver/src/pooltypes.h
trunk/sat-solver/src/repo.c
trunk/sat-solver/src/repo_solv.c
trunk/sat-solver/src/solver.c
trunk/sat-solver/tools/dumpsolv.c
trunk/sat-solver/tools/repo_write.c
Modified: trunk/sat-solver/doc/README.format
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/doc/README.format?rev=8024&r1=8023&r2=8024&view=diff
==============================================================================
--- trunk/sat-solver/doc/README.format (original)
+++ trunk/sat-solver/doc/README.format Tue Dec 4 18:44:31 2007
@@ -2,9 +2,11 @@
These files have the following format:
+V0 format
+=========
MAGIC: 'SOLV'
- U32: SOLVVERSION
+ U32: 0
-- sizes --
@@ -36,3 +38,58 @@
U8*: BITS
U8*: DATA
+
+V1 format
+=========
+
+ MAGIC: 'SOLV'
+ U32: 1
+
+ U32: NUMID /* number of Ids (names) */
+ U32: NUMREL /* number of RelDeps (dependencies) */
+ U32: NUMITEM /* number of items (packages) */
+ U32: NUMKEYS
+ U32: NUMSCHEMATA /* number of schemata */
+ U32: NUMINFO
+ U32: FLAGS /* solv file flags */
+ 1:HAS_PACKED_SIZES
+ 2:VERTICAL_PACKING
+
+ -- string data --
+ ID: SIZEID /* total size of string buffer */
+ U8*: DICT (SIZE SIZEID) /* (raw) string buffer */
+
+ -- reldep data --
+ U8*: RELDICT /* Buffer for RandDeps (Id,Id,u8) */
+
+
+ -- key data --
+ NUMKEYS *
+ ID: name
+ ID: type
+ ID: expanded num/size
+
+ -- schemata data --
+ ID: expanded schemata size
+ NUMSCHEMATA *
+ IDARRAY* keys
+
+ -- file information --
+ NUMINFO *
+ ID schema
+ U8 *data
+
+ -- packed item sizes (optional) --
+ ID*: sizeis
+
+IF_HORIZONTAL
+ -- item data --
+ NUMITEM *
+ ID schema
+ U8* data
+
+IF_VERTICAL
+ -- item data --
+ NUMINFO *
+ ID schema
+ U8* data
Modified: trunk/sat-solver/src/pool.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/pool.c?rev=8024&r1=8023&r2=8024&view=diff
==============================================================================
--- trunk/sat-solver/src/pool.c (original)
+++ trunk/sat-solver/src/pool.c Tue Dec 4 18:44:31 2007
@@ -28,17 +28,6 @@
#define SOLVABLE_BLOCK 255
-// reset all whatprovides
-//
-void
-pool_freewhatprovides(Pool *pool)
-{
- pool->whatprovides = xfree(pool->whatprovides);
- pool->whatprovidesdata = xfree(pool->whatprovidesdata);
- pool->whatprovidesdataoff = 0;
- pool->whatprovidesdataleft = 0;
-}
-
// list of string constants, so we can do pointer/Id instead of string comparison
// index into array matches ID_xxx constants in pool.h
@@ -71,8 +60,7 @@
0
};
-// create pool
-//
+/* create pool */
Pool *
pool_create(void)
{
@@ -101,8 +89,7 @@
}
-// empty the pool
-//
+/* free all the resources of our pool */
void
pool_free(Pool *pool)
{
@@ -204,6 +191,12 @@
return *(Id *)ap - *(Id *)bp;
}
+/*
+ * pool_shrink_whatprovides - unify whatprovides data
+ *
+ * whatprovides_rel must be empty for this to work!
+ *
+ */
static void
pool_shrink_whatprovides(Pool *pool)
{
@@ -287,10 +280,9 @@
/*
* pool_createwhatprovides()
*
- * create hashes over complete pool to ease lookups
+ * create hashes over pool of solvables to ease provide lookups
*
*/
-
void
pool_createwhatprovides(Pool *pool)
{
@@ -305,10 +297,11 @@
POOL_DEBUG(SAT_DEBUG_STATS, "number of solvables: %d\n", pool->nsolvables);
POOL_DEBUG(SAT_DEBUG_STATS, "number of ids: %d + %d\n", pool->ss.nstrings, pool->nrels);
- pool_freeidhashes(pool);
+ pool_freeidhashes(pool); /* XXX: should not be here! */
pool_freewhatprovides(pool);
- num = pool->ss.nstrings + pool->nrels;
- whatprovides = (Offset *)xcalloc(num, sizeof(Offset));
+ num = pool->ss.nstrings;
+ pool->whatprovides = whatprovides = (Offset *)xcalloc((num + WHATPROVIDES_BLOCK) & ~WHATPROVIDES_BLOCK, sizeof(Offset));
+ pool->whatprovides_rel = (Offset *)xcalloc((pool->nrels + WHATPROVIDES_BLOCK) & ~WHATPROVIDES_BLOCK, sizeof(Offset));
/* count providers for each name */
for (i = 1; i < pool->nsolvables; i++)
@@ -322,7 +315,7 @@
pp = s->repo->idarraydata + s->provides;
while ((id = *pp++) != ID_NULL)
{
- if (ISRELDEP(id))
+ while (ISRELDEP(id))
{
Reldep *rd = GETRELDEP(pool, id);
id = rd->name;
@@ -345,8 +338,9 @@
}
POOL_DEBUG(SAT_DEBUG_STATS, "provide ids: %d\n", np);
- extra = 2 * pool->nrels;
+ /* reserve some space for relation data */
+ extra = 2 * pool->nrels;
if (extra < 256)
extra = 256;
@@ -369,7 +363,7 @@
pp = s->repo->idarraydata + s->provides;
while ((id = *pp++) != 0)
{
- if (ISRELDEP(id))
+ while (ISRELDEP(id))
{
Reldep *rd = GETRELDEP(pool, id);
id = rd->name;
@@ -386,25 +380,38 @@
*d = i; /* put solvable Id into data */
}
}
- pool->whatprovides = whatprovides;
pool->whatprovidesdata = whatprovidesdata;
pool->whatprovidesdataoff = off;
pool->whatprovidesdataleft = extra;
pool_shrink_whatprovides(pool);
}
+/*
+ * free all of our whatprovides data
+ * be careful, everything internalized with pool_queuetowhatprovides is gone, too
+ */
+void
+pool_freewhatprovides(Pool *pool)
+{
+ pool->whatprovides = xfree(pool->whatprovides);
+ pool->whatprovides_rel = xfree(pool->whatprovides_rel);
+ pool->whatprovidesdata = xfree(pool->whatprovidesdata);
+ pool->whatprovidesdataoff = 0;
+ pool->whatprovidesdataleft = 0;
+}
+
/******************************************************************************/
/*
- * pool_queuetowhatprovides
+ * pool_queuetowhatprovides - add queue contents to whatprovidesdata
*
* on-demand filling of provider information
* move queue data into whatprovidesdata
* q: queue of Ids
* returns: Offset into whatprovides
+ *
*/
-
Id
pool_queuetowhatprovides(Pool *pool, Queue *q)
{
@@ -458,7 +465,7 @@
Id pid, *pidp;
Id p, *pp, *pp2, *pp3;
- d = GETRELID(pool, d);
+ d = GETRELID(d);
queue_init_buffer(&plist, buf, sizeof(buf)/sizeof(*buf));
switch (flags)
{
@@ -491,7 +498,7 @@
if (p > 1)
{
queue_free(&plist);
- pool->whatprovides[d] = p;
+ pool->whatprovides_rel[d] = p;
return pool->whatprovidesdata + p;
}
if (p == 1)
@@ -560,10 +567,10 @@
#if 0
POOL_DEBUG(DEBUG_1, "addrelproviders: adding %d packages to %d\n", plist.count, d);
#endif
- pool->whatprovides[d] = pool_queuetowhatprovides(pool, &plist);
+ pool->whatprovides_rel[d] = pool_queuetowhatprovides(pool, &plist);
queue_free(&plist);
- return pool->whatprovidesdata + pool->whatprovides[d];
+ return pool->whatprovidesdata + pool->whatprovides_rel[d];
}
/*************************************************************************/
Modified: trunk/sat-solver/src/pool.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/pool.h?rev=8024&r1=8023&r2=8024&view=diff
==============================================================================
--- trunk/sat-solver/src/pool.h (original)
+++ trunk/sat-solver/src/pool.h Tue Dec 4 18:44:31 2007
@@ -87,6 +87,8 @@
* whatprovidesdata[Offset] -> ID_NULL-terminated list of solvables providing Id
*/
Offset *whatprovides; /* Offset to providers of a specific name, Id -> Offset */
+ Offset *whatprovides_rel; /* Offset to providers of a specific relation, Id -> Offset */
+
Id *whatprovidesdata; /* Ids of solvable providing Id */
Offset whatprovidesdataoff; /* next free slot within whatprovidesdata */
int whatprovidesdataleft; /* number of 'free slots' within whatprovidesdata */
@@ -133,7 +135,7 @@
#define MAKERELDEP(id) ((id) | 0x80000000)
#define ISRELDEP(id) (((id) & 0x80000000) != 0)
-#define GETRELID(pool, id) ((pool)->ss.nstrings + ((id) ^ 0x80000000)) /* returns Id */
+#define GETRELID(id) ((id) ^ 0x80000000) /* returns Id */
#define GETRELDEP(pool, id) ((pool)->rels + ((id) ^ 0x80000000)) /* returns Reldep* */
#define REL_GT 1
@@ -145,6 +147,10 @@
#define REL_WITH 18
#define REL_NAMESPACE 19
+#if !defined(__GNUC__) && !defined(__attribute__)
+# define __attribute__(x)
+#endif
+
/**
* Creates a new pool
*/
@@ -154,11 +160,7 @@
*/
extern void pool_free(Pool *pool);
-extern void pool_debug(Pool *pool, int type, const char *format, ...)
-#ifdef __GNUC__
- __attribute__((format(printf, 3, 4)))
-#endif
-;
+extern void pool_debug(Pool *pool, int type, const char *format, ...) __attribute__((format(printf, 3, 4)));
/**
* Solvable management
@@ -197,9 +199,9 @@
Id v;
if (!ISRELDEP(d))
return pool->whatprovidesdata + pool->whatprovides[d];
- v = GETRELID(pool, d);
- if (pool->whatprovides[v])
- return pool->whatprovidesdata + pool->whatprovides[v];
+ v = GETRELID(d);
+ if (pool->whatprovides_rel[v])
+ return pool->whatprovidesdata + pool->whatprovides_rel[v];
return pool_addrelproviders(pool, d);
}
Modified: trunk/sat-solver/src/poolid.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/poolid.c?rev=8024&r1=8023&r2=8024&view=diff
==============================================================================
--- trunk/sat-solver/src/poolid.c (original)
+++ trunk/sat-solver/src/poolid.c Tue Dec 4 18:44:31 2007
@@ -21,18 +21,19 @@
#include "util.h"
-// intern string into pool
-// return Id
+/* intern string into pool, return id */
Id
str2id(Pool *pool, const char *str, int create)
{
- int old_nstrings = pool->ss.nstrings;
+ int oldnstrings = pool->ss.nstrings;
Id id = stringpool_str2id (&pool->ss, str, create);
- /* If we changed the ID->string relations we need to get rid of an
- existing provides lookup cache. */
- if (old_nstrings != pool->ss.nstrings)
- pool_freewhatprovides(pool);
+ if (create && oldnstrings != pool->ss.nstrings && (id & WHATPROVIDES_BLOCK) == 0)
+ {
+ /* grow whatprovides array */
+ pool->whatprovides = xrealloc(pool->whatprovides, (id + (WHATPROVIDES_BLOCK + 1)) * sizeof(Offset));
+ memset(pool->whatprovides + id, 0, (WHATPROVIDES_BLOCK + 1) * sizeof(Offset));
+ }
return id;
}
@@ -51,7 +52,7 @@
hashtbl = pool->relhashtbl;
ran = pool->rels;
- // extend hashtable if needed
+ /* extend hashtable if needed */
if (pool->nrels * 2 > hashmask)
{
xfree(pool->relhashtbl);
@@ -68,8 +69,7 @@
}
}
- // compute hash and check for match
-
+ /* compute hash and check for match */
h = relhash(name, evr, flags) & hashmask;
hh = HASHCHAIN_START;
while ((id = hashtbl[h]) != 0)
@@ -84,10 +84,8 @@
if (!create)
return ID_NULL;
- pool_freewhatprovides(pool);
-
id = pool->nrels++;
- // extend rel space if needed
+ /* extend rel space if needed */
if ((id & REL_BLOCK) == 0)
pool->rels = xrealloc(pool->rels, ((pool->nrels + REL_BLOCK) & ~REL_BLOCK) * sizeof(Reldep));
hashtbl[h] = id;
@@ -95,6 +93,13 @@
ran->name = name;
ran->evr = evr;
ran->flags = flags;
+
+ /* extend whatprovides_rel if needed */
+ if (pool->whatprovides_rel && (id & WHATPROVIDES_BLOCK) == 0)
+ {
+ pool->whatprovides_rel = xrealloc(pool->whatprovides_rel, (id + (WHATPROVIDES_BLOCK + 1)) * sizeof(Offset));
+ memset(pool->whatprovides_rel + id, 0, (WHATPROVIDES_BLOCK + 1) * sizeof(Offset));
+ }
return MAKERELDEP(id);
}
@@ -236,7 +241,7 @@
void
pool_shrink_strings(Pool *pool)
{
- stringpool_shrink (&pool->ss);
+ stringpool_shrink(&pool->ss);
}
void
Modified: trunk/sat-solver/src/poolid_private.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/poolid_private.h?rev=8024&r1=8023&r2=8024&view=diff
==============================================================================
--- trunk/sat-solver/src/poolid_private.h (original)
+++ trunk/sat-solver/src/poolid_private.h Tue Dec 4 18:44:31 2007
@@ -13,10 +13,11 @@
#ifndef SATSOLVER_POOLID_PRIVATE_H
#define SATSOLVER_POOLID_PRIVATE_H
-// the size of all buffers is incremented in blocks
-// these are the block values (increment values) for the
-// rel hashtable
-//
-#define REL_BLOCK 1023 // hashtable for relations
+/* the size of all buffers is incremented in blocks
+ * these are the block values (increment values) for the
+ * rel hashtable
+ */
+#define REL_BLOCK 1023 /* hashtable for relations */
+#define WHATPROVIDES_BLOCK 1023
#endif /* SATSOLVER_POOLID_PRIVATE_H */
Modified: trunk/sat-solver/src/pooltypes.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/pooltypes.h?rev=8024&r1=8023&r2=8024&view=diff
==============================================================================
--- trunk/sat-solver/src/pooltypes.h (original)
+++ trunk/sat-solver/src/pooltypes.h Tue Dec 4 18:44:31 2007
@@ -14,7 +14,10 @@
#define SATSOLVER_POOLTYPES_H
/* version number for .solv files */
-#define SOLV_VERSION 0
+#define SOLV_VERSION_0 0
+#define SOLV_VERSION_1 1
+#define SOLV_FLAG_PACKEDSIZES 1
+#define SOLV_FLAG_VERTICAL 2
struct _Stringpool;
typedef struct _Stringpool Stringpool;
Modified: trunk/sat-solver/src/repo.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repo.c?rev=8024&r1=8023&r2=8024&view=diff
==============================================================================
--- trunk/sat-solver/src/repo.c (original)
+++ trunk/sat-solver/src/repo.c Tue Dec 4 18:44:31 2007
@@ -444,4 +444,103 @@
return supplements;
}
+#if 0
+void
+repodata_search(Repodata *data, Id key)
+{
+}
+
+const char *
+repodata_lookup_id(Repodata *data, Id num, Id key)
+{
+ Id id, k, *kp, *keyp;
+
+ fseek(data->fp, data->itemoffsets[num] , SEEK_SET);
+ Id *keyp = data->schemadata + data->schemata[read_id(data->fp, data->numschemata)];
+ /* make sure our schema contains the key */
+ for (kp = keyp; (k = *kp++) != 0)
+ if (k == key)
+ break;
+ if (k == 0)
+ return 0;
+ /* get it */
+ while ((k = *keyp++) != 0)
+ {
+ if (k == key)
+ break;
+ switch (keys[key].type)
+ {
+ case TYPE_ID:
+ while ((read_u8(data->fp) & 0x80) != 0)
+ ;
+ break;
+ case TYPE_U32:
+ read_u32(data->fp);
+ break;
+ case TYPE_STR:
+ while(read_u8(data->fp) != 0)
+ ;
+ break;
+ case TYPE_IDARRAY:
+ while ((read_u8(data->fp) & 0xc0) != 0)
+ ;
+ break;
+ }
+ }
+ id = read_id(data->fp, 0);
+ return data->ss.stringspace + data->ss.strings[id];
+}
+
+Id
+repo_lookup_id(Solvable *s, Id key)
+{
+ Solvable *rs;
+ Repo *repo = s->repo;
+ Repodata *data;
+ int i, j, n;
+
+ switch(key)
+ {
+ case SOLVABLE_NAME:
+ return s->name;
+ case SOLVABLE_ARCH:
+ return s->arch;
+ case SOLVABLE_EVR:
+ return s->evr;
+ case SOLVABLE_VENDOR:
+ return s->vendor;
+ }
+ /* convert solvable id into repo item count */
+ if (repo->end - repo->start + 1 == repo->nsolvables)
+ {
+ n = (s - pool->solvables);
+ if (n < repo->start || n > repo->end)
+ return 0;
+ n -= repo->start;
+ }
+ else
+ {
+ for (i = repo->start, rs = pool->solvables + i, n = 0; i < repo->end; i++, rs++)
+ {
+ if (rs->repo != repo)
+ continue;
+ if (rs == s)
+ break;
+ n++;
+ }
+ if (i == repo->end)
+ return 0;
+ }
+ for (i = 0, data = repo->repodata; i < repo->nrepodata; i++, data++)
+ {
+ for (j = 0; j < data->nkeys; j++)
+ {
+ if (data->keys[j].name == key && data->keys[j].type == TYPE_ID)
+ return repodata_lookup_id(data, n, j);
+ }
+ }
+ return 0;
+}
+#endif
+
// EOF
Modified: trunk/sat-solver/src/repo_solv.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repo_solv.c?rev=8024&r1=8023&r2=8024&view=diff
==============================================================================
--- trunk/sat-solver/src/repo_solv.c (original)
+++ trunk/sat-solver/src/repo_solv.c Tue Dec 4 18:44:31 2007
@@ -97,7 +97,7 @@
if (!(c & 128))
{
x = (x << 7) | c;
- if (x >= max)
+ if (max && x >= max)
{
pool_debug(mypool, SAT_FATAL, "read_id: id too large (%u/%u)\n", x, max);
exit(1);
@@ -141,7 +141,9 @@
pool_debug(mypool, SAT_FATAL, "read_idarray: array overflow\n");
exit(1);
}
- *store++ = map[x];
+ if (map)
+ x = map[x];
+ *store++ = x;
if ((c & 64) == 0)
{
if (store == end)
@@ -162,11 +164,11 @@
/*-----------------------------------------------------------------*/
-typedef struct solvdata {
- int type;
- Id id;
- unsigned int size;
-} SolvData;
+struct key {
+ Id name;
+ Id type;
+ Id size;
+};
// ----------------------------------------------
@@ -180,9 +182,11 @@
repo_add_solv(Repo *repo, FILE *fp)
{
Pool *pool = repo->pool;
- int i, j, l;
- unsigned int numid, numrel, numsolv, numsrcdata, numsolvdata;
- int numsolvdatabits, type;
+ int i, l;
+ unsigned int numid, numrel, numsolv;
+ unsigned int numkeys, numschemata, numinfo;
+
+ int type;
Offset sizeid;
Offset *str; /* map Id -> Offset into string space */
char *strsp; /* repo string space */
@@ -195,12 +199,14 @@
Id name, evr, did;
int flags;
Reldep *ran;
- SolvData *solvdata;
- unsigned int size, size_str, size_idarray;
+ unsigned int size_idarray;
Id *idarraydatap, *idarraydataend;
Offset ido;
- unsigned int databits;
Solvable *s;
+ unsigned int solvflags;
+ struct key *keys;
+ Id *schemadata, *schemadatap, *schemadataend;
+ Id *schemata, key;
mypool = pool;
@@ -209,7 +215,7 @@
pool_debug(pool, SAT_FATAL, "not a SOLV file\n");
exit(1);
}
- if (read_u32(fp) != SOLV_VERSION)
+ if (read_u32(fp) != SOLV_VERSION_1)
{
pool_debug(pool, SAT_FATAL, "unsupported SOLV version\n");
exit(1);
@@ -219,7 +225,13 @@
numid = read_u32(fp);
numrel = read_u32(fp);
- numsolv= read_u32(fp);
+ numsolv = read_u32(fp);
+ numkeys = read_u32(fp);
+ numschemata = read_u32(fp);
+ numinfo = read_u32(fp);
+ solvflags = read_u32(fp);
+
+ /******* Part 1: string IDs *****************************************/
sizeid = read_u32(fp); /* size of string+Id space */
@@ -342,6 +354,8 @@
pool_shrink_strings(pool); /* vacuum */
+ /******* Part 2: Relation IDs ***************************************/
+
/*
* read RelDeps
*
@@ -413,82 +427,81 @@
pool_shrink_rels(pool); /* vacuum */
}
- /*
- * read (but dont store yet) repo data
- */
-#if 0
- POOL_DEBUG(SAT_DEBUG_STATS, "read repo data\n");
-#endif
- numsrcdata = read_u32(fp);
- for (i = 0; i < numsrcdata; i++)
+ /******* Part 3: Keys ***********************************************/
+
+ keys = xcalloc(numkeys, sizeof(*keys));
+ /* keys start at 1 */
+ for (i = 1; i < numkeys; i++)
{
- type = read_u8(fp);
- id = idmap[read_id(fp, numid)];
- switch(type)
- {
- case TYPE_ID:
- read_id(fp, numid + numrel); /* just check Id */
- break;
- case TYPE_U32:
- read_u32(fp);
- break;
- case TYPE_STR:
- while(read_u8(fp) != 0)
- ;
- break;
- default:
- pool_debug(pool, SAT_FATAL, "unknown type %d\n", type);
- exit(0);
- }
+ keys[i].name = idmap[read_id(fp, numid)];
+ keys[i].type = read_id(fp, 0);
+ keys[i].size = read_id(fp, 0);
}
-
- /*
- * read solvables
- */
+ /******* Part 4: Schemata ********************************************/
-#if 0
- POOL_DEBUG(SAT_DEBUG_STATS, "read solvable data info\n");
-#endif
- numsolvdata = read_u32(fp);
- numsolvdatabits = 0;
- solvdata = (SolvData *)xmalloc(numsolvdata * sizeof(SolvData));
- size_idarray = 0;
- size_str = 0;
+ id = read_id(fp, 0);
+ schemadata = xcalloc(id, sizeof(Id));
+ schemadatap = schemadata;
+ schemadataend = schemadata + id;
+ schemata = xcalloc(numschemata, sizeof(Id));
+ for (i = 0; i < numschemata; i++)
+ {
+ schemata[i] = schemadatap - schemadata;
+ schemadatap = read_idarray(fp, numid, 0, schemadatap, schemadataend);
+ }
- for (i = 0; i < numsolvdata; i++)
+ /******* Part 5: Info ***********************************************/
+ /* we skip the info for now... */
+ for (i = 0; i < numinfo; i++)
{
- type = read_u8(fp);
- solvdata[i].type = type;
- if ((type & TYPE_BITMAP) != 0)
- {
- type ^= TYPE_BITMAP;
- numsolvdatabits++;
- }
- id = idmap[read_id(fp, numid)];
-#if 0
- POOL_DEBUG(SAT_DEBUG_STATS, "#%d: %s\n", i, id2str(pool, id));
-#endif
- solvdata[i].id = id;
- size = read_u32(fp);
- solvdata[i].size = size;
- if (id >= INTERESTED_START && id <= INTERESTED_END)
+ Id *schema = schemadata + schemata[read_id(fp, numschemata)];
+ while ((key = *schema++) != 0)
{
- if (type == TYPE_STR)
- size_str += size;
- if (type == TYPE_IDARRAY)
- size_idarray += size;
+ type = keys[key].type;
+ switch (type)
+ {
+ case TYPE_ID:
+ read_id(fp, numid + numrel); /* just check Id */
+ break;
+ case TYPE_U32:
+ read_u32(fp);
+ break;
+ case TYPE_STR:
+ while(read_u8(fp) != 0)
+ ;
+ break;
+ case TYPE_IDARRAY:
+ while ((read_u8(fp) & 0xc0) != 0)
+ ;
+ break;
+ default:
+ pool_debug(pool, SAT_FATAL, "unknown type %d\n", type);
+ exit(0);
+ }
}
}
- if (numsolvdatabits >= 32)
+ /******* Part 6: packed sizes (optional) ****************************/
+ if ((solvflags & SOLV_FLAG_PACKEDSIZES) != 0)
{
- pool_debug(pool, SAT_FATAL, "too many data map bits\n");
- exit(1);
+ for (i = 0; i < numsolv; i++)
+ read_id(fp, 0);
}
- /* make room for our idarrays */
+ /******* Part 7: item data *******************************************/
+
+ /* calculate idarray size */
+ size_idarray = 0;
+ for (i = 1; i < numkeys; i++)
+ {
+ id = keys[i].name;
+ if (keys[i].type == TYPE_IDARRAY && id >= INTERESTED_START && id <= INTERESTED_END)
+ size_idarray += keys[i].size;
+ }
+
+ /* allocate needed space in repo */
if (size_idarray)
{
repo_reserve_ids(repo, 0, size_idarray);
@@ -503,37 +516,111 @@
idarraydataend = 0;
}
- /*
- * read solvables
- */
-
-#if 0
- POOL_DEBUG(SAT_DEBUG_STATS, "read solvables\n");
-#endif
+ /* read solvables */
s = pool_id2solvable(pool, repo_add_solvable_block(repo, numsolv));
- for (i = 0; i < numsolv; i++, s++)
+
+ if ((solvflags & SOLV_FLAG_VERTICAL) != 0)
{
- databits = 0;
- if (numsolvdatabits)
- {
- for (j = 0; j < (numsolvdatabits + 7) >> 3; j++)
- databits = (databits << 8) | read_u8(fp);
- }
- for (j = 0; j < numsolvdata; j++)
- {
- type = solvdata[j].type;
- if ((type & TYPE_BITMAP) != 0)
+ Id *solvschema = xcalloc(numsolv, sizeof(Id));
+ unsigned char *used = xmalloc(numschemata);
+ Solvable *sstart = s;
+ Id type;
+
+ for (i = 0; i < numsolv; i++)
+ solvschema[i] = read_id(fp, numschemata);
+ for (key = 1; key < numkeys; key++)
+ {
+ id = keys[key].name;
+ type = keys[key].type;
+ memset(used, 0, numschemata);
+ for (i = 0; i < numschemata; i++)
{
- if (!(databits & 1))
+ Id *keyp = schemadata + schemata[i];
+ while (*keyp)
+ if (*keyp++ == key)
+ {
+ used[i] = 1;
+ break;
+ }
+ }
+ for (i = 0, s = sstart; i < numsolv; i++, s++)
+ {
+ if (!used[solvschema[i]])
+ continue;
+ switch (type)
{
- databits >>= 1;
- continue;
+ case TYPE_ID:
+ did = idmap[read_id(fp, numid + numrel)];
+ if (id == SOLVABLE_NAME)
+ s->name = did;
+ else if (id == SOLVABLE_ARCH)
+ s->arch = did;
+ else if (id == SOLVABLE_EVR)
+ s->evr = did;
+ else if (id == SOLVABLE_VENDOR)
+ s->vendor = did;
+ break;
+ case TYPE_U32:
+ h = read_u32(fp);
+ if (id == RPM_RPMDBID)
+ {
+ if (!repo->rpmdbid)
+ repo->rpmdbid = (Id *)xcalloc(numsolv, sizeof(Id));
+ repo->rpmdbid[i] = h;
+ }
+ break;
+ case TYPE_STR:
+ while(read_u8(fp) != 0)
+ ;
+ break;
+ case TYPE_IDARRAY:
+ if (id < INTERESTED_START || id > INTERESTED_END)
+ {
+ /* not interested in array */
+ while ((read_u8(fp) & 0xc0) != 0)
+ ;
+ break;
+ }
+ ido = idarraydatap - repo->idarraydata;
+ idarraydatap = read_idarray(fp, numid + numrel, idmap, idarraydatap, idarraydataend);
+ if (id == SOLVABLE_PROVIDES)
+ s->provides = ido;
+ else if (id == SOLVABLE_OBSOLETES)
+ s->obsoletes = ido;
+ else if (id == SOLVABLE_CONFLICTS)
+ s->conflicts = ido;
+ else if (id == SOLVABLE_REQUIRES)
+ s->requires = ido;
+ else if (id == SOLVABLE_RECOMMENDS)
+ s->recommends= ido;
+ else if (id == SOLVABLE_SUPPLEMENTS)
+ s->supplements = ido;
+ else if (id == SOLVABLE_SUGGESTS)
+ s->suggests = ido;
+ else if (id == SOLVABLE_ENHANCES)
+ s->enhances = ido;
+ else if (id == SOLVABLE_FRESHENS)
+ s->freshens = ido;
+ break;
}
- databits >>= 1;
- type ^= TYPE_BITMAP;
}
- id = solvdata[j].id;
- switch (type)
+ }
+ xfree(used);
+ xfree(solvschema);
+ xfree(idmap);
+ xfree(schemata);
+ xfree(schemadata);
+ xfree(keys);
+ mypool = 0;
+ return;
+ }
+ for (i = 0; i < numsolv; i++, s++)
+ {
+ Id *keyp = schemadata + schemata[read_id(fp, numschemata)];
+ while ((key = *keyp++) != 0)
+ {
+ id = keys[key].name;
+ switch (keys[key].type)
{
case TYPE_ID:
did = idmap[read_id(fp, numid + numrel)];
@@ -603,7 +690,9 @@
}
}
xfree(idmap);
- xfree(solvdata);
+ xfree(schemata);
+ xfree(schemadata);
+ xfree(keys);
mypool = 0;
}
Modified: trunk/sat-solver/src/solver.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/solver.c?rev=8024&r1=8023&r2=8024&view=diff
==============================================================================
--- trunk/sat-solver/src/solver.c (original)
+++ trunk/sat-solver/src/solver.c Tue Dec 4 18:44:31 2007
@@ -3260,11 +3260,15 @@
Repo *installed = solv->installed;
int i;
int oldnrules;
- Map addedmap; /* '1' == have rule for solvable */
+ Map addedmap; /* '1' == have rpm-rules for solvable */
Id how, what, p, *pp, d;
Queue q;
Solvable *s;
+ /* create whatprovides if not already there */
+ if (pool->whatprovides)
+ pool_createwhatprovides(pool);
+
/* create obsolete index if needed */
if (solv->noupdateprovide)
create_obsolete_index(solv);
Modified: trunk/sat-solver/tools/dumpsolv.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/dumpsolv.c?rev=8024&r1=8023&r2=8024&view=diff
==============================================================================
--- trunk/sat-solver/tools/dumpsolv.c (original)
+++ trunk/sat-solver/tools/dumpsolv.c Tue Dec 4 18:44:31 2007
@@ -30,7 +30,7 @@
{
Repo *repo;
Pool *pool;
- int i;
+ int i, n;
Solvable *s;
if (argc != 1)
@@ -45,13 +45,13 @@
repo = repo_create(pool, argc != 1 ? argv[1] : "<stdin>");
repo_add_solv(repo, stdin);
printf("repo contains %d solvables\n", repo->nsolvables);
- for (i = repo->start; i < repo->end; i++)
+ for (i = repo->start, n = 1; i < repo->end; i++)
{
s = pool->solvables + i;
if (s->repo != repo)
continue;
printf("\n");
- printf("solvable %d:\n", i);
+ printf("solvable %d:\n", n++);
printf("name: %s %s %s\n", id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch));
if (s->vendor)
printf("vendor: %s\n", id2str(pool, s->vendor));
@@ -65,5 +65,6 @@
printids(repo, "enhances", s->enhances);
printids(repo, "freshens", s->freshens);
}
+ pool_free(pool);
exit(0);
}
Modified: trunk/sat-solver/tools/repo_write.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_write.c?rev=8024&r1=8023&r2=8024&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_write.c (original)
+++ trunk/sat-solver/tools/repo_write.c Tue Dec 4 18:44:31 2007
@@ -23,6 +23,7 @@
#include