Esempio n. 1
0
 public RADTuple[] ApplyRelationalAlgebra(AlgebraNodeTree tree) => tree.Apply();
        public CommandTable ConvertTable(ParseNode parseNode)
        {
            if (!parseNode.Equals("<table>"))
            {
                throw new IncompatableParseNodeException();
            }

            Table tableOutput;

            if (parseNode["<list_selection>"] != null)
            {
                string[]  selections, projections;
                ParseNode tableNode = parseNode["<table>"];

                if (parseNode.Contains("<columns>"))
                {
                    projections = ConvertColumns(parseNode["<columns>"]);
                }
                else
                {
                    projections = new string[0];
                }

                ParseNode[] selectionNodes = ConvertListNodeToListOfListObjects(parseNode["<list_selection>"]).ToArray();
                selections = new string[selectionNodes.Length];
                for (int i = 0; i < selectionNodes.Length; i++)
                {
                    selections[i] = $"{selectionNodes[i][0][0].Data}={selectionNodes[i][1][0].Data}";
                }

                if (tableNode.Contains("<join_info_full>"))
                {
                    var tree = new AlgebraNodeTree(db, projections, selections, tableNode["<join_info_full>"]);
                    tableOutput = tree.TableAply();
                    tree.PrintTree();
                }
                else if (tableNode.Contains("<table>"))
                {
                    Table t    = ConvertTable(tableNode["<table>"]).Data as Table;
                    var   tree = new AlgebraNodeTree(t, projections, selections);
                    tableOutput = tree.TableAply();
                    tree.PrintTree();
                }
                else
                {
                    var tree = new AlgebraNodeTree(db, projections, selections, tableNode["<string>"][0].Data);
                    tableOutput = tree.TableAply();
                    tree.PrintTree();
                }
            }
            else if (parseNode.Contains("<join_info_full>"))
            {
                var tree = new AlgebraNodeTree(db, new string[0], new string[0], parseNode["<join_info_full>"]);
                tableOutput = tree.TableAply();
                tree.PrintTree();
            }
            else
            {
                string tableInfo = parseNode["<string>"][0].Data;
                if (variables.ContainsKey(tableInfo))
                {
                    tableOutput = variables[tableInfo].Data as Table;
                    if (tableOutput == null)
                    {
                        tableOutput = db[tableInfo];
                    }
                }
                else
                {
                    tableOutput = db[tableInfo];
                }
            }



            return(new CommandTable(tableOutput));
        }
Esempio n. 3
0
 public Table TableApplyRelationalAlgebra(AlgebraNodeTree tree) => tree.TableAply();