Author: matz
Date: Thu Dec 6 04:03:29 2007
New Revision: 8042
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8042&view=rev
Log:
prefix-code the string store, difference-code the dependency idarrays.
V1 solv files still can be loaded.
Modified:
trunk/sat-solver/src/pool.h
trunk/sat-solver/src/pooltypes.h
trunk/sat-solver/src/repo_solv.c
trunk/sat-solver/tools/repo_write.c
Modified: trunk/sat-solver/src/pool.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/pool.h?rev=8042&r1=8041&r2=8042&view=diff
==============================================================================
--- trunk/sat-solver/src/pool.h (original)
+++ trunk/sat-solver/src/pool.h Thu Dec 6 04:03:29 2007
@@ -125,7 +125,7 @@
#define TYPE_IDARRAY 2
#define TYPE_STR 3
#define TYPE_U32 4
-#define TYPE_BITMAP 128
+#define TYPE_REL_IDARRAY 5
//-----------------------------------------------
Modified: trunk/sat-solver/src/pooltypes.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/pooltypes.h?rev=8042&r1=8041&r2=8042&view=diff
==============================================================================
--- trunk/sat-solver/src/pooltypes.h (original)
+++ trunk/sat-solver/src/pooltypes.h Thu Dec 6 04:03:29 2007
@@ -16,8 +16,10 @@
/* version number for .solv files */
#define SOLV_VERSION_0 0
#define SOLV_VERSION_1 1
+#define SOLV_VERSION_2 2
#define SOLV_FLAG_PACKEDSIZES 1
#define SOLV_FLAG_VERTICAL 2
+#define SOLV_FLAG_PREFIX_POOL 4
struct _Stringpool;
typedef struct _Stringpool Stringpool;
Modified: trunk/sat-solver/src/repo_solv.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repo_solv.c?rev=8042&r1=8041&r2=8042&view=diff
==============================================================================
--- trunk/sat-solver/src/repo_solv.c (original)
+++ trunk/sat-solver/src/repo_solv.c Thu Dec 6 04:03:29 2007
@@ -29,7 +29,7 @@
#define INTERESTED_START SOLVABLE_NAME
#define INTERESTED_END SOLVABLE_FRESHENS
-Pool *mypool; /* for pool_debug... */
+static Pool *mypool; /* for pool_debug... */
/*-----------------------------------------------------------------*/
/* .solv read functions */
@@ -116,10 +116,11 @@
*/
static Id *
-read_idarray(FILE *fp, Id max, Id *map, Id *store, Id *end)
+read_idarray(FILE *fp, Id max, Id *map, Id *store, Id *end, int relative)
{
unsigned int x = 0;
int c;
+ Id old = 0;
for (;;)
{
c = getc(fp);
@@ -131,18 +132,31 @@
if ((c & 128) == 0)
{
x = (x << 6) | (c & 63);
- if (x >= max)
+ if (!relative || x != 1)
{
- pool_debug(mypool, SAT_FATAL, "read_idarray: id too large (%u/%u)\n", x, max);
- exit(1);
+ if (relative)
+ {
+ x--;
+ x += old;
+ old = x;
+ }
+ if (x >= max)
+ {
+ pool_debug(mypool, SAT_FATAL, "read_idarray: id too large (%u/%u)\n", x, max);
+ exit(1);
+ }
+ if (map)
+ x = map[x];
}
+ else
+ /* (relative && x==1) :
+ Ugly PREREQ handling. See repo_write.c. */
+ x = SOLVABLE_PREREQMARKER, old = 1;
if (store == end)
{
pool_debug(mypool, SAT_FATAL, "read_idarray: array overflow\n");
exit(1);
}
- if (map)
- x = map[x];
*store++ = x;
if ((c & 64) == 0)
{
@@ -204,6 +218,7 @@
Offset ido;
Solvable *s;
unsigned int solvflags;
+ unsigned int solvversion;
struct key *keys;
Id *schemadata, *schemadatap, *schemadataend;
Id *schemata, key;
@@ -215,10 +230,15 @@
pool_debug(pool, SAT_FATAL, "not a SOLV file\n");
exit(1);
}
- if (read_u32(fp) != SOLV_VERSION_1)
+ solvversion = read_u32(fp);
+ switch (solvversion)
{
- pool_debug(pool, SAT_FATAL, "unsupported SOLV version\n");
- exit(1);
+ case SOLV_VERSION_1:
+ case SOLV_VERSION_2:
+ break;
+ default:
+ pool_debug(pool, SAT_FATAL, "unsupported SOLV version\n");
+ exit(1);
}
pool_freeidhashes(pool);
@@ -264,10 +284,38 @@
* read new repo at end of pool
*/
- if (fread(strsp, sizeid, 1, fp) != 1)
+ if ((solvflags & SOLV_FLAG_PREFIX_POOL) == 0)
{
- pool_debug(pool, SAT_FATAL, "read error while reading strings\n");
- exit(1);
+ if (fread(strsp, sizeid, 1, fp) != 1)
+ {
+ pool_debug(pool, SAT_FATAL, "read error while reading strings\n");
+ exit(1);
+ }
+ }
+ else
+ {
+ unsigned int pfsize = read_u32 (fp);
+ char *prefix = xmalloc (pfsize);
+ char *pp = prefix;
+ char *old_str = "";
+ char *dest = strsp;
+ if (fread (prefix, pfsize, 1, fp) != 1)
+ {
+ pool_debug(pool, SAT_FATAL, "read error while reading strings\n");
+ exit(1);
+ }
+ for (i = 1; i < numid; i++)
+ {
+ int same = (unsigned char)*pp++;
+ size_t len = strlen (pp) + 1;
+ if (same)
+ memcpy (dest, old_str, same);
+ memcpy (dest + same, pp, len);
+ pp += len;
+ old_str = dest;
+ dest += same + len;
+ }
+ xfree (prefix);
}
strsp[sizeid] = 0; /* make string space \0 terminated */
sp = strsp;
@@ -449,7 +497,7 @@
for (i = 0; i < numschemata; i++)
{
schemata[i] = schemadatap - schemadata;
- schemadatap = read_idarray(fp, numid, 0, schemadatap, schemadataend);
+ schemadatap = read_idarray(fp, numid, 0, schemadatap, schemadataend, 0);
}
/******* Part 5: Info ***********************************************/
@@ -473,6 +521,7 @@
;
break;
case TYPE_IDARRAY:
+ case TYPE_REL_IDARRAY:
while ((read_u8(fp) & 0xc0) != 0)
;
break;
@@ -497,7 +546,8 @@
for (i = 1; i < numkeys; i++)
{
id = keys[i].name;
- if (keys[i].type == TYPE_IDARRAY && id >= INTERESTED_START && id <= INTERESTED_END)
+ if ((keys[i].type == TYPE_IDARRAY || keys[i].type == TYPE_REL_IDARRAY)
+ && id >= INTERESTED_START && id <= INTERESTED_END)
size_idarray += keys[i].size;
}
@@ -574,6 +624,7 @@
;
break;
case TYPE_IDARRAY:
+ case TYPE_REL_IDARRAY:
if (id < INTERESTED_START || id > INTERESTED_END)
{
/* not interested in array */
@@ -582,7 +633,7 @@
break;
}
ido = idarraydatap - repo->idarraydata;
- idarraydatap = read_idarray(fp, numid + numrel, idmap, idarraydatap, idarraydataend);
+ idarraydatap = read_idarray(fp, numid + numrel, idmap, idarraydatap, idarraydataend, type == TYPE_REL_IDARRAY);
if (id == SOLVABLE_PROVIDES)
s->provides = ido;
else if (id == SOLVABLE_OBSOLETES)
@@ -653,6 +704,7 @@
;
break;
case TYPE_IDARRAY:
+ case TYPE_REL_IDARRAY:
if (id < INTERESTED_START || id > INTERESTED_END)
{
/* not interested in array */
@@ -661,7 +713,7 @@
break;
}
ido = idarraydatap - repo->idarraydata;
- idarraydatap = read_idarray(fp, numid + numrel, idmap, idarraydatap, idarraydataend);
+ idarraydatap = read_idarray(fp, numid + numrel, idmap, idarraydatap, idarraydataend, keys[key].type == TYPE_REL_IDARRAY);
if (id == SOLVABLE_PROVIDES)
s->provides = ido;
else if (id == SOLVABLE_OBSOLETES)
Modified: trunk/sat-solver/tools/repo_write.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_write.c?rev=8042&r1=8041&r2=8042&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_write.c (original)
+++ trunk/sat-solver/tools/repo_write.c Thu Dec 6 04:03:29 2007
@@ -21,11 +21,14 @@
#include