}
void
-transaction_init(Transaction *trans, Pool *pool)
-{
- memset(trans, 0, sizeof(*trans));
- trans->pool = pool;
-}
-
-void
-transaction_free(Transaction *trans)
-{
- queue_free(&trans->steps);
- queue_free(&trans->transaction_info);
- trans->transaction_installed = sat_free(trans->transaction_installed);
- map_free(&trans->transactsmap);
- trans->tes = sat_free(trans->tes);
- trans->ntes = 0;
- trans->invedgedata = sat_free(trans->invedgedata);
-}
-
-void
transaction_calculate(Transaction *trans, Queue *decisionq, Map *noobsmap)
{
Pool *pool = trans->pool;
}
}
+
+struct _TransactionElement {
+ Id p; /* solvable id */
+ Id type; /* installation type */
+ Id edges; /* pointer into edges data */
+ Id mark;
+};
+
+struct _TransactionOrderdata {
+ struct _TransactionElement *tes;
+ int ntes;
+ Id *invedgedata;
+};
+
#define TYPE_BROKEN (1<<0)
#define TYPE_CON (1<<1)
#define EDGEDATA_BLOCK 127
+void
+transaction_init(Transaction *trans, Pool *pool)
+{
+ memset(trans, 0, sizeof(*trans));
+ trans->pool = pool;
+}
+
+void
+transaction_free(Transaction *trans)
+{
+ queue_free(&trans->steps);
+ queue_free(&trans->transaction_info);
+ trans->transaction_installed = sat_free(trans->transaction_installed);
+ map_free(&trans->transactsmap);
+ if (trans->orderdata)
+ {
+ struct _TransactionOrderdata *od = trans->orderdata;
+ od->tes = sat_free(od->tes);
+ od->invedgedata = sat_free(od->invedgedata);
+ trans->orderdata = sat_free(trans->orderdata);
+ }
+}
+
struct orderdata {
Transaction *trans;
struct _TransactionElement *tes;
}
void
-transaction_order(Transaction *trans)
+transaction_order(Transaction *trans, int flags)
{
Pool *pool = trans->pool;
Queue *tr = &trans->steps;
int oldcount;
int start, now;
- POOL_DEBUG(SAT_DEBUG_STATS, "ordering transaction\n");
start = now = sat_timems(0);
+ POOL_DEBUG(SAT_DEBUG_STATS, "ordering transaction\n");
+ /* free old data if present */
+ if (trans->orderdata)
+ {
+ struct _TransactionOrderdata *od = trans->orderdata;
+ od->tes = sat_free(od->tes);
+ od->invedgedata = sat_free(od->invedgedata);
+ trans->orderdata = sat_free(trans->orderdata);
+ }
+
/* create a transaction element for every active component */
numte = 0;
for (i = 0; i < tr->count; i += 2)
continue;
numte++;
}
+ POOL_DEBUG(SAT_DEBUG_STATS, "transaction elements: %d\n", numte);
if (!numte)
return; /* nothing to do... */
- POOL_DEBUG(SAT_DEBUG_STATS, "transaction elements: %d\n", numte);
numte++; /* leave first one zero */
memset(&od, 0, sizeof(od));
od.trans = trans;
POOL_DEBUG(SAT_DEBUG_STATS, "creating new transaction took %d ms\n", sat_timems(now));
POOL_DEBUG(SAT_DEBUG_STATS, "transaction ordering took %d ms\n", sat_timems(start));
- trans->tes = od.tes;
- trans->ntes = numte;
- trans->invedgedata = od.invedgedata;
+ if ((flags & SOLVER_TRANSACTION_KEEP_ORDERDATA) != 0)
+ {
+ trans->orderdata = sat_calloc(1, sizeof(*trans->orderdata));
+ trans->orderdata->tes = od.tes;
+ trans->orderdata->ntes = numte;
+ trans->orderdata->invedgedata = od.invedgedata;
+ }
+ else
+ {
+ sat_free(od.tes);
+ sat_free(od.invedgedata);
+ }
}
static void
transaction_add_choices(Transaction *trans, Queue *choices, Id chosen)
{
int i, j;
+ struct _TransactionOrderdata *od = trans->orderdata;
struct _TransactionElement *te;
+ if (!od)
+ return choices->count;
if (!chosen)
{
/* initialization step */
- for (i = 1, te = trans->tes + i; i < trans->ntes; i++, te++)
+ for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
te->mark = 0;
- for (i = 1, te = trans->tes + i; i < trans->ntes; i++, te++)
+ for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
{
- for (j = te->edges; trans->invedgedata[j]; j++)
- trans->tes[trans->invedgedata[j]].mark++;
+ for (j = te->edges; od->invedgedata[j]; j++)
+ od->tes[od->invedgedata[j]].mark++;
}
- for (i = 1, te = trans->tes + i; i < trans->ntes; i++, te++)
+ for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
if (!te->mark)
{
queue_push(choices, te->type);
}
return choices->count;
}
- for (i = 1, te = trans->tes + i; i < trans->ntes; i++, te++)
+ for (i = 1, te = od->tes + i; i < od->ntes; i++, te++)
if (te->p == chosen)
break;
- if (i == trans->ntes)
+ if (i == od->ntes)
return choices->count;
if (te->mark > 0)
{
/* hey! out-of-order installation! */
te->mark = -1;
}
- for (j = te->edges; trans->invedgedata[j]; j++)
+ for (j = te->edges; od->invedgedata[j]; j++)
{
- te = trans->tes + trans->invedgedata[j];
+ te = od->tes + od->invedgedata[j];
assert(te->mark > 0 || te->mark == -1);
if (te->mark > 0 && --te->mark == 0)
{
#include "bitmap.h"
struct _Pool;
-
-/* internal */
-struct _TransactionElement {
- Id p; /* solvable id */
- Id type; /* installation type */
- Id edges;
- Id mark;
-};
+struct _TransactionOrderdata;
typedef struct _Transaction {
struct _Pool *pool; /* back pointer to pool */
Id *transaction_installed;
Map transactsmap;
- struct _TransactionElement *tes;
- int ntes;
- Id *invedgedata;
+ struct _TransactionOrderdata *orderdata;
} Transaction;
extern void solver_transaction_all_pkgs(Transaction *trans, Id p, Queue *pkgs);
extern Id solver_transaction_pkg(Transaction *trans, Id p);
extern Id solver_transaction_show(Transaction *trans, Id type, Id p, int mode);
-extern void transaction_order(Transaction *trans);
+extern void transaction_order(Transaction *trans, int flags);
extern void transaction_check(Transaction *trans);
+extern int transaction_add_choices(Transaction *trans, Queue *choices, Id chosen);
+
+/* order flags */
+#define SOLVER_TRANSACTION_KEEP_ORDERDATA (1 << 0)
#ifdef __cplusplus
}