use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel 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.timegraph.ITimeGraphRowModel in project tracecompass by tracecompass.
the class CallStackDataProvider method getFollowEvent.
/**
* Get the next or previous interval for a call stack entry ID, time and
* direction
*
* @param ss
* this data provider's state system
* @param entry
* whose key is the ID and value is the quark for the entry whose
* next / previous state we are searching for
* @param time
* selection start time
* @param forward
* if going to next or previous
* @return the next / previous state encapsulated in a row if it exists,
* else null
* @throws StateSystemDisposedException
*/
private static List<ITimeGraphRowModel> getFollowEvent(ITmfStateSystem ss, Entry<Long, Integer> entry, long time, boolean forward) throws StateSystemDisposedException {
int parentQuark = ss.getParentAttributeQuark(entry.getValue());
ITmfStateInterval current = ss.querySingleState(Long.max(ss.getStartTime(), Long.min(time, ss.getCurrentEndTime())), parentQuark);
ITmfStateInterval interval = null;
if (forward && current.getEndTime() + 1 <= ss.getCurrentEndTime()) {
interval = ss.querySingleState(current.getEndTime() + 1, parentQuark);
} else if (!forward && current.getStartTime() - 1 >= ss.getStartTime()) {
interval = ss.querySingleState(current.getStartTime() - 1, parentQuark);
}
if (interval != null && interval.getValue() instanceof Number) {
Object object = interval.getValue();
if (object instanceof Number) {
int value = ((Number) object).intValue();
TimeGraphState state = new TimeGraphState(interval.getStartTime(), interval.getEndTime() - interval.getStartTime(), value);
TimeGraphRowModel row = new TimeGraphRowModel(entry.getKey(), Collections.singletonList(state));
return Collections.singletonList(row);
}
}
return null;
}
use of org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphRowModel in project tracecompass by tracecompass.
the class DataDrivenTimeGraphDataProvider method createRows.
private Collection<ITimeGraphRowModel> createRows(ITmfStateSystem ss, Map<Integer, Long> idToDisplayQuark, Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) throws StateSystemDisposedException {
Map<@NonNull Integer, @NonNull Predicate<@NonNull Multimap<@NonNull String, @NonNull Object>>> predicates = new HashMap<>();
Multimap<@NonNull Integer, @NonNull String> regexesMap = DataProviderParameterUtils.extractRegexFilter(fetchParameters);
if (regexesMap != null) {
predicates.putAll(computeRegexPredicate(regexesMap));
}
long currentEndTime = ss.getCurrentEndTime();
Map<Integer, ITimeGraphRowModel> quarkToRow = new HashMap<>(idToDisplayQuark.size());
for (Entry<Integer, Long> entry : idToDisplayQuark.entrySet()) {
quarkToRow.put(entry.getKey(), new TimeGraphRowModel(entry.getValue(), new ArrayList<>()));
}
List<Long> timesRequested = DataProviderParameterUtils.extractTimeRequested(fetchParameters);
for (ITmfStateInterval interval : ss.query2D(idToDisplayQuark.keySet(), getTimes(ss, timesRequested))) {
if (monitor != null && monitor.isCanceled()) {
return Collections.emptyList();
}
ITimeGraphRowModel row = quarkToRow.get(interval.getAttribute());
if (row != null) {
List<@NonNull ITimeGraphState> states = row.getStates();
ITimeGraphState timeGraphState = getStateFromInterval(interval, currentEndTime);
applyFilterAndAddState(states, timeGraphState, row.getEntryID(), predicates, monitor);
}
}
for (ITimeGraphRowModel model : quarkToRow.values()) {
model.getStates().sort(Comparator.comparingLong(ITimeGraphState::getStartTime));
}
return quarkToRow.values();
}
Aggregations