下面列出了com.google.common.collect.ImmutableMultimap.Builder#org.eclipse.jdt.annotation.NonNull 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* @param time
* The event type
* @param longVal
* The event value or null
* @return A new TmfEvent
*/
public @NonNull ITmfEvent createEvent(long time, Long longVal) {
ITmfStateValue value;
if (longVal == null) {
value = TmfStateValue.nullValue();
} else if (type == ITmfStateValue.Type.LONG) {
value = TmfStateValue.newValueLong(longVal);
} else if (type == ITmfStateValue.Type.INTEGER) {
value = TmfStateValue.newValueInt(longVal.intValue());
} else if (type == ITmfStateValue.Type.DOUBLE) {
value = TmfStateValue.newValueDouble(longVal.doubleValue());
} else {
value = TmfStateValue.nullValue();
}
ITmfTimestamp timestamp = TmfTimestamp.fromNanos(time);
ITmfEventType eventType = new TmfEventType(MIPMAP_ID, null);
ITmfEventField content = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, value, null);
ITmfEvent event = new TmfEvent(null, ITmfContext.UNKNOWN_RANK, timestamp, eventType, content);
return event;
}
/**
* @return an array of {@link ISymbolProviderPreferencePage} that will configure
* the current traces
*/
private ISymbolProviderPreferencePage[] getProviderPages() {
List<ISymbolProviderPreferencePage> pages = new ArrayList<>();
ITmfTrace trace = getTrace();
if (trace != null) {
for (ITmfTrace subTrace : getTracesToBuild(trace)) {
Collection<@NonNull ISymbolProvider> symbolProviders = SymbolProviderManager.getInstance().getSymbolProviders(subTrace);
for (org.eclipse.tracecompass.tmf.ui.symbols.ISymbolProvider provider : Iterables.filter(symbolProviders, org.eclipse.tracecompass.tmf.ui.symbols.ISymbolProvider.class)) {
ISymbolProviderPreferencePage page = provider.createPreferencePage();
if (page != null) {
pages.add(page);
}
}
}
}
return pages.toArray(new ISymbolProviderPreferencePage[pages.size()]);
}
/**
* Test getting the XML data provider for one trace, with an analysis that
* applies to a trace
*/
@Test
public void testOneTrace() {
ITmfTrace trace = null;
try {
// Initialize the trace and module
trace = XmlUtilsTest.initializeTrace(TEST_TRACE);
TmfTraceOpenedSignal signal = new TmfTraceOpenedSignal(this, trace, null);
((TmfTrace) trace).traceOpened(signal);
// The data provider manager uses opened traces from the manager
TmfTraceManager.getInstance().traceOpened(signal);
// Get the view element from the file
Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.STATE_VALUE_FILE.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, TRACE_VIEW_ID);
assertNotNull(viewElement);
ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> timeGraphProvider = XmlDataProviderManager.getInstance().getTimeGraphProvider(trace, viewElement);
assertNotNull(timeGraphProvider);
} finally {
if (trace != null) {
trace.dispose();
TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
}
}
}
private @NonNull IResource createAndVerifyLink(IPath path, String name, boolean isFile, boolean isSymLink, boolean checkSymLink) throws IOException, CoreException {
IResource resource;
if (isFile) {
resource = fTestFolder.getFile(name);
} else {
resource = fTestFolder.getFolder(name);
}
assertNotNull(resource);
boolean success = ResourceUtil.createSymbolicLink(resource, path, isSymLink, null);
assertTrue(success);
assertTrue(resource.exists());
assertTrue(isFileSystemSymbolicLink(resource) == (checkSymLink ? isSymLink : false));
assertTrue(resource.isLinked() == ((checkSymLink ? !isSymLink : true)));
assertTrue(ResourceUtil.isSymbolicLink(resource));
verifyLocation(path, resource);
return resource;
}
/**
* Basic generation of command for session creation
*
* @param sessionInfo
* the session to create
* @return the basic command for command creation
*/
protected @NonNull ICommandInput prepareSessionCreationCommand(ISessionInfo sessionInfo) {
ICommandInput command = createCommand(LTTngControlServiceConstants.COMMAND_CREATE_SESSION);
if (!sessionInfo.getName().isEmpty()) {
command.add(sessionInfo.getName());
}
String newPath = sessionInfo.getSessionPath();
if (newPath != null && !"".equals(newPath)) { //$NON-NLS-1$
command.add(LTTngControlServiceConstants.OPTION_OUTPUT_PATH);
command.add(newPath);
}
if (sessionInfo.isSnapshotSession()) {
command.add(LTTngControlServiceConstants.OPTION_SNAPSHOT);
}
return command;
}
/**
* Create (if necessary) and get the {@link ITmfTreeXYDataProvider} for the
* specified trace and viewElement.
*
* @param trace
* trace for which we are querying a provider
* @param viewElement
* the XML XY view element for which we are querying a provider
* @return the unique instance of an XY provider for the queried parameters
*/
public synchronized @Nullable ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> getXyProvider(ITmfTrace trace, Element viewElement) {
if (!viewElement.hasAttribute(ID_ATTRIBUTE)) {
return null;
}
String viewId = viewElement.getAttribute(ID_ATTRIBUTE);
ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> provider = fXyProviders.get(trace, viewId);
if (provider != null) {
return provider;
}
if (Iterables.any(TmfTraceManager.getInstance().getOpenedTraces(),
opened -> TmfTraceManager.getTraceSetWithExperiment(opened).contains(trace))) {
DataDrivenXYProviderFactory xyFactory = getXyProviderFactory(viewElement);
// Create with the trace or experiment first
if (xyFactory != null) {
return createXYProvider(trace, viewId, xyFactory);
}
}
return null;
}
private static void assertEqualsStates(String string, @NonNull List<@NonNull ITimeGraphState> states, String element) {
String[] stringStates = string.split(",");
for (int i = 0; i < stringStates.length / 4; i++) {
ITimeGraphState state = states.get(i);
assertEquals(element + ": start time at position " + i, Long.parseLong(stringStates[i * 4]), state.getStartTime());
assertEquals(element + ": duration at position " + i, Long.parseLong(stringStates[i * 4 + 1]), state.getDuration());
OutputElementStyle style = state.getStyle();
if (style == null) {
// Expected a value of Long
try {
assertEquals(element + ": value at position " + i, Long.parseLong(stringStates[i * 4 + 2]), state.getValue());
} catch (NumberFormatException e) {
fail(element + ": value at position " + i + ": did not expect a null style");
}
} else {
assertEquals(element + ": value at position " + i, stringStates[i * 4 + 2], style.getParentKey());
}
assertEquals(element + ": label at position " + i, stringStates[i * 4 + 3], String.valueOf(state.getLabel()));
}
}
@Override
@NonNullByDefault({})
public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event, long hoverTime) {
Map<String, String> retMap = super.getEventHoverToolTipInfo(event, hoverTime);
if (retMap == null) {
retMap = new LinkedHashMap<>(1);
}
if (!(event instanceof TimeEvent) || !((TimeEvent) event).hasValue() ||
!(event.getEntry() instanceof TimeGraphEntry)) {
return retMap;
}
TimeGraphEntry entry = (TimeGraphEntry) event.getEntry();
ITimeGraphDataProvider<? extends TimeGraphEntryModel> dataProvider = BaseDataProviderTimeGraphView.getProvider(entry);
TmfModelResponse<@NonNull Map<@NonNull String, @NonNull String>> response = dataProvider.fetchTooltip(
FetchParametersUtils.selectionTimeQueryToMap(new SelectionTimeQueryFilter(hoverTime, hoverTime, 1, Collections.singletonList(entry.getEntryModel().getId()))), null);
Map<@NonNull String, @NonNull String> tooltipModel = response.getModel();
if (tooltipModel != null) {
retMap.putAll(tooltipModel);
}
return retMap;
}
/**
* Test a data set with a large number of objects of random values
*
* NOTE: This test contains negative values
*/
@Test
public void testLargeDatasetNegative() {
// Create a fixture of a large number of random values
List<@NonNull Long> longFixture = new ArrayList<>(LARGE_AMOUNT_OF_SEGMENTS);
Random rng = new Random(10);
for (int i = 1; i <= LARGE_AMOUNT_OF_SEGMENTS; i++) {
longFixture.add(rng.nextLong());
}
// Create the statistics object for the objects that will return those
// values
Collection<@NonNull E> fixture = createElementsWithValues(longFixture);
// Compare with an offline algorithm
testOnlineVsOffline(fixture);
}
private static void assertMarkerListEquals(@NonNull List<IMarkerEvent> expectedList, @NonNull List<@NonNull IMarkerEvent> markerList) {
assertEquals(expectedList.size(), markerList.size());
for (int i = 0; i < expectedList.size(); i++) {
IMarkerEvent expected = expectedList.get(i);
IMarkerEvent marker = markerList.get(i);
assertEquals(marker.toString(), expected.getEntry(), marker.getEntry());
assertEquals(marker.toString(), expected.getTime(), marker.getTime());
assertEquals(marker.toString(), expected.getDuration(), marker.getDuration());
assertEquals(marker.toString(), expected.getCategory(), marker.getCategory());
assertEquals(marker.toString(), expected.getLabel(), marker.getLabel());
assertEquals(marker.toString(), expected.getColor(), marker.getColor());
}
}
@Override
public Subscription addBindSubscription(@NonNull Subscription subscription) {
synchronized(bindSubscriptions) {
bindSubscriptions.add(subscription);
return subscription;
}
}
@Override
public @NonNull ITmfTrace getTrace() {
// A good moment to initialize the expected data by reading the trace
ITmfTrace trace = super.getTrace();
if (!fDataInitialized) {
setCallStackData(getExpectedData(trace));
fDataInitialized = true;
}
return trace;
}
/**
* Get the legend image for a entry's name
*
* @param name
* the entry's name (used in both Tree and Chart viewer
* @return the correctly dimensioned image if there is a legend image provider
*/
protected Image getLegendImage(@NonNull String name) {
/* If the image height match the row height, row height will increment */
ILegendImageProvider legendImageProvider = fLegendImageProvider;
int legendColumnIndex = fLegendIndex;
if (legendImageProvider != null && legendColumnIndex >= 0) {
Tree tree = getTreeViewer().getTree();
int imageWidth = tree.getColumn(legendColumnIndex).getWidth();
int imageHeight = tree.getItemHeight() - 1;
if (imageHeight > 0 && imageWidth > 0) {
return legendImageProvider.getLegendImage(imageHeight, imageWidth, name);
}
}
return null;
}
private static SynchronizationAlgorithm synchronize(final File syncFile,
final Collection<@NonNull ITmfTrace> traces, SynchronizationAlgorithm syncAlgo) {
ITmfEventMatching matching = new TmfEventMatching(traces, syncAlgo);
matching.matchEvents();
SynchronizationBackend syncBackend;
try {
syncBackend = new SynchronizationBackend(syncFile, false);
syncBackend.saveSync(syncAlgo);
} catch (IOException e) {
Activator.logError("Error while saving trace synchronization file", e); //$NON-NLS-1$
}
return syncAlgo;
}
@Override
public @NonNull TmfModelResponse<List<ITimeGraphArrow>> fetchArrows(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
/**
* If there were arrows to be drawn, this is where they would be defined
*/
return new TmfModelResponse<>(null, Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
@Override
protected ISeries createSwtSeries(ChartSeries chartSeries, ISeriesSet swtSeriesSet, @NonNull Color color) {
String title = chartSeries.getY().getLabel();
IBarSeries swtSeries = (IBarSeries) swtSeriesSet.createSeries(SeriesType.BAR, title);
swtSeries.setBarPadding(BAR_PADDING);
swtSeries.setBarColor(color);
return swtSeries;
}
/**
* Compute the predicate for every property regexes
*
* @return A map of time event filters predicate by property
* @since 3.1
* @deprecated Use {@link #generateRegexPredicate()}
*/
@Deprecated
protected Map<Integer, Predicate<@NonNull Map<@NonNull String, @NonNull Object>>> computeRegexPredicate() {
Multimap<@NonNull Integer, @NonNull String> regexes = getRegexes();
Map<@NonNull Integer, @NonNull Predicate<@NonNull Map<@NonNull String, @NonNull Object>>> predicates = new HashMap<>();
for (Map.Entry<Integer, Collection<String>> entry : regexes.asMap().entrySet()) {
String regex = IFilterStrings.mergeFilters(entry.getValue());
FilterCu cu = FilterCu.compile(regex);
Predicate<@NonNull Map<@NonNull String, @NonNull Object>> predicate = cu != null ? multiToMapPredicate(cu.generate()) : null;
if (predicate != null) {
predicates.put(entry.getKey(), predicate);
}
}
return predicates;
}
/**
* Test table with an on-disk segment store that is lazy loaded in the table
*
* @throws IOException
* when creating the segment store
*/
@Test
public void onDiskSegStoreTest() throws IOException {
Path segmentFile = Files.createTempFile("tmpSegStore", ".tmp");
assertNotNull(segmentFile);
ISegmentStore<@NonNull BasicSegment> fixture = null;
try {
final int size = 1000000;
fixture = SegmentStoreFactory.createOnDiskSegmentStore(segmentFile, BasicSegment.BASIC_SEGMENT_READ_FACTORY, 1);
for (int i = 0; i < size; i++) {
fixture.add(new BasicSegment(i, 2 * i));
}
fixture.close(false);
assertNotNull(getTable());
getTable().updateModel(fixture);
SWTBotTable tableBot = new SWTBotTable(getTable().getTableViewer().getTable());
fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "0", 0, 2));
tableBot.header("Duration").click();
fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "0", 0, 2));
tableBot.header("Duration").click();
fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "999,999", 0, 2));
} finally {
if (fixture != null) {
fixture.close(true);
}
Files.deleteIfExists(segmentFile);
}
}
@POST
@Path("/compat/cards/{cardUID}/unbookmark")
@ApiOperation(value = "Removes the bookmark on a card (compatibility endpoint).")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"),
@ApiResponse(code = 404, message = "The card with the provided UID doesn't exist"),
@ApiResponse(code = 500, message = "An error occured") })
public Response unsetCardBookmarkCompat(
@PathParam("cardUID") @ApiParam(value = "cardUID", required = true) @NonNull String cardUID) {
return this.unsetCardBookmark(cardUID);
}
@Override
public @NonNull ISegment next() {
/* hasNext implies next != null */
if (hasNext()) {
ISegment segment = Objects.requireNonNull(fNext);
fLasts.put(getSegmentName(segment), segment);
fNext = null;
return segment;
}
throw new NoSuchElementException();
}
private void drawStyledDot(GC gc, Color lineColor, int imageWidth, int imageHeight, @NonNull OutputElementStyle appearance) {
BaseXYPresentationProvider presProvider = fChartViewer.getPresentationProvider();
String symbolStyle = (String) presProvider.getStyleOrDefault(appearance, StyleProperties.SYMBOL_TYPE, StyleProperties.SymbolType.NONE);
int symbolSize = ((Number) presProvider.getFloatStyleOrDefault(appearance, StyleProperties.HEIGHT, 1.0f)).intValue();
int centerX = imageWidth / 2;
int centerY = imageHeight / 2;
Color prevBg = gc.getBackground();
Color prevFg = gc.getForeground();
switch(symbolStyle) {
case StyleProperties.SymbolType.CIRCLE:
SymbolHelper.drawCircle(gc, lineColor, symbolSize, centerX, centerY);
break;
case StyleProperties.SymbolType.DIAMOND:
SymbolHelper.drawDiamond(gc, lineColor, symbolSize, centerX, centerY);
break;
case StyleProperties.SymbolType.SQUARE:
SymbolHelper.drawSquare(gc, lineColor, symbolSize, centerX, centerY);
break;
case StyleProperties.SymbolType.CROSS:
SymbolHelper.drawCross(gc, lineColor, symbolSize, centerX, centerY);
break;
case StyleProperties.SymbolType.PLUS:
SymbolHelper.drawPlus(gc, lineColor, symbolSize, centerX, centerY);
break;
case StyleProperties.SymbolType.INVERTED_TRIANGLE:
SymbolHelper.drawInvertedTriangle(gc, lineColor, symbolSize, centerX, centerY);
break;
case StyleProperties.SymbolType.TRIANGLE:
SymbolHelper.drawTriangle(gc, lineColor, symbolSize, centerX, centerY);
break;
default:
// Default is nothing
break;
}
gc.setForeground(prevFg);
gc.setBackground(prevBg);
}
@NonNull
@Override
public Iterator<?> iterator(Event e) {
try {
return Iterators.filter(new ArrayIterator<>(this.objects.getArray(e)), object -> {
current = object;
return condition.check(e);
});
} finally {
current = null;
}
}
@Override
public void readSpecificHeader(@NonNull ByteBuffer buffer) {
super.readSpecificHeader(buffer);
int size = getNode().getMaxChildren();
for (int i = 0; i < getNbChildren(); i++) {
fChildStart[i] = buffer.getLong();
}
for (int i = getNbChildren(); i < size; i++) {
buffer.getLong();
}
}
/**
* Test the {@link TmfTraceUtils#getPreviousEventMatching} method, where the
* event from which we start the search already matches the criterion (it
* should be correctly skipped).
*/
@Test
public void testPreviousMatchingEventStartMatches() {
ITmfTrace trace = fTrace;
assertNotNull(trace);
Predicate<@NonNull ITmfEvent> predicate = event -> event.getName().equals("softirq_raise");
ITmfEvent foundEvent = TmfTraceUtils.getPreviousEventMatching(trace, START_RANK, predicate, null);
assertNotNull(foundEvent);
assertNotEquals(fStartEvent, foundEvent);
}
@Override
public Map<@NonNull String, @NonNull Long> getEventTypesTotal() {
int quark = fTypesStats.optQuarkAbsolute(Attributes.EVENT_TYPES);
if (quark == ITmfStateSystem.INVALID_ATTRIBUTE) {
return Collections.emptyMap();
}
/* Get the list of quarks, one for each even type in the database */
List<Integer> quarks = fTypesStats.getSubAttributes(quark, false);
long endTime = fTypesStats.getCurrentEndTime();
final Map<@NonNull String, @NonNull Long> map = new HashMap<>();
try {
/* Since we want the total we can look only at the end */
List<ITmfStateInterval> endState = fTypesStats.queryFullState(endTime);
for (int typeQuark : quarks) {
String curEventName = fTypesStats.getAttributeName(typeQuark);
long eventCount = extractCount(endState.get(typeQuark).getValue());
map.put(curEventName, eventCount);
}
return map;
} catch (StateSystemDisposedException e) {
/* Assume there is no events, nothing will be put in the map. */
return Collections.emptyMap();
}
}
/**
* The type constructor
* @param name the event name
* @param description the event description
*/
public BtfEventType(@NonNull String name, String description) {
super();
fName = name;
fDescription = description;
fCols = ImmutableList.copyOf(FIELDS_WITH_NOTES_COLUMNS);
fFields = FIELDS_WITH_NOTES;
}
@Override
protected @NonNull AbstractTmfTreeViewer createSegmentStoreStatisticsViewer(@NonNull Composite parent) {
PatternStatisticsViewer viewer = new PatternStatisticsViewer(parent);
fViewer = viewer;
loadStatisticView();
return viewer;
}
@NonNull
private static BitBuffer create32BitNegativeFloatByteBuffer() {
float[] data = new float[2];
data[0] = -2.0f;
data[1] = -3.14f;
ByteBuffer byb = ByteBuffer.allocate(128);
byb.order(ByteOrder.nativeOrder());
byb.mark();
byb.putFloat(data[0]);
byb.putFloat(data[1]);
byb.reset();
BitBuffer bb = new BitBuffer(byb);
return bb;
}
/**
* @return the tracing group option if configured in the preferences
*/
protected @NonNull List<@NonNull String> getTracingGroupOption() {
List<@NonNull String> groupOption = new ArrayList<>();
if (!ControlPreferences.getInstance().isDefaultTracingGroup() && !ControlPreferences.getInstance().getTracingGroup().equals("")) { //$NON-NLS-1$
groupOption.add(LTTngControlServiceConstants.OPTION_TRACING_GROUP);
groupOption.add(ControlPreferences.getInstance().getTracingGroup());
}
return groupOption;
}
/**
* Run the ArrayDefinition(ArrayDeclaration,DefinitionScope,String)
* constructor test.
*/
@Test
public void testArrayDefinition_baseDeclaration() {
CompoundDeclaration declaration = (CompoundDeclaration) charArrayFixture.getDeclaration();
String fieldName = "";
ArrayDefinition result = new ArrayDefinition(declaration, this.trace, fieldName, Arrays.asList(new @NonNull Definition[0]));
assertNotNull(result);
}