Added debug flags to improve debugging performance.
Change-Id: I165e643b92a63c36fcfea59a6ff2a50df5076b92
diff --git a/Changes b/Changes
index 42755eb..8a293e9 100644
--- a/Changes
+++ b/Changes
@@ -1,8 +1,9 @@
-0.58.3 2018-12-12
+0.58.3 2018-12-17
- [feature] Introduced attachements as meta data fields
(fixes #49) (diewald).
- [feature] Introduced preliminary support of arbitrary
metadata fields (see #47) (diewald)
+ - [performance] Added debug flags (margaretha)
0.58.2 2018-12-05
- [bugfix] Fixed the candidate list in NextSpans, see de.ids_mannheim.
diff --git a/src/main/java/de/ids_mannheim/korap/collection/CachedVCFilter.java b/src/main/java/de/ids_mannheim/korap/collection/CachedVCFilter.java
index 5b1bff7..de851c1 100644
--- a/src/main/java/de/ids_mannheim/korap/collection/CachedVCFilter.java
+++ b/src/main/java/de/ids_mannheim/korap/collection/CachedVCFilter.java
@@ -17,6 +17,8 @@
*/
public class CachedVCFilter extends Filter {
+ public static final boolean DEBUG = false;
+
public static Logger jlog = LogManager.getLogger(CachedVCFilter.class);
private CachedVCData cachedCollection;
@@ -34,7 +36,8 @@
cachedCollection.getDocIdMap().get(context.hashCode());
if (docBits == null) {
- jlog.debug("LeafReaderContext is not found in the cache.");
+ if (DEBUG)
+ jlog.debug("LeafReaderContext is not found in the cache.");
return null;
}
return docBits.createBitDocIdSet();
diff --git a/src/main/java/de/ids_mannheim/korap/collection/CollectionBuilder.java b/src/main/java/de/ids_mannheim/korap/collection/CollectionBuilder.java
index 10f4645..07a1598 100644
--- a/src/main/java/de/ids_mannheim/korap/collection/CollectionBuilder.java
+++ b/src/main/java/de/ids_mannheim/korap/collection/CollectionBuilder.java
@@ -289,7 +289,9 @@
Element element = KrillCollection.cache.get(this.reference);
if (element == null) {
- log.debug(reference + " is NOT found in the cache");
+ if (DEBUG) {
+ log.debug(reference + " is NOT found in the cache");
+ }
KrillCollection kc = new KrillCollection();
kc.fromStore(this.reference);
@@ -309,7 +311,9 @@
);
}
else {
- log.debug(reference + " is FOUND in the cache.");
+ if (DEBUG) {
+ log.debug(reference + " is FOUND in the cache.");
+ }
CachedVCData cc = (CachedVCData) element.getObjectValue();
return new CachedVCFilter(this.reference, cc);
}
diff --git a/src/main/java/de/ids_mannheim/korap/collection/ToCacheVCFilter.java b/src/main/java/de/ids_mannheim/korap/collection/ToCacheVCFilter.java
index 3a3675d..4e638ee 100644
--- a/src/main/java/de/ids_mannheim/korap/collection/ToCacheVCFilter.java
+++ b/src/main/java/de/ids_mannheim/korap/collection/ToCacheVCFilter.java
@@ -32,6 +32,7 @@
private boolean isAutoCachingEnabled = false;
public final static Logger log = LoggerFactory.getLogger(ToCacheVCFilter.class);
+ public static final boolean DEBUG = false;
public ToCacheVCFilter (String cacheKey, Map<Integer, DocBits> docIdMap,
Interface cbi, Filter filter) {
@@ -76,7 +77,9 @@
KrillCollection.cache.put(new Element(cacheKey, cachedVCData));
}
- log.debug("To cache doc bits length: "+ docIdSet.bits().length());
+ if (DEBUG){
+ log.debug("To cache doc bits length: "+ docIdSet.bits().length());
+ }
return docIdSet;
}
diff --git a/src/main/java/de/ids_mannheim/korap/index/Indexer.java b/src/main/java/de/ids_mannheim/korap/index/Indexer.java
index d17215f..0967860 100644
--- a/src/main/java/de/ids_mannheim/korap/index/Indexer.java
+++ b/src/main/java/de/ids_mannheim/korap/index/Indexer.java
@@ -1,9 +1,13 @@
package de.ids_mannheim.korap.index;
-import java.util.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.Paths;
+import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import java.io.*;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
@@ -15,13 +19,11 @@
import org.apache.commons.cli.ParseException;
import org.apache.commons.lang.StringUtils;
import org.apache.lucene.store.MMapDirectory;
-import de.ids_mannheim.korap.KrillIndex;
-import de.ids_mannheim.korap.util.KrillProperties;
-
-import static de.ids_mannheim.korap.util.KrillProperties.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.nio.file.Paths;
+
+import de.ids_mannheim.korap.KrillIndex;
+import de.ids_mannheim.korap.util.KrillProperties;
/**
* Standalone indexer tool for Krill.
@@ -59,6 +61,7 @@
// Init logger
private final static Logger log = LoggerFactory.getLogger(Indexer.class);
+ private static final boolean DEBUG = false;
/**
* Construct a new indexer object.
@@ -109,7 +112,9 @@
continue;
}
this.count++;
- log.debug("Finished adding files. (" + count + ").");
+ if (DEBUG){
+ log.debug("Finished adding files. (" + count + ").");
+ }
// Commit in case the commit count is reached
if ((this.count % this.commitCount) == 0)
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/FocusSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/FocusSpans.java
index 3e5fab0..b341c77 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/FocusSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/FocusSpans.java
@@ -17,7 +17,6 @@
import de.ids_mannheim.korap.constants.RelationDirection;
import de.ids_mannheim.korap.query.SpanFocusQuery;
-
/**
* originalSpans, that can focus on the span boundaries of classed
* subqueries.
@@ -58,7 +57,6 @@
private PriorityQueue<CandidateSpan> candidates;
private CandidateSpanComparator comparator;
-
/**
* Construct a FocusSpan for the given {@link SpanQuery}.
*
@@ -96,7 +94,6 @@
this.query = query;
}
-
@Override
public boolean next () throws IOException {
matchPayload.clear();
@@ -127,24 +124,25 @@
return false;
}
-
private void collectCandidates () throws IOException {
CandidateSpan cs = null;
CandidateSpan head = null;
-
+
while (hasMoreSpans && firstSpans.doc() == currentDoc) {
- if (head == null){
+ if (head == null) {
head = candidates.peek();
}
- else if (head.getStart() < firstSpans.start()){
+ else if (head.getStart() < firstSpans.start()) {
break;
}
-
+
if (firstSpans.isPayloadAvailable() && updateSpanPositions(
cs = new CandidateSpan(firstSpans))) {
if (cs.getDoc() == prevDoc && cs.getStart() < prevStart) {
- log.warn("Span (" + cs.getStart() + ", " + cs.getEnd()
- + ") is out of order and skipped.");
+ if (DEBUG) {
+ log.debug("Span (" + cs.getStart() + ", " + cs.getEnd()
+ + ") is out of order and skipped.");
+ }
}
else {
candidates.add(cs);
@@ -154,7 +152,6 @@
}
}
-
private void setMatch (CandidateSpan cs) {
matchStartPosition = cs.getStart();
prevStart = matchStartPosition;
@@ -187,8 +184,9 @@
// throw new
// IllegalArgumentException("Classnumber is not found.");
// }
- if (spanId > 0)
+ if (spanId > 0) {
hasSpanId = true;
+ }
}
else if (cs.getSpanId() > 0) {
setSpanId(cs.getSpanId());
@@ -197,7 +195,6 @@
}
-
private boolean updateSpanPositions (CandidateSpan candidateSpan)
throws IOException {
int minPos = 0, maxPos = 0;
@@ -207,7 +204,8 @@
candidateSpan.getPayloads().clear();
- // Iterate over all payloads and find the maximum span per class
+ // Iterate over all payloads and find the maximum span per
+ // class
for (byte[] payload : firstSpans.getPayload()) {
// No class payload - ignore
// this may be problematic for other calculated payloads!
@@ -241,7 +239,7 @@
continue;
};
- if (//payload.length == 8 ||
+ if (// payload.length == 8 ||
(removeTemporaryClasses && payload.length == 11)) {
continue;
}
@@ -257,7 +255,6 @@
return isClassFound;
}
-
// Todo: Check for this on document boundaries!
@Override
public boolean skipTo (int target) throws IOException {
@@ -278,14 +275,12 @@
return false;
};
-
@Override
public String toString () {
return getClass().getName() + "(" + this.query.toString() + ")@"
+ (doc() + ":" + start() + "-" + end());
};
-
@Override
public long cost () {
return firstSpans.cost();
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/RelationSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/RelationSpans.java
index b9926fd..8f9a807 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/RelationSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/RelationSpans.java
@@ -52,6 +52,7 @@
*/
public class RelationSpans extends RelationBaseSpans {
+ private static final boolean DEBUG = false;
private int currentDoc, currentPosition;
private RelationDirection direction;
private Spans relationTermSpan;
@@ -158,7 +159,9 @@
* @throws IOException
*/
private void setCandidateList () throws IOException {
- logger.debug("hasMoreSpans "+hasMoreSpans+" "+relationTermSpan.doc());
+ if (DEBUG){
+ logger.debug("hasMoreSpans "+hasMoreSpans+" "+relationTermSpan.doc());
+ }
while (hasMoreSpans && relationTermSpan.doc() == currentDoc
&& relationTermSpan.start() == currentPosition) {
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/SubSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/SubSpans.java
index 4989957..92048e8 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/SubSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/SubSpans.java
@@ -43,7 +43,6 @@
private PriorityQueue<CandidateSpan> candidates;
private CandidateSpanComparator comparator;
-
/**
* Constructs SubSpans for the given {@link SpanSubspanQuery}
* specifiying the start offset and the length of the subspans.
@@ -72,14 +71,12 @@
hasMoreSpans = firstSpans.next();
}
-
@Override
public boolean next () throws IOException {
isStartEnumeration = false;
return advance();
}
-
/**
* Advances the SubSpans to the next match.
*
@@ -111,7 +108,6 @@
return false;
}
-
private void collectCandidates () throws IOException {
while (hasMoreSpans && candidates.size() < windowSize
@@ -119,8 +115,11 @@
CandidateSpan cs;
if (findMatch(cs = new CandidateSpan(firstSpans))) {
if (cs.getDoc() == prevDoc && cs.getStart() < prevStart) {
- log.warn("Span (" + cs.getStart() + ", " + cs.getEnd()
- + ") is out of order and skipped.");
+ if (DEBUG) {
+ log.debug("Span (" + cs.getStart() + ", " + cs.getEnd()
+ + ") is out of order and skipped.");
+ }
+
}
else {
candidates.add(cs);
@@ -130,7 +129,6 @@
}
}
-
/**
* Sets the properties of the current match/subspan.
*
@@ -187,7 +185,6 @@
return true;
}
-
private void setMatch (CandidateSpan cs) {
matchStartPosition = cs.getStart();
prevStart = matchStartPosition;
@@ -198,7 +195,6 @@
matchPayload.addAll(cs.getPayloads());
}
-
@Override
public boolean skipTo (int target) throws IOException {
if (candidates.size() > 0) {
@@ -218,7 +214,6 @@
return advance();
}
-
@Override
public long cost () {
return firstSpans.cost() + 1;