use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter 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();
}
}
use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class DataDrivenTimeGraphDataProvider method fetchRowModel.
@Override
@NonNull
public TmfModelResponse<@NonNull TimeGraphModel> fetchRowModel(@NonNull Map<@NonNull String, @NonNull Object> fetchParameters, @Nullable IProgressMonitor monitor) {
// 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, Status.FAILED, CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
}
Table<ITmfStateSystem, Integer, Long> table = HashBasedTable.create();
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(), 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);
}
use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class HistogramDataProvider method fetchXY.
@Override
@NonNull
public TmfModelResponse<ITmfXyModel> fetchXY(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
fModule.waitForInitialization();
SelectionTimeQueryFilter filter = FetchParametersUtils.createSelectionTimeQuery(fetchParameters);
long[] xValues = new long[0];
if (filter == null) {
return TmfXyResponseFactory.create(TITLE, xValues, Collections.emptyList(), true);
}
xValues = filter.getTimesRequested();
Collection<Long> selected = filter.getSelectedItems();
int n = xValues.length;
ImmutableList.Builder<IYModel> builder = ImmutableList.builder();
final ITmfStatistics stats = Objects.requireNonNull(fModule.getStatistics());
if (selected.contains(fTotalId)) {
List<Long> values = stats.histogramQuery(filter.getTimesRequested());
double[] y = new double[n];
Arrays.setAll(y, values::get);
String totalName = getTrace().getName() + '/' + Messages.HistogramDataProvider_Total;
builder.add(new YModel(fTotalId, totalName, y));
}
ITmfStateSystem eventsSs = fModule.getStateSystem(TmfStatisticsEventTypesModule.ID);
if (selected.contains(fLostId) && eventsSs != null) {
try {
YModel series = getLostEvents(eventsSs, xValues);
builder.add(series);
} catch (StateSystemDisposedException e) {
return TmfXyResponseFactory.createFailedResponse(CommonStatusMessage.STATE_SYSTEM_FAILED);
}
}
boolean completed = eventsSs != null ? eventsSs.waitUntilBuilt(0) || eventsSs.getCurrentEndTime() >= filter.getEnd() : false;
return TmfXyResponseFactory.create(TITLE, xValues, builder.build(), completed);
}
use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class FetchParametersUtils method createSelectionTimeQuery.
/**
* Create a {@link SelectionTimeQueryFilter} with the given map of parameters
*
* @param parameters
* Map of parameters
* @return A {@link SelectionTimeQueryFilter} or null if the parameters are invalid
*/
@Nullable
public static SelectionTimeQueryFilter createSelectionTimeQuery(Map<String, Object> parameters) {
List<Long> timeRequested = DataProviderParameterUtils.extractTimeRequested(parameters);
List<Long> selectedItems = DataProviderParameterUtils.extractSelectedItems(parameters);
return (timeRequested == null || selectedItems == null) ? null : new SelectionTimeQueryFilter(timeRequested, selectedItems);
}
use of org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter in project tracecompass by tracecompass.
the class AbstractTreeCommonXDataProvider method fetchXY.
@Override
public final TmfModelResponse<ITmfXyModel> fetchXY(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
A module = getAnalysisModule();
// 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 TmfXyResponseFactory.createFailedResponse(CommonStatusMessage.INCORRECT_QUERY_PARAMETERS);
}
TmfModelResponse<ITmfXyModel> res = verifyParameters(module, filter, monitor);
if (res != null) {
return res;
}
ITmfStateSystem ss = Objects.requireNonNull(module.getStateSystem(), // $NON-NLS-1$
"Statesystem should have been verified by verifyParameters");
long currentEnd = ss.getCurrentEndTime();
boolean complete = ss.waitUntilBuilt(0) || filter.getEnd() <= currentEnd;
try (FlowScopeLog scope = // $NON-NLS-1$
new FlowScopeLogBuilder(LOGGER, Level.FINE, "AbstractTreeXyDataProvider#fetchXY").setCategory(getClass().getSimpleName()).build()) {
Collection<IYModel> yModels = getYSeriesModels(ss, fetchParameters, monitor);
if (yModels == null) {
// getModels returns null if the query was cancelled.
return TmfXyResponseFactory.createCancelledResponse(CommonStatusMessage.TASK_CANCELLED);
}
return TmfXyResponseFactory.create(getTitle(), filter.getTimesRequested(), ImmutableList.copyOf(yModels), complete);
} catch (StateSystemDisposedException | TimeRangeException | IndexOutOfBoundsException e) {
return TmfXyResponseFactory.createFailedResponse(String.valueOf(e.getMessage()));
}
}
Aggregations