use of org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval in project tracecompass by tracecompass.
the class DataDrivenScenarioHistoryBuilder method getStoredFieldValue.
/**
* Get the value of a special field in the state system
*
* @param container
* The state system container this class use
* @param attributeName
* The attribute name of the special field
* @param info
* The scenario details
* @param event
* The current event
*
* @return The value of a special field saved into the state system
*/
public ITmfStateValue getStoredFieldValue(IAnalysisDataContainer container, String attributeName, DataDrivenScenarioInfo info, ITmfEvent event) {
ITmfStateSystemBuilder ss = (ITmfStateSystemBuilder) container.getStateSystem();
long ts = event.getTimestamp().toNanos();
ITmfStateInterval state = null;
try {
int attributeQuark = getQuarkRelativeAndAdd(ss, info.getQuark(), TmfXmlStrings.STORED_FIELDS, attributeName);
state = ss.querySingleState(ts, attributeQuark);
} catch (StateSystemDisposedException e) {
// $NON-NLS-1$
Activator.logError("failed to get the value of the stored field " + attributeName, e);
}
return (state != null) ? NonNullUtils.checkNotNull(state.getStateValue()) : TmfStateValue.nullValue();
}
use of org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval in project tracecompass by tracecompass.
the class DataDrivenScenarioHistoryBuilder method getSpecificStateStartTime.
/**
* Get the start time of a specific state of the scenario
*
* @param container
* The state system container this class use
* @param stateName
* The name of the current state of the scenario
* @param info
* The scenario details
* @param event
* The current event
*
* @return The start time for the specified state
*/
public long getSpecificStateStartTime(IXmlStateSystemContainer container, String stateName, DataDrivenScenarioInfo info, ITmfEvent event) {
long ts = event.getTimestamp().getValue();
ITmfStateSystemBuilder ss = (ITmfStateSystemBuilder) container.getStateSystem();
try {
int attributeQuark = getQuarkRelativeAndAdd(ss, info.getQuark(), TmfXmlStrings.STATE, stateName, START_TIME);
ITmfStateInterval state = ss.querySingleState(ts, attributeQuark);
return state.getStartTime();
} catch (StateSystemDisposedException e) {
// $NON-NLS-1$
Activator.logError("failed the start time of the state " + stateName, e);
}
return -1l;
}
use of org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval in project tracecompass by tracecompass.
the class DataDrivenValueStackPeek method resolveValue.
@Override
@Nullable
protected Object resolveValue(ITmfEvent event, int baseQuark, DataDrivenScenarioInfo scenarioInfo, IAnalysisDataContainer container) {
final long ts = event.getTimestamp().toNanos();
/* Query the state system for the value */
Object value = null;
ITmfStateSystem ss = container.getStateSystem();
int quarkQuery = fPath.getQuark(event, baseQuark, scenarioInfo, container);
/*
* the query can fail : for example, if a value is requested but has not been
* set yet
*/
if (quarkQuery >= 0) {
try {
@Nullable ITmfStateInterval stackTopInterval = StateSystemUtils.querySingleStackTop(ss, ts, quarkQuery);
return (stackTopInterval != null ? stackTopInterval.getStateValue().unboxValue() : null);
} catch (AttributeNotFoundException | StateSystemDisposedException e) {
// $NON-NLS-1$
throw new DataDrivenException("Resolving stack peek: " + e.getMessage(), event);
}
}
return value;
}
use of org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval in project tracecompass by tracecompass.
the class XmlTimeGraphDataProvider method processEntry.
private Builder processEntry(@NonNull Element entryElement, DataDrivenStateSystemPath displayPath, @NonNull Builder parentEntry, int quark, ITmfStateSystem ss, long currentEnd) {
/*
* Get the start time and end time of this entry from the display attribute
*/
int displayQuark = displayPath.getQuark(quark, parentEntry);
long id = fBaseQuarkToId.row(ss).computeIfAbsent(quark, s -> sfAtomicId.getAndIncrement());
if (displayQuark < 0) {
return new Builder(id, parentEntry.getId(), Collections.singletonList(String.format("Unknown display quark for %s", ss.getAttributeName(quark))), ss.getStartTime(), ss.getCurrentEndTime(), null, ss, quark, // $NON-NLS-1$
fCompilationData);
}
fIDToDisplayQuark.put(id, new Pair<>(ss, displayQuark));
long entryStart = ss.getStartTime();
long entryEnd = currentEnd;
try {
ITmfStateInterval oneInterval = ss.querySingleState(entryStart, displayQuark);
/* The entry start is the first non-null interval */
while (oneInterval.getStateValue().isNull()) {
long ts = oneInterval.getEndTime() + 1;
if (ts > currentEnd) {
break;
}
oneInterval = ss.querySingleState(ts, displayQuark);
}
entryStart = oneInterval.getStartTime();
/* The entry end is the last non-null interval */
oneInterval = ss.querySingleState(entryEnd - 1, displayQuark);
while (oneInterval.getStateValue().isNull()) {
long ts = oneInterval.getStartTime() - 1;
if (ts < ss.getStartTime()) {
break;
}
oneInterval = ss.querySingleState(ts, displayQuark);
}
entryEnd = Math.min(oneInterval.getEndTime() + 1, currentEnd);
} catch (StateSystemDisposedException e) {
}
return new Builder(id, parentEntry.getId(), Collections.singletonList(ss.getAttributeName(quark)), entryStart, entryEnd, entryElement, ss, quark, fCompilationData);
}
use of org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval in project tracecompass by tracecompass.
the class XmlTimeGraphDataProvider method createRows.
@NonNull
private Collection<@NonNull ITimeGraphRowModel> createRows(ITmfStateSystem ss, Map<Integer, Long> idToDisplayQuark, long[] timesRequested, @NonNull Map<@NonNull String, @NonNull Object> parameters, @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(parameters);
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<>()));
}
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