Esempio n. 1
0
        public override SqlStatementKind BuildSql(StringBuilder b, SqlQueryContext context)
        {
            if (context.RequireIDList)
            {
                throw new NotSupportedException();
            }

            CallTreeNodeSqlNameSet newNames = new CallTreeNodeSqlNameSet(context);

            context.SetCurrent(newNames, SqlTableType.None, false);

            b.AppendLine("SELECT "
                         + SqlAs("nameid", newNames.NameID) + ", "
                         + SqlAs("SUM(cpucyclesspent)", newNames.CpuCyclesSpent) + ", "
                         + SqlAs("SUM(cpucyclesspentself)", newNames.CpuCyclesSpentSelf) + ", "
                         + SqlAs("SUM(callcount)", newNames.CallCount) + ", "
                         + SqlAs("MAX(hasChildren)", newNames.HasChildren) + ", "
                         + SqlAs("SUM(CASE WHEN datasetid = " + context.StartDataSet.ID + " THEN activecallcount ELSE 0 END)", newNames.ActiveCallCount));
            b.AppendLine("FROM Functions");
            if (StartDataSet >= 0)
            {
                b.AppendLine("WHERE datasetid BETWEEN " + StartDataSet + " AND " + EndDataSet);
            }
            b.AppendLine("GROUP BY nameid");
            return(SqlStatementKind.SelectGroupBy);
        }
Esempio n. 2
0
        public override SqlStatementKind BuildSql(StringBuilder b, SqlQueryContext context)
        {
            Target.BuildSql(b, context);

            CallTreeNodeSqlNameSet oldNames = context.CurrentNameSet;
            CallTreeNodeSqlNameSet newNames = new CallTreeNodeSqlNameSet(context);

            string query = "SELECT "
                           + SqlAs(oldNames.NameID, newNames.NameID) + ", "
                           + SqlAs("SUM(" + oldNames.CpuCyclesSpent + ")", newNames.CpuCyclesSpent) + ", "
                           + SqlAs("SUM(" + oldNames.CpuCyclesSpentSelf + ")", newNames.CpuCyclesSpentSelf) + ", "
                           + SqlAs("SUM(" + oldNames.CallCount + ")", newNames.CallCount) + ", "
                           + SqlAs("MAX(" + oldNames.HasChildren + ")", newNames.HasChildren) + ", "
                           + SqlAs("SUM(" + oldNames.ActiveCallCount + ")", newNames.ActiveCallCount);

            if (context.HasIDList)
            {
                query += ", " + SqlAs("GROUP_CONCAT(" + oldNames.ID + ")", newNames.ID);
            }
            query += Environment.NewLine + "FROM (" + Environment.NewLine;
            b.Insert(0, query);
            b.AppendLine(") GROUP BY " + oldNames.NameID);
            context.SetCurrent(newNames, SqlTableType.None, context.HasIDList);

            return(SqlStatementKind.SelectGroupBy);
        }
		public ExpressionSqlWriter(TextWriter w, SqlQueryContext context, ParameterExpression callTreeNodeParameter)
		{
			if (w == null)
				throw new ArgumentNullException("w");
			if (context == null)
				throw new ArgumentNullException("context");
			this.w = w;
			this.context = context;
			this.nameSet = context.CurrentNameSet;
			this.callTreeNodeParameter = callTreeNodeParameter;
		}
 public ExpressionSqlWriter(TextWriter w, SqlQueryContext context, ParameterExpression callTreeNodeParameter)
 {
     if (w == null)
     {
         throw new ArgumentNullException("w");
     }
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     this.w       = w;
     this.context = context;
     this.nameSet = context.CurrentNameSet;
     this.callTreeNodeParameter = callTreeNodeParameter;
 }
