public string ToDot()
        {
            string dot = "";

            dot += Id + "[label=\"" + (PhysicalOperation != null ? PhysicalOperation.ToString() : "root") + "\"]\r";

            foreach (QueryPlanNodeEdge edge in Edges)
            {
                dot += edge.To.ToDot();
                dot += Id + " -> " + edge.To.Id + "[label=" + edge.Cost + "]\r";
            }

            return(dot);
        }
 public QueryPlanNode(LogicalElement logicalElement, PhysicalOperation physicalOperation)
 {
     LogicalElement    = logicalElement;
     PhysicalOperation = physicalOperation;
     Id = MaxId++;
 }
Esempio n. 3
0
        public static List <CustomTuple> ExecuteQuery(string query, bool debug = false)
        {
            if (LogicalQueryPlan == null)
            {
                LogicalQueryPlan = new LogicalQueryPlan(RelationManager);
            }
            if (PhysicalQueryPlan == null)
            {
                PhysicalQueryPlan = new PhysicalQueryPlan(RelationManager, StatisticsManager);
            }

            if (Program.Debug)
            {
                Console.WriteLine("[DEBUG]: Query: " + query);
            }
            LogicalElement logicalTree = LogicalQueryPlan.GetTreeForQuery(query);

            List <CustomTuple> results = new List <CustomTuple>();

            if (logicalTree == null)
            {
                return(results);
            }

            PhysicalOperation physicalOperation = PhysicalQueryPlan.GetPhysicalPlan(logicalTree);

            if (query == UserQuery)
            {
                ;
            }

            if (debug)
            {
                //string s = element.ToDot();
                //;
            }

            physicalOperation.Prepare();


            CustomTuple result;

            do
            {
                result = physicalOperation.GetNext();

                if (result != null)
                {
                    results.Add(result);
                }
            }while (result != null);

            //QueryPlan plan = new QueryPlan(command);

            //int reads = MemoryBuffer.Reads;
            //int writes = MemoryManager.Writes;
            //List<CustomTuple> result = plan.Execute();
            //if (Program.Debug)
            //{
            //    Console.WriteLine("[DEBUG]: Reads for last query: " + (MemoryBuffer.Reads - reads) + " (total: " + reads + "), writes: " + (MemoryManager.Writes - writes) + " (total: " + writes + ")");
            //}

            return(results);
        }