Changeset: 0620a1e41855 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0620a1e41855
Modified Files:
        monetdb5/extras/jaql/Tests/transform00.mal
        monetdb5/extras/jaql/Tests/transform00.stable.out
        monetdb5/extras/jaql/jaqlgencode.c
Branch: jacqueline
Log Message:

transform: finished by implementing pair generation

Full transform support has now been implemented.  Object's pair support
is a slight variation to arrays.


diffs (132 lines):

diff --git a/monetdb5/extras/jaql/Tests/transform00.mal 
b/monetdb5/extras/jaql/Tests/transform00.mal
--- a/monetdb5/extras/jaql/Tests/transform00.mal
+++ b/monetdb5/extras/jaql/Tests/transform00.mal
@@ -7,3 +7,5 @@ jaql.x("[1,2,3] -> transform 2 * ($ * 2)
 jaql.x("[1,2,3] -> transform 2 * 2.0 * $;");
 jaql.x("[1,2,3] -> transform ($ * 2.0) / 4;");
 jaql.x("[1,2,3] -> transform [$, $];");
+jaql.x("[1,2,3] -> transform {\"value\":$};");
+jaql.x("[1,2,3] -> transform {\"value\":$ + $};");
diff --git a/monetdb5/extras/jaql/Tests/transform00.stable.out 
b/monetdb5/extras/jaql/Tests/transform00.stable.out
--- a/monetdb5/extras/jaql/Tests/transform00.stable.out
+++ b/monetdb5/extras/jaql/Tests/transform00.stable.out
@@ -26,6 +26,8 @@ function user.main():void;
     jaql.x("[1,2,3] -> transform 2 * 2.0 * $;");
     jaql.x("[1,2,3] -> transform ($ * 2.0) / 4;");
     jaql.x("[1,2,3] -> transform [$, $];");
+    jaql.x("[1,2,3] -> transform {\"value\":$};");
+    jaql.x("[1,2,3] -> transform {\"value\":$ + $};");
 end main;
 [ 4, 4, 4 ]
 [ 1, 2.600000 ]
@@ -36,6 +38,8 @@ end main;
 [ 4.000000, 8.000000, 12.000000 ]
 [ 0.500000, 1.000000, 1.500000 ]
 [ [ 1, 1 ], [ 2, 2 ], [ 3, 3 ] ]
+[ { "value": 1 }, { "value": 2 }, { "value": 3 } ]
+[ { "value": 2 }, { "value": 4 }, { "value": 6 } ]
 
 # 21:27:13 >  
 # 21:27:13 >  "Done."
diff --git a/monetdb5/extras/jaql/jaqlgencode.c 
b/monetdb5/extras/jaql/jaqlgencode.c
--- a/monetdb5/extras/jaql/jaqlgencode.c
+++ b/monetdb5/extras/jaql/jaqlgencode.c
@@ -1233,6 +1233,98 @@ dumpvariabletransformation(MalBlkPtr mb,
 
                        return a;
                }
+               case j_pair:
+                       b = dumpvariabletransformation(mb, t->tval1, elems,
+                                       j1, j2, j3, j4, j5, j6, j7);
+                       /* only need to copy if tval1 is a var, otherwise we 
have a
+                        * new copy already */
+                       if (t->tval1->type == j_var) {
+                               int *lv[] = {j2, j3, j4, j5, j6, NULL};
+                               int **lp = lv;
+
+                               a = dumpnextid(mb, *j1);
+
+                               q = newInstruction(mb, ASSIGNsymbol);
+                               setModuleId(q, algebraRef);
+                               setFunctionId(q, markHRef);
+                               q = pushReturn(mb, q, newTmpVariable(mb, 
TYPE_any));
+                               q = pushArgument(mb, q, b);
+                               q = pushArgument(mb, q, a);
+                               c = getArg(q, 0);
+                               pushInstruction(mb, q);
+                               q = newInstruction(mb, ASSIGNsymbol);
+                               setModuleId(q, algebraRef);
+                               setFunctionId(q, putName("kunion", 6));
+                               q = pushReturn(mb, q, newTmpVariable(mb, 
TYPE_any));
+                               q = pushArgument(mb, q, *j1);
+                               q = pushArgument(mb, q, c);
+                               *j1 = getArg(q, 0);
+                               pushInstruction(mb, q);
+
+                               q = newInstruction(mb, ASSIGNsymbol);
+                               setModuleId(q, algebraRef);
+                               setFunctionId(q, markTRef);
+                               q = pushReturn(mb, q, newTmpVariable(mb, 
TYPE_any));
+                               q = pushArgument(mb, q, b);
+                               q = pushArgument(mb, q, a);
+                               d = getArg(q, 0);
+                               pushInstruction(mb, q);
+                               q = newInstruction(mb, ASSIGNsymbol);
+                               setModuleId(q, batRef);
+                               setFunctionId(q, reverseRef);
+                               q = pushReturn(mb, q, newTmpVariable(mb, 
TYPE_any));
+                               q = pushArgument(mb, q, d);
+                               d = getArg(q, 0);
+                               pushInstruction(mb, q);
+
+                               for (; *lp != NULL; lp++) {
+                                       q = newInstruction(mb, ASSIGNsymbol);
+                                       setModuleId(q, algebraRef);
+                                       setFunctionId(q, semijoinRef);
+                                       q = pushReturn(mb, q, 
newTmpVariable(mb, TYPE_any));
+                                       q = pushArgument(mb, q, **lp);
+                                       q = pushArgument(mb, q, b);
+                                       e = getArg(q, 0);
+                                       pushInstruction(mb, q);
+                                       q = newInstruction(mb, ASSIGNsymbol);
+                                       setModuleId(q, algebraRef);
+                                       setFunctionId(q, joinRef);
+                                       q = pushReturn(mb, q, 
newTmpVariable(mb, TYPE_any));
+                                       q = pushArgument(mb, q, d);
+                                       q = pushArgument(mb, q, e);
+                                       e = getArg(q, 0);
+                                       pushInstruction(mb, q);
+                                       q = newInstruction(mb, ASSIGNsymbol);
+                                       setModuleId(q, algebraRef);
+                                       setFunctionId(q, putName("kunion", 6));
+                                       q = pushReturn(mb, q, 
newTmpVariable(mb, TYPE_any));
+                                       q = pushArgument(mb, q, **lp);
+                                       q = pushArgument(mb, q, e);
+                                       **lp = getArg(q, 0);
+                                       pushInstruction(mb, q);
+                               }
+
+                               b = c;
+                       }
+
+                       q = newInstruction(mb, ASSIGNsymbol);
+                       setModuleId(q, algebraRef);
+                       setFunctionId(q, projectRef);
+                       q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any));
+                       q = pushArgument(mb, q, b);
+                       q = pushStr(mb, q, t->sval);
+                       c = getArg(q, 0);
+                       pushInstruction(mb, q);
+                       q = newInstruction(mb, ASSIGNsymbol);
+                       setModuleId(q, algebraRef);
+                       setFunctionId(q, putName("kunion", 6));
+                       q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any));
+                       q = pushArgument(mb, q, *j7);
+                       q = pushArgument(mb, q, c);
+                       *j7 = getArg(q, 0);
+                       pushInstruction(mb, q);
+
+                       return b;
                case j_json_obj:
                        g = 1;
                case j_json_arr:
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to