[zypp-commit] r8279 - in /trunk/sat-solver: src/attr_store.c src/attr_store_p.h src/pool.h src/repo_solv.c tools/dumpattr.c
Author: matz Date: Mon Jan 14 17:25:33 2008 New Revision: 8279 URL: http://svn.opensuse.org/viewcvs/zypp?rev=8279&view=rev Log: It's nicer to represent the special numbers as TYPE_VOID with the actual value sitting in key->size. Modified: trunk/sat-solver/src/attr_store.c trunk/sat-solver/src/attr_store_p.h trunk/sat-solver/src/pool.h trunk/sat-solver/src/repo_solv.c trunk/sat-solver/tools/dumpattr.c Modified: trunk/sat-solver/src/attr_store.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/attr_store.c?rev=8279&r1=8278&r2=8279&view=diff ============================================================================== --- trunk/sat-solver/src/attr_store.c (original) +++ trunk/sat-solver/src/attr_store.c Mon Jan 14 17:25:33 2008 @@ -352,14 +352,9 @@ void add_attr_special_int (Attrstore *s, unsigned int entry, Id name, unsigned int val) { - if (val > (TYPE_ATTR_SPECIAL_END - TYPE_ATTR_SPECIAL_START)) - add_attr_int (s, entry, name, val); - else - { - LongNV nv; - nv.key = add_key (s, name, TYPE_ATTR_SPECIAL_START + val, 0); - add_attr (s, entry, nv); - } + LongNV nv; + nv.key = add_key (s, name, TYPE_VOID, val); + add_attr (s, entry, nv); } static void @@ -505,14 +500,17 @@ /* This routine is used only when attributes are embedded into the normal repo SOLV file. */ void -add_attr_from_file (Attrstore *s, unsigned entry, Id name, int type, Id *idmap, unsigned maxid, FILE *fp) +add_attr_from_file (Attrstore *s, unsigned entry, Id name, int type, Id *idmap, unsigned maxid, FILE *fp, unsigned size) { Pool *pool = s->pool; //fprintf (stderr, "%s: attribute in a repo SOLV?\n", id2str (pool, name)); switch (type) { case TYPE_VOID: - add_attr_void (s, entry, name); + if (size) + add_attr_special_int (s, entry, name, size); + else + add_attr_void (s, entry, name); break; case TYPE_ATTR_CHUNK: { @@ -582,11 +580,6 @@ } break; default: - if (type >= TYPE_ATTR_SPECIAL_START && type <= TYPE_ATTR_SPECIAL_END) - { - add_attr_special_int (s, entry, name, type - TYPE_ATTR_SPECIAL_START); - break; - } pool_debug(pool, SAT_FATAL, "unknown type %d\n", type); exit(0); } @@ -816,11 +809,13 @@ { unsigned i; for (i = 0; i < s->nkeys; i++) - if (s->keys[i].name == name && s->keys[i].type == type) + if (s->keys[i].name == name && s->keys[i].type == type + && (type != TYPE_VOID || s->keys[i].size == size)) break; if (i < s->nkeys) { - s->keys[i].size += size; + if (type != TYPE_VOID) + s->keys[i].size += size; return i; } if ((s->nkeys & KEY_BLOCK) == 0) @@ -1058,7 +1053,10 @@ switch (ai.type) { case TYPE_VOID: - add_attr_void (s, i, ai.name); + if (ai.as_int) + add_attr_special_int (s, i, ai.name, ai.as_int); + else + add_attr_void (s, i, ai.name); break; case TYPE_ATTR_INT: add_attr_int (s, i, ai.name, ai.as_int); @@ -1094,9 +1092,6 @@ break; } default: - if (ai.type >= TYPE_ATTR_SPECIAL_START - && ai.type <= TYPE_ATTR_SPECIAL_END) - add_attr_special_int (s, i, ai.name, ai.type - TYPE_ATTR_SPECIAL_START); break; } } Modified: trunk/sat-solver/src/attr_store_p.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/attr_store_p.h?rev=8279&r1=8278&r2=8279&view=diff ============================================================================== --- trunk/sat-solver/src/attr_store_p.h (original) +++ trunk/sat-solver/src/attr_store_p.h Mon Jan 14 17:25:33 2008 @@ -98,7 +98,7 @@ unsigned int packed:1; }; -void add_attr_from_file (Attrstore *s, unsigned entry, Id name, int type, Id *idmap, unsigned maxid, FILE *fp); +void add_attr_from_file (Attrstore *s, unsigned entry, Id name, int type, Id *idmap, unsigned maxid, FILE *fp, unsigned size); void read_or_setup_pages (FILE *fp, Attrstore *s); #define get_num(ptr,val) do { \ @@ -159,7 +159,8 @@ switch (ai->type) { case TYPE_VOID: - /* No data. */ + /* No data, except perhaps a constant value. */ + ai->as_int = s->keys[key].size; break; case TYPE_ATTR_INT: { @@ -208,7 +209,6 @@ break; } default: - /* ??? Convert TYPE_ATTR_SPECIAL_* to _INT type with the right value? */ break; } return 1; Modified: trunk/sat-solver/src/pool.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/pool.h?rev=8279&r1=8278&r2=8279&view=diff ============================================================================== --- trunk/sat-solver/src/pool.h (original) +++ trunk/sat-solver/src/pool.h Mon Jan 14 17:25:33 2008 @@ -128,6 +128,12 @@ #define SAT_DEBUG_JOB (1<<11) #define SAT_DEBUG_SCHUBI (1<<12) +/* The void type is usable to encode one-valued attributes, they have + no associated data. This is useful to encode values which many solvables + have in common, and whose overall set is relatively limited. A prime + example would be the media number. The actual value is encoded in the + SIZE member of the key structure. Be warned: careless use of this + leads to combinatoric explosion of number of schemas. */ #define TYPE_VOID 0 #define TYPE_ID 1 #define TYPE_IDARRAY 2 @@ -147,14 +153,7 @@ #define TYPE_IDVALUEARRAY 13 #define TYPE_IDVALUEVALUEARRAY 14 -/* The special types are usable to encode one-valued attributes, they have - no associated data. This is useful to encode values which many solvables - have in common, and whose overall set is relatively limited. A prime - example would be the media number. Be warned: careless use of this - leads to combinatoric explosion of number of schemas. */ -#define TYPE_ATTR_SPECIAL_START 15 -#define TYPE_ATTR_SPECIAL_END (TYPE_ATTR_SPECIAL_START + 31) -#define TYPE_ATTR_TYPE_MAX TYPE_ATTR_SPECIAL_END +#define TYPE_ATTR_TYPE_MAX TYPE_IDVALUEVALUEARRAY //----------------------------------------------- Modified: trunk/sat-solver/src/repo_solv.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repo_solv.c?rev=8279&r1=8278&r2=8279&view=diff ============================================================================== --- trunk/sat-solver/src/repo_solv.c (original) +++ trunk/sat-solver/src/repo_solv.c Mon Jan 14 17:25:33 2008 @@ -1040,7 +1040,7 @@ case TYPE_ATTR_LOCALIDS: if (!embedded_store) embedded_store = new_store (pool); - add_attr_from_file (embedded_store, i, id, keys[key].type, idmap, numid, &data); + add_attr_from_file (embedded_store, i, id, keys[key].type, idmap, numid, &data, keys[key].size); break; #endif default: Modified: trunk/sat-solver/tools/dumpattr.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/dumpattr.c?rev=8279&r1=8278&r2=8279&view=diff ============================================================================== --- trunk/sat-solver/tools/dumpattr.c (original) +++ trunk/sat-solver/tools/dumpattr.c Mon Jan 14 17:25:33 2008 @@ -59,6 +59,9 @@ fprintf (stdout, "%s:", id2str (s->pool, ai.name)); switch (ai.type) { + case TYPE_VOID: + fprintf (stdout, "spec %d\n", ai.as_int); + break; case TYPE_ATTR_INT: fprintf (stdout, "int %u\n", ai.as_int); break; @@ -106,10 +109,6 @@ break; } default: - if (ai.type >= TYPE_ATTR_SPECIAL_START - && ai.type <= TYPE_ATTR_SPECIAL_END) - fprintf (stdout, "spec %d", ai.type - TYPE_ATTR_SPECIAL_START); - fprintf (stdout, "\n"); break; } } -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
matz@svn.opensuse.org