Changeset: 5b86c05dfad3 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5b86c05dfad3
Modified Files:
monetdb5/extras/dvf/opt_dvf_bam.c
sql/backends/monet5/bam/Tests/benchmarks_0/benchmark2.sql
sql/backends/monet5/bam/Tests/benchmarks_0/query2.11.sql
sql/backends/monet5/bam/Tests/benchmarks_0/query2.12.sql
sql/backends/monet5/bam/Tests/benchmarks_1/benchmark2.sql
sql/backends/monet5/bam/Tests/benchmarks_1/query2.12.sql
sql/backends/monet5/bam/Tests/benchmarks_2/benchmark2.sql
sql/backends/monet5/bam/Tests/benchmarks_2/query2.1.sql
sql/backends/monet5/bam/Tests/benchmarks_2/query2.10.sql
sql/backends/monet5/bam/Tests/benchmarks_2/query2.11.sql
sql/backends/monet5/bam/Tests/benchmarks_2/query2.12.sql
sql/backends/monet5/bam/Tests/benchmarks_2/query2.2.sql
sql/backends/monet5/bam/Tests/benchmarks_2/query2.3.sql
sql/backends/monet5/bam/Tests/benchmarks_2/query2.4.sql
sql/backends/monet5/bam/Tests/benchmarks_2/query2.5.sql
sql/backends/monet5/bam/Tests/benchmarks_2/query2.6.sql
sql/backends/monet5/bam/Tests/benchmarks_2/query2.7.sql
sql/backends/monet5/bam/Tests/benchmarks_2/query2.9.sql
sql/backends/monet5/bam/Tests/common/common.c
sql/backends/monet5/bam/Tests/db_exec/db_exec
sql/backends/monet5/bam/Tests/db_exec/db_exec.c
sql/backends/monet5/bam/Tests/usecase_exec/usecase_exec
sql/backends/monet5/bam/Tests/usecase_exec/usecase_exec.c
sql/backends/monet5/bam/bam_loader.c
Branch: DVframework_bam
Log Message:
Adapted benchmark queries in benchmark_2 to postpone evaluation of external
table for as long as possible. In order to support a double join of external
data, which is needed in queries 2.10, 2.11 and 2.12, some additions were done
to opt_dvf_bam.c.
Furthermore, did some debugging in usecase_exec, since it turned out that the
equality checks were not done correctly.
diffs (truncated from 5470 to 300 lines):
diff --git a/monetdb5/extras/dvf/opt_dvf_bam.c
b/monetdb5/extras/dvf/opt_dvf_bam.c
--- a/monetdb5/extras/dvf/opt_dvf_bam.c
+++ b/monetdb5/extras/dvf/opt_dvf_bam.c
@@ -18,11 +18,14 @@
*
* ...
* (X_m, r_m) := algebra.join(X_a, X_l);
+ * ...
+ * (X_m2, r_m2) := algebra.join(X_a2, X_l); //Optional, occurs only when the
same external table gets joined with a virtual offset list twice (three times
in the benchmark queries)
*
*
- * So, both patterns start with the sql.bind instruction and both patterns end
with the algebra.join instruction.
+ * So, both patterns start with the sql.bind instruction and both patterns end
with one or two algebra.join instructions.
*
- * In both patterns we would like to inject a call to the mount function with
as its argument X_a.
+ * In both patterns we would like to inject a (two) call(s) to the mount
function with as its argument X_a (and X_a2). When the lines in the patterns
+ * are recognized, they are immediately removed from the MAL plan, since they
will be superfluous when a mount instruction will be inserted.
* Furthermore, we have to translate extern_alignments_i to an actual
file_location, which we can
* accomplish by injecting the right MAL:
*
@@ -43,16 +46,18 @@
* In this example X_3 is the mvc and X_c is the BAT containing the
file_location. This file location BAT
* can be passed to the mount instruction, together with X_a from the obtained
pattern.
*
- * Directly after the definition of X_a, we inject the above file_location
instructions, directly followed by
- * the following mount instruction:
+ * Directly after the definition of X_a (X_a2), we inject the above
file_location instructions, directly followed by
+ * the following mount instruction(s):
*
- * (X_x, X_y, X_z) = bam.mount(X_c, X_a);
+ * (X_x, X_y, X_z ) = bam.mount(X_c, X_a);
+ * ...
+ * (X_x2, X_y2, X_z2) = bam.mount(X_c, X_a2); //Only if two joins were found,
gets injected directly after the definition of X_a2
*
*
* The mount instruction will return a table of the form (oids:bat[:oid,:oid],
seqs:bat[:oid,:str], quals:bat[:oid,:str]).
- * The first return value contains the oids that would normally occupy the
first return value of algebra.join (X_m).
+ * The first return value contains the oids that would normally occupy X_m;
the first return value of algebra.join.
* All bind/delta/fetch instructions meant to load the sequence and quality
strings become superfluous and thus have
- * to be removed. Depending on which pattern was obtained first (1 or 2), we
assume that we can remove one of the following
+ * to be removed. Depending on which pattern was obtained (1 or 2), we assume
that we can remove one of the following
* patterns safely:
*
* X_p := sql.bind(.., "bam", "extern_alignments_i", "seq", 0);
@@ -71,9 +76,10 @@
*
* ...
* X_s := algebra.leftfetchjoin(r_m, X_r);
+ * X_s2 := algebra.leftfetchjoin(r_l, X_r); //Only if two joins were found,
can occur either before or after the X_s := instruction
*
- * Recall that r_m contains the virtual offset oids that follow from the
algebra.join on the internal and external table.
- * So the result of X_s contains a bat[:oid,:str] with all the external seqs.
+ * Recall that r_m (r_m2) contains the virtual offset oids that follow from
the algebra.join on the internal and external table.
+ * So the result of X_s (X_s2) contains a bat[:oid,:str] with all the external
seqs.
*
*
* For the qual field, a similar pattern holds:
@@ -94,13 +100,17 @@
*
* ...
* X_w := algebra.leftfetchjoin(r_m, X_v);
+ * X_w2 := algebra.leftfetchjoin(r_m2, X_v); //Only if two joins were found,
can occur either before or after the X_w := instruction
*
*
- * In this case, X_w contains a bat[:oid,:str] with all the quals.
+ * In this case, X_w (X_w2) contains a bat[:oid,:str] with all the quals.
*
* Hence, X_y = X_s and X_z = X_w and the mount function becomes the following:
*
* (X_m, X_s, X_w) = bam.mount(X_c, X_a);
+ *
+ * In case of two joins, we find the following extra mount function:
+ * (X_m2, X_s2, X_w2) = bam.mount(X_c, X_a2);
*/
#include "monetdb_config.h"
@@ -116,20 +126,20 @@ typedef struct _external_file_data {
int x_j;
int x_k;
int x_l;
- int x_a;
- int x_m;
- int r_m;
+ int x_a, x_a2;
+ int x_m, x_m2;
+ int r_m, r_m2;
/* Vars for recognizing part where the seq and qual get bound*/
int x_p;
int x_q;
int x_r;
- int x_s;
+ int x_s, x_s2;
int x_t;
int x_u;
int x_v;
- int x_w;
+ int x_w, x_w2;
} _external_file_data;
static _external_file_data *
@@ -139,19 +149,19 @@ static _external_file_data *
efd->x_j = -1;
efd->x_k = -1;
efd->x_l = -1;
- efd->x_a = -1;
- efd->x_m = -1;
- efd->r_m = -1;
+ efd->x_a = efd->x_a2 = -1;
+ efd->x_m = efd->x_m2 = -1;
+ efd->r_m = efd->r_m2 = -1;
efd->x_p = -1;
efd->x_q = -1;
efd->x_r = -1;
- efd->x_s = -1;
+ efd->x_s = efd->x_s2 = -1;
efd->x_t = -1;
efd->x_u = -1;
efd->x_v = -1;
- efd->x_w = -1;
+ efd->x_w = efd->x_w2 = -1;
return efd;
}
@@ -389,7 +399,6 @@ static int
(void) stk;
(void) pci;
-
/* iterate over the instructions of the input MAL program to inject all
file_location calculations and to remove all instructions
that try to bind to the external tables or use the results of these
binds; during the loop necessary information will be stored in efds;
a new malblock will be build, instead of shuffling instructions around
in the old one. */
@@ -544,6 +553,17 @@ static int
}
/* check for
+ * X_s2 := algebra.leftfetchjoin(r_m2, X_r);
+ */
+ if(efd_storage[j].r_m2 == getArg(p, 1) && efd_storage[j].x_r
== getArg(p, 2))
+ {
+ assert(efd_storage[j].x_s2 == -1);
+ efd_storage[j].x_s2 = getArg(p, 0);
+ push_instr = FALSE;
+ break;
+ }
+
+ /* check for
* X_v := algebra.leftfetchjoin(.., X_u);
*/
if(efd_storage[j].x_u == getArg(p, 2))
@@ -564,6 +584,17 @@ static int
push_instr = FALSE;
break;
}
+
+ /* check for
+ * X_w2 := algebra.leftfetchjoin(r_m2, X_v);
+ */
+ if(efd_storage[j].r_m2 == getArg(p, 1) && efd_storage[j].x_v
== getArg(p, 2))
+ {
+ assert(efd_storage[j].x_w2 == -1);
+ efd_storage[j].x_w2 = getArg(p, 0);
+ push_instr = FALSE;
+ break;
+ }
}
}
@@ -612,7 +643,7 @@ static int
}
/* check for
- * (X_m, r_m) := algebra.join(X_a, X_l);
+ * algebra.join(...);
*/
else if(
getModuleId(p) == algebraRef &&
@@ -620,12 +651,29 @@ static int
{
for(j=0; j<nr_externals; ++j)
{
+ /* check for
+ * algebra.join(.., X_l);
+ */
if(efd_storage[j].x_l == getArg(p, 3))
{
- assert(efd_storage[j].x_a == -1 && efd_storage[j].x_m ==
-1 && efd_storage[j].r_m == -1);
- efd_storage[j].x_a = getArg(p, 2);
- efd_storage[j].x_m = getArg(p, 0);
- efd_storage[j].r_m = getArg(p, 1);
+ if(efd_storage[j].x_a == -1)
+ {
+ /* Current instruction: (X_m, r_m) :=
algebra.join(X_a, X_l); */
+ assert(efd_storage[j].x_m == -1 && efd_storage[j].r_m
== -1);
+ efd_storage[j].x_a = getArg(p, 2);
+ efd_storage[j].x_m = getArg(p, 0);
+ efd_storage[j].r_m = getArg(p, 1);
+ }
+ else if(efd_storage[j].x_a2 == -1)
+ {
+ /* Current instruction: (X_m2, r_m2) :=
algebra.join(X_a2, X_l); */
+ assert(efd_storage[j].x_m2 == -1 &&
efd_storage[j].r_m2 == -1);
+ efd_storage[j].x_a2 = getArg(p, 2);
+ efd_storage[j].x_m2 = getArg(p, 0);
+ efd_storage[j].r_m2 = getArg(p, 1);
+ }
+ else assert(FALSE); /* More than two algebra.join
detected... */
+
push_instr = FALSE;
break;
}
@@ -646,42 +694,62 @@ static int
if (newMalBlkStmt(mb,mb->ssize) < 0)
return 0;
-
- for(i=0; i<limit; ++i)
+
{
- bit push_instr = TRUE;
- p = old[i];
-
- for(j=0; j<nr_externals; ++j)
+ InstrPtr instr;
+ int file_location = -1;
+
+ for(i=0; i<limit; ++i)
{
- if(efd_storage[j].x_a == getArg(p, 0))
+ bit push_instr = TRUE;
+ p = old[i];
+
+ for(j=0; j<nr_externals; ++j)
{
- InstrPtr instr;
- int file_location;
-
- assert(efd_storage[j].x_s >= 0 && efd_storage[j].x_w >= 0);
-
+ if(efd_storage[j].x_a == getArg(p, 0))
+ {
+ assert(efd_storage[j].x_s >= 0 && efd_storage[j].x_w >= 0);
+
+ pushInstruction(mb, p);
+ file_location = push_mal_file_location(mb,
efd_storage[j].file_id, mvc);
+
+ instr = newInstruction(mb, ASSIGNsymbol);
+ setModuleId(instr, bamRef);
+ setFunctionId(instr, mountRef);
+ instr = pushReturn(mb, instr, efd_storage[j].x_m);
+ instr = pushReturn(mb, instr, efd_storage[j].x_s);
+ instr = pushReturn(mb, instr, efd_storage[j].x_w);
+ instr = pushArgument(mb, instr, file_location);
+ instr = pushArgument(mb, instr, efd_storage[j].x_a);
+ pushInstruction(mb, instr);
+ push_instr = FALSE;
+ break;
+ }
+ else if(efd_storage[j].x_a2 == getArg(p, 0))
+ {
+ assert(file_location >= 0 && efd_storage[j].x_m2 >= 0 &&
efd_storage[j].x_s2 >= 0 && efd_storage[j].x_w2 >= 0);
+
+ pushInstruction(mb, p);
+
+ instr = newInstruction(mb, ASSIGNsymbol);
+ setModuleId(instr, bamRef);
+ setFunctionId(instr, mountRef);
+ instr = pushReturn(mb, instr, efd_storage[j].x_m2);
+ instr = pushReturn(mb, instr, efd_storage[j].x_s2);
+ instr = pushReturn(mb, instr, efd_storage[j].x_w2);
+ instr = pushArgument(mb, instr, file_location);
+ instr = pushArgument(mb, instr, efd_storage[j].x_a2);
+ pushInstruction(mb, instr);
+ push_instr = FALSE;
+ break;
+ }
+ }
+
+ if(push_instr)
+ {
pushInstruction(mb, p);
- file_location = push_mal_file_location(mb,
efd_storage[j].file_id, mvc);
-
- instr = newInstruction(mb, ASSIGNsymbol);
- setModuleId(instr, bamRef);
- setFunctionId(instr, mountRef);
- instr = pushReturn(mb, instr, efd_storage[j].x_m);
- instr = pushReturn(mb, instr, efd_storage[j].x_s);
- instr = pushReturn(mb, instr, efd_storage[j].x_w);
- instr = pushArgument(mb, instr, file_location);
- instr = pushArgument(mb, instr, efd_storage[j].x_a);
- pushInstruction(mb, instr);
- push_instr = FALSE;
- break;
}
}
-
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list