use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class ActiveThreadsFilter method getOnCpuThreads.
@NonNull
private static Set<Long> getOnCpuThreads(@NonNull List<Range<Long>> cpuRanges, TmfTimeRange winRange, @NonNull ITmfTrace trace) {
ThreadStatusDataProvider threadStatusProvider = DataProviderManager.getInstance().getDataProvider(trace, ThreadStatusDataProvider.ID, ThreadStatusDataProvider.class);
if (threadStatusProvider == null) {
return Collections.emptySet();
}
long beginTS = winRange.getStartTime().getValue();
long endTS = winRange.getEndTime().getValue();
@NonNull Set<@NonNull Long> cpus = new HashSet<>();
for (Range<Long> range : cpuRanges) {
for (long cpu = range.lowerEndpoint(); cpu <= range.upperEndpoint(); cpu++) {
cpus.add(cpu);
}
}
SelectionTimeQueryFilter filter = new SelectionTimeQueryFilter(beginTS, endTS, 2, cpus);
Map<@NonNull String, @NonNull Object> parameters = FetchParametersUtils.selectionTimeQueryToMap(filter);
parameters.put(ThreadStatusDataProvider.ACTIVE_THREAD_FILTER_KEY, true);
TmfModelResponse<TmfTreeModel<@NonNull TimeGraphEntryModel>> response = threadStatusProvider.fetchTree(parameters, null);
TmfTreeModel<@NonNull TimeGraphEntryModel> model = response.getModel();
if (model == null) {
return Collections.emptySet();
}
HashSet<Long> onCpuThreads = Sets.newHashSet(Iterables.transform(model.getEntries(), TimeGraphEntryModel::getId));
return onCpuThreads == null ? Collections.emptySet() : onCpuThreads;
}
use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class CpuUsageXYViewer method createQueryParameters.
@Override
@NonNull
protected Map<String, Object> createQueryParameters(long start, long end, int nb) {
Map<@NonNull String, @NonNull Object> parameters = FetchParametersUtils.selectionTimeQueryToMap(new SelectionTimeQueryFilter(start, end, nb, getSelected()));
parameters.put(CpuUsageDataProvider.REQUESTED_CPUS_KEY, CpuUsageView.getCpus(getTrace()));
return parameters;
}
use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class ResourcesPresentationProvider method getTooltip.
private static Map<String, String> getTooltip(ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider, long id, long hoverTime) {
SelectionTimeQueryFilter filter = new SelectionTimeQueryFilter(Collections.singletonList(hoverTime), Collections.singleton(id));
TmfModelResponse<Map<String, String>> response = provider.fetchTooltip(FetchParametersUtils.selectionTimeQueryToMap(filter), null);
Map<String, String> tooltip = response.getModel();
if (tooltip == null) {
return Collections.emptyMap();
}
Map<String, String> retMap = new LinkedHashMap<>();
retMap.putAll(tooltip);
return retMap;
}
use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class CallStackDataProvider method getRowModel.
@Override
protected TimeGraphModel getRowModel(ITmfStateSystem ss, @NonNull Map<@NonNull String, @NonNull Object> parameters, @Nullable IProgressMonitor monitor) throws StateSystemDisposedException {
SelectionTimeQueryFilter filter = FetchParametersUtils.createSelectionTimeQuery(parameters);
if (filter == null) {
return null;
}
Map<@NonNull Long, @NonNull Integer> entries = getSelectedEntries(filter);
if (entries.size() == 1 && filter.getTimesRequested().length == 2) {
// this is a request for a follow event.
Entry<@NonNull Long, @NonNull Integer> entry = entries.entrySet().iterator().next();
if (filter.getStart() == Long.MIN_VALUE) {
return new TimeGraphModel(getFollowEvent(ss, entry, filter.getEnd(), false));
} else if (filter.getEnd() == Long.MAX_VALUE) {
return new TimeGraphModel(getFollowEvent(ss, entry, filter.getStart(), true));
}
}
// $NON-NLS-1$
SubMonitor subMonitor = SubMonitor.convert(monitor, "CallStackDataProvider#fetchRowModel", 2);
ArrayListMultimap<Integer, ITmfStateInterval> intervals = ArrayListMultimap.create();
Collection<Long> times = getTimes(filter, ss.getStartTime(), ss.getCurrentEndTime());
/* Do the actual query */
for (ITmfStateInterval interval : ss.query2D(entries.values(), times)) {
if (subMonitor.isCanceled()) {
return null;
}
intervals.put(interval.getAttribute(), interval);
}
subMonitor.worked(1);
Map<@NonNull Integer, @NonNull Predicate<@NonNull Multimap<@NonNull String, @NonNull Object>>> predicates = new HashMap<>();
Multimap<@NonNull Integer, @NonNull String> regexesMap = DataProviderParameterUtils.extractRegexFilter(parameters);
if (regexesMap != null) {
predicates.putAll(computeRegexPredicate(regexesMap));
}
List<@NonNull ITimeGraphRowModel> rows = new ArrayList<>();
for (Map.Entry<Long, Integer> entry : entries.entrySet()) {
if (subMonitor.isCanceled()) {
return null;
}
Collection<ITmfStateInterval> states = intervals.get(entry.getValue());
Long key = Objects.requireNonNull(entry.getKey());
List<ITimeGraphState> eventList = new ArrayList<>(states.size());
states.forEach(state -> {
ITimeGraphState timeGraphState = createTimeGraphState(state);
applyFilterAndAddState(eventList, timeGraphState, key, predicates, monitor);
});
eventList.sort(Comparator.comparingLong(ITimeGraphState::getStartTime));
rows.add(new TimeGraphRowModel(entry.getKey(), eventList));
}
subMonitor.worked(1);
return new TimeGraphModel(rows);
}
use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class FlameChartView method getNextEventAction.
/**
* Get the the next event action.
*
* @return The action object
*/
private Action getNextEventAction() {
Action nextAction = fNextEventAction;
if (nextAction == null) {
Action superNextAction = getTimeGraphViewer().getNextEventAction();
nextAction = new Action() {
@Override
public void run() {
TimeGraphViewer viewer = getTimeGraphViewer();
ITimeGraphEntry entry = viewer.getSelection();
if (entry instanceof TimeGraphEntry) {
TimeGraphEntry callStackEntry = (TimeGraphEntry) entry;
ITimeGraphDataProvider<? extends TimeGraphEntryModel> provider = getProvider(callStackEntry);
long selectionBegin = viewer.getSelectionBegin();
SelectionTimeQueryFilter filter = new SelectionTimeQueryFilter(selectionBegin, Long.MAX_VALUE, 2, Collections.singleton(callStackEntry.getEntryModel().getId()));
TmfModelResponse<@NonNull TimeGraphModel> response = provider.fetchRowModel(FetchParametersUtils.selectionTimeQueryToMap(filter), null);
TimeGraphModel model = response.getModel();
if (model == null || model.getRows().size() != 1) {
return;
}
List<@NonNull ITimeGraphState> row = model.getRows().get(0).getStates();
if (row.size() != 1) {
return;
}
ITimeGraphState stackInterval = row.get(0);
if (stackInterval.getStartTime() <= selectionBegin && selectionBegin <= stackInterval.getStartTime() + stackInterval.getDuration()) {
viewer.setSelectedTimeNotify(stackInterval.getStartTime() + stackInterval.getDuration() + 1, true);
} else {
viewer.setSelectedTimeNotify(stackInterval.getStartTime(), true);
}
int stackLevel = stackInterval.getValue();
ITimeGraphEntry selectedEntry = callStackEntry.getParent().getChildren().get(Integer.max(0, stackLevel - 1));
viewer.setSelection(selectedEntry, true);
viewer.getTimeGraphControl().fireSelectionChanged();
startZoomThread(viewer.getTime0(), viewer.getTime1());
}
}
};
nextAction.setText(superNextAction.getText());
nextAction.setToolTipText(superNextAction.getToolTipText());
nextAction.setImageDescriptor(superNextAction.getImageDescriptor());
fNextEventAction = nextAction;
}
return nextAction;
}
Aggregations