Search in sources :

Example 1 with SelectionTimeQueryFilter

use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.

the class CriticalPathDataProvider method fetchTooltip.

@Override
@NonNull
public TmfModelResponse<@NonNull Map<@NonNull String, @NonNull String>> fetchTooltip(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    SelectionTimeQueryFilter filter = FetchParametersUtils.createSelectionTimeQuery(fetchParameters);
    if (filter == null) {
        return new TmfModelResponse<>(null, Status.FAILED, CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
    }
    IGraphWorker worker = fWorkerToEntryId.inverse().get(filter.getSelectedItems().iterator().next());
    if (worker == null) {
        return new TmfModelResponse<>(null, Status.COMPLETED, CommonStatusMessage.COMPLETED);
    }
    Map<@NonNull String, @NonNull String> info = worker.getWorkerInformation(filter.getStart());
    return new TmfModelResponse<>(info, Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
Also used : SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) IGraphWorker(org.eclipse.tracecompass.analysis.graph.core.base.IGraphWorker) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 2 with SelectionTimeQueryFilter

use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.

the class UstMemoryUsageDataProvider method getYSeriesModels.

/**
 * @since 3.3
 */
@Override
@Nullable
protected Collection<IYModel> getYSeriesModels(ITmfStateSystem ss, Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) throws StateSystemDisposedException {
    SelectionTimeQueryFilter filter = FetchParametersUtils.createSelectionTimeQuery(fetchParameters);
    if (filter == null) {
        return null;
    }
    long[] xValues = filter.getTimesRequested();
    long currentEnd = ss.getCurrentEndTime();
    Map<Integer, IYModel> models = initYModels(ss, filter);
    for (ITmfStateInterval interval : ss.query2D(models.keySet(), getTimes(filter, ss.getStartTime(), currentEnd))) {
        if (monitor != null && monitor.isCanceled()) {
            return null;
        }
        IYModel model = models.get(interval.getAttribute());
        Object value = interval.getValue();
        if (model != null && value instanceof Number) {
            int from = Arrays.binarySearch(xValues, interval.getStartTime());
            from = (from >= 0) ? from : -1 - from;
            int to = Arrays.binarySearch(xValues, interval.getEndTime());
            to = (to >= 0) ? to + 1 : -1 - to;
            Arrays.fill(model.getData(), from, to, ((Number) value).doubleValue());
        }
    }
    return models.values();
}
Also used : SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) IYModel(org.eclipse.tracecompass.tmf.core.model.xy.IYModel) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 3 with SelectionTimeQueryFilter

use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.

the class XmlTimeGraphDataProviderTest method assertRows.

private static void assertRows(ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> provider, Map<Long, String> tree, List<String> expectedStrings) {
    TmfModelResponse<@NonNull TimeGraphModel> rowResponse = provider.fetchRowModel(FetchParametersUtils.selectionTimeQueryToMap(new SelectionTimeQueryFilter(1, 20, 20, tree.keySet())), null);
    assertNotNull(rowResponse);
    assertEquals(ITmfResponse.Status.COMPLETED, rowResponse.getStatus());
    TimeGraphModel timeGraphModel = rowResponse.getModel();
    assertNotNull(timeGraphModel);
    List<@NonNull ITimeGraphRowModel> rowModel = timeGraphModel.getRows();
    // ensure row order
    rowModel.sort(Comparator.comparingLong(ITimeGraphRowModel::getEntryID));
    assertEquals(expectedStrings.size(), rowModel.size());
    for (int i = 0; i < expectedStrings.size(); i++) {
        String expectedString = expectedStrings.get(i);
        String[] split = expectedString.split(":");
        ITimeGraphRowModel row = rowModel.get(i);
        assertEquals(split[0], tree.get(row.getEntryID()));
        assertEqualsStates(split[0], split[1], row.getStates());
    }
}
Also used : ITimeGraphRowModel(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) TimeGraphModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel)

Example 4 with SelectionTimeQueryFilter

use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.

the class XmlXyDataProviderTest method assertRows.

