Author: matz Date: Tue Dec 18 22:09:58 2007 New Revision: 8128 URL: http://svn.opensuse.org/viewcvs/zypp?rev=8128&view=rev Log: One-valued types for media number. They can be encoded in the schema, no need for storing 1, 2 or 3 all the time. Modified: trunk/sat-solver/src/attr_store.c trunk/sat-solver/src/attr_store.h trunk/sat-solver/src/attr_store_p.h trunk/sat-solver/src/pool.h trunk/sat-solver/tools/dumpattr.c trunk/sat-solver/tools/repo_susetags.c Modified: trunk/sat-solver/src/attr_store.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/attr_store.c?rev=8128&r1=8127&r2=8128&view=diff ============================================================================== --- trunk/sat-solver/src/attr_store.c (original) +++ trunk/sat-solver/src/attr_store.c Tue Dec 18 22:09:58 2007 @@ -154,6 +154,19 @@ add_attr (s, entry, nv); } +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); + } +} + static void add_attr_chunk (Attrstore *s, unsigned int entry, Id name, unsigned int ofs, unsigned int len) { @@ -342,6 +355,11 @@ } 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); } @@ -781,6 +799,9 @@ 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.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/attr_store.h?rev=8128&r1=8127&r2=8128&view=diff ============================================================================== --- trunk/sat-solver/src/attr_store.h (original) +++ trunk/sat-solver/src/attr_store.h Tue Dec 18 22:09:58 2007 @@ -33,6 +33,7 @@ const char * localid2str(Attrstore *s, LocalId id); void add_attr_int (Attrstore *s, unsigned int entry, Id name, unsigned int val); +void add_attr_special_int (Attrstore *s, unsigned int entry, Id name, unsigned int val); void add_attr_blob (Attrstore *s, unsigned int entry, Id name, const void *ptr, unsigned int len); void add_attr_string (Attrstore *s, unsigned int entry, Id name, const char *val); void add_attr_intlist_int (Attrstore *s, unsigned int entry, Id name, int val); 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=8128&r1=8127&r2=8128&view=diff ============================================================================== --- trunk/sat-solver/src/attr_store_p.h (original) +++ trunk/sat-solver/src/attr_store_p.h Tue Dec 18 22:09:58 2007 @@ -185,6 +185,7 @@ 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=8128&r1=8127&r2=8128&view=diff ============================================================================== --- trunk/sat-solver/src/pool.h (original) +++ trunk/sat-solver/src/pool.h Tue Dec 18 22:09:58 2007 @@ -142,11 +142,19 @@ #define TYPE_COUNT_NAMED 11 #define TYPE_COUNTED 12 -#define TYPE_ATTR_TYPE_MAX 12 #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 + //----------------------------------------------- Modified: trunk/sat-solver/tools/dumpattr.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/dumpattr.c?rev=8128&r1=8127&r2=8128&view=diff ============================================================================== --- trunk/sat-solver/tools/dumpattr.c (original) +++ trunk/sat-solver/tools/dumpattr.c Tue Dec 18 22:09:58 2007 @@ -71,6 +71,9 @@ 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; } Modified: trunk/sat-solver/tools/repo_susetags.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_susetags.c?rev=8128&r1=8127&r2=8128&view=diff ============================================================================== --- trunk/sat-solver/tools/repo_susetags.c (original) +++ trunk/sat-solver/tools/repo_susetags.c Tue Dec 18 22:09:58 2007 @@ -159,7 +159,7 @@ { /* medianr filename dir don't optimize this one */ - add_attr_int (attr, entry, str2id (pool, "medianr", 1), atoi (sp[0])); + add_attr_special_int (attr, entry, str2id (pool, "medianr", 1), atoi (sp[0])); add_attr_localids_id (attr, entry, str2id (pool, "mediadir", 1), str2localid (attr, sp[2], 1)); add_attr_string (attr, entry, str2id (pool, "mediafile", 1), sp[1]); return; @@ -190,12 +190,12 @@ break; if (*n2 || strcmp (n1, ".rpm")) goto nontrivial; - add_attr_int (attr, entry, str2id (pool, "medianr", 1), medianr); + add_attr_special_int (attr, entry, str2id (pool, "medianr", 1), medianr); add_attr_void (attr, entry, str2id (pool, "mediafile", 1)); return; nontrivial: - add_attr_int (attr, entry, str2id (pool, "medianr", 1), medianr); + add_attr_special_int (attr, entry, str2id (pool, "medianr", 1), medianr); add_attr_string (attr, entry, str2id (pool, "mediafile", 1), sp[1]); return; } -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org