--- a/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/dataprovider/impl/FunctionsListDataProviderImpl.java Tue Sep 20 18:05:07 2011 +0400 +++ a/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/dataprovider/impl/FunctionsListDataProviderImpl.java Wed Sep 21 10:12:52 2011 +0400 @@ -49,10 +49,13 @@ import org.netbeans.modules.dlight.api.storage.DataTableMetadata.Column; import org.netbeans.modules.dlight.core.stack.api.FunctionCall; import org.netbeans.modules.dlight.core.stack.api.FunctionCallWithMetric; +import org.netbeans.modules.dlight.core.stack.api.FunctionContext; import org.netbeans.modules.dlight.core.stack.api.FunctionMetric; import org.netbeans.modules.dlight.core.stack.api.support.FunctionDatatableDescription; import org.netbeans.modules.dlight.core.stack.dataprovider.FunctionCallTreeTableNode; import org.netbeans.modules.dlight.core.stack.dataprovider.FunctionsListDataProvider; +import org.netbeans.modules.dlight.core.stack.dataprovider.SourceFileInfoDataProvider; +import org.netbeans.modules.dlight.core.stack.storage.FunctionContextStorage; import org.netbeans.modules.dlight.core.stack.storage.StackDataStorage; import org.netbeans.modules.dlight.spi.SourceFileInfoProvider; import org.netbeans.modules.dlight.spi.SourceFileInfoProvider.SourceFileInfo; @@ -90,7 +93,7 @@ synchronized(lock) { filtersCopy = new ArrayList(filters); } - if (functionDescription.getOffsetColumnName() == null) { + if (functionDescription.getOffsetColumnName() == null && functionDescription.getContextIDColumnName() == null) { List result = new ArrayList(); List nodes = FunctionCallTreeTableNode.getFunctionCallTreeTableNodes(storage.getHotSpotFunctions(FunctionMetric.CpuTimeExclusiveMetric, filtersCopy, Integer.MAX_VALUE)); for (FunctionCallTreeTableNode node : nodes) { @@ -113,6 +116,24 @@ @Override public SourceFileInfo getSourceFileInfo(FunctionCall functionCall) { //we should get here SourceFileInfoProvider + Collection fcStorages = Lookup.getDefault().lookupAll(FunctionContextStorage.class); + + if (fcStorages != null) { + for (FunctionContextStorage fcStorage : fcStorages) { + FunctionContext context = fcStorage.getFunctionContext(functionCall.getFunction().getContextID()); + + if (context == null) { + continue; + } + + SourceFileInfoDataProvider infoProvider = context.getLookup().lookup(SourceFileInfoDataProvider.class); + + if (infoProvider != null) { + return infoProvider.getSourceFileInfo(functionCall); + } + } + } + Collection sourceInfoProviders = Lookup.getDefault().lookupAll(SourceFileInfoProvider.class); --- a/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/storage/impl/SQLStackDataStorage.java Tue Sep 20 18:05:07 2011 +0400 +++ a/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/storage/impl/SQLStackDataStorage.java Wed Sep 21 10:12:52 2011 +0400 @@ -103,6 +103,7 @@ import org.netbeans.modules.dlight.util.DLightLogger; import org.netbeans.modules.dlight.util.Range; import org.netbeans.modules.dlight.util.Util; +import org.openide.util.Exceptions; import org.openide.util.Lookup; import org.openide.util.NotImplementedException; @@ -114,7 +115,9 @@ private static final Logger LOG = DLightLogger.getLogger(SQLStackDataStorage.class); private static final CallStackEntryParser defaultParser = new DefaultStackParserImpl(); - private final List tableMetadatas; + private static final HashMap, String> classToType = new HashMap, String>(); + + private final HashMap tableMetadatas; private final AtomicBoolean closed = new AtomicBoolean(false); private DBProxy dbProxy; private SQLRequestsProcessor requestsProcessor; @@ -124,8 +127,19 @@ private CppSymbolDemangler demangler; private ServiceInfoDataStorage serviceInfoDataStorage; + static { + classToType.put(Byte.class, "tinyint"); // NOI18N + classToType.put(Short.class, "smallint"); // NOI18N + classToType.put(Integer.class, "int"); // NOI18N + classToType.put(Long.class, "bigint"); // NOI18N + classToType.put(Double.class, "double"); // NOI18N + classToType.put(Float.class, "real"); // NOI18N + classToType.put(String.class, "varchar"); // NOI18N + classToType.put(Time.class, "bigint"); // NOI18N + } + public SQLStackDataStorage() { - tableMetadatas = new ArrayList(); + tableMetadatas = new HashMap(); } @Override @@ -164,6 +178,7 @@ dbProxy = new DBProxy(requestsProcessor, requestsProvider); initTables(); + loadSchema(); } private Collection getDataFilters(List filters, Class clazz) { @@ -178,7 +193,7 @@ @Override public boolean hasData(DataTableMetadata data) { - return data.isProvidedBy(tableMetadatas); + return data.isProvidedBy(new ArrayList(tableMetadatas.values())); } @Override @@ -198,7 +213,9 @@ @Override public void createTables(List tableMetadatas) { - this.tableMetadatas.addAll(tableMetadatas); + for (DataTableMetadata dataTableMetadata : tableMetadatas) { + this.tableMetadatas.put(dataTableMetadata.getName(), dataTableMetadata); + } } // For tests ... @@ -269,6 +286,51 @@ } } + private void loadSchema() { + try { + ResultSet rs = sqlStorage.select("INFORMATION_SCHEMA.TABLES", null, // NOI18N + "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE LIKE 'TABLE'"); // NOI18N + + if (rs == null) { + return; + } + + while (rs.next()) { + String tableName = rs.getString(1); + loadTable(tableName); + } + } catch (SQLException ex) { + Exceptions.printStackTrace(ex); + } + } + + protected Class typeToClass(String type) { + Set> clazzes = classToType.keySet(); + for (Class clazz : clazzes) { + if (classToType.get(clazz).equalsIgnoreCase(type)) { + return clazz; + } + } + return String.class; + } + + private void loadTable(String tableName) { + try { + ResultSet rs = sqlStorage.select("INFORMATION_SCHEMA.COLUMNS", null, "SELECT COLUMN_NAME, "// NOI18N + + "TYPE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME LIKE '" + tableName + "'");// NOI18N + List columns = new ArrayList(); + while (rs.next()) { + Column c = new Column(rs.getString("COLUMN_NAME"), typeToClass(rs.getString("TYPE_NAME")));// NOI18N + columns.add(c); + } + DataTableMetadata result = new DataTableMetadata(tableName, columns, null); +// sqlStorage.loadTable(result); + tableMetadatas.put(tableName, result); + } catch (SQLException ex) { + Exceptions.printStackTrace(ex); + } + } + @Override public long putStack(long contextID, List stack) { // Even if this stack has no any associated metrics, we need to store the @@ -440,7 +502,6 @@ Map metricValues = new HashMap(); for (FunctionMetric m : metrics) { try { - rs.findColumn(m.getMetricID()); Object value = rs.getObject(m.getMetricID()); if (m.getMetricValueClass() == Time.class && value != null) { value = new Time(Long.valueOf(value.toString())); --- a/dlight.visualizers/src/org/netbeans/modules/dlight/visualizers/GotoSourceActionProvider.java Tue Sep 20 18:05:07 2011 +0400 +++ a/dlight.visualizers/src/org/netbeans/modules/dlight/visualizers/GotoSourceActionProvider.java Wed Sep 21 10:12:52 2011 +0400 @@ -54,7 +54,7 @@ import java.util.concurrent.locks.ReentrantLock; import javax.swing.AbstractAction; import org.netbeans.modules.dlight.core.stack.api.FunctionCallWithMetric; -import org.netbeans.modules.dlight.core.stack.dataprovider.FunctionsListDataProvider; +import org.netbeans.modules.dlight.core.stack.dataprovider.SourceFileInfoDataProvider; import org.netbeans.modules.dlight.spi.SourceFileInfoProvider.SourceFileInfo; import org.netbeans.modules.dlight.spi.SourceSupportProvider; import org.netbeans.modules.dlight.util.DLightExecutorService; @@ -70,7 +70,7 @@ public final class GotoSourceActionProvider { private final RequestProcessor RP = new RequestProcessor(GotoSourceActionProvider.class.getName(), 1); - private final FunctionsListDataProvider dataprovider; + private final SourceFileInfoDataProvider dataprovider; private final SourceSupportProvider sourceSupportProvider; private final LinkedBlockingQueue queue = new LinkedBlockingQueue(); private final ReentrantLock lock = new ReentrantLock(); @@ -79,7 +79,7 @@ new HashMap(); private Future task = null; - public GotoSourceActionProvider(SourceSupportProvider sourceSupportProvider, FunctionsListDataProvider dataprovider) { + public GotoSourceActionProvider(SourceSupportProvider sourceSupportProvider, SourceFileInfoDataProvider dataprovider) { this.dataprovider = dataprovider; this.sourceSupportProvider = sourceSupportProvider; } --- a/dlight.visualizers/src/org/netbeans/modules/dlight/visualizers/ui/FunctionCallNode.java Tue Sep 20 18:05:07 2011 +0400 +++ a/dlight.visualizers/src/org/netbeans/modules/dlight/visualizers/ui/FunctionCallNode.java Wed Sep 21 10:12:52 2011 +0400 @@ -196,12 +196,17 @@ String infoSuffix = null; if (action != null && action.isEnabled()) { - result.append("").append(dispName).append(""); // NOI18N - SourceFileInfo sourceInfo = action.getSourceInfo(); if (sourceInfo != null && sourceInfo.isSourceKnown()) { String fname = new File(sourceInfo.getFileName()).getName(); int line = sourceInfo.getLine(); + + if (line > 0) { + result.append("").append(dispName).append(""); // NOI18N + } else { + result.append("").append(dispName).append(""); // NOI18N + } + String infoPrefix = line > 0 ? NbBundle.getMessage(FunctionCallNode.class, "FunctionCallNode.prefix.withLine") // NOI18N : NbBundle.getMessage(FunctionCallNode.class, "FunctionCallNode.prefix.withoutLine"); // NOI18N --- a/dlight/src/org/netbeans/modules/dlight/spi/support/SQLDataStorage.java Tue Sep 20 18:05:07 2011 +0400 +++ a/dlight/src/org/netbeans/modules/dlight/spi/support/SQLDataStorage.java Wed Sep 21 10:12:52 2011 +0400 @@ -215,6 +215,12 @@ if (columns.contains(filterColumn)) { Range range = filter.getNumericDataFilter().getInterval(); if (range.getStart() != null || range.getEnd() != null) { + // TODO: this is a workaround ... + if (filterColumn.getColumnName().equals("bucket")) { // NOI18N + Number start = range.getStart(); + Number end = range.getEnd(); + range = new Range(start.longValue() / 1000000000, end.longValue() / 1000000000); + } whereClause = range.toString(" WHERE ", "%d <= " + filterColumn.getColumnName(), " AND ", filterColumn.getColumnName() + " <= %d", null); // NOI18N break; }