Package ra

Examples of ra.Term.execute()


        //Reference
        Utils.reset();
        t = union(rel("tab", 1), ref("tab"));
        System.out.println(t);
        r = t.execute();
        System.out.println(r.getResultRelation());
        System.out.println(r.getFormulas());
        ats.storeAlgebra("examples/test_reference1.xml", t);
        ats.writeExcel("examples/excel_reference1.xlsx", r);
        t = ats.readAlgebra("examples/test_reference1.xml");
View Full Code Here


        //select x.a, y.b from tab x, tab y where x.b=y.a minus select a, b from tab;
        //tab(a,b,dl)
        Utils.reset();
        t = diffSet(project(eqJoin(rel("tab", 3), ref("tab"), 2, 1), 2, 4), project(ref("tab"), 1, 2));
        System.out.println(t);
        r = t.execute();
        System.out.println(r.getResultRelation());
        System.out.println(r.getFormulas());
        ats.storeAlgebra("examples/test_example1.xml", t);
        ats.writeExcel("examples/excel_example1.xlsx", r);
        t = ats.readAlgebra("examples/test_example1.xml");
View Full Code Here

        //groupby: x.a, y.b, z.dl, min(x.dl+y.dl)
        //filter: x.a, y.b, z.dl, min(x.dl+y.dl) {z.dl > min(x.dl+y.dl)}
        Utils.reset();
        t = filter(groupBy(select(genJoin(eqJoin(rel("tab", 3), ref("tab"), 2, 1), ref("tab"), "And(#2=#6,#4=#7)"), "#2", "#4", "#3+#5", "#8"), 1, 2, 4).min(3), "#3>#4");
        System.out.println(t);
        r = t.execute();
        System.out.println(r.getResultRelation());
        System.out.println(r.getFormulas());
        ats.storeAlgebra("examples/test_example2.xml", t);
        ats.writeExcel("examples/excel_example2.xlsx", r);
        t = ats.readAlgebra("examples/test_example2.xml");
View Full Code Here

        }

        AlgebraToSpreadsheet ats = new AlgebraToSpreadsheet();
        Utils.reset();
        Term t = ats.readAlgebra(args[0]);
        Result r = t.execute();
        ats.writeExcel(fos, r);
    }
}
View Full Code Here

            String txtOutputPath = String.format("%s/%s.txt", file.getParent(), Files.getNameWithoutExtension(file.toString()));
            System.out.println(String.format("Writing %s", txtOutputPath));

            StringBuilder builder = new StringBuilder();
            reportRelationalAlgebraForm(builder, formula, sqlQuery);
            Result result = formula.execute();
            reportSpreadsheetForm(builder, result);

            try {
                Files.write(builder.toString(), new File(txtOutputPath), Charsets.UTF_8);
            } catch (IOException e) {
View Full Code Here

        System.out.format("*** SQL query:\n\t%s\n", SQL_QUERY);
        System.out.format("*** Translated to relational algebra:\n\t%s\n", translated);
        System.out.format("\n*** Indented:\n%s\n", indentString(Terms.indent(translated)));

        Result r = translated.execute();
        System.out.format("Implemented in excel:\n");
        System.out.format("*** Result relations:\n\t%s\n", r.getResultRelation().toString(Utils.getCaf()));
        System.out.format("*** Formulas:\n%s\n", indentString(r.getFormulas().toString(Utils.getCaf())));
        System.out.format("*** Labels:\n%s\n", indentString(r.getLabels().toString(Utils.getCaf())));
    }
View Full Code Here

        //GroupBy
        Utils.reset();
        t = groupBy(rel(1), 1);
        System.out.println(t);
        r = t.execute();
        System.out.println(r.getResultRelation());
        System.out.println(r.getFormulas());
        ats.storeAlgebra("examples/test_groupBy1.xml", t);
        ats.writeExcel("examples/excel_groupBy1.xlsx", r);
        t = ats.readAlgebra("examples/test_groupBy1.xml");
View Full Code Here

        System.out.println("----------------------------------------------------");

        Utils.reset();
        t = groupBy(rel(2), 1, 2).countDistinct(1);
        System.out.println(t);
        r = t.execute();
        System.out.println(r.getResultRelation());
        System.out.println(r.getFormulas());
        ats.storeAlgebra("examples/test_groupBy2.xml", t);
        ats.writeExcel("examples/excel_groupBy2.xlsx", r);
        t = ats.readAlgebra("examples/test_groupBy2.xml");
View Full Code Here

        //no columns to group over
        Utils.reset();
        t = groupBy(rel(2)).countDistinct(1);
        System.out.println(t);
        r = t.execute();
        System.out.println(r.getResultRelation());
        System.out.println(r.getFormulas());
        ats.storeAlgebra("examples/test_groupBy2_no_columns_to_group_over.xml", t);
        ats.writeExcel("examples/excel_groupBy2_no_columns_to_group_over.xlsx", r);
        t = ats.readAlgebra("examples/test_groupBy2_no_columns_to_group_over.xml");
View Full Code Here

        System.out.println("----------------------------------------------------");

        Utils.reset();
        t = groupBy(rel(10), 1, 2);
        System.out.println(t);
        r = t.execute();
        System.out.println(r.getResultRelation());
        System.out.println(r.getFormulas());
        ats.storeAlgebra("examples/test_groupBy3.xml", t);
        ats.writeExcel("examples/excel_groupBy3.xlsx", r);
        t = ats.readAlgebra("examples/test_groupBy3.xml");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.