Esempio n. 5
0
		public override SqlStatementKind BuildSql(StringBuilder b, SqlQueryContext context)
		{
			CallTreeNodeSqlNameSet newNames = new CallTreeNodeSqlNameSet(context);
			context.SetCurrent(newNames, SqlTableType.Calls, true);
			
			b.AppendLine("SELECT "
			             + SqlAs("nameid", newNames.NameID) + ", "
			             + SqlAs("cpucyclesspent", newNames.CpuCyclesSpent) + ", "
			             + SqlAs("cpucyclesspentself", newNames.CpuCyclesSpentSelf) + ", "
			             + SqlAs("callcount", newNames.CallCount) + ", "
			             + SqlAs("(id != endid)", newNames.HasChildren) + ", "
			             + SqlAs("((id BETWEEN " + context.StartDataSet.RootID + " AND " + context.StartDataSet.CallEndID
			                     + ") AND isActiveAtStart)", newNames.ActiveCallCount) + ", "
			             + SqlAs("id", newNames.ID));
			b.AppendLine("FROM Calls");
			return SqlStatementKind.Select;
		}
Esempio n. 6
0
        public override SqlStatementKind BuildSql(StringBuilder b, SqlQueryContext context)
        {
            CallTreeNodeSqlNameSet newNames = new CallTreeNodeSqlNameSet(context);

            context.SetCurrent(newNames, SqlTableType.Calls, true);

            b.AppendLine("SELECT "
                         + SqlAs("nameid", newNames.NameID) + ", "
                         + SqlAs("cpucyclesspent", newNames.CpuCyclesSpent) + ", "
                         + SqlAs("cpucyclesspentself", newNames.CpuCyclesSpentSelf) + ", "
                         + SqlAs("callcount", newNames.CallCount) + ", "
                         + SqlAs("(id != endid)", newNames.HasChildren) + ", "
                         + SqlAs("((id BETWEEN " + context.StartDataSet.RootID + " AND " + context.StartDataSet.CallEndID
                                 + ") AND isActiveAtStart)", newNames.ActiveCallCount) + ", "
                         + SqlAs("id", newNames.ID));
            b.AppendLine("FROM Calls");
            return(SqlStatementKind.Select);
        }
Esempio n. 7
0
		/// <summary>
		/// Wraps the current SQL statement into an inner select, allowing to continue with "WHERE" queries
		/// even after ORDER BY or LIMIT.
		/// </summary>
		protected static void WrapSqlIntoNestedStatement(StringBuilder b, SqlQueryContext context)
		{
			CallTreeNodeSqlNameSet oldNames = context.CurrentNameSet;
			CallTreeNodeSqlNameSet newNames = new CallTreeNodeSqlNameSet(context);
			
			string query = "SELECT "
				+ SqlAs(oldNames.NameID, newNames.NameID) + ", "
				+ SqlAs(oldNames.CpuCyclesSpent, newNames.CpuCyclesSpent) + ", "
				+ SqlAs(oldNames.CpuCyclesSpentSelf, newNames.CpuCyclesSpentSelf) + ", "
				+ SqlAs(oldNames.CallCount, newNames.CallCount) + ", "
				+ SqlAs(oldNames.HasChildren, newNames.HasChildren) + ", "
				+ SqlAs(oldNames.ActiveCallCount, newNames.ActiveCallCount);
			if (context.HasIDList) {
				query += ", " + SqlAs(oldNames.ID, newNames.ID);
			}
			query += Environment.NewLine + "FROM (" + Environment.NewLine;
			b.Insert(0, query);
			b.AppendLine(")");
			context.SetCurrent(newNames, SqlTableType.None, context.HasIDList);
		}
Esempio n. 8
0
		public override SqlStatementKind BuildSql(StringBuilder b, SqlQueryContext context)
		{
			if (context.RequireIDList)
				throw new NotSupportedException();
			
			CallTreeNodeSqlNameSet newNames = new CallTreeNodeSqlNameSet(context);
			context.SetCurrent(newNames, SqlTableType.None, false);
			
			b.AppendLine("SELECT "
			             + SqlAs("nameid", newNames.NameID) + ", "
			             + SqlAs("SUM(cpucyclesspent)", newNames.CpuCyclesSpent) + ", "
			             + SqlAs("SUM(cpucyclesspentself)", newNames.CpuCyclesSpentSelf) + ", "
			             + SqlAs("SUM(callcount)", newNames.CallCount) + ", "
			             + SqlAs("MAX(hasChildren)", newNames.HasChildren) + ", "
			             + SqlAs("SUM(CASE WHEN datasetid = " + context.StartDataSet.ID + " THEN activecallcount ELSE 0 END)", newNames.ActiveCallCount));
			b.AppendLine("FROM Functions");
			if (StartDataSet >= 0)
				b.AppendLine("WHERE datasetid BETWEEN " + StartDataSet + " AND " + EndDataSet);
			b.AppendLine("GROUP BY nameid");
			return SqlStatementKind.SelectGroupBy;
		}
