Skip to content

Commit f076600

Browse files
committed
CorrelationMetadataWrapper can be instantiated with given timestamp.
Don't classify distances that are Double.NaN.
1 parent 6ed585a commit f076600

File tree

4 files changed

+47
-23
lines changed

4 files changed

+47
-23
lines changed

.classpath

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<classpath>
3-
<classpathentry kind="src" output="target/classes" path="src">
4-
<attributes>
5-
<attribute name="optional" value="true"/>
6-
<attribute name="maven.pomderived" value="true"/>
7-
</attributes>
8-
</classpathentry>
9-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
10-
<attributes>
11-
<attribute name="maven.pomderived" value="true"/>
12-
</attributes>
13-
</classpathentry>
14-
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
15-
<attributes>
16-
<attribute name="maven.pomderived" value="true"/>
17-
</attributes>
18-
</classpathentry>
19-
<classpathentry kind="output" path="target/classes"/>
20-
</classpath>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
15+
<attributes>
16+
<attribute name="maven.pomderived" value="true"/>
17+
</attributes>
18+
</classpathentry>
19+
<classpathentry kind="output" path="target/classes"/>
20+
</classpath>

src/cz/cuni/mff/d3s/metaadaptation/correlation/CorrelationManager.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ public void monitor() {
164164
// ignore fields that are not specified as CorrelationMetadataWrapper instances
165165
if (o instanceof CorrelationMetadataWrapper) {
166166
addFieldToHistory(memberKnowledgeHistory, (CorrelationMetadataWrapper<?>) o);
167+
} else if(dumpValues){
168+
System.out.println(String.format(
169+
"Correlation manager is ignoring the field \"%s\" because it is not an instance of \"%s\"",
170+
knowlegeField, CorrelationMetadataWrapper.class.getName()));
167171
}
168172
}
169173
}
@@ -480,7 +484,9 @@ private List<DistancePair> computeDistances(
480484
labels.getSecondLabel(),
481485
knowledge.c1Value2.getValue(),
482486
knowledge.c2Value2.getValue());
483-
distancePairs.add(new DistancePair(distance, distanceClass, knowledge.c1Value1.getTimestamp()));
487+
if(!Double.isNaN(distance) && distanceClass != DistanceClass.Undefined) {
488+
distancePairs.add(new DistancePair(distance, distanceClass, knowledge.c1Value1.getTimestamp()));
489+
}
484490
}
485491
}
486492

src/cz/cuni/mff/d3s/metaadaptation/correlation/CorrelationMetadataWrapper.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,18 @@ public class CorrelationMetadataWrapper<T> implements Serializable{
4040
* @param value The knowledge field value to be wrapped.
4141
*/
4242
public CorrelationMetadataWrapper(T value, String name){
43+
this(value, name, 0);
44+
}
45+
46+
/**
47+
* Wrap the knowledge field value into the {@link CorrelationMetadataWrapper}.
48+
* The wrapper is created with the timestamp = 0 and operational = true.
49+
* @param value The knowledge field value to be wrapped.
50+
*/
51+
public CorrelationMetadataWrapper(T value, String name, long time){
4352
this.value = value;
4453
this.name = name;
45-
timestamp = 0;
54+
timestamp = time;
4655
operational = true;
4756
}
4857

@@ -94,5 +103,10 @@ public boolean isOperational(){
94103
public void malfunction(){
95104
operational = false;
96105
}
106+
107+
@Override
108+
public String toString() {
109+
return String.format("(%s:%s:%d:%s)", name, value, timestamp, operational ? "o" : "f");
110+
}
97111

98112
}

src/cz/cuni/mff/d3s/metaadaptation/correlation/KnowledgeMetadataHolder.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,12 @@ public static DistanceClass classifyDistance(String label, Object value1, Object
170170
if(containsLabel(label)){
171171
Metric metric = getMetric(label);
172172
double bound = getBound(label);
173+
double distance = metric.distance(value1, value2);
173174

174-
if(metric.distance(value1, value2) <= bound){
175+
if(Double.isNaN(distance)) {
176+
return DistanceClass.Undefined;
177+
}
178+
if(distance <= bound){
175179
return DistanceClass.Close;
176180
}
177181
else{

0 commit comments

Comments
 (0)