private static void assertRows(ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> xyProvider, Map<Long, String> tree, List<String> expectedStrings) {
    TmfModelResponse<@NonNull ITmfXyModel> rowResponse = xyProvider.fetchXY(FetchParametersUtils.selectionTimeQueryToMap(new SelectionTimeQueryFilter(1, 20, 20, tree.keySet())), null);
    assertNotNull(rowResponse);
    assertEquals(ITmfResponse.Status.COMPLETED, rowResponse.getStatus());
    ITmfXyModel rowModel = rowResponse.getModel();
    assertNotNull(rowModel);
    Collection<@NonNull ISeriesModel> series = rowModel.getSeriesData();
    ImmutableMap<Long, @NonNull ISeriesModel> data = Maps.uniqueIndex(series, ISeriesModel::getId);
    for (int i = 0; i < expectedStrings.size(); i++) {
        String expectedString = expectedStrings.get(i);
        String[] split = expectedString.split(":");
        String rowName = split[0];
        Long rowId = null;
        for (Entry<Long, String> entry : tree.entrySet()) {
            if (entry.getValue().equals(rowName)) {
                rowId = entry.getKey();
                break;
            }
        }
        assertNotNull(rowId);
        ISeriesModel row = data.get(rowId);
        assertNotNull(row);
        String[] expectedData = split[1].split(",");
        double[] actualData = row.getData();
        for (int j = 0; j < expectedData.length; j++) {
            assertTrue("Presence of data at position " + j + " for row " + rowName, actualData.length > j);
            double expectedValue = Double.parseDouble(expectedData[j]);
            assertEquals("Data at position " + j + " for row " + rowName, expectedValue, actualData[j], 0.001);
        }
    }
    assertEquals("Same number of data", expectedStrings.size(), data.size());
}
Also used : ISeriesModel(org.eclipse.tracecompass.tmf.core.model.xy.ISeriesModel) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) ITmfXyModel(org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel)

Example 5 with SelectionTimeQueryFilter

use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.

the class XmlTimeGraphDataProvider method fetchRowModel.

@Override
@NonNull
public TmfModelResponse<@NonNull TimeGraphModel> fetchRowModel(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    Table<ITmfStateSystem, Integer, Long> table = HashBasedTable.create();
    // TODO server: Parameters validation should be handle separately. It
    // can be either in the data provider itself or before calling it. It
    // will avoid the creation of filters and the content of the map can be
    // use directly.
    SelectionTimeQueryFilter filter = FetchParametersUtils.createSelectionTimeQuery(fetchParameters);
    if (filter == null) {
        return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
    }
    for (Long id : filter.getSelectedItems()) {
        Pair<ITmfStateSystem, Integer> pair = fIDToDisplayQuark.get(id);
        if (pair != null) {
            table.put(pair.getFirst(), pair.getSecond(), id);
        }
    }
    List<@NonNull ITimeGraphRowModel> allRows = new ArrayList<>();
    try {
        for (Entry<ITmfStateSystem, Map<Integer, Long>> ssEntry : table.rowMap().entrySet()) {
            Collection<@NonNull ITimeGraphRowModel> rows = createRows(ssEntry.getKey(), ssEntry.getValue(), filter.getTimesRequested(), fetchParameters, monitor);
            allRows.addAll(rows);
        }
    } catch (IndexOutOfBoundsException | TimeRangeException | StateSystemDisposedException e) {
        return new TmfModelResponse<>(null, Status.FAILED, CommonStatusMessage.STATE_SYSTEM_FAILED);
    }
    return new TmfModelResponse<>(new TimeGraphModel(allRows), Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
Also used : TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) TimeGraphModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel) ArrayList(java.util.ArrayList) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) ITimeGraphRowModel(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) AtomicLong(java.util.concurrent.atomic.AtomicLong) Map(java.util.Map) HashMap(java.util.HashMap) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) NonNull(org.eclipse.jdt.annotation.NonNull)

Aggregations

SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)37 NonNull (org.eclipse.jdt.annotation.NonNull)21 HashMap (java.util.HashMap)13 TimeGraphModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphModel)12 ITimeGraphRowModel (org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel)10 ArrayList (java.util.ArrayList)9 LinkedHashMap (java.util.LinkedHashMap)9 Map (java.util.Map)9 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)9 AtomicLong (java.util.concurrent.atomic.AtomicLong)8 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)7 StateSystemDisposedException (org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException)7 ITmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)7 IYModel (org.eclipse.tracecompass.tmf.core.model.xy.IYModel)7 Nullable (org.eclipse.jdt.annotation.Nullable)6 ITimeGraphState (org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphState)6 ITimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)6 TimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)6 ImmutableList (com.google.common.collect.ImmutableList)5 YModel (org.eclipse.tracecompass.tmf.core.model.YModel)5