Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Counter aspect changes #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
Bundle-Version: 2.2.1.qualifier
Bundle-Version: 2.3.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.tracecompass.analysis.counters.core;singleton:=true
Bundle-Activator: org.eclipse.tracecompass.internal.analysis.counters.core.Activator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public static CounterStateProvider create(ITmfTrace trace) {
Iterable<ITmfEventAspect<?>> counterAspects = TmfTraceUtils.getEventAspects(trace, ITmfCounterAspect.class);
for (ITmfEventAspect<?> counter : counterAspects) {

if (counter instanceof CounterAspect) {
CounterAspect counterAspect = (CounterAspect) counter;
if (counter instanceof ITmfCounterAspect) {
ITmfCounterAspect counterAspect = (ITmfCounterAspect) counter;
for (Class<? extends ITmfEventAspect<?>> parentAspectClass : counterAspect.getGroups()) {

// Avoid creating the same aggregated aspect multiple times
Expand Down Expand Up @@ -122,14 +122,14 @@ protected void eventHandle(@NonNull ITmfEvent event) {
}

for (ITmfEventAspect<?> aspect : fCounterAspects) {
if (aspect instanceof CounterAspect) {
CounterAspect counterAspect = (CounterAspect) aspect;
if (aspect instanceof ITmfCounterAspect) {
ITmfCounterAspect counterAspect = (ITmfCounterAspect) aspect;
if (counterAspect.getGroups().length > 0) {
int rootQuark = ss.getQuarkAbsoluteAndAdd(CounterAnalysis.GROUPED_COUNTER_ASPECTS_ATTRIB);
handleGroupedCounterAspect(event, ss, counterAspect, rootQuark);
handleGroupedCounterAspect(event, ss, rootQuark, counterAspect);
} else {
int rootQuark = ss.getQuarkAbsoluteAndAdd(CounterAnalysis.UNGROUPED_COUNTER_ASPECTS_ATTRIB);
handleCounterAspect(event, ss, counterAspect, rootQuark);
handleCounterAspect(event, ss, rootQuark, counterAspect);
}
}
}
Expand All @@ -147,8 +147,29 @@ protected void eventHandle(@NonNull ITmfEvent event) {
* Grouped counter aspect
* @param rootQuark
* Key to a relative root of the state system
* @deprecated use
* {@link #handleGroupedCounterAspect(ITmfEvent, ITmfStateSystemBuilder, int, ITfmCounterAspect)}
*/
@Deprecated
protected void handleGroupedCounterAspect(ITmfEvent event, ITmfStateSystemBuilder ss, CounterAspect aspect, int rootQuark) {
handleGroupedCounterAspect(event, ss, rootQuark, aspect);
}

/**
* Add the field value of a grouped counter aspect to the state system
* (override in specific implementations)
*
* @param event
* Event to process
* @param ss
* State system object to fill
* @param rootQuark
* Key to a relative root of the state system
* @param aspect
* Grouped counter aspect
* @since 2.3
*/
protected void handleGroupedCounterAspect(ITmfEvent event, ITmfStateSystemBuilder ss, int rootQuark, ITmfCounterAspect aspect) {
/*
* Retrieve the child quark of the counter aspect by going through its
* attribute tree in the state system. The concatenation of the aspect's
Expand All @@ -170,10 +191,10 @@ protected void handleGroupedCounterAspect(ITmfEvent event, ITmfStateSystemBuilde
}
}

handleCounterAspect(event, ss, aspect, quark);
handleCounterAspect(event, ss, quark, aspect);
}

private static void handleCounterAspect(ITmfEvent event, ITmfStateSystemBuilder ss, CounterAspect aspect, int rootQuark) {
private static void handleCounterAspect(ITmfEvent event, ITmfStateSystemBuilder ss, int rootQuark, ITmfCounterAspect aspect) {
int quark = ss.getQuarkRelativeAndAdd(rootQuark, aspect.getName());
Number eventContent = aspect.resolve(event);
if (eventContent != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,7 @@ public boolean equals(@Nullable Object obj) {
return Objects.equals(fFieldName, other.fFieldName) && Objects.equals(fLabel, other.fLabel);
}

/**
* Gets the type of this counter
*
* @return the type of this counter
* @since 2.1
*/
@Override
public CounterType getType() {
return fType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ public CounterAspect(String fieldName, String label, CounterType type, Class<? e
fGroups = Arrays.copyOf(groups, groups.length);
}

/**
* Get the groups
*
* @return the groups
*/
@Override
public Class<? extends ITmfEventAspect<?>>[] getGroups() {
return fGroups;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

package org.eclipse.tracecompass.analysis.counters.core.aspects;

import org.eclipse.tracecompass.analysis.counters.core.CounterType;
import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;

/**
Expand Down Expand Up @@ -52,4 +53,24 @@ default boolean isHiddenByDefault() {
default boolean isCumulative() {
return true;
}

/**
* Get the groups
*
* @return the groups
* @since 2.3
*/
default Class<? extends ITmfEventAspect<?>>[] getGroups() {
return new Class[0];
}

/**
PatrickTasse marked this conversation as resolved.
Show resolved Hide resolved
* Gets the type of this counter
*
* @return the groups
* @since 2.3
*/
default CounterType getType() {
return CounterType.LONG;
}
}
Loading