Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernd Hufmann2014-07-21 16:36:45 +0000
committerBernd Hufmann2014-07-24 12:16:08 +0000
commit1d113245ffeb37b6181de74f52472a1c24474890 (patch)
treea842bd32483005f41965f4c832613dc7e099287c /lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf
parent2fc169e1f0e9b6352d36bbaa60da8aa684b98758 (diff)
downloadorg.eclipse.linuxtools-1d113245ffeb37b6181de74f52472a1c24474890.tar.gz
org.eclipse.linuxtools-1d113245ffeb37b6181de74f52472a1c24474890.tar.xz
org.eclipse.linuxtools-1d113245ffeb37b6181de74f52472a1c24474890.zip
tmf: update calculation of confidence level of text trace validation
With this patch text traces with patterns that have higher number of groups to match have higher confidence level. Change-Id: I631c2ad15630a79e989c95ced93e9ff0c8cc3ed0 Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com> Reviewed-on: https://git.eclipse.org/r/30281 Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Tested-by: Hudson CI
Diffstat (limited to 'lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf')
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomTxtTrace.java7
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/text/TextTrace.java8
2 files changed, 8 insertions, 7 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomTxtTrace.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomTxtTrace.java
index c7d462b1c3..5d45ce359b 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomTxtTrace.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomTxtTrace.java
@@ -416,17 +416,18 @@ public class CustomTxtTrace extends TmfTrace implements ITmfEventParser, ITmfPer
int confidence = 0;
try (BufferedRandomAccessFile rafile = new BufferedRandomAccessFile(path, "r")) { //$NON-NLS-1$
int lineCount = 0;
- int matches = 0;
+ double matches = 0.0;
String line = rafile.getNextLine();
while ((line != null) && (lineCount++ < MAX_LINES)) {
for (InputLine inputLine : fDefinition.inputs) {
Matcher matcher = inputLine.getPattern().matcher(line);
if (matcher.matches()) {
- matches++;
+ int groupCount = matcher.groupCount();
+ matches += (1.0 + groupCount / ((double) groupCount + 1));
break;
}
}
- confidence = MAX_CONFIDENCE * matches / lineCount;
+ confidence = (int) (MAX_CONFIDENCE * matches / lineCount);
line = rafile.getNextLine();
}
} catch (IOException e) {
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/text/TextTrace.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/text/TextTrace.java
index aa810e2bac..5c48b14cee 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/text/TextTrace.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/text/TextTrace.java
@@ -88,14 +88,15 @@ public abstract class TextTrace<T extends TextTraceEvent> extends TmfTrace imple
int confidence = 0;
try (BufferedRandomAccessFile rafile = new BufferedRandomAccessFile(path, "r")) { //$NON-NLS-1$
int lineCount = 0;
- int matches = 0;
+ double matches = 0.0;
String line = rafile.getNextLine();
while ((line != null) && (lineCount++ < MAX_LINES)) {
Matcher matcher = getFirstLinePattern().matcher(line);
if (matcher.matches()) {
- matches++;
+ int groupCount = matcher.groupCount();
+ matches += (1.0 + groupCount / ((double) groupCount + 1));
}
- confidence = MAX_CONFIDENCE * matches / lineCount;
+ confidence = (int) (MAX_CONFIDENCE * matches / lineCount);
line = rafile.getNextLine();
}
} catch (IOException e) {
@@ -106,7 +107,6 @@ public abstract class TextTrace<T extends TextTraceEvent> extends TmfTrace imple
return new TraceValidationStatus(confidence, Activator.PLUGIN_ID);
}
-
@Override
public void initTrace(IResource resource, String path, Class<? extends ITmfEvent> type) throws TmfTraceException {
super.initTrace(resource, path, type);

Back to the top