use of org.eclipse.tracecompass.segmentstore.core.ISegment in project tracecompass by tracecompass.
the class IOStateSystemSegmentStore method getIntersectingElements.
@Override
@NonNull
public Iterable<@NonNull ISegment> getIntersectingElements(long start, long end) {
long startTime = Math.max(start, fStateSystem.getStartTime());
long endTime = Math.min(end, fStateSystem.getCurrentEndTime());
if (startTime > endTime) {
return Collections.emptySet();
}
List<@NonNull ISegment> segments = new ArrayList<>();
try {
for (ITmfStateInterval interval : fStateSystem.query2D(fSegmentQuarks.keySet(), startTime, endTime)) {
RequestIntervalSegment segment = RequestIntervalSegment.create(interval, fSegmentQuarks.get(interval.getAttribute()));
if (segment != null) {
segments.add(segment);
}
}
} catch (IndexOutOfBoundsException | TimeRangeException | StateSystemDisposedException e1) {
// Nothing to do
}
return segments;
}
use of org.eclipse.tracecompass.segmentstore.core.ISegment in project tracecompass by tracecompass.
the class CallStackSegmentStoreTest method testSeriesSegmentStoreIterator.
/**
* Test the callstack data using the callstack object
*/
@Test
public void testSeriesSegmentStoreIterator() {
CallStackAnalysisStub module = getModule();
assertNotNull(module);
ISegmentStore<@NonNull ISegment> segmentStore = module.getSegmentStore();
assertNotNull(segmentStore);
Iterator<@NonNull ISegment> iterator = segmentStore.iterator();
assertEquals("Segment store iterator count", 21, Iterators.size(iterator));
assertEquals("Segment store size", 21, segmentStore.size());
assertFalse(segmentStore.isEmpty());
}
use of org.eclipse.tracecompass.segmentstore.core.ISegment in project tracecompass by tracecompass.
the class CallStackSegmentStoreTest method testIntersectingSegmentStore.
/**
* Test the segment store's intersecting query methods
*/
@Test
public void testIntersectingSegmentStore() {
CallStackAnalysisStub module = getModule();
assertNotNull(module);
ISegmentStore<@NonNull ISegment> segmentStore = module.getSegmentStore();
assertNotNull(segmentStore);
// Test with some boundaries: all elements that start or end at 10 should be
// included
Iterable<@NonNull ISegment> elements = segmentStore.getIntersectingElements(10L);
assertEquals("Intersecting 10", 9, Iterables.size(elements));
elements = segmentStore.getIntersectingElements(10L, 15L);
assertEquals("Between 10 and 15", 12, Iterables.size(elements));
}
use of org.eclipse.tracecompass.segmentstore.core.ISegment in project tracecompass by tracecompass.
the class CallStackSeries method getIntersectingElements.
/**
* Retrieve all elements that inclusively cross another segment and evaluate
* a predicate to true. We define this target segment by its start and end
* positions.
*
* This effectively means, all elements that respect *all* conditions:
*
* <ul>
* <li>Their end is after the 'start' parameter</li>
* <li>Their start is before the 'end' parameter</li>
* <li>They match the predicate</li>
* </ul>
*
* @param start
* The target start position
* @param end
* The target end position
* @param intervalTest
* A {@link Predicate} object. The predicate must evaluate to
* true in order to consider the interval, otherwise the interval
* is ignored
* @return The elements overlapping with this segment
* @since 2.2
*/
protected Iterable<ISegment> getIntersectingElements(long start, long end, Predicate<ITmfStateInterval> intervalTest) {
ITmfStateSystem stateSystem = fRootGroup.getStateSystem();
long startTime = Math.max(SaturatedArithmetic.add(start, -1L), stateSystem.getStartTime());
long endTime = Math.min(end, stateSystem.getCurrentEndTime());
if (startTime > endTime) {
return Collections.emptyList();
}
Map<Integer, CallStack> quarksToElement = getCallStackQuarks();
try {
Iterable<ITmfStateInterval> query2d = stateSystem.query2D(quarksToElement.keySet(), startTime, endTime);
query2d = Iterables.filter(query2d, interval -> !interval.getStateValue().isNull() && intervalTest.test(interval));
Function<ITmfStateInterval, ICalledFunction> fct = interval -> {
CallStack callstack = quarksToElement.get(interval.getAttribute());
if (callstack == null) {
// $NON-NLS-1$
throw new NullPointerException("The quark was in that map in the first place, there must be a callstack to go with it!");
}
int pid = callstack.getSymbolKeyAt(interval.getStartTime());
return CalledFunctionFactory.create(interval.getStartTime(), interval.getEndTime() + 1, Integer.parseInt(stateSystem.getAttributeName(interval.getAttribute())), Objects.requireNonNull(interval.getValue()), pid, null);
};
return Iterables.transform(query2d, fct);
} catch (StateSystemDisposedException e) {
// $NON-NLS-1$
Activator.getInstance().logError("Error getting intersecting elements: StateSystemDisposed");
}
return Collections.emptyList();
}
use of org.eclipse.tracecompass.segmentstore.core.ISegment in project tracecompass by tracecompass.
the class CallStackSeries method contains.
@Override
public boolean contains(@Nullable Object o) {
// narrow down search when object is a segment
if (o instanceof ICalledFunction) {
ICalledFunction seg = (ICalledFunction) o;
Iterable<@NonNull ISegment> iterable = getIntersectingElements(seg.getStart());
return Iterables.contains(iterable, seg);
}
return false;
}
Aggregations