cbdata->dirused[0] = 2;
}
+/*
+ * pass 1 callback:
+ * collect key/id/dirid usage information, create needed schemas
+ */
static int
repo_write_collect_needed(struct cbdata *cbdata, Repo *repo, Repodata *data, Repokey *key, KeyValue *kv)
{
rm = cbdata->keymap[cbdata->keymapstart[data - data->repo->repodata] + (key - data->keys)];
if (!rm)
return SEARCH_NEXT_KEY; /* we do not want this one */
+
/* record key in schema */
if ((key->type != REPOKEY_TYPE_FIXARRAY || kv->eof == 0)
&& (cbdata->sp == cbdata->schema || cbdata->sp[-1] != rm))
*cbdata->sp++ = rm;
+
switch(key->type)
{
case REPOKEY_TYPE_ID:
return repo_write_collect_needed(cbdata, repo, data, key, kv);
}
+
+/*
+ * pass 2 callback:
+ * encode all of the data into the correct buffers
+ */
+
static int
repo_write_adddata(struct cbdata *cbdata, Repodata *data, Repokey *key, KeyValue *kv)
{
}
}
-
-#if 0
-static Id subfilekeys[] = {
- REPODATA_INFO, REPOKEY_TYPE_VOID,
- REPODATA_EXTERNAL, REPOKEY_TYPE_VOID,
- REPODATA_KEYS, REPOKEY_TYPE_IDARRAY,
- REPODATA_LOCATION, REPOKEY_TYPE_STR,
- REPODATA_ADDEDFILEPROVIDES, REPOKEY_TYPE_REL_IDARRAY,
- REPODATA_RPMDBCOOKIE, REPOKEY_TYPE_SHA256,
- 0,
-};
-#endif
-
static Id verticals[] = {
SOLVABLE_AUTHORS,
SOLVABLE_DESCRIPTION,
* Repo
*/
+/*
+ * the code works the following way:
+ *
+ * 1) find which keys should be written
+ * 2) collect usage information for keys/ids/dirids, create schema
+ * data
+ * 3) use usage information to create mapping tables, so that often
+ * used ids get a lower number
+ * 4) encode data into buffers using the mapping tables
+ * 5) write everything to disk
+ */
void
repo_write(Repo *repo, FILE *fp, int (*keyfilter)(Repo *repo, Repokey *key, void *kfdata), void *kfdata, Id **keyarrayp)
{