From: Michael Schroeder Date: Mon, 13 Jul 2009 15:36:33 +0000 (+0200) Subject: - do not autoload unneded repodata X-Git-Tag: BASE-SuSE-Code-12_1-Branch~166^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=65287027951f3e491c37f300ab3ab87358126e64;p=platform%2Fupstream%2Flibsolv.git - do not autoload unneded repodata - add repo_write_stdkeyfilter function --- diff --git a/ext/repo_write.c b/ext/repo_write.c index 6d48942..46dfbdb 100644 --- a/ext/repo_write.c +++ b/ext/repo_write.c @@ -956,6 +956,42 @@ static Id subfilekeys[] = { }; #endif +static Id verticals[] = { + SOLVABLE_AUTHORS, + SOLVABLE_DESCRIPTION, + SOLVABLE_MESSAGEDEL, + SOLVABLE_MESSAGEINS, + SOLVABLE_EULA, + SOLVABLE_DISKUSAGE, + SOLVABLE_FILELIST, + 0 +}; + +static char *languagetags[] = { + "solvable:summary:", + "solvable:description:", + "solvable:messageins:", + "solvable:messagedel:", + "solvable:eula:", + 0 +}; + +int +repo_write_stdkeyfilter(Repo *repo, Repokey *key, void *kfdata) +{ + const char *keyname; + int i; + + for (i = 0; verticals[i]; i++) + if (key->name == verticals[i]) + return KEY_STORAGE_VERTICAL_OFFSET; + keyname = id2str(repo->pool, key->name); + for (i = 0; languagetags[i] != 0; i++) + if (!strncmp(keyname, languagetags[i], strlen(languagetags[i]))) + return KEY_STORAGE_VERTICAL_OFFSET; + return KEY_STORAGE_INCORE; +} + /* * Repo */ @@ -1087,6 +1123,11 @@ repo_write(Repo *repo, FILE *fp, int (*keyfilter)(Repo *repo, Repokey *key, void for (j = 1; j < data->nkeys; j++, n++) { key = data->keys + j; + if (key->name == REPOSITORY_SOLVABLES && key->type == REPOKEY_TYPE_FLEXARRAY) + { + cbdata.keymap[n] = cbdata.keymap[key->name]; + continue; + } /* see if we already had this one, should use hash for fast miss */ for (k = 0; k < cbdata.nmykeys; k++) { @@ -1260,7 +1301,11 @@ for (i = 1; i < cbdata.nmykeys; i++) /* collect all other data from all repodatas */ /* XXX: merge arrays of equal keys? */ for (j = 0, data = repo->repodata; j < repo->nrepodata; j++, data++) - repodata_search(data, SOLVID_META, 0, SEARCH_SUB|SEARCH_ARRAYSENTINEL, repo_write_cb_needed, &cbdata); + { + if (!repodataused[j]) + continue; + repodata_search(data, SOLVID_META, 0, SEARCH_SUB|SEARCH_ARRAYSENTINEL, repo_write_cb_needed, &cbdata); + } sp = cbdata.sp; /* add solvables if needed */ if (repo->nsolvables) @@ -1582,7 +1627,11 @@ fprintf(stderr, "dir %d used %d\n", i, cbdata.dirused ? cbdata.dirused[i] : 1); #if 1 for (j = 0, data = repo->repodata; j < repo->nrepodata; j++, data++) - repodata_search(data, SOLVID_META, 0, SEARCH_SUB|SEARCH_ARRAYSENTINEL, repo_write_cb_adddata, &cbdata); + { + if (!repodataused[j]) + continue; + repodata_search(data, SOLVID_META, 0, SEARCH_SUB|SEARCH_ARRAYSENTINEL, repo_write_cb_adddata, &cbdata); + } #endif if (xd->len - cbdata.lastlen > cbdata.maxdata) diff --git a/ext/repo_write.h b/ext/repo_write.h index fd622d4..5fc9bf2 100644 --- a/ext/repo_write.h +++ b/ext/repo_write.h @@ -15,24 +15,9 @@ #include -#include "pool.h" #include "repo.h" -/* Describes a repodata file */ -typedef struct _Repodatafile -{ - /* These have the same meaning as the equally named fields in - Repodata. */ - char *location; - char *checksum; - unsigned int nchecksum; - unsigned int checksumtype; - struct _Repokey *keys; - unsigned int nkeys; - Id *addedfileprovides; - unsigned char *rpmdbcookie; -} Repodatafile; - void repo_write(Repo *repo, FILE *fp, int (*keyfilter)(Repo *repo, Repokey *key, void *kfdata), void *kfdata, Id **keyarrayp); +int repo_write_stdkeyfilter(Repo *repo, Repokey *key, void *kfdata); #endif