use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class CriticalPathDataProvider method fetchTooltip.
@Override
@NonNull
public TmfModelResponse<@NonNull Map<@NonNull String, @NonNull String>> fetchTooltip(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, @Nullable IProgressMonitor monitor) {
SelectionTimeQueryFilter filter = FetchParametersUtils.createSelectionTimeQuery(fetchParameters);
if (filter == null) {
return new TmfModelResponse<>(null, Status.FAILED, CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
}
IGraphWorker worker = fWorkerToEntryId.inverse().get(filter.getSelectedItems().iterator().next());
if (worker == null) {
return new TmfModelResponse<>(null, Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
Map<@NonNull String, @NonNull String> info = worker.getWorkerInformation(filter.getStart());
return new TmfModelResponse<>(info, Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter 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();
}
use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class XmlTimeGraphDataProviderTest method assertRows.
private static void assertRows(ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> provider, Map<Long, String> tree, List<String> expectedStrings) {
TmfModelResponse<@NonNull TimeGraphModel> rowResponse = provider.fetchRowModel(FetchParametersUtils.selectionTimeQueryToMap(new SelectionTimeQueryFilter(1, 20, 20, tree.keySet())), null);
assertNotNull(rowResponse);
assertEquals(ITmfResponse.Status.COMPLETED, rowResponse.getStatus());
TimeGraphModel timeGraphModel = rowResponse.getModel();
assertNotNull(timeGraphModel);
List<@NonNull ITimeGraphRowModel> rowModel = timeGraphModel.getRows();
// ensure row order
rowModel.sort(Comparator.comparingLong(ITimeGraphRowModel::getEntryID));
assertEquals(expectedStrings.size(), rowModel.size());
for (int i = 0; i < expectedStrings.size(); i++) {
String expectedString = expectedStrings.get(i);
String[] split = expectedString.split(":");
ITimeGraphRowModel row = rowModel.get(i);
assertEquals(split[0], tree.get(row.getEntryID()));
assertEqualsStates(split[0], split[1], row.getStates());
}
}
use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class XmlXyDataProviderTest method assertRows.
private static void assertRows(ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> xyProvider, Map<Long, String> tree, List<String> expectedStrings) {
TmfModelResponse<@NonNull ITmfXyModel> rowResponse = xyProvider.fetchXY(FetchParametersUtils.selectionTimeQueryToMap(new SelectionTimeQueryFilter(1, 20, 20, tree.keySet())), null);
assertNotNull(rowResponse);
assertEquals(ITmfResponse.Status.COMPLETED, rowResponse.getStatus());
ITmfXyModel rowModel = rowResponse.getModel();
assertNotNull(rowModel);
Collection<@NonNull ISeriesModel> series = rowModel.getSeriesData();
ImmutableMap<Long, @NonNull ISeriesModel> data = Maps.uniqueIndex(series, ISeriesModel::getId);
for (int i = 0; i < expectedStrings.size(); i++) {
String expectedString = expectedStrings.get(i);
String[] split = expectedString.split(":");
String rowName = split[0];
Long rowId = null;
for (Entry<Long, String> entry : tree.entrySet()) {
if (entry.getValue().equals(rowName)) {
rowId = entry.getKey();
break;
}
}
assertNotNull(rowId);
ISeriesModel row = data.get(rowId);
assertNotNull(row);
String[] expectedData = split[1].split(",");
double[] actualData = row.getData();
for (int j = 0; j < expectedData.length; j++) {
assertTrue("Presence of data at position " + j + " for row " + rowName, actualData.length > j);
double expectedValue = Double.parseDouble(expectedData[j]);
assertEquals("Data at position " + j + " for row " + rowName, expectedValue, actualData[j], 0.001);
}
}
assertEquals("Same number of data", expectedStrings.size(), data.size());
}
use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class XmlTimeGraphDataProvider method fetchRowModel.
@Override
@NonNull
public TmfModelResponse<@NonNull TimeGraphModel> fetchRowModel(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, @Nullable IProgressMonitor monitor) {
Table<ITmfStateSystem, Integer, Long> table = HashBasedTable.create();
// 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, ITmfResponse.Status.FAILED, CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
}
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(), filter.getTimesRequested(), 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);
}
Aggregations