Search in sources :

Example 1 with IYModel

use of org.eclipse.tracecompass.tmf.core.model.xy.IYModel in project tracecompass by tracecompass.

the class CounterDataProvider method internalFetch.

@Nullable
private Collection<IYModel> internalFetch(ITmfStateSystem ss, Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) throws StateSystemDisposedException {
    SelectedCounterQueryFilter filter = createCounterQuery(fetchParameters);
    if (filter == null) {
        return null;
    }
    long stateSystemEndTime = ss.getCurrentEndTime();
    Collection<Long> times = extractRequestedTimes(ss, filter, stateSystemEndTime);
    Map<Long, Integer> entries = Maps.filterValues(getSelectedEntries(filter), q -> ss.getSubAttributes(q, false).isEmpty());
    TreeMultimap<Integer, ITmfStateInterval> countersIntervals = TreeMultimap.create(Comparator.naturalOrder(), Comparator.comparingLong(ITmfStateInterval::getStartTime));
    Iterable<@NonNull ITmfStateInterval> query2d = ss.query2D(entries.values(), times);
    for (ITmfStateInterval interval : query2d) {
        if (monitor != null && monitor.isCanceled()) {
            return null;
        }
        countersIntervals.put(interval.getAttribute(), interval);
    }
    ImmutableList.Builder<IYModel> ySeries = ImmutableList.builder();
    for (Entry<Long, Integer> entry : entries.entrySet()) {
        if (monitor != null && monitor.isCanceled()) {
            return null;
        }
        int quark = entry.getValue();
        double[] yValues = buildYValues(countersIntervals.get(quark), filter);
        String seriesName = getTrace().getName() + '/' + ss.getFullAttributePath(quark);
        ySeries.add(new YModel(entry.getKey(), seriesName, yValues));
    }
    return ySeries.build();
}
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) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) SelectedCounterQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectedCounterQueryFilter) IYModel(org.eclipse.tracecompass.tmf.core.model.xy.IYModel) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 2 with IYModel

use of org.eclipse.tracecompass.tmf.core.model.xy.IYModel 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 IYModel

use of org.eclipse.tracecompass.tmf.core.model.xy.IYModel in project tracecompass by tracecompass.

the class UstMemoryUsageDataProvider method initYModels.

/**
 * Get map of UST_MEMORY_MEMORY_ATTRIBUTE to relevant model
 *
 * @param ss
 *            the queried {@link ITmfStateSystem}
 * @param filter
 *            the {@link TimeQueryFilter}
 * @return a map of the UST_MEMORY_MEMORY_ATTRIBUTE attributes to the
 *         initialized model
 */
private Map<Integer, IYModel> initYModels(ITmfStateSystem ss, SelectionTimeQueryFilter filter) {
    Map<Integer, IYModel> selectedSeries = new HashMap<>();
    int length = filter.getTimesRequested().length;
    for (Entry<Long, Integer> entry : getSelectedEntries(filter).entrySet()) {
        int tidQuark = entry.getValue();
        int memoryAttribute = ss.optQuarkRelative(tidQuark, UstMemoryStrings.UST_MEMORY_MEMORY_ATTRIBUTE);
        if (memoryAttribute != ITmfStateSystem.INVALID_ATTRIBUTE) {
            String name = getTrace().getName() + ':' + ss.getAttributeName(tidQuark);
            selectedSeries.put(memoryAttribute, new YModel(entry.getKey(), name, new double[length]));
        }
    }
    return selectedSeries;
}
Also used : YModel(org.eclipse.tracecompass.tmf.core.model.YModel) IYModel(org.eclipse.tracecompass.tmf.core.model.xy.IYModel) HashMap(java.util.HashMap) IYModel(org.eclipse.tracecompass.tmf.core.model.xy.IYModel)

Example 4 with IYModel

use of org.eclipse.tracecompass.tmf.core.model.xy.IYModel in project tracecompass by tracecompass.

the class XmlXYDataProvider method fetchXY.

@Override
public TmfModelResponse<ITmfXyModel> fetchXY(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    DataDrivenStateSystemPath display = fDisplay;
    XmlXYEntry entry = fXmlEntry;
    ITmfStateSystem ss = entry.getStateSystem();
    TimeQueryFilter filter = FetchParametersUtils.createTimeQuery(fetchParameters);
    if (filter == null) {
        return TmfXyResponseFactory.createFailedResponse(CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
    }
    long[] xValues = filter.getTimesRequested();
    Map<Integer, IYModel> map = initSeries(fetchParameters);
    if (map.isEmpty()) {
        return TmfXyResponseFactory.create(TITLE, xValues, Collections.emptyList(), true);
    }
    long currentEnd = ss.getCurrentEndTime();
    try {
        for (int i = 0; i < xValues.length; i++) {
            if (monitor != null && monitor.isCanceled()) {
                return TmfXyResponseFactory.createCancelledResponse(CommonStatusMessage.TASK_CANCELLED);
            }
            long time = xValues[i];
            if (time > currentEnd) {
                break;
            } else if (ss.getStartTime() <= time) {
                List<@NonNull ITmfStateInterval> full = ss.queryFullState(time);
                for (Entry<Integer, IYModel> series : map.entrySet()) {
                    int attributeQuark = display.getQuark(series.getKey(), entry);
                    if (attributeQuark >= 0 && attributeQuark < full.size()) {
                        Object value = full.get(attributeQuark).getValue();
                        series.getValue().getData()[i] = extractValue(value);
                    }
                }
            }
        }
        // Update the series value if delta is requested
        for (Entry<Integer, IYModel> series : map.entrySet()) {
            if (entry.getType().equals(DisplayType.DELTA)) {
                getSeriesDelta(series.getValue().getData());
            }
        }
    } catch (StateSystemDisposedException e) {
        return TmfXyResponseFactory.createFailedResponse(e.getMessage());
    }
    boolean complete = ss.waitUntilBuilt(0) || filter.getEnd() <= currentEnd;
    return TmfXyResponseFactory.create(TITLE, xValues, map.values(), complete);
}
Also used : IYModel(org.eclipse.tracecompass.tmf.core.model.xy.IYModel) DataDrivenStateSystemPath(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.DataDrivenStateSystemPath) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) Entry(java.util.Map.Entry) NonNull(org.eclipse.jdt.annotation.NonNull) TimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter) SelectionTimeQueryFilter(org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)

Example 5 with IYModel

use of org.eclipse.tracecompass.tmf.core.model.xy.IYModel 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)

Aggregations

IYModel (org.eclipse.tracecompass.tmf.core.model.xy.IYModel)15 YModel (org.eclipse.tracecompass.tmf.core.model.YModel)10 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)9 ImmutableList (com.google.common.collect.ImmutableList)7 HashMap (java.util.HashMap)6 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)5 StateSystemDisposedException (org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException)5 AtomicLong (java.util.concurrent.atomic.AtomicLong)4 Nullable (org.eclipse.jdt.annotation.Nullable)4 ITmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)4 ArrayList (java.util.ArrayList)3 NonNull (org.eclipse.jdt.annotation.NonNull)3 TimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter)3 List (java.util.List)2 Entry (java.util.Map.Entry)2 TimeRangeException (org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException)2 TmfCommonXAxisModel (org.eclipse.tracecompass.tmf.core.model.TmfCommonXAxisModel)2 ITmfXyModel (org.eclipse.tracecompass.tmf.core.model.xy.ITmfXyModel)2 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)2 LinkedHashMap (java.util.LinkedHashMap)1