public IQueryable <CallTreeNode> Execute(SQLiteQueryProvider provider, QueryExecutionOptions options) { StringBuilder b = new StringBuilder(); SqlQueryContext context = new SqlQueryContext(provider); BuildSql(b, context); if (options.HasLoggers) { options.WriteLogLine(b.ToString()); } Stopwatch w = Stopwatch.StartNew(); IList <CallTreeNode> result = provider.RunSQLNodeList(b.ToString(), context.HasIDList); w.Stop(); if (options.HasLoggers) { options.WriteLogLine("Query returned " + result.Count + " rows in " + w.Elapsed); } return(result.AsQueryable()); }
public ExecuteAllQueriesVisitor(SQLiteQueryProvider sqliteProvider, QueryExecutionOptions options) { this.sqliteProvider = sqliteProvider; this.options = options; }
/// <summary> /// Creates a new CallTreeNode. /// </summary> public SQLiteCallTreeNode(int nameId, CallTreeNode parent, SQLiteQueryProvider provider) { this.nameId = nameId; this.parent = parent; this.provider = provider; }
internal IList<CallTreeNode> RunSQLNodeList(SQLiteQueryProvider queryProvider, string command, bool hasIdList) { List<CallTreeNode> result = new List<CallTreeNode>(); SQLiteCommand cmd; using (LockAndCreateCommand(out cmd)) { cmd.CommandText = command; using (SQLiteDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { SQLiteCallTreeNode node = new SQLiteCallTreeNode(reader.GetInt32(0), null, queryProvider); node.callCount = reader.GetInt32(3); node.cpuCyclesSpent = reader.GetInt64(1); node.cpuCyclesSpentSelf = reader.GetInt64(2); if (hasIdList) { object ids = reader.GetValue(6); if (ids is long) { node.IdList = new int[] { (int)(long)ids }; } else { int[] idList = ids.ToString().Split(',').Select(s => int.Parse(s)).ToArray(); Array.Sort(idList); node.IdList = idList; } } node.hasChildren = reader.GetBoolean(4); node.activeCallCount = reader.GetInt32(5); result.Add(node); } } } return result; }
/// <inheritdoc/> public override IQueryable<CallTreeNode> GetFunctions(int startIndex, int endIndex) { if (startIndex < 0 || startIndex >= DataSets.Count) throw new ArgumentOutOfRangeException("startIndex", startIndex, "Value must be between 0 and " + endIndex); if (endIndex < startIndex || endIndex >= DataSets.Count) throw new ArgumentOutOfRangeException("endIndex", endIndex, "Value must be between " + startIndex + " and " + (DataSets.Count - 1)); SQLiteQueryProvider queryProvider = new SQLiteQueryProvider(this, startIndex, endIndex); var query = queryProvider.CreateQuery(new Filter(AllCalls.Instance, DataSetFilter(startIndex, endIndex))); return query.Where(c => c.NameMapping.Id != 0 && !c.IsThread).MergeByName(); }
/// <inheritdoc/> public override CallTreeNode GetRoot(int startIndex, int endIndex) { if (startIndex > endIndex) { int help = startIndex; startIndex = endIndex; endIndex = help; } SQLiteQueryProvider queryProvider = new SQLiteQueryProvider(this, startIndex, endIndex); Expression<Func<SingleCall, bool>> filterLambda = c => c.ParentID == -1; return queryProvider.CreateQuery(new Filter(AllCalls.Instance, DataSetFilter(startIndex, endIndex), filterLambda)).Merge(); }
public SqlQueryContext(SQLiteQueryProvider provider) { this.provider = provider; this.StartDataSet = provider.StartDataSet; this.EndDataSet = provider.EndDataSet; }
public IQueryable<CallTreeNode> Execute(SQLiteQueryProvider provider, QueryExecutionOptions options) { StringBuilder b = new StringBuilder(); SqlQueryContext context = new SqlQueryContext(provider); BuildSql(b, context); if (options.HasLoggers) options.WriteLogLine(b.ToString()); Stopwatch w = Stopwatch.StartNew(); IList<CallTreeNode> result = provider.RunSQLNodeList(b.ToString(), context.HasIDList); w.Stop(); if (options.HasLoggers) { options.WriteLogLine("Query returned " + result.Count + " rows in " + w.Elapsed); } return result.AsQueryable(); }