Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Chouinard2012-06-12 12:43:33 +0000
committerFrancois Chouinard2012-06-12 12:43:33 +0000
commit9a6edbb3e54e4a76afbb02529ba9385cf5c93d75 (patch)
treefb7e90b5adef8561789fbf7e319c43da4e5d54d7 /lttng/org.eclipse.linuxtools.tmf.core
parentbe02c14cd88cc427b741e006d7df7355b062fd24 (diff)
downloadorg.eclipse.linuxtools-9a6edbb3e54e4a76afbb02529ba9385cf5c93d75.tar.gz
org.eclipse.linuxtools-9a6edbb3e54e4a76afbb02529ba9385cf5c93d75.tar.xz
org.eclipse.linuxtools-9a6edbb3e54e4a76afbb02529ba9385cf5c93d75.zip
Revert "Fix for bug 381411: Implement ranked location in experiment."
Diffstat (limited to 'lttng/org.eclipse.linuxtools.tmf.core')
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfExperimentContext.java14
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfExperimentLocation.java6
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfLocationArray.java19
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfRankedLocation.java158
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java30
5 files changed, 34 insertions, 193 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfExperimentContext.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfExperimentContext.java
index 981e8c213d..dfe716fedd 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfExperimentContext.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfExperimentContext.java
@@ -15,6 +15,7 @@ package org.eclipse.linuxtools.internal.tmf.core.trace;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
/**
@@ -61,17 +62,20 @@ public class TmfExperimentContext extends TmfContext implements Cloneable {
super();
fContexts = contexts;
fEvents = new ITmfEvent[fContexts.length];
- final TmfRankedLocation[] locations = new TmfRankedLocation[fContexts.length];
+ final ITmfLocation<?>[] locations = new ITmfLocation[fContexts.length];
+ setLocation(new TmfExperimentLocation(new TmfLocationArray(locations.clone())));
+
+ final long[] ranks = new long[fContexts.length];
long rank = 0;
- for (int i = 0; i < fContexts.length; i++) {
+ for (int i = 0; i < fContexts.length; i++)
if (contexts[i] != null) {
- locations[i] = new TmfRankedLocation(contexts[i]);
+ locations[i] = contexts[i].getLocation();
+ ranks[i] = contexts[i].getRank();
rank += contexts[i].getRank();
}
- }
- setLocation(new TmfExperimentLocation(new TmfLocationArray(locations)));
+// setLocation(new TmfExperimentLocation(new TmfLocationArray(locations)));
setRank(rank);
fLastTraceRead = NO_TRACE;
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfExperimentLocation.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfExperimentLocation.java
index 0fae162287..22e4357a9b 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfExperimentLocation.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfExperimentLocation.java
@@ -13,6 +13,7 @@
package org.eclipse.linuxtools.internal.tmf.core.trace;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfLocation;
/**
@@ -63,6 +64,7 @@ public class TmfExperimentLocation extends TmfLocation<TmfLocationArray> impleme
*/
@Override
public TmfExperimentLocation clone() {
+// super.clone(); // To keep FindBugs happy
TmfLocationArray array = (TmfLocationArray) getLocation();
TmfLocationArray clones = array.clone();
return new TmfExperimentLocation(clones);
@@ -79,8 +81,8 @@ public class TmfExperimentLocation extends TmfLocation<TmfLocationArray> impleme
@SuppressWarnings("nls")
public String toString() {
StringBuilder result = new StringBuilder("[TmfExperimentLocation");
- TmfRankedLocation[] locations = ((TmfLocationArray) getLocation()).getLocations();
- for (TmfRankedLocation location : locations) {
+ ITmfLocation<? extends Comparable<?>>[] locations = ((TmfLocationArray) getLocation()).getLocations();
+ for (ITmfLocation<?> location : locations) {
result.append("[" + location + "]");
}
result.append("]");
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfLocationArray.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfLocationArray.java
index 8720caf6c0..06a324528a 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfLocationArray.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfLocationArray.java
@@ -15,6 +15,8 @@ package org.eclipse.linuxtools.internal.tmf.core.trace;
import java.util.Arrays;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+
/**
* A convenience class to store trace location arrays. The main purpose is to
* provide a Comparable implementation for TmfExperimentLocation.
@@ -28,7 +30,7 @@ public class TmfLocationArray implements Comparable<TmfLocationArray>, Cloneable
// Attributes
// ------------------------------------------------------------------------
- private TmfRankedLocation[] fLocations;
+ private ITmfLocation<? extends Comparable<?>>[] fLocations;
// ------------------------------------------------------------------------
// Constructors
@@ -39,7 +41,7 @@ public class TmfLocationArray implements Comparable<TmfLocationArray>, Cloneable
*
* @param locations the locations
*/
- public TmfLocationArray(TmfRankedLocation[] locations) {
+ public TmfLocationArray(ITmfLocation<? extends Comparable<?>>[] locations) {
fLocations = locations;
}
@@ -52,7 +54,7 @@ public class TmfLocationArray implements Comparable<TmfLocationArray>, Cloneable
*
* @param locations the locations
*/
- public TmfRankedLocation[] getLocations() {
+ public ITmfLocation<? extends Comparable<?>>[] getLocations() {
return fLocations;
}
@@ -65,9 +67,9 @@ public class TmfLocationArray implements Comparable<TmfLocationArray>, Cloneable
*/
@Override
public TmfLocationArray clone() {
- TmfRankedLocation[] clones = new TmfRankedLocation[fLocations.length];
+ ITmfLocation<? extends Comparable<?>>[] clones = (ITmfLocation<? extends Comparable<?>>[]) new ITmfLocation<?>[fLocations.length];
for (int i = 0; i < fLocations.length; i++) {
- TmfRankedLocation location = fLocations[i];
+ ITmfLocation<?> location = fLocations[i];
clones[i] = (location != null) ? location.clone() : null;
}
return new TmfLocationArray(clones);
@@ -78,11 +80,12 @@ public class TmfLocationArray implements Comparable<TmfLocationArray>, Cloneable
// ------------------------------------------------------------------------
@Override
+ @SuppressWarnings({ "unchecked", "rawtypes" })
public int compareTo(TmfLocationArray o) {
for (int i = 0; i < fLocations.length; i++) {
- TmfRankedLocation l1 = fLocations[i];
- TmfRankedLocation l2 = o.fLocations[i];
- int result = l1.compareTo(l2);
+ ITmfLocation<? extends Comparable> l1 = (ITmfLocation<? extends Comparable>) fLocations[i].getLocation();
+ ITmfLocation<? extends Comparable> l2 = (ITmfLocation<? extends Comparable>) o.fLocations[i].getLocation();
+ int result = l1.getLocation().compareTo(l2.getLocation());
if (result != 0) {
return result;
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfRankedLocation.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfRankedLocation.java
deleted file mode 100644
index c72da5efb7..0000000000
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/trace/TmfRankedLocation.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick Tasse - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.internal.tmf.core.trace;
-
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
-
-/**
- * A pair of trace location and trace rank.
- *
- * @version 1.0
- * @author Patrick Tasse
- */
-public class TmfRankedLocation implements Comparable<TmfRankedLocation>, Cloneable {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private ITmfLocation<? extends Comparable<?>> fLocation;
- private long fRank;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * The standard constructor
- *
- * @param context a trace context
- */
- public TmfRankedLocation(ITmfContext context) {
- fLocation = context.getLocation().clone();
- fRank = context.getRank();
- }
-
- /**
- * Private constructor
- *
- * @param location the trace location
- * @param rank the trace rank
- */
- private TmfRankedLocation(ITmfLocation<? extends Comparable<?>> location, long rank) {
- fLocation = location;
- fRank = rank;
- }
-
- // ------------------------------------------------------------------------
- // Getters
- // ------------------------------------------------------------------------
-
- /**
- * Get the trace location
- *
- * @return the trace location
- */
- public ITmfLocation<? extends Comparable<?>> getLocation() {
- return fLocation;
- }
-
- /**
- * Get the trace rank
- *
- * @return the trace rank
- */
- public long getRank() {
- return fRank;
- }
-
- // ------------------------------------------------------------------------
- // Cloneable
- // ------------------------------------------------------------------------
-
- /* (non-Javadoc)
- * @see java.lang.Object#clone()
- */
- @Override
- public TmfRankedLocation clone() {
- return new TmfRankedLocation(fLocation.clone(), fRank);
- }
-
- // ------------------------------------------------------------------------
- // Comparable
- // ------------------------------------------------------------------------
-
- /*
- * (non-Javadoc)
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- @Override
- public int compareTo(TmfRankedLocation o) {
- return Long.valueOf(fRank).compareTo(Long.valueOf(o.fRank));
- }
-
- // ------------------------------------------------------------------------
- // Object
- // ------------------------------------------------------------------------
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((fLocation == null) ? 0 : fLocation.hashCode());
- result = prime * result + (int) (fRank ^ (fRank >>> 32));
- return result;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- TmfRankedLocation other = (TmfRankedLocation) obj;
- if (fLocation == null) {
- if (other.fLocation != null) {
- return false;
- }
- } else if (!fLocation.equals(other.fLocation)) {
- return false;
- }
- if (fRank != other.fRank) {
- return false;
- }
- return true;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- @SuppressWarnings("nls")
- public String toString() {
- return fLocation + "," + fRank;
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java
index 0a065173c8..a5d0716f3a 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java
@@ -19,7 +19,6 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentContext;
import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentLocation;
import org.eclipse.linuxtools.internal.tmf.core.trace.TmfLocationArray;
-import org.eclipse.linuxtools.internal.tmf.core.trace.TmfRankedLocation;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
@@ -284,29 +283,24 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfTrace<T> implements I
// Instantiate the location
final TmfExperimentLocation expLocation = (location == null)
- ? new TmfExperimentLocation(new TmfLocationArray(new TmfRankedLocation[fTraces.length]))
+ ? new TmfExperimentLocation(new TmfLocationArray(new ITmfLocation<?>[fTraces.length]))
: (TmfExperimentLocation) location.clone();
// Create and populate the context's traces contexts
final TmfExperimentContext context = new TmfExperimentContext(new ITmfContext[fTraces.length]);
- long rank = 0;
for (int i = 0; i < fTraces.length; i++) {
// Get the relevant trace attributes
- final TmfRankedLocation rankedLocation = expLocation.getLocation().getLocations()[i];
- final ITmfLocation<?> traceLocation = (rankedLocation == null) ? null : rankedLocation.getLocation();
- final long traceRank = (rankedLocation == null) ? 0 : rankedLocation.getRank();
- context.getContexts()[i] = fTraces[i].seekEvent(traceLocation);
- context.getContexts()[i].setRank(traceRank);
- expLocation.getLocation().getLocations()[i] = new TmfRankedLocation(context.getContexts()[i]);
+ final ITmfLocation<?> trcLocation = expLocation.getLocation().getLocations()[i];
+ context.getContexts()[i] = fTraces[i].seekEvent(trcLocation);
+ expLocation.getLocation().getLocations()[i] = context.getContexts()[i].getLocation().clone();
context.getEvents()[i] = fTraces[i].getNext(context.getContexts()[i]);
- rank += traceRank;
}
// Finalize context
context.setLocation(expLocation);
context.setLastTrace(TmfExperimentContext.NO_TRACE);
- context.setRank(rank);
+ context.setRank(ITmfContext.UNKNOWN_RANK);
fExperimentContext = context;
return (ITmfContext) context;
@@ -331,11 +325,7 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfTrace<T> implements I
@Override
public double getLocationRatio(final ITmfLocation<?> location) {
if (location instanceof TmfExperimentLocation) {
- long rank = 0;
- for (TmfRankedLocation rankedLocation : ((TmfExperimentLocation) location).getLocation().getLocations()) {
- rank += rankedLocation.getRank();
- }
- return (double) rank / getNbEvents();
+ return (double) seekEvent(location).getRank() / getNbEvents();
}
return 0.0;
}
@@ -345,9 +335,9 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfTrace<T> implements I
*/
@Override
public ITmfLocation<?> getCurrentLocation() {
- TmfRankedLocation[] locations = new TmfRankedLocation[fTraces.length];
+ ITmfLocation<?>[] locations = new ITmfLocation<?>[fTraces.length];
for (int i = 0; i < fTraces.length; i++) {
- locations[i] = new TmfRankedLocation(new TmfContext(fTraces[i].getCurrentLocation(), ITmfContext.UNKNOWN_RANK));
+ locations[i] = fTraces[i].getCurrentLocation();
}
return new TmfExperimentLocation(new TmfLocationArray(locations));
}
@@ -414,9 +404,9 @@ public class TmfExperiment<T extends ITmfEvent> extends TmfTrace<T> implements I
updateAttributes(expContext, event.getTimestamp());
expContext.increaseRank();
expContext.setLastTrace(trace);
- final TmfExperimentLocation expLocation = (TmfExperimentLocation) expContext.getLocation();
+ final TmfExperimentLocation location = (TmfExperimentLocation) expContext.getLocation();
final ITmfContext traceContext = expContext.getContexts()[trace];
- expLocation.getLocation().getLocations()[trace] = new TmfRankedLocation(traceContext);
+ location.getLocation().getLocations()[trace] = traceContext.getLocation().clone();
fExperimentContext = expContext;
processEvent(event);
}

Back to the top