use of org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter in project tracecompass by tracecompass.
the class TmfEventTableDataProviderTest method fetchColumnId.
private static Map<String, Long> fetchColumnId() {
TmfTreeModel<TmfEventTableColumnDataModel> columns = fProvider.fetchTree(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(0, 0, 1)), null).getModel();
if (columns == null) {
return Collections.emptyMap();
}
List<TmfEventTableColumnDataModel> columnEntries = columns.getEntries();
// Order should be timestamp, event type and contents
assertEquals(TIMESTAMP_COLUMN_NAME, columnEntries.get(0).getName());
assertEquals(EVENT_TYPE_COLUMN_NAME, columnEntries.get(1).getName());
assertEquals(CONTENTS_COLUMN_NAME, columnEntries.get(2).getName());
assertEquals(TIMESTAMP_NS_COLUMN_NAME, columnEntries.get(3).getName());
Map<String, Long> expectedColumns = new LinkedHashMap<>();
for (TmfEventTableColumnDataModel column : columnEntries) {
expectedColumns.put(column.getName(), column.getId());
}
return expectedColumns;
}
use of org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter in project tracecompass by tracecompass.
the class FetchParametersTest method testTimeQuery.
/**
* Test {@link FetchParametersUtils#timeQueryToMap(TimeQueryFilter)} and
* {@link FetchParametersUtils#createTimeQuery(Map)}
*/
@Test
public void testTimeQuery() {
TimeQueryFilter timeQuery = FetchParametersUtils.createTimeQuery(fExpectedTimeQueryMap);
assertNotNull(timeQuery);
assertEquals(fExpectedTimeQuery, timeQuery);
Map<String, Object> timeQueryMap = FetchParametersUtils.timeQueryToMap(fExpectedTimeQuery);
assertFalse(timeQueryMap.isEmpty());
assertEquals(fExpectedTimeQueryMap, timeQueryMap);
}
use of org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter in project tracecompass by tracecompass.
the class UstMemoryUsageDataProvider method getTree.
/**
* @since 3.3
*/
@Override
protected TmfTreeModel<MemoryUsageTreeModel> getTree(ITmfStateSystem ss, Map<String, Object> parameters, @Nullable IProgressMonitor monitor) throws StateSystemDisposedException {
TimeQueryFilter filter = FetchParametersUtils.createTimeQuery(parameters);
if (filter == null) {
return new TmfTreeModel<>(Collections.emptyList(), Collections.emptyList());
}
long start = filter.getStart();
long end = filter.getEnd();
// Let the list of active states be null if we aren't filtering
List<ITmfStateInterval> active = null;
Boolean isFiltered = DataProviderParameterUtils.extractIsFiltered(parameters);
if (isFiltered != null && isFiltered) {
if (start == end || start > ss.getCurrentEndTime() || end < ss.getStartTime()) {
/*
* return an empty list if the filter is empty or does not intersect the state
* system
*/
return new TmfTreeModel<>(Collections.emptyList(), Collections.emptyList());
}
active = ss.queryFullState(Long.max(start, ss.getStartTime()));
}
List<ITmfStateInterval> nameFullState = ss.queryFullState(ss.getCurrentEndTime());
List<Integer> tidQuarks = ss.getSubAttributes(-1, false);
ImmutableList.Builder<MemoryUsageTreeModel> builder = ImmutableList.builder();
long rootId = getId(ITmfStateSystem.ROOT_ATTRIBUTE);
builder.add(new MemoryUsageTreeModel(rootId, -1L, -1, Collections.singletonList(getTrace().getName())));
for (int quark : tidQuarks) {
int memoryAttribute = ss.optQuarkRelative(quark, UstMemoryStrings.UST_MEMORY_MEMORY_ATTRIBUTE);
int procNameQuark = ss.optQuarkRelative(quark, UstMemoryStrings.UST_MEMORY_PROCNAME_ATTRIBUTE);
String name = ss.getAttributeName(quark);
if (procNameQuark != ITmfStateSystem.INVALID_ATTRIBUTE && procNameQuark < nameFullState.size()) {
name = String.valueOf(nameFullState.get(procNameQuark).getValue());
}
if (memoryAttribute != ITmfStateSystem.INVALID_ATTRIBUTE && (active == null || (memoryAttribute < active.size() && active.get(memoryAttribute).getEndTime() < end))) {
int tid = Integer.parseInt(ss.getAttributeName(quark));
builder.add(new MemoryUsageTreeModel(getId(quark), rootId, tid, Collections.singletonList(name)));
}
}
return new TmfTreeModel<>(Collections.emptyList(), builder.build());
}
use of org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter in project tracecompass by tracecompass.
the class XmlTimeGraphDataProviderTest method assertAndGetTree.
private static Map<Long, String> assertAndGetTree(ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> timeGraphProvider, ITmfTrace trace, List<String> expectedStrings) {
TmfModelResponse<@NonNull TmfTreeModel<@NonNull TimeGraphEntryModel>> treeResponse = timeGraphProvider.fetchTree(FetchParametersUtils.timeQueryToMap(new TimeQueryFilter(0, Long.MAX_VALUE, 2)), MONITOR);
assertNotNull(treeResponse);
assertEquals(ITmfResponse.Status.COMPLETED, treeResponse.getStatus());
TmfTreeModel<@NonNull TimeGraphEntryModel> treeModel = treeResponse.getModel();
assertNotNull(treeModel);
List<@NonNull TimeGraphEntryModel> xmlEntries = treeModel.getEntries();
Collections.sort(xmlEntries, Comparator.comparingLong(TimeGraphEntryModel::getId));
Map<Long, String> map = new HashMap<>();
for (int i = 0; i < expectedStrings.size(); i++) {
String expectedString = expectedStrings.get(i);
assertTrue("actual entry present at " + i + ": " + expectedString, xmlEntries.size() > i);
String[] split = expectedString.split(",");
TimeGraphEntryModel xmlTgEntry = xmlEntries.get(i);
assertEquals("Checking entry name at " + i, split[0], xmlTgEntry.getName());
assertEquals("Checking entry start time at " + i, Long.parseLong(split[1]), xmlTgEntry.getStartTime());
assertEquals("Checking entry end time at " + i, Long.parseLong(split[2]), xmlTgEntry.getEndTime());
// Check the parent
long parentId = xmlTgEntry.getParentId();
if (parentId < 0) {
assertEquals("Checking empty parent at " + i, split[3], "null");
} else {
String parentName = map.get(parentId);
assertEquals("Checking parent at " + i, split[3], parentName);
}
map.put(xmlTgEntry.getId(), xmlTgEntry.getName());
}
assertEquals("Extra actual entries", expectedStrings.size(), xmlEntries.size());
return map;
}
use of org.eclipse.tracecompass.tmf.core.model.filters.TimeQueryFilter in project tracecompass by tracecompass.
the class CriticalPathView method getLinkList.
@Override
protected List<ILinkEvent> getLinkList(long startTime, long endTime, long resolution, IProgressMonitor monitor) {
List<@NonNull TimeGraphEntry> traceEntries = getEntryList(getTrace());
if (traceEntries == null) {
return Collections.emptyList();
}
List<@NonNull ILinkEvent> linkList = new ArrayList<>();
TimeQueryFilter queryFilter = new TimeQueryFilter(startTime, endTime, 2);
/*
* group entries by critical path data provider as several hosts may refer to
* the same data provider
*/
Table<ITimeGraphDataProvider<?>, Long, TimeGraphEntry> table = HashBasedTable.create();
for (TraceEntry traceEntry : Iterables.filter(traceEntries, TraceEntry.class)) {
for (TimeGraphEntry entry : Utils.flatten(traceEntry)) {
table.put(traceEntry.getProvider(), entry.getEntryModel().getId(), entry);
}
}
for (Map.Entry<ITimeGraphDataProvider<?>, Map<Long, TimeGraphEntry>> entry : table.rowMap().entrySet()) {
ITimeGraphDataProvider<?> provider = entry.getKey();
Map<Long, TimeGraphEntry> map = entry.getValue();
TmfModelResponse<List<ITimeGraphArrow>> response = provider.fetchArrows(FetchParametersUtils.timeQueryToMap(queryFilter), monitor);
List<ITimeGraphArrow> model = response.getModel();
if (monitor.isCanceled()) {
return null;
}
if (model != null) {
for (ITimeGraphArrow arrow : model) {
ITimeGraphEntry src = map.get(arrow.getSourceId());
ITimeGraphEntry dst = map.get(arrow.getDestinationId());
if (src != null && dst != null) {
linkList.add(new TimeLinkEvent(src, dst, arrow.getStartTime(), arrow.getDuration(), arrow.getValue()));
}
}
}
}
return linkList;
}
Aggregations