Search in sources :

Example 6 with SelectionTimeQueryFilter

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

the class XmlXYDataProvider method initSeries.

private Map<Integer, IYModel> initSeries(Map<String, Object> parameters) {
    SelectionTimeQueryFilter filter = FetchParametersUtils.createSelectionTimeQuery(parameters);
    if (filter == null) {
        return Collections.emptyMap();
    }
    fLock.readLock().lock();
    try {
        Map<Integer, IYModel> map = new HashMap<>();
        int length = filter.getTimesRequested().length;
        for (Long id : filter.getSelectedItems()) {
            Integer quark = fIdToQuark.get(id);
            if (quark != null) {
                String name = String.valueOf(fQuarkToString.get(quark));
                map.put(quark, new YModel(id, name, new double[length]));
            }
        }
        return map;
    } finally {
        fLock.readLock().unlock();
    }
}
Also used : YModel(org.eclipse.tracecompass.tmf.core.model.YModel) IYModel(org.eclipse.tracecompass.tmf.core.model.xy.IYModel) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) HashMap(java.util.HashMap) AtomicLong(java.util.concurrent.atomic.AtomicLong) IYModel(org.eclipse.tracecompass.tmf.core.model.xy.IYModel)

Example 7 with SelectionTimeQueryFilter

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

the class DataDrivenTimeGraphDataProvider method fetchRowModel.

@Override
@NonNull
public TmfModelResponse<@NonNull TimeGraphModel> fetchRowModel(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    // 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, Status.FAILED, CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
    }
    Table<ITmfStateSystem, Integer, Long> table = HashBasedTable.create();
    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(), 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) HashMap(java.util.HashMap) Map(java.util.Map) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 8 with SelectionTimeQueryFilter

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

the class HistogramDataProvider method fetchXY.

@Override
@NonNull
public TmfModelResponse<ITmfXyModel> fetchXY(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    fModule.waitForInitialization();
    SelectionTimeQueryFilter filter = FetchParametersUtils.createSelectionTimeQuery(fetchParameters);
    long[] xValues = new long[0];
    if (filter == null) {
        return TmfXyResponseFactory.create(TITLE, xValues, Collections.emptyList(), true);
    }
    xValues = filter.getTimesRequested();
    Collection<Long> selected = filter.getSelectedItems();
    int n = xValues.length;
    ImmutableList.Builder<IYModel> builder = ImmutableList.builder();
    final ITmfStatistics stats = Objects.requireNonNull(fModule.getStatistics());
    if (selected.contains(fTotalId)) {
        List<Long> values = stats.histogramQuery(filter.getTimesRequested());
        double[] y = new double[n];
        Arrays.setAll(y, values::get);
        String totalName = getTrace().getName() + '/' + Messages.HistogramDataProvider_Total;
        builder.add(new YModel(fTotalId, totalName, y));
    }
    ITmfStateSystem eventsSs = fModule.getStateSystem(TmfStatisticsEventTypesModule.ID);
    if (selected.contains(fLostId) && eventsSs != null) {
        try {
            YModel series = getLostEvents(eventsSs, xValues);
            builder.add(series);
        } catch (StateSystemDisposedException e) {
            return TmfXyResponseFactory.createFailedResponse(CommonStatusMessage.STATE_SYSTEM_FAILED);
        }
    }
    boolean completed = eventsSs != null ? eventsSs.waitUntilBuilt(0) || eventsSs.getCurrentEndTime() >= filter.getEnd() : false;
    return TmfXyResponseFactory.create(TITLE, xValues, builder.build(), completed);
}
Also used : YModel(org.eclipse.tracecompass.tmf.core.model.YModel) IYModel(org.eclipse.tracecompass.tmf.core.model.xy.IYModel) ImmutableList(com.google.common.collect.ImmutableList) ITmfStatistics(org.eclipse.tracecompass.tmf.core.statistics.ITmfStatistics) IYModel(org.eclipse.tracecompass.tmf.core.model.xy.IYModel) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) AtomicLong(java.util.concurrent.atomic.AtomicLong) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 9 with SelectionTimeQueryFilter

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

the class FetchParametersUtils method createSelectionTimeQuery.

/**
 * Create a {@link SelectionTimeQueryFilter} with the given map of parameters
 *
 * @param parameters
 *            Map of parameters
 * @return A {@link SelectionTimeQueryFilter} or null if the parameters are invalid
 */
@Nullable
public static SelectionTimeQueryFilter createSelectionTimeQuery(Map<String, Object> parameters) {
    List<Long> timeRequested = DataProviderParameterUtils.extractTimeRequested(parameters);
    List<Long> selectedItems = DataProviderParameterUtils.extractSelectedItems(parameters);
    return (timeRequested == null || selectedItems == null) ? null : new SelectionTimeQueryFilter(timeRequested, selectedItems);
}
Also used : SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 10 with SelectionTimeQueryFilter

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

the class AbstractTreeCommonXDataProvider method fetchXY.

@Override
public final TmfModelResponse<ITmfXyModel> fetchXY(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    A module = getAnalysisModule();
    // 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 TmfXyResponseFactory.createFailedResponse(CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
    }
    TmfModelResponse<ITmfXyModel> res = verifyParameters(module, filter, monitor);
    if (res != null) {
        return res;
    }
    ITmfStateSystem ss = Objects.requireNonNull(module.getStateSystem(), // $NON-NLS-1$
    "Statesystem should have been verified by verifyParameters");
    long currentEnd = ss.getCurrentEndTime();
    boolean complete = ss.waitUntilBuilt(0) || filter.getEnd() <= currentEnd;
    try (FlowScopeLog scope = // $NON-NLS-1$
    new FlowScopeLogBuilder(LOGGER, Level.FINE, "AbstractTreeXyDataProvider#fetchXY").setCategory(getClass().getSimpleName()).build()) {
        Collection<IYModel> yModels = getYSeriesModels(ss, fetchParameters, monitor);
        if (yModels == null) {
            // getModels returns null if the query was cancelled.
            return TmfXyResponseFactory.createCancelledResponse(CommonStatusMessage.TASK_CANCELLED);
        }
        return TmfXyResponseFactory.create(getTitle(), filter.getTimesRequested(), ImmutableList.copyOf(yModels), complete);
    } catch (StateSystemDisposedException | TimeRangeException | IndexOutOfBoundsException e) {
        return TmfXyResponseFactory.createFailedResponse(String.valueOf(e.getMessage()));
    }
}
Also used : TimeRangeException(org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException) FlowScopeLogBuilder(org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLogBuilder) IYModel(org.eclipse.tracecompass.tmf.core.model.xy.IYModel) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) FlowScopeLog(org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLog) ITmfXyModel(org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)

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