Esempio n. 9
0
        /// <summary>
        /// Wraps the current SQL statement into an inner select, allowing to continue with "WHERE" queries
        /// even after ORDER BY or LIMIT.
        /// </summary>
        protected static void WrapSqlIntoNestedStatement(StringBuilder b, SqlQueryContext context)
        {
            CallTreeNodeSqlNameSet oldNames = context.CurrentNameSet;
            CallTreeNodeSqlNameSet newNames = new CallTreeNodeSqlNameSet(context);

            string query = "SELECT "
                           + SqlAs(oldNames.NameID, newNames.NameID) + ", "
                           + SqlAs(oldNames.CpuCyclesSpent, newNames.CpuCyclesSpent) + ", "
                           + SqlAs(oldNames.CpuCyclesSpentSelf, newNames.CpuCyclesSpentSelf) + ", "
                           + SqlAs(oldNames.CallCount, newNames.CallCount) + ", "
                           + SqlAs(oldNames.HasChildren, newNames.HasChildren) + ", "
                           + SqlAs(oldNames.ActiveCallCount, newNames.ActiveCallCount);

            if (context.HasIDList)
            {
                query += ", " + SqlAs(oldNames.ID, newNames.ID);
            }
            query += Environment.NewLine + "FROM (" + Environment.NewLine;
            b.Insert(0, query);
            b.AppendLine(")");
            context.SetCurrent(newNames, SqlTableType.None, context.HasIDList);
        }
Esempio n. 10
0
		public override SqlStatementKind BuildSql(StringBuilder b, SqlQueryContext context)
		{
			Target.BuildSql(b, context);
			
			CallTreeNodeSqlNameSet oldNames = context.CurrentNameSet;
			CallTreeNodeSqlNameSet newNames = new CallTreeNodeSqlNameSet(context);
			
			string query = "SELECT "
				+ SqlAs(oldNames.NameID, newNames.NameID) + ", "
				+ SqlAs("SUM(" + oldNames.CpuCyclesSpent + ")", newNames.CpuCyclesSpent) + ", "
				+ SqlAs("SUM(" + oldNames.CpuCyclesSpentSelf + ")", newNames.CpuCyclesSpentSelf) + ", "
				+ SqlAs("SUM(" + oldNames.CallCount + ")", newNames.CallCount) + ", "
				+ SqlAs("MAX(" + oldNames.HasChildren + ")", newNames.HasChildren) + ", "
				+ SqlAs("SUM(" + oldNames.ActiveCallCount + ")", newNames.ActiveCallCount);
			if (context.HasIDList) {
				query += ", " + SqlAs("GROUP_CONCAT(" + oldNames.ID + ")", newNames.ID);
			}
			query += Environment.NewLine + "FROM (" + Environment.NewLine;
			b.Insert(0, query);
			b.AppendLine(") GROUP BY " + oldNames.NameID);
			context.SetCurrent(newNames, SqlTableType.None, context.HasIDList);
			
			return SqlStatementKind.SelectGroupBy;
		}
Esempio n. 11
0
		public void SetCurrent(CallTreeNodeSqlNameSet nameSet, SqlTableType table, bool hasIDList)
		{
			CurrentNameSet = nameSet;
			CurrentTable = table;
			HasIDList = hasIDList;
		}
Esempio n. 12
0
 public void SetCurrent(CallTreeNodeSqlNameSet nameSet, SqlTableType table, bool hasIDList)
 {
     CurrentNameSet = nameSet;
     CurrentTable   = table;
     HasIDList      = hasIDList;
 }