Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

replaced new Number(Number) with Number.instanceOf to remove deprecation warnings for Java 9

Michael Peter Christene9c5e78868d8
diff --git a/libbuild/J7Zip-modified/src/Common/IntVector.java b/libbuild/J7Zip-modified/src/Common/IntVector.java
index 8d69c88d6..c7d606bc6 100644
--- a/libbuild/J7Zip-modified/src/Common/IntVector.java
+++ b/libbuild/J7Zip-modified/src/Common/IntVector.java
@@ -117,7 +117,7 @@ public class IntVector {
int oldValue = data[index];
int numMoved = elt - index - 1;
- Integer n = new Integer(elt);
+ Integer n = Integer.valueOf(elt);
if (numMoved > 0)
System.arraycopy(n, index+1, n, index,numMoved);
elt = n.intValue();
diff --git a/libbuild/J7Zip-modified/src/Common/LongVector.java b/libbuild/J7Zip-modified/src/Common/LongVector.java
index cb2b29f1e..86ea31d0c 100644
--- a/libbuild/J7Zip-modified/src/Common/LongVector.java
+++ b/libbuild/J7Zip-modified/src/Common/LongVector.java
@@ -114,7 +114,7 @@ public class LongVector {
long oldValue = data[index];
int numMoved = elt - index - 1;
- Integer n = new Integer(elt);
+ Integer n = Integer.valueOf(elt);
if (numMoved > 0)
System.arraycopy(n, index+1, n, index,numMoved);
elt = n.intValue();
diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/ArchiveDB.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/ArchiveDB.java
index d01d841d0..db7e8eca2 100644
--- a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/ArchiveDB.java
+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/ArchiveDB.java
@@ -322,11 +322,11 @@ public class ArchiveDB {
Folder folder = (Folder)folders.get(i);
if (numSubstreams == 1 && folder.UnPackCRCDefined) {
bsizes.add(Boolean.TRUE);
- sizes.add(new Integer(folder.UnPackCRC));
+ sizes.add(Integer.valueOf(folder.UnPackCRC));
} else {
for (int j=0; j<numSubstreams; j++, digestIndex++) {
- bsizes.add(new Boolean(digestsDefined2.get(digestIndex)));
- sizes.add(new Integer(digests2.get(digestIndex)));
+ bsizes.add(Boolean.valueOf(digestsDefined2.get(digestIndex)));
+ sizes.add(Integer.valueOf(digests2.get(digestIndex)));
}
}
}
diff --git a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionWriter.java b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionWriter.java
index 3cdaeb31c..2df453581 100644
--- a/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionWriter.java
+++ b/libbuild/WebCat-swf/src/pt/tumba/parser/swf/ActionWriter.java
@@ -1406,7 +1406,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
*@exception IOException Description of the Exception
*/
public void push(float value) throws IOException {
- pushValues.add(new Float(value));
+ pushValues.add(Float.valueOf(value));
if (flashVersion < 5) {
flushPushValues();
}
diff --git a/source/net/yacy/cora/federate/solr/SolrType.java b/source/net/yacy/cora/federate/solr/SolrType.java
index 06b350dfc..1b844a903 100644
--- a/source/net/yacy/cora/federate/solr/SolrType.java
+++ b/source/net/yacy/cora/federate/solr/SolrType.java
@@ -29,11 +29,11 @@ public enum SolrType {
date("dt", "dts"), // date format as in http://www.w3.org/TR/xmlschema-2/#dateTime with trailing 'Z'
bool("b", "bs", "boolean"),
num_integer("i", "val", "int"),
- num_long("l", "ls", "long"),
- num_float("f", "fs", "float"),
+ num_long("l", "ls", "long"),
+ num_float("f", "fs", "float"),
num_double("d", "ds", "double"),
coordinate("coordinate", "coordinatex", "tdouble");
-
+
private String printName, singlevalExt, multivalExt;
private SolrType(final String singlevalExt, final String multivalExt) {
this.printName = this.name();
@@ -49,21 +49,21 @@ public enum SolrType {
return this.printName;
}
public boolean appropriateName(final SchemaDeclaration collectionSchema) {
- String field = collectionSchema.name();
- int p = field.indexOf('_');
+ final String field = collectionSchema.name();
+ final int p = field.indexOf('_');
if (p < 0 || field.length() - p > 4) return true; // special names may have no type extension
- String ext = field.substring(p + 1);
+ final String ext = field.substring(p + 1);
boolean ok = collectionSchema.isMultiValued() ? this.multivalExt.equals(ext) : this.singlevalExt.equals(ext);
- assert ok : "SolrType = " + this.name() + ", field = " + field + ", ext = " + ext + ", multivalue = " + new Boolean(collectionSchema.isMultiValued()).toString() + ", singlevalExt = " + this.singlevalExt + ", multivalExt = " + this.multivalExt;
+ assert ok : "SolrType = " + this.name() + ", field = " + field + ", ext = " + ext + ", multivalue = " + Boolean.toString(collectionSchema.isMultiValued()) + ", singlevalExt = " + this.singlevalExt + ", multivalExt = " + this.multivalExt;
if (!ok) return ok;
ok = !"s".equals(this.singlevalExt) || collectionSchema.isMultiValued() || field.endsWith("s");
- assert ok : "SolrType = " + this.name() + ", field = " + field + ", ext = " + ext + ", multivalue = " + new Boolean(collectionSchema.isMultiValued()).toString() + ", singlevalExt = " + this.singlevalExt + ", multivalExt = " + this.multivalExt;
+ assert ok : "SolrType = " + this.name() + ", field = " + field + ", ext = " + ext + ", multivalue = " + Boolean.toString(collectionSchema.isMultiValued()) + ", singlevalExt = " + this.singlevalExt + ", multivalExt = " + this.multivalExt;
if (!ok) return ok;
ok = !"sxt".equals(this.singlevalExt) || !collectionSchema.isMultiValued() || field.endsWith("sxt");
- assert ok : "SolrType = " + this.name() + ", field = " + field + ", ext = " + ext + ", multivalue = " + new Boolean(collectionSchema.isMultiValued()).toString() + ", singlevalExt = " + this.singlevalExt + ", multivalExt = " + this.multivalExt;
+ assert ok : "SolrType = " + this.name() + ", field = " + field + ", ext = " + ext + ", multivalue = " + Boolean.toString(collectionSchema.isMultiValued()) + ", singlevalExt = " + this.singlevalExt + ", multivalExt = " + this.multivalExt;
if (!ok) return ok;
ok = !"t".equals(this.singlevalExt) || collectionSchema.isMultiValued() || field.endsWith("t");
- assert ok : "SolrType = " + this.name() + ", field = " + field + ", ext = " + ext + ", multivalue = " + new Boolean(collectionSchema.isMultiValued()).toString() + ", singlevalExt = " + this.singlevalExt + ", multivalExt = " + this.multivalExt;
+ assert ok : "SolrType = " + this.name() + ", field = " + field + ", ext = " + ext + ", multivalue = " + Boolean.toString(collectionSchema.isMultiValued()) + ", singlevalExt = " + this.singlevalExt + ", multivalExt = " + this.multivalExt;
if (!ok) return ok;
return ok;
}
diff --git a/source/net/yacy/cora/sorting/Array.java b/source/net/yacy/cora/sorting/Array.java
index 0d6966b22..c71081fae 100644
--- a/source/net/yacy/cora/sorting/Array.java
+++ b/source/net/yacy/cora/sorting/Array.java
@@ -133,14 +133,14 @@ public class Array {
@Override
public Integer buffer() {
- return new Integer(0);
+ return Integer.valueOf(0);
}
@Override
public void swap(final int i, final int j, Integer buffer) {
- buffer = get(i);
- set(i, get(j));
- set(j, buffer);
+ buffer = this.get(i);
+ this.set(i, this.get(j));
+ this.set(j, buffer);
}
@Override
@@ -150,7 +150,7 @@ public class Array {
@Override
public Integer get(final int i, final boolean clone) {
- return get(i);
+ return this.get(i);
}
}
diff --git a/source/net/yacy/document/LargeNumberCache.java b/source/net/yacy/document/LargeNumberCache.java
index ccba8593c..9c908b237 100644
--- a/source/net/yacy/document/LargeNumberCache.java
+++ b/source/net/yacy/document/LargeNumberCache.java
@@ -7,12 +7,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public License
* along with this program in the file lgpl21.txt
* If not, see <http://www.gnu.org/licenses/>.
@@ -34,7 +34,7 @@ public class LargeNumberCache {
// fill the cache
static {
integerCache = new Integer[integerCacheLimit];
- for (int i = 0; i < integerCache.length; i++) integerCache[i] = new Integer(i);
+ for (int i = 0; i < integerCache.length; i++) integerCache[i] = Integer.valueOf(i);
}
/**
@@ -50,8 +50,8 @@ public class LargeNumberCache {
*/
public final static Integer valueOf(final int i) {
if (i < 0) return Integer.valueOf(i);
- if (i >= integerCacheLimit) return new Integer(i);
+ if (i >= integerCacheLimit) return Integer.valueOf(i);
return integerCache[i];
}
-
+
}
diff --git a/source/net/yacy/kelondro/blob/MapDataMining.java b/source/net/yacy/kelondro/blob/MapDataMining.java
index a05307a6b..afe85dc32 100644
--- a/source/net/yacy/kelondro/blob/MapDataMining.java
+++ b/source/net/yacy/kelondro/blob/MapDataMining.java
@@ -83,10 +83,10 @@ public class MapDataMining extends MapHeap {
ScoreMap<String>[] cluster = null;
if (sortfields == null) this.sortClusterMap = null; else {
- this.sortClusterMap = new ConcurrentHashMap<String, ScoreMap<String>>();
+ this.sortClusterMap = new ConcurrentHashMap<>();
cluster = (ScoreMap<String>[]) Array.newInstance(ScoreMap.class, sortfields.length);
for (int i = 0; i < sortfields.length; i++) {
- cluster[i] = new ConcurrentScoreMap<String>();
+ cluster[i] = new ConcurrentScoreMap<>();
}
}
@@ -95,7 +95,7 @@ public class MapDataMining extends MapHeap {
if (longaccfields == null) {
this.accLong = null;
} else {
- this.accLong = new ConcurrentHashMap<String, Long>();
+ this.accLong = new ConcurrentHashMap<>();
longaccumulator = new Long[longaccfields.length];
for (int i = 0; i < longaccfields.length; i++) {
longaccumulator[i] = LONG0;
@@ -104,7 +104,7 @@ public class MapDataMining extends MapHeap {
if (floataccfields == null) {
this.accFloat = null;
} else {
- this.accFloat = new ConcurrentHashMap<String, Float>();
+ this.accFloat = new ConcurrentHashMap<>();
floataccumulator = new Float[floataccfields.length];
for (int i = 0; i < floataccfields.length; i++) {
floataccumulator[i] = FLOAT0;
@@ -153,7 +153,7 @@ public class MapDataMining extends MapHeap {
valued = 0f;
if (cell != null) try {
valued = Float.parseFloat(cell);
- floataccumulator[i] = new Float(floataccumulator[i].floatValue() + valued);
+ floataccumulator[i] = Float.valueOf(floataccumulator[i].floatValue() + valued);
} catch (final NumberFormatException e) {}
}
}
@@ -178,7 +178,7 @@ public class MapDataMining extends MapHeap {
public synchronized void clear() {
super.clear();
if (this.sortfields == null) this.sortClusterMap = null; else {
- this.sortClusterMap = new HashMap<String, ScoreMap<String>>();
+ this.sortClusterMap = new HashMap<>();
for (final String sortfield : this.sortfields) {
this.sortClusterMap.put(sortfield, new ConcurrentScoreMap<String>());
}
@@ -187,7 +187,7 @@ public class MapDataMining extends MapHeap {
if (this.longaccfields == null) {
this.accLong = null;
} else {
- this.accLong = new HashMap<String, Long>();
+ this.accLong = new HashMap<>();
for (final String longaccfield : this.longaccfields) {
this.accLong.put(longaccfield, LONG0);
}
@@ -195,7 +195,7 @@ public class MapDataMining extends MapHeap {
if (this.floataccfields == null) {
this.accFloat = null;
} else {
- this.accFloat = new HashMap<String, Float>();
+ this.accFloat = new HashMap<>();
for (final String floataccfield : this.floataccfields) {
this.accFloat.put(floataccfield, FLOAT0);
}
@@ -215,17 +215,17 @@ public class MapDataMining extends MapHeap {
final Map<String, String> oldMap = super.get(key, false);
if (oldMap != null) {
// element exists, update acc
- updateAcc(oldMap, false);
+ this.updateAcc(oldMap, false);
}
// update accumulators with new values (add)
- updateAcc(newMap, true);
+ this.updateAcc(newMap, true);
}
super.insert(key, newMap);
// update sortCluster
- if (this.sortClusterMap != null) updateSortCluster(UTF8.String(key), newMap);
+ if (this.sortClusterMap != null) this.updateSortCluster(UTF8.String(key), newMap);
this.columnIndex.update(key, newMap);
}
@@ -295,10 +295,10 @@ public class MapDataMining extends MapHeap {
if (map != null) {
// update accumulators (subtract)
- if (this.longaccfields != null || this.floataccfields != null) updateAcc(map, false);
+ if (this.longaccfields != null || this.floataccfields != null) this.updateAcc(map, false);
// remove from sortCluster
- if (this.sortfields != null) deleteSortCluster(UTF8.String(key));
+ if (this.sortfields != null) this.deleteSortCluster(UTF8.String(key));
}
} catch (final SpaceExceededException e) {
map = null;
@@ -365,7 +365,7 @@ public class MapDataMining extends MapHeap {
try {
idx = this.columnIndex.getIndex(whereKey, isValue);
} catch (final UnsupportedOperationException e) {
- this.columnIndex.init(whereKey, isValue, new FullMapIterator(keys()));
+ this.columnIndex.init(whereKey, isValue, new FullMapIterator(this.keys()));
try {
idx = this.columnIndex.getIndex(whereKey, isValue);
} catch (final UnsupportedOperationException ee) {
@@ -376,7 +376,7 @@ public class MapDataMining extends MapHeap {
}
public synchronized Iterator<Map.Entry<byte[], Map<String, String>>> entries(final boolean up, final String field) {
- return new FullMapIterator(keys(up, field));
+ return new FullMapIterator(this.keys(up, field));
}
public synchronized long getLongAcc(final String field) {
@@ -412,7 +412,7 @@ public class MapDataMining extends MapHeap {
super.close();
}
-
+
private static final long minutemillis = 60000;
private static long date2000 = 0;
@@ -499,17 +499,17 @@ public class MapDataMining extends MapHeap {
public static void main(final String[] args) {
try {
- File f = new File("/tmp/MapDataMinig.test.db");
+ final File f = new File("/tmp/MapDataMinig.test.db");
f.delete();
final MapDataMining db = new MapDataMining(f, Word.commonHashLength, Base64Order.enhancedCoder, 1024 * 512, 500, new String[] {"X"}, new String[] {"X"}, new String[] {});
- final Map<String, String> m1 = new HashMap<String, String>();
- long t = System.currentTimeMillis();
+ final Map<String, String> m1 = new HashMap<>();
+ final long t = System.currentTimeMillis();
m1.put("X", Long.toString(t));
db.put("abcdefghijk1".getBytes(), m1);
- final Map<String, String> m2 = new HashMap<String, String>();
+ final Map<String, String> m2 = new HashMap<>();
m2.put("X", Long.toString(t - 1000));
db.put("abcdefghijk2".getBytes(), m2);
- final Map<String, String> m3 = new HashMap<String, String>();
+ final Map<String, String> m3 = new HashMap<>();
m3.put("X", Long.toString(t + 2000));
db.put("abcdefghijk3".getBytes(), m3);
diff --git a/source/net/yacy/kelondro/logging/LogParser.java b/source/net/yacy/kelondro/logging/LogParser.java
index f577f41dc..7ea052ff4 100644
--- a/source/net/yacy/kelondro/logging/LogParser.java
+++ b/source/net/yacy/kelondro/logging/LogParser.java
@@ -213,10 +213,10 @@ public final class LogParser {
private long DHTSendTraffic=0;
private int DHTSendURLs=0;
private int RWIRejectCount=0;
- private final Set<String> RWIRejectPeerNames = new HashSet<String>();
- private final Set<String> RWIRejectPeerHashs = new HashSet<String>();
- private final Set<String> DHTPeerNames = new HashSet<String>();
- private final Set<String> DHTPeerHashs = new HashSet<String>();
+ private final Set<String> RWIRejectPeerNames = new HashSet<>();
+ private final Set<String> RWIRejectPeerHashs = new HashSet<>();
+ private final Set<String> DHTPeerNames = new HashSet<>();
+ private final Set<String> DHTPeerHashs = new HashSet<>();
private int DHTSelectionTargetCount = 1;
private int DHTSelectionWordsCount = 0;
private int DHTSelectionWordsTimeCount = 0;
@@ -437,7 +437,7 @@ public final class LogParser {
}
public final Map<String, Object> getResults() {
- final Map<String, Object> results = new HashMap<String, Object>();
+ final Map<String, Object> results = new HashMap<>();
results.put(PARSER_VERSION , Float.valueOf(parserVersion));
results.put(URLS_RECEIVED , Integer.valueOf(this.urlSum));
results.put(URLS_REQUESTED , Integer.valueOf(this.urlReqSum));
@@ -473,10 +473,10 @@ public final class LogParser {
results.put(INDEXED_WORDS , Integer.valueOf(this.indexedWordSum));
results.put(INDEXED_SITES_SIZE , Integer.valueOf(this.indexedSiteSizeSum));
results.put(INDEXED_ANCHORS , Integer.valueOf(this.indexedAnchorsCount));
-// results.put(INDEXED_STACK_TIME , new Integer(indexedStackingTime));
-// results.put(INDEXED_PARSE_TIME , new Integer(indexedParsingTime));
-// results.put(INDEXED_INDEX_TIME , new Integer(indexedIndexingTime));
-// results.put(INDEXED_STORE_TIME , new Integer(indexedStorageTime));
+// results.put(INDEXED_STACK_TIME , Integer.valueOf(indexedStackingTime));
+// results.put(INDEXED_PARSE_TIME , Integer.valueOf(indexedParsingTime));
+// results.put(INDEXED_INDEX_TIME , Integer.valueOf(indexedIndexingTime));
+// results.put(INDEXED_STORE_TIME , Integer.valueOf(indexedStorageTime));
results.put(INDEXED_LINKSTORE_TIME , Integer.valueOf(this.indexedLinkStorageTime));
results.put(INDEXED_INDEXSTORE_TIME, Integer.valueOf(this.indexedIndexStorageTime));
results.put(TOTAL_PARSER_TIME , Long.valueOf(this.totalParserTime));
diff --git a/source/net/yacy/search/schema/CollectionConfiguration.java b/source/net/yacy/search/schema/CollectionConfiguration.java
index 4e2b6076a..6dca8d889 100644
--- a/source/net/yacy/search/schema/CollectionConfiguration.java
+++ b/source/net/yacy/search/schema/CollectionConfiguration.java
@@ -114,27 +114,27 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
public static boolean UNIQUE_HEURISTIC_PREFER_HTTPS = false;
public static boolean UNIQUE_HEURISTIC_PREFER_WWWPREFIX = true;
-
+
private final ArrayList<Ranking> rankings;
-
+
/**
* initialize the schema with a given configuration file
* the configuration file simply contains a list of lines with keywords
* or keyword = value lines (while value is a custom Solr field name
* @param configurationFile
- * @throws IOException
+ * @throws IOException
*/
public CollectionConfiguration(final File configurationFile, final boolean lazy) throws IOException {
super(configurationFile);
super.lazy = lazy;
- this.rankings = new ArrayList<Ranking>(4);
- for (int i = 0; i <= 3; i++) rankings.add(new Ranking());
+ this.rankings = new ArrayList<>(4);
+ for (int i = 0; i <= 3; i++) this.rankings.add(new Ranking());
// check consistency: compare with YaCyField enum
if (this.isEmpty()) return;
- Iterator<Entry> it = this.entryIterator();
+ final Iterator<Entry> it = this.entryIterator();
for (SchemaConfiguration.Entry etr = it.next(); it.hasNext(); etr = it.next()) {
try {
- CollectionSchema f = CollectionSchema.valueOf(etr.key());
+ final CollectionSchema f = CollectionSchema.valueOf(etr.key());
f.setSolrFieldName(etr.getValue());
} catch (final IllegalArgumentException e) {
ConcurrentLog.fine("SolrCollectionWriter", "solr schema file " + configurationFile.getAbsolutePath() + " defines unknown attribute '" + etr.toString() + "'");
@@ -142,7 +142,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
}
}
// check consistency the other way: look if all enum constants in SolrField appear in the configuration file
- for (CollectionSchema field: CollectionSchema.values()) {
+ for (final CollectionSchema field: CollectionSchema.values()) {
if (this.get(field.name()) == null) {
if (CollectionSchema.author_sxt.getSolrFieldName().endsWith(field.name())) continue; // exception for this: that is a copy-field
if (CollectionSchema.coordinate_p_0_coordinate.getSolrFieldName().endsWith(field.name())) continue; // exception for this: automatically generated
@@ -150,8 +150,8 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
ConcurrentLog.warn("SolrCollectionWriter", " solr schema file " + configurationFile.getAbsolutePath() + " is missing declaration for '" + field.name() + "'");
}
}
- checkMandatoryFields(); // Check minimum needed fields for proper operation are enabled
- checkFieldRelationConsistency();
+ this.checkMandatoryFields(); // Check minimum needed fields for proper operation are enabled
+ this.checkFieldRelationConsistency();
}
/**
@@ -184,13 +184,13 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
this.put(CollectionSchema.images_protocol_sxt.name(), e);
}
}
-
+
/**
* Check and update schema configuration with fields strictly needed for proper YaCy operation.
*/
private void checkMandatoryFields() {
SchemaConfiguration.Entry entry;
- for (CollectionSchema field: CollectionSchema.values()) {
+ for (final CollectionSchema field: CollectionSchema.values()) {
if(field.isMandatory()) {
entry = this.get(field.name());
if (entry != null) {
@@ -207,17 +207,17 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
}
public String[] allFields() {
- ArrayList<String> a = new ArrayList<>(this.size());
- for (CollectionSchema f: CollectionSchema.values()) {
+ final ArrayList<String> a = new ArrayList<>(this.size());
+ for (final CollectionSchema f: CollectionSchema.values()) {
if (this.contains(f)) a.add(f.getSolrFieldName());
}
return a.toArray(new String[a.size()]);
}
-
+
public Ranking getRanking(final int idx) {
return this.rankings.get(idx % this.rankings.size()); // simply prevent out of bound exeption (& callers don't check for null)
}
-
+
/**
* @param name The name of the ranking to get.
* @return The corresponding Ranking-object.
@@ -225,7 +225,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
public Ranking getRanking(final String name) {
if (name == null) return null;
for (int i = 0; i < this.rankings.size(); i++) {
- Ranking currentRanking = this.rankings.get(i);
+ final Ranking currentRanking = this.rankings.get(i);
if (name.equals(currentRanking.getName())) return currentRanking;
}
return null;
@@ -237,15 +237,15 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
*/
@Override
public void commit() throws IOException {
- checkMandatoryFields(); // Check minimum needed fields for proper operation are enabled
- checkFieldRelationConsistency(); // in case of changes, check related fields are enabled before save
+ this.checkMandatoryFields(); // Check minimum needed fields for proper operation are enabled
+ this.checkFieldRelationConsistency(); // in case of changes, check related fields are enabled before save
try {
super.commit();
// make sure the enum SolrField.SolrFieldName is current
- Iterator<Entry> it = this.entryIterator();
+ final Iterator<Entry> it = this.entryIterator();
for (SchemaConfiguration.Entry etr = it.next(); it.hasNext(); etr = it.next()) {
try {
- SchemaDeclaration f = CollectionSchema.valueOf(etr.key());
+ final SchemaDeclaration f = CollectionSchema.valueOf(etr.key());
f.setSolrFieldName(etr.getValue());
} catch (final IllegalArgumentException e) {
continue;
@@ -253,22 +253,22 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
}
} catch (final IOException e) {}
}
-
- private final static Set<String> omitFields = new HashSet<String>(3);
+
+ private final static Set<String> omitFields = new HashSet<>(3);
static {
omitFields.add(CollectionSchema.author_sxt.getSolrFieldName());
omitFields.add(CollectionSchema.coordinate_p_0_coordinate.getSolrFieldName());
omitFields.add(CollectionSchema.coordinate_p_1_coordinate.getSolrFieldName());
}
-
+
public SolrInputDocument toSolrInputDocument(final SolrDocument doc) {
- return toSolrInputDocument(doc, omitFields);
+ return this.toSolrInputDocument(doc, omitFields);
}
-
+
public SolrDocument toSolrDocument(final SolrInputDocument doc) {
- return toSolrDocument(doc, omitFields);
+ return this.toSolrDocument(doc, omitFields);
}
-
+
/**
* add uri attributes to solr document and assign the document id
* @param doc
@@ -277,54 +277,54 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
* @return the normalized url
*/
public String addURIAttributes(final SolrInputDocument doc, final boolean allAttr, final DigestURL digestURL) {
- add(doc, CollectionSchema.id, ASCII.String(digestURL.hash()));
- if (allAttr || contains(CollectionSchema.host_id_s)) add(doc, CollectionSchema.host_id_s, digestURL.hosthash());
- String us = digestURL.toNormalform(true);
- add(doc, CollectionSchema.sku, us);
- if (allAttr || contains(CollectionSchema.ip_s)) {
+ this.add(doc, CollectionSchema.id, ASCII.String(digestURL.hash()));
+ if (allAttr || this.contains(CollectionSchema.host_id_s)) this.add(doc, CollectionSchema.host_id_s, digestURL.hosthash());
+ final String us = digestURL.toNormalform(true);
+ this.add(doc, CollectionSchema.sku, us);
+ if (allAttr || this.contains(CollectionSchema.ip_s)) {
final InetAddress address = digestURL.getInetAddress();
- if (address != null) add(doc, CollectionSchema.ip_s, address.getHostAddress());
+ if (address != null) this.add(doc, CollectionSchema.ip_s, address.getHostAddress());
}
String host = null;
if ((host = digestURL.getHost()) != null) {
- String dnc = Domains.getDNC(host);
- String subdomOrga = host.length() - dnc.length() <= 0 ? "" : host.substring(0, host.length() - dnc.length() - 1);
- int p = subdomOrga.lastIndexOf('.');
- String subdom = (p < 0) ? "" : subdomOrga.substring(0, p);
- String orga = (p < 0) ? subdomOrga : subdomOrga.substring(p + 1);
- if (allAttr || contains(CollectionSchema.host_s)) add(doc, CollectionSchema.host_s, host);
- if (allAttr || contains(CollectionSchema.host_dnc_s)) add(doc, CollectionSchema.host_dnc_s, dnc);
- if (allAttr || contains(CollectionSchema.host_organization_s)) add(doc, CollectionSchema.host_organization_s, orga);
- if (allAttr || contains(CollectionSchema.host_organizationdnc_s)) add(doc, CollectionSchema.host_organizationdnc_s, orga + '.' + dnc);
- if (allAttr || contains(CollectionSchema.host_subdomain_s)) add(doc, CollectionSchema.host_subdomain_s, subdom);
- }
-
+ final String dnc = Domains.getDNC(host);
+ final String subdomOrga = host.length() - dnc.length() <= 0 ? "" : host.substring(0, host.length() - dnc.length() - 1);
+ final int p = subdomOrga.lastIndexOf('.');
+ final String subdom = (p < 0) ? "" : subdomOrga.substring(0, p);
+ final String orga = (p < 0) ? subdomOrga : subdomOrga.substring(p + 1);
+ if (allAttr || this.contains(CollectionSchema.host_s)) this.add(doc, CollectionSchema.host_s, host);
+ if (allAttr || this.contains(CollectionSchema.host_dnc_s)) this.add(doc, CollectionSchema.host_dnc_s, dnc);
+ if (allAttr || this.contains(CollectionSchema.host_organization_s)) this.add(doc, CollectionSchema.host_organization_s, orga);
+ if (allAttr || this.contains(CollectionSchema.host_organizationdnc_s)) this.add(doc, CollectionSchema.host_organizationdnc_s, orga + '.' + dnc);
+ if (allAttr || this.contains(CollectionSchema.host_subdomain_s)) this.add(doc, CollectionSchema.host_subdomain_s, subdom);
+ }
+
// path elements of link
- String filename = digestURL.getFileName();
+ final String filename = digestURL.getFileName();
String extension = MultiProtocolURL.getFileExtension(filename);
- String filenameStub = filename.toLowerCase(Locale.ROOT).endsWith("." + extension) ? filename.substring(0, filename.length() - extension.length() - 1) : filename;
- // remove possible jsession (or other url parm like "img.jpg;jsession=123")
+ final String filenameStub = filename.toLowerCase(Locale.ROOT).endsWith("." + extension) ? filename.substring(0, filename.length() - extension.length() - 1) : filename;
+ // remove possible jsession (or other url parm like "img.jpg;jsession=123")
// TODO: consider to implement ";jsession=123" check in getFileExtension()
if (extension.indexOf(';') >= 0) extension = extension.substring(0,extension.indexOf(';'));
-
- if (allAttr || contains(CollectionSchema.url_chars_i)) add(doc, CollectionSchema.url_chars_i, us.length());
- if (allAttr || contains(CollectionSchema.url_protocol_s)) add(doc, CollectionSchema.url_protocol_s, digestURL.getProtocol());
- if (allAttr || contains(CollectionSchema.url_paths_sxt) || contains(CollectionSchema.url_paths_count_i)) {
- String[] paths = digestURL.getPaths();
- if (allAttr || contains(CollectionSchema.url_paths_count_i)) add(doc, CollectionSchema.url_paths_count_i, paths.length);
- if (allAttr || contains(CollectionSchema.url_paths_sxt)) add(doc, CollectionSchema.url_paths_sxt, paths);
- }
- if (allAttr || contains(CollectionSchema.url_file_name_s)) add(doc, CollectionSchema.url_file_name_s, filenameStub);
- if (allAttr || contains(CollectionSchema.url_file_name_tokens_t)) add(doc, CollectionSchema.url_file_name_tokens_t, MultiProtocolURL.toTokens(filenameStub));
- if (allAttr || contains(CollectionSchema.url_file_ext_s)) add(doc, CollectionSchema.url_file_ext_s, extension);
-
- Map<String, String> searchpart = digestURL.getSearchpartMap();
+
+ if (allAttr || this.contains(CollectionSchema.url_chars_i)) this.add(doc, CollectionSchema.url_chars_i, us.length());
+ if (allAttr || this.contains(CollectionSchema.url_protocol_s)) this.add(doc, CollectionSchema.url_protocol_s, digestURL.getProtocol());
+ if (allAttr || this.contains(CollectionSchema.url_paths_sxt) || this.contains(CollectionSchema.url_paths_count_i)) {
+ final String[] paths = digestURL.getPaths();
+ if (allAttr || this.contains(CollectionSchema.url_paths_count_i)) this.add(doc, CollectionSchema.url_paths_count_i, paths.length);
+ if (allAttr || this.contains(CollectionSchema.url_paths_sxt)) this.add(doc, CollectionSchema.url_paths_sxt, paths);
+ }
+ if (allAttr || this.contains(CollectionSchema.url_file_name_s)) this.add(doc, CollectionSchema.url_file_name_s, filenameStub);
+ if (allAttr || this.contains(CollectionSchema.url_file_name_tokens_t)) this.add(doc, CollectionSchema.url_file_name_tokens_t, MultiProtocolURL.toTokens(filenameStub));
+ if (allAttr || this.contains(CollectionSchema.url_file_ext_s)) this.add(doc, CollectionSchema.url_file_ext_s, extension);
+
+ final Map<String, String> searchpart = digestURL.getSearchpartMap();
if (searchpart == null) {
- if (allAttr || contains(CollectionSchema.url_parameter_i)) add(doc, CollectionSchema.url_parameter_i, 0);
+ if (allAttr || this.contains(CollectionSchema.url_parameter_i)) this.add(doc, CollectionSchema.url_parameter_i, 0);
} else {
- if (allAttr || contains(CollectionSchema.url_parameter_i)) add(doc, CollectionSchema.url_parameter_i, searchpart.size());
- if (allAttr || contains(CollectionSchema.url_parameter_key_sxt)) add(doc, CollectionSchema.url_parameter_key_sxt, searchpart.keySet().toArray(new String[searchpart.size()]));
- if (allAttr || contains(CollectionSchema.url_parameter_value_sxt)) add(doc, CollectionSchema.url_parameter_value_sxt, searchpart.values().toArray(new String[searchpart.size()]));
+ if (allAttr || this.contains(CollectionSchema.url_parameter_i)) this.add(doc, CollectionSchema.url_parameter_i, searchpart.size());
+ if (allAttr || this.contains(CollectionSchema.url_parameter_key_sxt)) this.add(doc, CollectionSchema.url_parameter_key_sxt, searchpart.keySet().toArray(new String[searchpart.size()]));
+ if (allAttr || this.contains(CollectionSchema.url_parameter_value_sxt)) this.add(doc, CollectionSchema.url_parameter_value_sxt, searchpart.values().toArray(new String[searchpart.size()]));
}
return us;
}
@@ -338,67 +338,67 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
*/
public SolrInputDocument metadata2solr(final URIMetadataNode md) {
- SolrInputDocument doc = toSolrInputDocument(md); //urimetadatanode stores some values in private fields, add now to sorldocument
+ final SolrInputDocument doc = this.toSolrInputDocument(md); //urimetadatanode stores some values in private fields, add now to sorldocument
- boolean allAttr = this.isEmpty();
- addURIAttributes(doc, allAttr, md.url()); // assign doc.id, doc.sku and url attribute fields
+ final boolean allAttr = this.isEmpty();
+ this.addURIAttributes(doc, allAttr, md.url()); // assign doc.id, doc.sku and url attribute fields
- String title = md.dc_title();
- if (allAttr || contains(CollectionSchema.title_count_i)) add(doc, CollectionSchema.title_count_i, 1);
- if (allAttr || contains(CollectionSchema.title_chars_val)) {
- Integer[] cv = new Integer[]{new Integer(title.length())};
- add(doc, CollectionSchema.title_chars_val, cv);
+ final String title = md.dc_title();
+ if (allAttr || this.contains(CollectionSchema.title_count_i)) this.add(doc, CollectionSchema.title_count_i, 1);
+ if (allAttr || this.contains(CollectionSchema.title_chars_val)) {
+ final Integer[] cv = new Integer[]{Integer.valueOf(title.length())};
+ this.add(doc, CollectionSchema.title_chars_val, cv);
}
- if (allAttr || contains(CollectionSchema.title_words_val)) {
- Integer[] cv = new Integer[]{new Integer(CommonPattern.SPACES.split(title).length)};
- add(doc, CollectionSchema.title_words_val, cv);
+ if (allAttr || this.contains(CollectionSchema.title_words_val)) {
+ final Integer[] cv = new Integer[]{Integer.valueOf(CommonPattern.SPACES.split(title).length)};
+ this.add(doc, CollectionSchema.title_words_val, cv);
}
String description = md.snippet();
- boolean description_exist = description != null;
+ final boolean description_exist = description != null;
if (description == null) description = "";
- if (allAttr || contains(CollectionSchema.description_txt)) add(doc, CollectionSchema.description_txt, description_exist ? new String[]{description} : new String[0]);
- if (allAttr || contains(CollectionSchema.description_count_i)) add(doc, CollectionSchema.description_count_i, description_exist ? 1 : 0);
- if (allAttr || contains(CollectionSchema.description_chars_val)) {
- add(doc, CollectionSchema.description_chars_val, description_exist ? new Integer[]{new Integer(description.length())} : new Integer[0]);
+ if (allAttr || this.contains(CollectionSchema.description_txt)) this.add(doc, CollectionSchema.description_txt, description_exist ? new String[]{description} : new String[0]);
+ if (allAttr || this.contains(CollectionSchema.description_count_i)) this.add(doc, CollectionSchema.description_count_i, description_exist ? 1 : 0);
+ if (allAttr || this.contains(CollectionSchema.description_chars_val)) {
+ this.add(doc, CollectionSchema.description_chars_val, description_exist ? new Integer[]{Integer.valueOf(description.length())} : new Integer[0]);
}
- if (allAttr || contains(CollectionSchema.description_words_val)) {
- add(doc, CollectionSchema.description_words_val, description_exist ? new Integer[]{new Integer(description.length() == 0 ? 0 : CommonPattern.SPACES.split(description).length)} : new Integer[0]);
+ if (allAttr || this.contains(CollectionSchema.description_words_val)) {
+ this.add(doc, CollectionSchema.description_words_val, description_exist ? new Integer[]{Integer.valueOf(description.length() == 0 ? 0 : CommonPattern.SPACES.split(description).length)} : new Integer[0]);
}
String keywords = md.dc_subject();
- Bitfield flags = md.flags();
+ final Bitfield flags = md.flags();
if (flags.get(Tokenizer.flag_cat_indexof)) {
if (keywords == null || keywords.isEmpty()) keywords = "indexof"; else {
if (keywords.indexOf(',') > 0) keywords += ", indexof"; else keywords += " indexof";
}
}
- if (allAttr || contains(CollectionSchema.keywords)) {
- add(doc, CollectionSchema.keywords, keywords);
+ if (allAttr || this.contains(CollectionSchema.keywords)) {
+ this.add(doc, CollectionSchema.keywords, keywords);
}
/* Metadata node may contain one favicon url when transmitted as dht chunk */
- processIcons(doc, allAttr, md.getIcons());
- if (allAttr || contains(CollectionSchema.imagescount_i)) add(doc, CollectionSchema.imagescount_i, md.limage());
- if (allAttr || contains(CollectionSchema.linkscount_i)) add(doc, CollectionSchema.linkscount_i, md.llocal() + md.lother());
- if (allAttr || contains(CollectionSchema.inboundlinkscount_i)) add(doc, CollectionSchema.inboundlinkscount_i, md.llocal());
- if (allAttr || contains(CollectionSchema.outboundlinkscount_i)) add(doc, CollectionSchema.outboundlinkscount_i, md.lother());
- if (allAttr || contains(CollectionSchema.charset_s)) add(doc, CollectionSchema.charset_s, StandardCharsets.UTF_8.name());
+ this.processIcons(doc, allAttr, md.getIcons());
+ if (allAttr || this.contains(CollectionSchema.imagescount_i)) this.add(doc, CollectionSchema.imagescount_i, md.limage());
+ if (allAttr || this.contains(CollectionSchema.linkscount_i)) this.add(doc, CollectionSchema.linkscount_i, md.llocal() + md.lother());
+ if (allAttr || this.contains(CollectionSchema.inboundlinkscount_i)) this.add(doc, CollectionSchema.inboundlinkscount_i, md.llocal());
+ if (allAttr || this.contains(CollectionSchema.outboundlinkscount_i)) this.add(doc, CollectionSchema.outboundlinkscount_i, md.lother());
+ if (allAttr || this.contains(CollectionSchema.charset_s)) this.add(doc, CollectionSchema.charset_s, StandardCharsets.UTF_8.name());
// coordinates
if (md.lat() != 0.0 && md.lon() != 0.0) {
// i.e. from <meta name="geo.position" content="50.78;11.52" /> or <meta name="ICBM" content="52.50695, 13.328348">
- if (allAttr || contains(CollectionSchema.coordinate_p)) {
- add(doc, CollectionSchema.coordinate_p, Double.toString(md.lat()) + "," + Double.toString(md.lon()));
+ if (allAttr || this.contains(CollectionSchema.coordinate_p)) {
+ this.add(doc, CollectionSchema.coordinate_p, Double.toString(md.lat()) + "," + Double.toString(md.lon()));
}
}
- if (allAttr || contains(CollectionSchema.httpstatus_i)) add(doc, CollectionSchema.httpstatus_i, 200);
- if (allAttr || contains(CollectionSchema.publisher_t)) add(doc, CollectionSchema.publisher_t, md.dc_publisher());
+ if (allAttr || this.contains(CollectionSchema.httpstatus_i)) this.add(doc, CollectionSchema.httpstatus_i, 200);
+ if (allAttr || this.contains(CollectionSchema.publisher_t)) this.add(doc, CollectionSchema.publisher_t, md.dc_publisher());
// fields that are in URIMetadataRow additional to yacy2solr basic requirement
- if (allAttr || contains(CollectionSchema.audiolinkscount_i)) add(doc, CollectionSchema.audiolinkscount_i, md.laudio());
- if (allAttr || contains(CollectionSchema.videolinkscount_i)) add(doc, CollectionSchema.videolinkscount_i, md.lvideo());
- if (allAttr || contains(CollectionSchema.applinkscount_i)) add(doc, CollectionSchema.applinkscount_i, md.lapp());
+ if (allAttr || this.contains(CollectionSchema.audiolinkscount_i)) this.add(doc, CollectionSchema.audiolinkscount_i, md.laudio());
+ if (allAttr || this.contains(CollectionSchema.videolinkscount_i)) this.add(doc, CollectionSchema.videolinkscount_i, md.lvideo());
+ if (allAttr || this.contains(CollectionSchema.applinkscount_i)) this.add(doc, CollectionSchema.applinkscount_i, md.lapp());
return doc;
}
@@ -408,34 +408,34 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
@SuppressWarnings("unchecked")
public Subgraph(int inboundSize, int outboundSize) {
this.urlProtocols = (ArrayList<String>[]) Array.newInstance(ArrayList.class, 2);
- this.urlProtocols[0] = new ArrayList<String>(inboundSize);
- this.urlProtocols[1] = new ArrayList<String>(outboundSize);
+ this.urlProtocols[0] = new ArrayList<>(inboundSize);
+ this.urlProtocols[1] = new ArrayList<>(outboundSize);
this.urlStubs = (ArrayList<String>[]) Array.newInstance(ArrayList.class, 2);
- this.urlStubs[0] = new ArrayList<String>(inboundSize);
- this.urlStubs[1] = new ArrayList<String>(outboundSize);
+ this.urlStubs[0] = new ArrayList<>(inboundSize);
+ this.urlStubs[1] = new ArrayList<>(outboundSize);
this.urlAnchorTexts = (ArrayList<String>[]) Array.newInstance(ArrayList.class, 2);
- this.urlAnchorTexts[0] = new ArrayList<String>(inboundSize);
- this.urlAnchorTexts[1] = new ArrayList<String>(outboundSize);
+ this.urlAnchorTexts[0] = new ArrayList<>(inboundSize);
+ this.urlAnchorTexts[1] = new ArrayList<>(outboundSize);
}
}
-
+
public static boolean enrichSubgraph(final Subgraph subgraph, final DigestURL source_url, AnchorURL target_url) {
final String text = target_url.getTextProperty(); // the text between the <a></a> tag
- String source_host = source_url.getHost();
- String target_host = target_url.getHost();
- boolean inbound =
- (source_host == null && target_host == null) ||
+ final String source_host = source_url.getHost();
+ final String target_host = target_url.getHost();
+ final boolean inbound =
+ (source_host == null && target_host == null) ||
(source_host != null && target_host != null &&
(target_host.equals(source_host) ||
target_host.equals("www." + source_host) ||
source_host.equals("www." + target_host))); // well, not everybody defines 'outbound' that way but however, thats used here.
- int ioidx = inbound ? 0 : 1;
+ final int ioidx = inbound ? 0 : 1;
subgraph.urlProtocols[ioidx].add(target_url.getProtocol());
subgraph.urlStubs[ioidx].add(target_url.urlstub(true, true));
subgraph.urlAnchorTexts[ioidx].add(text);
return inbound;
}
-
+
/**
* a SolrVector is a SolrInputDocument with the ability
* to store also the webgraph that is associated with
@@ -443,10 +443,10 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
*/
public static class SolrVector extends SolrInputDocument {
private static final long serialVersionUID = -210901881471714939L;
- private List<SolrInputDocument> webgraphDocuments;
+ private final List<SolrInputDocument> webgraphDocuments;
public SolrVector() {
super();
- this.webgraphDocuments = new ArrayList<SolrInputDocument>();
+ this.webgraphDocuments = new ArrayList<>();
}
public void addWebgraphDocument(SolrInputDocument webgraphDocument) {
this.webgraphDocuments.add(webgraphDocument);
@@ -455,87 +455,87 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
return this.webgraphDocuments;
}
}
-
+
public SolrVector yacy2solr(
final Segment segment,
final Map<String, Pattern> collections, final ResponseHeader responseHeader,
final Document document, final Condenser condenser, final DigestURL referrerURL, final String language, final boolean setUnique,
final WebgraphConfiguration webgraph, final String sourceName) {
// we use the SolrCell design as index schema
- SolrVector doc = new SolrVector();
+ final SolrVector doc = new SolrVector();
final DigestURL digestURL = document.dc_source();
- boolean allAttr = this.isEmpty();
- String url = addURIAttributes(doc, allAttr, digestURL);
- add(doc, CollectionSchema.content_type, new String[]{document.dc_format()}); // content_type (mime) is defined a schema field and we rely on it in some queries like imagequery (makes it mandatory, no need to check)
-
- Set<ProcessType> processTypes = new LinkedHashSet<ProcessType>();
- String host = digestURL.getHost();
-
- int crawldepth = document.getDepth();
- if ((allAttr || contains(CollectionSchema.crawldepth_i))) {
+ final boolean allAttr = this.isEmpty();
+ final String url = this.addURIAttributes(doc, allAttr, digestURL);
+ this.add(doc, CollectionSchema.content_type, new String[]{document.dc_format()}); // content_type (mime) is defined a schema field and we rely on it in some queries like imagequery (makes it mandatory, no need to check)
+
+ final Set<ProcessType> processTypes = new LinkedHashSet<>();
+ final String host = digestURL.getHost();
+
+ final int crawldepth = document.getDepth();
+ if ((allAttr || this.contains(CollectionSchema.crawldepth_i))) {
CollectionSchema.crawldepth_i.add(doc, crawldepth);
}
-
- if (allAttr || (contains(CollectionSchema.cr_host_chance_d) && contains(CollectionSchema.cr_host_count_i) && contains(CollectionSchema.cr_host_norm_i))) {
+
+ if (allAttr || (this.contains(CollectionSchema.cr_host_chance_d) && this.contains(CollectionSchema.cr_host_count_i) && this.contains(CollectionSchema.cr_host_norm_i))) {
processTypes.add(ProcessType.CITATION); // postprocessing needed
}
-
- if (allAttr || contains(CollectionSchema.collection_sxt) && collections != null && collections.size() > 0) {
- List<String> cs = new ArrayList<String>();
- for (Map.Entry<String, Pattern> e: collections.entrySet()) {
+
+ if (allAttr || this.contains(CollectionSchema.collection_sxt) && collections != null && collections.size() > 0) {
+ final List<String> cs = new ArrayList<>();
+ for (final Map.Entry<String, Pattern> e: collections.entrySet()) {
if (e.getValue().matcher(url).matches()) cs.add(e.getKey());
}
- add(doc, CollectionSchema.collection_sxt, cs);
+ this.add(doc, CollectionSchema.collection_sxt, cs);
}
- List<String> titles = document.titles();
- if (allAttr || contains(CollectionSchema.title)) {
- add(doc, CollectionSchema.title, titles);
- if ((allAttr || contains(CollectionSchema.title_exact_signature_l)) && titles.size() > 0) {
- add(doc, CollectionSchema.title_exact_signature_l, EnhancedTextProfileSignature.getSignatureLong(titles.get(0)));
+ final List<String> titles = document.titles();
+ if (allAttr || this.contains(CollectionSchema.title)) {
+ this.add(doc, CollectionSchema.title, titles);
+ if ((allAttr || this.contains(CollectionSchema.title_exact_signature_l)) && titles.size() > 0) {
+ this.add(doc, CollectionSchema.title_exact_signature_l, EnhancedTextProfileSignature.getSignatureLong(titles.get(0)));
}
-
+
}
- if (allAttr || contains(CollectionSchema.title_count_i)) add(doc, CollectionSchema.title_count_i, titles.size());
- if (allAttr || contains(CollectionSchema.title_chars_val)) {
- ArrayList<Integer> cv = new ArrayList<Integer>(titles.size());
- for (String s: titles) cv.add(new Integer(s.length()));
- add(doc, CollectionSchema.title_chars_val, cv);
+ if (allAttr || this.contains(CollectionSchema.title_count_i)) this.add(doc, CollectionSchema.title_count_i, titles.size());
+ if (allAttr || this.contains(CollectionSchema.title_chars_val)) {
+ final ArrayList<Integer> cv = new ArrayList<>(titles.size());
+ for (final String s: titles) cv.add(Integer.valueOf(s.length()));
+ this.add(doc, CollectionSchema.title_chars_val, cv);
}
- if (allAttr || contains(CollectionSchema.title_words_val)) {
- ArrayList<Integer> cv = new ArrayList<Integer>(titles.size());
- for (String s: titles) cv.add(new Integer(CommonPattern.SPACES.split(s).length));
- add(doc, CollectionSchema.title_words_val, cv);
+ if (allAttr || this.contains(CollectionSchema.title_words_val)) {
+ final ArrayList<Integer> cv = new ArrayList<>(titles.size());
+ for (final String s: titles) cv.add(Integer.valueOf(CommonPattern.SPACES.split(s).length));
+ this.add(doc, CollectionSchema.title_words_val, cv);
}
- String[] descriptions = document.dc_description();
- if (allAttr || contains(CollectionSchema.description_txt)) {
- add(doc, CollectionSchema.description_txt, descriptions);
- if ((allAttr || contains(CollectionSchema.description_exact_signature_l)) && descriptions != null && descriptions.length > 0) {
- add(doc, CollectionSchema.description_exact_signature_l, EnhancedTextProfileSignature.getSignatureLong(descriptions));
+ final String[] descriptions = document.dc_description();
+ if (allAttr || this.contains(CollectionSchema.description_txt)) {
+ this.add(doc, CollectionSchema.description_txt, descriptions);
+ if ((allAttr || this.contains(CollectionSchema.description_exact_signature_l)) && descriptions != null && descriptions.length > 0) {
+ this.add(doc, CollectionSchema.description_exact_signature_l, EnhancedTextProfileSignature.getSignatureLong(descriptions));
}
}
- if (allAttr || contains(CollectionSchema.description_count_i)) add(doc, CollectionSchema.description_count_i, descriptions.length);
- if (allAttr || contains(CollectionSchema.description_chars_val)) {
- ArrayList<Integer> cv = new ArrayList<Integer>(descriptions.length);
- for (String s: descriptions) cv.add(new Integer(s.length()));
- add(doc, CollectionSchema.description_chars_val, cv);
+ if (allAttr || this.contains(CollectionSchema.description_count_i)) this.add(doc, CollectionSchema.description_count_i, descriptions.length);
+ if (allAttr || this.contains(CollectionSchema.description_chars_val)) {
+ final ArrayList<Integer> cv = new ArrayList<>(descriptions.length);
+ for (final String s: descriptions) cv.add(Integer.valueOf(s.length()));
+ this.add(doc, CollectionSchema.description_chars_val, cv);
}
- if (allAttr || contains(CollectionSchema.description_words_val)) {
- ArrayList<Integer> cv = new ArrayList<Integer>(descriptions.length);
- for (String s: descriptions) cv.add(new Integer(CommonPattern.SPACES.split(s).length));
- add(doc, CollectionSchema.description_words_val, cv);
+ if (allAttr || this.contains(CollectionSchema.description_words_val)) {
+ final ArrayList<Integer> cv = new ArrayList<>(descriptions.length);
+ for (final String s: descriptions) cv.add(Integer.valueOf(CommonPattern.SPACES.split(s).length));
+ this.add(doc, CollectionSchema.description_words_val, cv);
}
- if (allAttr || contains(CollectionSchema.author)) {
+ if (allAttr || this.contains(CollectionSchema.author)) {
String author = document.dc_creator();
if (author == null || author.length() == 0) author = document.dc_publisher();
- add(doc, CollectionSchema.author, author);
+ this.add(doc, CollectionSchema.author, author);
}
- if (allAttr || contains(CollectionSchema.last_modified)) {
+ if (allAttr || this.contains(CollectionSchema.last_modified)) {
Date lastModified = responseHeader == null ? document.getLastModified() : responseHeader.lastModified();
if (lastModified == null) {
- long firstSeen = segment.getFirstSeenTime(digestURL.hash());
+ final long firstSeen = segment.getFirstSeenTime(digestURL.hash());
if (firstSeen > 0) {
lastModified = new Date(firstSeen); // patch the date if we have seen the document earlier
} else {
@@ -545,76 +545,76 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
if (document.getLastModified().before(lastModified)) {
lastModified = document.getLastModified();
}
- add(doc, CollectionSchema.last_modified, lastModified);
+ this.add(doc, CollectionSchema.last_modified, lastModified);
}
- if (allAttr || contains(CollectionSchema.dates_in_content_dts) || contains(CollectionSchema.dates_in_content_count_i)) {
- LinkedHashSet<Date> dates_in_content = condenser.dates_in_content;
- if (allAttr || contains(CollectionSchema.dates_in_content_count_i)) {
- add(doc, CollectionSchema.dates_in_content_count_i, dates_in_content.size());
+ if (allAttr || this.contains(CollectionSchema.dates_in_content_dts) || this.contains(CollectionSchema.dates_in_content_count_i)) {
+ final LinkedHashSet<Date> dates_in_content = condenser.dates_in_content;
+ if (allAttr || this.contains(CollectionSchema.dates_in_content_count_i)) {
+ this.add(doc, CollectionSchema.dates_in_content_count_i, dates_in_content.size());
}
- if (dates_in_content.size() > 0 && (allAttr || contains(CollectionSchema.dates_in_content_dts))) {
- add(doc, CollectionSchema.dates_in_content_dts, dates_in_content.toArray(new Date[dates_in_content.size()]));
+ if (dates_in_content.size() > 0 && (allAttr || this.contains(CollectionSchema.dates_in_content_dts))) {
+ this.add(doc, CollectionSchema.dates_in_content_dts, dates_in_content.toArray(new Date[dates_in_content.size()]));
}
}
- if (allAttr || contains(CollectionSchema.keywords)) {
- String keywords = document.dc_subject(' ');
- add(doc, CollectionSchema.keywords, keywords);
+ if (allAttr || this.contains(CollectionSchema.keywords)) {
+ final String keywords = document.dc_subject(' ');
+ this.add(doc, CollectionSchema.keywords, keywords);
}
// unique-fields; these values must be corrected during postprocessing. (the following logic is !^ (not-xor) but I prefer to write it that way as it is)
- add(doc, CollectionSchema.http_unique_b, setUnique || UNIQUE_HEURISTIC_PREFER_HTTPS ? digestURL.isHTTPS() : digestURL.isHTTP()); // this must be corrected afterwards during storage!
- add(doc, CollectionSchema.www_unique_b, setUnique || host != null && (UNIQUE_HEURISTIC_PREFER_WWWPREFIX ? host.startsWith("www.") : !host.startsWith("www."))); // this must be corrected afterwards during storage!
-
- add(doc, CollectionSchema.exact_signature_l, condenser.exactSignature());
- add(doc, CollectionSchema.exact_signature_unique_b, true); // this must be corrected afterwards during storage!
- add(doc, CollectionSchema.exact_signature_copycount_i, 0); // this must be corrected afterwards during postprocessing!
- add(doc, CollectionSchema.fuzzy_signature_l, condenser.fuzzySignature());
- add(doc, CollectionSchema.fuzzy_signature_text_t, condenser.fuzzySignatureText());
- add(doc, CollectionSchema.fuzzy_signature_unique_b, true); // this must be corrected afterwards during storage!
- add(doc, CollectionSchema.fuzzy_signature_copycount_i, 0); // this must be corrected afterwards during postprocessing!
+ this.add(doc, CollectionSchema.http_unique_b, setUnique || UNIQUE_HEURISTIC_PREFER_HTTPS ? digestURL.isHTTPS() : digestURL.isHTTP()); // this must be corrected afterwards during storage!
+ this.add(doc, CollectionSchema.www_unique_b, setUnique || host != null && (UNIQUE_HEURISTIC_PREFER_WWWPREFIX ? host.startsWith("www.") : !host.startsWith("www."))); // this must be corrected afterwards during storage!
+
+ this.add(doc, CollectionSchema.exact_signature_l, condenser.exactSignature());
+ this.add(doc, CollectionSchema.exact_signature_unique_b, true); // this must be corrected afterwards during storage!
+ this.add(doc, CollectionSchema.exact_signature_copycount_i, 0); // this must be corrected afterwards during postprocessing!
+ this.add(doc, CollectionSchema.fuzzy_signature_l, condenser.fuzzySignature());
+ this.add(doc, CollectionSchema.fuzzy_signature_text_t, condenser.fuzzySignatureText());
+ this.add(doc, CollectionSchema.fuzzy_signature_unique_b, true); // this must be corrected afterwards during storage!
+ this.add(doc, CollectionSchema.fuzzy_signature_copycount_i, 0); // this must be corrected afterwards during postprocessing!
if (this.contains(CollectionSchema.exact_signature_unique_b) || this.contains(CollectionSchema.exact_signature_copycount_i) ||
this.contains(CollectionSchema.fuzzy_signature_l) || this.contains(CollectionSchema.fuzzy_signature_copycount_i) ||
this.contains(CollectionSchema.http_unique_b) || this.contains(CollectionSchema.www_unique_b)) {
- processTypes.add(ProcessType.UNIQUE);
+ processTypes.add(ProcessType.UNIQUE);
}
-
+
// get list of all links; they will be shrinked by urls that appear in other fields of the solr schema
- LinkedHashMap<DigestURL,String> inboundLinks = document.inboundLinks();
- LinkedHashMap<DigestURL,String> outboundLinks = document.outboundLinks();
+ final LinkedHashMap<DigestURL,String> inboundLinks = document.inboundLinks();
+ final LinkedHashMap<DigestURL,String> outboundLinks = document.outboundLinks();
- Subgraph subgraph = new Subgraph(inboundLinks.size(), outboundLinks.size());
+ final Subgraph subgraph = new Subgraph(inboundLinks.size(), outboundLinks.size());
int c = 0;
final Object scraper = document.getScraperObject();
boolean containsCanonical = false;
DigestURL canonical = null;
-
- processIcons(doc, allAttr, inboundLinks, outboundLinks, document.getIcons().values());
+
+ this.processIcons(doc, allAttr, inboundLinks, outboundLinks, document.getIcons().values());
if (scraper instanceof ContentScraper) {
final ContentScraper html = (ContentScraper) scraper;
- List<ImageEntry> images = html.getImages();
+ final List<ImageEntry> images = html.getImages();
// header tags
int h = 0;
int f = 1;
String[] hs;
- hs = html.getHeadlines(1); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, CollectionSchema.h1_txt, hs); add(doc, CollectionSchema.h1_i, hs.length);
- hs = html.getHeadlines(2); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, CollectionSchema.h2_txt, hs); add(doc, CollectionSchema.h2_i, hs.length);
- hs = html.getHeadlines(3); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, CollectionSchema.h3_txt, hs); add(doc, CollectionSchema.h3_i, hs.length);
- hs = html.getHeadlines(4); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, CollectionSchema.h4_txt, hs); add(doc, CollectionSchema.h4_i, hs.length);
- hs = html.getHeadlines(5); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, CollectionSchema.h5_txt, hs); add(doc, CollectionSchema.h5_i, hs.length);
- hs = html.getHeadlines(6); h = h | (hs.length > 0 ? f : 0); f = f * 2; add(doc, CollectionSchema.h6_txt, hs); add(doc, CollectionSchema.h6_i, hs.length);
-
- add(doc, CollectionSchema.htags_i, h);
- add(doc, CollectionSchema.schema_org_breadcrumb_i, html.breadcrumbCount());
+ hs = html.getHeadlines(1); h = h | (hs.length > 0 ? f : 0); f = f * 2; this.add(doc, CollectionSchema.h1_txt, hs); this.add(doc, CollectionSchema.h1_i, hs.length);
+ hs = html.getHeadlines(2); h = h | (hs.length > 0 ? f : 0); f = f * 2; this.add(doc, CollectionSchema.h2_txt, hs); this.add(doc, CollectionSchema.h2_i, hs.length);
+ hs = html.getHeadlines(3); h = h | (hs.length > 0 ? f : 0); f = f * 2; this.add(doc, CollectionSchema.h3_txt, hs); this.add(doc, CollectionSchema.h3_i, hs.length);
+ hs = html.getHeadlines(4); h = h | (hs.length > 0 ? f : 0); f = f * 2; this.add(doc, CollectionSchema.h4_txt, hs); this.add(doc, CollectionSchema.h4_i, hs.length);
+ hs = html.getHeadlines(5); h = h | (hs.length > 0 ? f : 0); f = f * 2; this.add(doc, CollectionSchema.h5_txt, hs); this.add(doc, CollectionSchema.h5_i, hs.length);
+ hs = html.getHeadlines(6); h = h | (hs.length > 0 ? f : 0); f = f * 2; this.add(doc, CollectionSchema.h6_txt, hs); this.add(doc, CollectionSchema.h6_i, hs.length);
+
+ this.add(doc, CollectionSchema.htags_i, h);
+ this.add(doc, CollectionSchema.schema_org_breadcrumb_i, html.breadcrumbCount());
// meta tags: Open Graph properties
String og;
- og = html.getMetas().get("og:title"); if (og != null) add(doc, CollectionSchema.opengraph_title_t, og);
- og = html.getMetas().get("og:type"); if (og != null) add(doc, CollectionSchema.opengraph_type_s, og);
- og = html.getMetas().get("og:url"); if (og != null) add(doc, CollectionSchema.opengraph_url_s, og);
- og = html.getMetas().get("og:image"); if (og != null) add(doc, CollectionSchema.opengraph_image_s, og);
+ og = html.getMetas().get("og:title"); if (og != null) this.add(doc, CollectionSchema.opengraph_title_t, og);
+ og = html.getMetas().get("og:type"); if (og != null) this.add(doc, CollectionSchema.opengraph_type_s, og);
+ og = html.getMetas().get("og:url"); if (og != null) this.add(doc, CollectionSchema.opengraph_url_s, og);
+ og = html.getMetas().get("og:image"); if (og != null) this.add(doc, CollectionSchema.opengraph_image_s, og);
// noindex and nofollow attributes
// from HTML (meta-tag in HTML header: robots)
@@ -647,7 +647,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
if (robots_meta.indexOf("nofollow",0) >= 0) b += 16; // set bit 4
if (robots_meta.indexOf("noarchive",0) >= 0) b += 32; // set bit 5
}
- String x_robots_tag = responseHeader == null ? "" : responseHeader.getXRobotsTag();
+ final String x_robots_tag = responseHeader == null ? "" : responseHeader.getXRobotsTag();
if (!x_robots_tag.isEmpty()) {
// this tag may have values: all, noindex, nofollow, noarchive, nosnippet, noodp, notranslate, noimageindex, unavailable_after, none; see https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag?hl=de
if (x_robots_tag.indexOf("all",0) >= 0) b += 1<<8; // set bit 8
@@ -660,63 +660,63 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
if (x_robots_tag.indexOf("noimageindex",0) >= 0) b += 1<<15; // set bit 15
if (x_robots_tag.indexOf("unavailable_after",0) >= 0) b += 1<<16; // set bit 16
}
- add(doc, CollectionSchema.robots_i, b);
+ this.add(doc, CollectionSchema.robots_i, b);
// meta tags: generator
final String generator = html.getMetas().get("generator");
- if (generator != null) add(doc, CollectionSchema.metagenerator_t, generator);
+ if (generator != null) this.add(doc, CollectionSchema.metagenerator_t, generator);
// bold, italic
final String[] bold = html.getBold();
- add(doc, CollectionSchema.boldcount_i, bold.length);
+ this.add(doc, CollectionSchema.boldcount_i, bold.length);
if (bold.length > 0) {
- add(doc, CollectionSchema.bold_txt, bold);
- if (allAttr || contains(CollectionSchema.bold_val)) {
- add(doc, CollectionSchema.bold_val, html.getBoldCount(bold));
+ this.add(doc, CollectionSchema.bold_txt, bold);
+ if (allAttr || this.contains(CollectionSchema.bold_val)) {
+ this.add(doc, CollectionSchema.bold_val, html.getBoldCount(bold));
}
}
final String[] italic = html.getItalic();
- add(doc, CollectionSchema.italiccount_i, italic.length);
+ this.add(doc, CollectionSchema.italiccount_i, italic.length);
if (italic.length > 0) {
- add(doc, CollectionSchema.italic_txt, italic);
- if (allAttr || contains(CollectionSchema.italic_val)) {
- add(doc, CollectionSchema.italic_val, html.getItalicCount(italic));
+ this.add(doc, CollectionSchema.italic_txt, italic);
+ if (allAttr || this.contains(CollectionSchema.italic_val)) {
+ this.add(doc, CollectionSchema.italic_val, html.getItalicCount(italic));
}
}
final String[] underline = html.getUnderline();
- add(doc, CollectionSchema.underlinecount_i, underline.length);
+ this.add(doc, CollectionSchema.underlinecount_i, underline.length);
if (underline.length > 0) {
- add(doc, CollectionSchema.underline_txt, underline);
- if (allAttr || contains(CollectionSchema.underline_val)) {
- add(doc, CollectionSchema.underline_val, html.getUnderlineCount(underline));
+ this.add(doc, CollectionSchema.underline_txt, underline);
+ if (allAttr || this.contains(CollectionSchema.underline_val)) {
+ this.add(doc, CollectionSchema.underline_val, html.getUnderlineCount(underline));
}
}
final String[] li = html.getLi();
- add(doc, CollectionSchema.licount_i, li.length);
- if (li.length > 0) add(doc, CollectionSchema.li_txt, li);
-
+ this.add(doc, CollectionSchema.licount_i, li.length);
+ if (li.length > 0) this.add(doc, CollectionSchema.li_txt, li);
+
final String[] dt = html.getDt();
- add(doc, CollectionSchema.dtcount_i, dt.length);
- if (dt.length > 0) add(doc, CollectionSchema.dt_txt, dt);
+ this.add(doc, CollectionSchema.dtcount_i, dt.length);
+ if (dt.length > 0) this.add(doc, CollectionSchema.dt_txt, dt);
final String[] dd = html.getDd();
- add(doc, CollectionSchema.ddcount_i, dd.length);
- if (dd.length > 0) add(doc, CollectionSchema.dd_txt, dd);
+ this.add(doc, CollectionSchema.ddcount_i, dd.length);
+ if (dd.length > 0) this.add(doc, CollectionSchema.dd_txt, dd);
final List<Date> startDates = html.getStartDates();
- if (startDates.size() > 0) add(doc, CollectionSchema.startDates_dts, startDates.toArray(new Date[startDates.size()]));
+ if (startDates.size() > 0) this.add(doc, CollectionSchema.startDates_dts, startDates.toArray(new Date[startDates.size()]));
final List<Date> endDates = html.getEndDates();
- if (endDates.size() > 0) add(doc, CollectionSchema.endDates_dts, endDates.toArray(new Date[endDates.size()]));
-
+ if (endDates.size() > 0) this.add(doc, CollectionSchema.endDates_dts, endDates.toArray(new Date[endDates.size()]));
+
final List<String> articles = html.getArticles();
- add(doc, CollectionSchema.articlecount_i, articles.size());
- if (articles.size() > 0) add(doc, CollectionSchema.article_txt, articles);
+ this.add(doc, CollectionSchema.articlecount_i, articles.size());
+ if (articles.size() > 0) this.add(doc, CollectionSchema.article_txt, articles);
// images
- processImages(doc, allAttr, inboundLinks, outboundLinks, images);
+ this.processImages(doc, allAttr, inboundLinks, outboundLinks, images);
// style sheets
- if (allAttr || contains(CollectionSchema.css_tag_sxt)) {
+ if (allAttr || this.contains(CollectionSchema.css_tag_sxt)) {
final Map<DigestURL, String> csss = html.getCSS();
final String[] css_tag = new String[csss.size()];
final String[] css_url = new String[csss.size()];
@@ -731,13 +731,13 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
css_url[c] = cssurl;
c++;
}
- add(doc, CollectionSchema.csscount_i, css_tag.length);
- if (css_tag.length > 0) add(doc, CollectionSchema.css_tag_sxt, css_tag);
- if (css_url.length > 0) add(doc, CollectionSchema.css_url_sxt, css_url);
+ this.add(doc, CollectionSchema.csscount_i, css_tag.length);
+ if (css_tag.length > 0) this.add(doc, CollectionSchema.css_tag_sxt, css_tag);
+ if (css_url.length > 0) this.add(doc, CollectionSchema.css_url_sxt, css_url);
}
// Scripts
- if (allAttr || contains(CollectionSchema.scripts_sxt)) {
+ if (allAttr || this.contains(CollectionSchema.scripts_sxt)) {
final Set<AnchorURL> scriptss = html.getScript();
final String[] scripts = new String[scriptss.size()];
c = 0;
@@ -746,12 +746,12 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
outboundLinks.remove(u);
scripts[c++] = u.toNormalform(false);
}
- add(doc, CollectionSchema.scriptscount_i, scripts.length);
- if (scripts.length > 0) add(doc, CollectionSchema.scripts_sxt, scripts);
+ this.add(doc, CollectionSchema.scriptscount_i, scripts.length);
+ if (scripts.length > 0) this.add(doc, CollectionSchema.scripts_sxt, scripts);
}
// Frames
- if (allAttr || contains(CollectionSchema.frames_sxt)) {
+ if (allAttr || this.contains(CollectionSchema.frames_sxt)) {
final Set<AnchorURL> framess = html.getFrames();
final String[] frames = new String[framess.size()];
c = 0;
@@ -760,15 +760,15 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
outboundLinks.remove(u);
frames[c++] = u.toNormalform(false);
}
- add(doc, CollectionSchema.framesscount_i, frames.length);
+ this.add(doc, CollectionSchema.framesscount_i, frames.length);
if (frames.length > 0) {
- add(doc, CollectionSchema.frames_sxt, frames);
+ this.add(doc, CollectionSchema.frames_sxt, frames);
//webgraph.addEdges(subgraph, digestURI, responseHeader, collections, crawldepth, alllinks, images, true, framess, citations); // add here because links have been removed from remaining inbound/outbound
}
}
// IFrames
- if (allAttr || contains(CollectionSchema.iframes_sxt)) {
+ if (allAttr || this.contains(CollectionSchema.iframes_sxt)) {
final Set<AnchorURL> iframess = html.getIFrames();
final String[] iframes = new String[iframess.size()];
c = 0;
@@ -777,15 +777,15 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
outboundLinks.remove(u);
iframes[c++] = u.toNormalform(false);
}
- add(doc, CollectionSchema.iframesscount_i, iframes.length);
+ this.add(doc, CollectionSchema.iframesscount_i, iframes.length);
if (iframes.length > 0) {
- add(doc, CollectionSchema.iframes_sxt, iframes);
+ this.add(doc, CollectionSchema.iframes_sxt, iframes);
//webgraph.addEdges(subgraph, digestURI, responseHeader, collections, crawldepth, alllinks, images, true, iframess, citations); // add here because links have been removed from remaining inbound/outbound
}
}
// canonical tag
- if (allAttr || contains(CollectionSchema.canonical_s)) {
+ if (allAttr || this.contains(CollectionSchema.canonical_s)) {
canonical = html.getCanonical();
// if there is no canonical in the html then look into the http header:
if (canonical == null && responseHeader != null) {
@@ -794,12 +794,12 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
if (link != null && ((p = link.indexOf("rel=\"canonical\"")) > 0)) {
link = link.substring(0, p).trim();
p = link.indexOf('<');
- int q = link.lastIndexOf('>');
+ final int q = link.lastIndexOf('>');
if (p >= 0 && q > 0) {
link = link.substring(p + 1, q);
try {
canonical = new DigestURL(link);
- } catch (MalformedURLException e) {}
+ } catch (final MalformedURLException e) {}
}
}
}
@@ -807,17 +807,17 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
containsCanonical = true;
inboundLinks.remove(canonical);
outboundLinks.remove(canonical);
- add(doc, CollectionSchema.canonical_s, canonical.toNormalform(false));
+ this.add(doc, CollectionSchema.canonical_s, canonical.toNormalform(false));
// set a flag if this is equal to sku
- if (contains(CollectionSchema.canonical_equal_sku_b)) {
- add(doc, CollectionSchema.canonical_equal_sku_b, canonical.equals(digestURL));
+ if (this.contains(CollectionSchema.canonical_equal_sku_b)) {
+ this.add(doc, CollectionSchema.canonical_equal_sku_b, canonical.equals(digestURL));
}
}
}
// meta refresh tag
- if (allAttr || contains(CollectionSchema.refresh_s)) {
- String refresh = html.getRefreshPath();
+ if (allAttr || this.contains(CollectionSchema.refresh_s)) {
+ final String refresh = html.getRefreshPath();
if (refresh != null && refresh.length() > 0) {
MultiProtocolURL refreshURL;
try {
@@ -825,105 +825,105 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
if (refreshURL != null) {
inboundLinks.remove(refreshURL);
outboundLinks.remove(refreshURL);
- add(doc, CollectionSchema.refresh_s, refreshURL.toNormalform(false));
+ this.add(doc, CollectionSchema.refresh_s, refreshURL.toNormalform(false));
}
} catch (final MalformedURLException e) {
- add(doc, CollectionSchema.refresh_s, refresh);
+ this.add(doc, CollectionSchema.refresh_s, refresh);
}
}
}
// flash embedded
- if (allAttr || contains(CollectionSchema.flash_b)) {
- MultiProtocolURL[] flashURLs = html.getFlash();
- for (MultiProtocolURL u: flashURLs) {
+ if (allAttr || this.contains(CollectionSchema.flash_b)) {
+ final MultiProtocolURL[] flashURLs = html.getFlash();
+ for (final MultiProtocolURL u: flashURLs) {
// remove all flash links from ibound/outbound links
inboundLinks.remove(u);
outboundLinks.remove(u);
}
- add(doc, CollectionSchema.flash_b, flashURLs.length > 0);
+ this.add(doc, CollectionSchema.flash_b, flashURLs.length > 0);
}
// generic evaluation pattern
for (final String model: html.getEvaluationModelNames()) {
- if (allAttr || contains("ext_" + model + "_txt")) {
+ if (allAttr || this.contains("ext_" + model + "_txt")) {
final String[] scorenames = html.getEvaluationModelScoreNames(model);
if (scorenames.length > 0) {
- add(doc, CollectionSchema.valueOf("ext_" + model + "_txt"), scorenames);
- add(doc, CollectionSchema.valueOf("ext_" + model + "_val"), html.getEvaluationModelScoreCounts(model, scorenames));
+ this.add(doc, CollectionSchema.valueOf("ext_" + model + "_txt"), scorenames);
+ this.add(doc, CollectionSchema.valueOf("ext_" + model + "_val"), html.getEvaluationModelScoreCounts(model, scorenames));
}
}
}
// response time
- add(doc, CollectionSchema.responsetime_i, responseHeader == null ? 0 : Integer.parseInt(responseHeader.get(HeaderFramework.RESPONSE_TIME_MILLIS, "0")));
-
+ this.add(doc, CollectionSchema.responsetime_i, responseHeader == null ? 0 : Integer.parseInt(responseHeader.get(HeaderFramework.RESPONSE_TIME_MILLIS, "0")));
+
// hreflang link tag, see http://support.google.com/webmasters/bin/answer.py?hl=de&answer=189077
- if (allAttr || (contains(CollectionSchema.hreflang_url_sxt) && contains(CollectionSchema.hreflang_cc_sxt))) {
+ if (allAttr || (this.contains(CollectionSchema.hreflang_url_sxt) && this.contains(CollectionSchema.hreflang_cc_sxt))) {
final String[] ccs = new String[html.getHreflang().size()];
final String[] urls = new String[html.getHreflang().size()];
c = 0;
- for (Map.Entry<String, DigestURL> e: html.getHreflang().entrySet()) {
+ for (final Map.Entry<String, DigestURL> e: html.getHreflang().entrySet()) {
ccs[c] = e.getKey();
urls[c] = e.getValue().toNormalform(true);
c++;
}
- add(doc, CollectionSchema.hreflang_cc_sxt, ccs);
- add(doc, CollectionSchema.hreflang_url_sxt, urls);
+ this.add(doc, CollectionSchema.hreflang_cc_sxt, ccs);
+ this.add(doc, CollectionSchema.hreflang_url_sxt, urls);
}
// page navigation url, see http://googlewebmastercentral.blogspot.de/2011/09/pagination-with-relnext-and-relprev.html
- if (allAttr || (contains(CollectionSchema.navigation_url_sxt) && contains(CollectionSchema.navigation_type_sxt))) {
+ if (allAttr || (this.contains(CollectionSchema.navigation_url_sxt) && this.contains(CollectionSchema.navigation_type_sxt))) {
final String[] navs = new String[html.getNavigation().size()];
final String[] urls = new String[html.getNavigation().size()];
c = 0;
- for (Map.Entry<String, DigestURL> e: html.getNavigation().entrySet()) {
+ for (final Map.Entry<String, DigestURL> e: html.getNavigation().entrySet()) {
navs[c] = e.getKey();
urls[c] = e.getValue().toNormalform(true);
c++;
}
- add(doc, CollectionSchema.navigation_type_sxt, navs);
- add(doc, CollectionSchema.navigation_url_sxt, urls);
-
+ this.add(doc, CollectionSchema.navigation_type_sxt, navs);
+ this.add(doc, CollectionSchema.navigation_url_sxt, urls);
+
}
// publisher url as defined in http://support.google.com/plus/answer/1713826?hl=de
- if (allAttr || contains(CollectionSchema.publisher_url_s) && html.getPublisherLink() != null) {
- add(doc, CollectionSchema.publisher_url_s, html.getPublisherLink().toNormalform(true));
+ if (allAttr || this.contains(CollectionSchema.publisher_url_s) && html.getPublisherLink() != null) {
+ this.add(doc, CollectionSchema.publisher_url_s, html.getPublisherLink().toNormalform(true));
}
}
if (scraper instanceof DCEntry) {
// the document was created with a surrogate parsing; overwrite all md: -entries to Solr
- DCEntry dcentry = (DCEntry) scraper;
- for (Map.Entry<String, String[]> entry: dcentry.getMap().entrySet()) {
- String tag = entry.getKey();
+ final DCEntry dcentry = (DCEntry) scraper;
+ for (final Map.Entry<String, String[]> entry: dcentry.getMap().entrySet()) {
+ final String tag = entry.getKey();
if (!tag.startsWith("md:") || tag.length() < 4) continue; // md: is a YaCy internal identifier for metadata in surrugate.xml files ( md:SOLR_FIELDNAME )
- CollectionSchema solr_field = CollectionSchema.valueOf(tag.substring(3));
+ final CollectionSchema solr_field = CollectionSchema.valueOf(tag.substring(3));
if (solr_field == null) continue;
- String[] values = entry.getValue();
+ final String[] values = entry.getValue();
if (values == null || values.length == 0) continue;
- if (allAttr || contains(solr_field)) {
- add(doc, solr_field, values);
+ if (allAttr || this.contains(solr_field)) {
+ this.add(doc, solr_field, values);
}
}
}
-
+
String content = document.getTextString();
// handle image source meta data
if (document.getContentDomain() == ContentDomain.IMAGE) {
// add image pixel sizes if enabled in index
// get values if as least one of the size fields is enabled in index
- if (allAttr || (contains(CollectionSchema.images_height_val) || contains(CollectionSchema.images_width_val)) || contains(CollectionSchema.images_pixel_val)) {
+ if (allAttr || (this.contains(CollectionSchema.images_height_val) || this.contains(CollectionSchema.images_width_val)) || this.contains(CollectionSchema.images_pixel_val)) {
// add image pixel size if known
- Iterator<ImageEntry> imgit = document.getImages().values().iterator();
- List<Integer> heights = new ArrayList<>();
- List<Integer> widths = new ArrayList<>();
- List<Integer> pixels = new ArrayList<>();
+ final Iterator<ImageEntry> imgit = document.getImages().values().iterator();
+ final List<Integer> heights = new ArrayList<>();
+ final List<Integer> widths = new ArrayList<>();
+ final List<Integer> pixels = new ArrayList<>();
while (imgit.hasNext()) {
- ImageEntry img = imgit.next();
- int imgpixels = (img.height() < 0 || img.width() < 0) ? -1 : img.height() * img.width();
+ final ImageEntry img = imgit.next();
+ final int imgpixels = (img.height() < 0 || img.width() < 0) ? -1 : img.height() * img.width();
if (imgpixels > 0) {
heights.add(img.height());
widths.add(img.width());
@@ -931,111 +931,111 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
}
}
if (heights.size() > 0) { // add to index document
- add(doc, CollectionSchema.images_height_val, heights); // add() checks if field is enabled in index
- add(doc, CollectionSchema.images_width_val, widths);
- add(doc, CollectionSchema.images_pixel_val, pixels);
+ this.add(doc, CollectionSchema.images_height_val, heights); // add() checks if field is enabled in index
+ this.add(doc, CollectionSchema.images_width_val, widths);
+ this.add(doc, CollectionSchema.images_pixel_val, pixels);
}
}
- if (allAttr || contains(CollectionSchema.images_text_t)) {
- add(doc, CollectionSchema.images_text_t, content); // the content may contain the exif data from the image parser
+ if (allAttr || this.contains(CollectionSchema.images_text_t)) {
+ this.add(doc, CollectionSchema.images_text_t, content); // the content may contain the exif data from the image parser
content = digestURL.toTokens(); // remove all other entry but the url tokens
}
}
// content (must be written after special parser data, since this can influence the content)
- if (allAttr || contains(CollectionSchema.text_t)) add(doc, CollectionSchema.text_t, content);
- if (allAttr || contains(CollectionSchema.wordcount_i)) {
+ if (allAttr || this.contains(CollectionSchema.text_t)) this.add(doc, CollectionSchema.text_t, content);
+ if (allAttr || this.contains(CollectionSchema.wordcount_i)) {
if (content.length() == 0) {
- add(doc, CollectionSchema.wordcount_i, 0);
+ this.add(doc, CollectionSchema.wordcount_i, 0);
} else {
int contentwc = 1;
for (int i = content.length() - 1; i >= 0; i--) if (content.charAt(i) == ' ') contentwc++;
- add(doc, CollectionSchema.wordcount_i, contentwc);
+ this.add(doc, CollectionSchema.wordcount_i, contentwc);
}
}
-
+
// statistics about the links
- if (allAttr || contains(CollectionSchema.linkscount_i)) add(doc, CollectionSchema.linkscount_i, inboundLinks.size() + outboundLinks.size());
- if (allAttr || contains(CollectionSchema.linksnofollowcount_i)) add(doc, CollectionSchema.linksnofollowcount_i, document.inboundLinkNofollowCount() + document.outboundLinkNofollowCount());
- if (allAttr || contains(CollectionSchema.inboundlinkscount_i)) add(doc, CollectionSchema.inboundlinkscount_i, inboundLinks.size());
- if (allAttr || contains(CollectionSchema.inboundlinksnofollowcount_i)) add(doc, CollectionSchema.inboundlinksnofollowcount_i, document.inboundLinkNofollowCount());
- if (allAttr || contains(CollectionSchema.outboundlinkscount_i)) add(doc, CollectionSchema.outboundlinkscount_i, outboundLinks.size());
- if (allAttr || contains(CollectionSchema.outboundlinksnofollowcount_i)) add(doc, CollectionSchema.outboundlinksnofollowcount_i, document.outboundLinkNofollowCount());
-
+ if (allAttr || this.contains(CollectionSchema.linkscount_i)) this.add(doc, CollectionSchema.linkscount_i, inboundLinks.size() + outboundLinks.size());
+ if (allAttr || this.contains(CollectionSchema.linksnofollowcount_i)) this.add(doc, CollectionSchema.linksnofollowcount_i, document.inboundLinkNofollowCount() + document.outboundLinkNofollowCount());
+ if (allAttr || this.contains(CollectionSchema.inboundlinkscount_i)) this.add(doc, CollectionSchema.inboundlinkscount_i, inboundLinks.size());
+ if (allAttr || this.contains(CollectionSchema.inboundlinksnofollowcount_i)) this.add(doc, CollectionSchema.inboundlinksnofollowcount_i, document.inboundLinkNofollowCount());
+ if (allAttr || this.contains(CollectionSchema.outboundlinkscount_i)) this.add(doc, CollectionSchema.outboundlinkscount_i, outboundLinks.size());
+ if (allAttr || this.contains(CollectionSchema.outboundlinksnofollowcount_i)) this.add(doc, CollectionSchema.outboundlinksnofollowcount_i, document.outboundLinkNofollowCount());
+
// create a subgraph
- Boolean canonical_equal_sku = canonical == null ? null : canonical.toNormalform(true).equals(url);
+ final Boolean canonical_equal_sku = canonical == null ? null : canonical.toNormalform(true).equals(url);
if (webgraph != null && (!containsCanonical || (canonical_equal_sku != null && (canonical_equal_sku.booleanValue())))) {
// a document with canonical tag should not get a webgraph relation, because that belongs to the canonical document
- List<SolrInputDocument> edges = webgraph.getEdges(subgraph, digestURL, responseHeader, collections, crawldepth, processTypes, document.getHyperlinks().keySet(), sourceName);
+ final List<SolrInputDocument> edges = webgraph.getEdges(subgraph, digestURL, responseHeader, collections, crawldepth, processTypes, document.getHyperlinks().keySet(), sourceName);
// this also enriched the subgraph
doc.webgraphDocuments.addAll(edges);
} else {
if (allAttr ||
- contains(CollectionSchema.inboundlinks_protocol_sxt) ||
- contains(CollectionSchema.inboundlinks_urlstub_sxt) ||
- contains(CollectionSchema.inboundlinks_anchortext_txt) ||
- contains(CollectionSchema.outboundlinks_protocol_sxt) ||
- contains(CollectionSchema.outboundlinks_urlstub_sxt) ||
- contains(CollectionSchema.outboundlinks_anchortext_txt)) {
+ this.contains(CollectionSchema.inboundlinks_protocol_sxt) ||
+ this.contains(CollectionSchema.inboundlinks_urlstub_sxt) ||
+ this.contains(CollectionSchema.inboundlinks_anchortext_txt) ||
+ this.contains(CollectionSchema.outboundlinks_protocol_sxt) ||
+ this.contains(CollectionSchema.outboundlinks_urlstub_sxt) ||
+ this.contains(CollectionSchema.outboundlinks_anchortext_txt)) {
for (final AnchorURL target_url: document.getHyperlinks().keySet()) {
enrichSubgraph(subgraph, digestURL, target_url);
}
}
}
-
+
// attach the subgraph content
- if (allAttr || contains(CollectionSchema.inboundlinks_protocol_sxt)) add(doc, CollectionSchema.inboundlinks_protocol_sxt, protocolList2indexedList(subgraph.urlProtocols[0]));
- if (allAttr || contains(CollectionSchema.inboundlinks_urlstub_sxt)) add(doc, CollectionSchema.inboundlinks_urlstub_sxt, subgraph.urlStubs[0]);
- if (allAttr || contains(CollectionSchema.inboundlinks_anchortext_txt)) add(doc, CollectionSchema.inboundlinks_anchortext_txt, subgraph.urlAnchorTexts[0]);
- if (allAttr || contains(CollectionSchema.outboundlinks_protocol_sxt)) add(doc, CollectionSchema.outboundlinks_protocol_sxt, protocolList2indexedList(subgraph.urlProtocols[1]));
- if (allAttr || contains(CollectionSchema.outboundlinks_urlstub_sxt)) add(doc, CollectionSchema.outboundlinks_urlstub_sxt, subgraph.urlStubs[1]);
- if (allAttr || contains(CollectionSchema.outboundlinks_anchortext_txt)) add(doc, CollectionSchema.outboundlinks_anchortext_txt, subgraph.urlAnchorTexts[1]);
-
+ if (allAttr || this.contains(CollectionSchema.inboundlinks_protocol_sxt)) this.add(doc, CollectionSchema.inboundlinks_protocol_sxt, protocolList2indexedList(subgraph.urlProtocols[0]));
+ if (allAttr || this.contains(CollectionSchema.inboundlinks_urlstub_sxt)) this.add(doc, CollectionSchema.inboundlinks_urlstub_sxt, subgraph.urlStubs[0]);
+ if (allAttr || this.contains(CollectionSchema.inboundlinks_anchortext_txt)) this.add(doc, CollectionSchema.inboundlinks_anchortext_txt, subgraph.urlAnchorTexts[0]);
+ if (allAttr || this.contains(CollectionSchema.outboundlinks_protocol_sxt)) this.add(doc, CollectionSchema.outboundlinks_protocol_sxt, protocolList2indexedList(subgraph.urlProtocols[1]));
+ if (allAttr || this.contains(CollectionSchema.outboundlinks_urlstub_sxt)) this.add(doc, CollectionSchema.outboundlinks_urlstub_sxt, subgraph.urlStubs[1]);
+ if (allAttr || this.contains(CollectionSchema.outboundlinks_anchortext_txt)) this.add(doc, CollectionSchema.outboundlinks_anchortext_txt, subgraph.urlAnchorTexts[1]);
+
// charset
- if (allAttr || contains(CollectionSchema.charset_s)) add(doc, CollectionSchema.charset_s, document.getCharset());
+ if (allAttr || this.contains(CollectionSchema.charset_s)) this.add(doc, CollectionSchema.charset_s, document.getCharset());
// coordinates
if (document.lat() != 0.0 && document.lon() != 0.0) {
- if (allAttr || contains(CollectionSchema.coordinate_p)) add(doc, CollectionSchema.coordinate_p, Double.toString(document.lat()) + "," + Double.toString(document.lon()));
+ if (allAttr || this.contains(CollectionSchema.coordinate_p)) this.add(doc, CollectionSchema.coordinate_p, Double.toString(document.lat()) + "," + Double.toString(document.lon()));
}
- if (allAttr || contains(CollectionSchema.httpstatus_i)) add(doc, CollectionSchema.httpstatus_i, responseHeader == null ? 200 : responseHeader.getStatusCode());
+ if (allAttr || this.contains(CollectionSchema.httpstatus_i)) this.add(doc, CollectionSchema.httpstatus_i, responseHeader == null ? 200 : responseHeader.getStatusCode());
// fields that were additionally in URIMetadataRow
- Date loadDate = new Date();
+ final Date loadDate = new Date();
Date modDate = responseHeader == null ? new Date() : responseHeader.lastModified();
if (modDate.getTime() > loadDate.getTime()) modDate = loadDate;
- int size = (int) Math.max(document.dc_source().length(), responseHeader == null ? 0 : responseHeader.getContentLength());
- if (allAttr || contains(CollectionSchema.load_date_dt)) add(doc, CollectionSchema.load_date_dt, loadDate);
- if (allAttr || contains(CollectionSchema.fresh_date_dt)) add(doc, CollectionSchema.fresh_date_dt, new Date(loadDate.getTime() + Math.max(0, loadDate.getTime() - modDate.getTime()) / 2)); // freshdate, computed with Proxy-TTL formula
- if ((allAttr || contains(CollectionSchema.referrer_id_s)) && referrerURL != null) add(doc, CollectionSchema.referrer_id_s, ASCII.String(referrerURL.hash()));
+ final int size = (int) Math.max(document.dc_source().length(), responseHeader == null ? 0 : responseHeader.getContentLength());
+ if (allAttr || this.contains(CollectionSchema.load_date_dt)) this.add(doc, CollectionSchema.load_date_dt, loadDate);
+ if (allAttr || this.contains(CollectionSchema.fresh_date_dt)) this.add(doc, CollectionSchema.fresh_date_dt, new Date(loadDate.getTime() + Math.max(0, loadDate.getTime() - modDate.getTime()) / 2)); // freshdate, computed with Proxy-TTL formula
+ if ((allAttr || this.contains(CollectionSchema.referrer_id_s)) && referrerURL != null) this.add(doc, CollectionSchema.referrer_id_s, ASCII.String(referrerURL.hash()));
//if (allAttr || contains(SolrField.md5_s)) add(solrdoc, SolrField.md5_s, new byte[0]);
- if (allAttr || contains(CollectionSchema.publisher_t)) add(doc, CollectionSchema.publisher_t, document.dc_publisher());
- if ((allAttr || contains(CollectionSchema.language_s)) && language != null) add(doc, CollectionSchema.language_s, language);
- if (allAttr || contains(CollectionSchema.size_i)) add(doc, CollectionSchema.size_i, size);
- if (allAttr || contains(CollectionSchema.audiolinkscount_i)) add(doc, CollectionSchema.audiolinkscount_i, document.getAudiolinks().size());
- if (allAttr || contains(CollectionSchema.videolinkscount_i)) add(doc, CollectionSchema.videolinkscount_i, document.getVideolinks().size());
- if (allAttr || contains(CollectionSchema.applinkscount_i)) add(doc, CollectionSchema.applinkscount_i, document.getApplinks().size());
+ if (allAttr || this.contains(CollectionSchema.publisher_t)) this.add(doc, CollectionSchema.publisher_t, document.dc_publisher());
+ if ((allAttr || this.contains(CollectionSchema.language_s)) && language != null) this.add(doc, CollectionSchema.language_s, language);
+ if (allAttr || this.contains(CollectionSchema.size_i)) this.add(doc, CollectionSchema.size_i, size);
+ if (allAttr || this.contains(CollectionSchema.audiolinkscount_i)) this.add(doc, CollectionSchema.audiolinkscount_i, document.getAudiolinks().size());
+ if (allAttr || this.contains(CollectionSchema.videolinkscount_i)) this.add(doc, CollectionSchema.videolinkscount_i, document.getVideolinks().size());
+ if (allAttr || this.contains(CollectionSchema.applinkscount_i)) this.add(doc, CollectionSchema.applinkscount_i, document.getApplinks().size());
// document post-processing
- if ((allAttr || contains(CollectionSchema.process_sxt)) && processTypes.size() > 0) {
- List<String> p = new ArrayList<String>();
- for (ProcessType t: processTypes) p.add(t.name());
- add(doc, CollectionSchema.process_sxt, p);
- if (allAttr || contains(CollectionSchema.harvestkey_s)) {
- add(doc, CollectionSchema.harvestkey_s, sourceName);
+ if ((allAttr || this.contains(CollectionSchema.process_sxt)) && processTypes.size() > 0) {
+ final List<String> p = new ArrayList<>();
+ for (final ProcessType t: processTypes) p.add(t.name());
+ this.add(doc, CollectionSchema.process_sxt, p);
+ if (allAttr || this.contains(CollectionSchema.harvestkey_s)) {
+ this.add(doc, CollectionSchema.harvestkey_s, sourceName);
}
}
-
+
// document enrichments (synonyms, facets)
- enrich(doc, condenser.synonyms(), document.getGenericFacets());
+ this.enrich(doc, condenser.synonyms(), document.getGenericFacets());
return doc;
}
-
+
/**
* Add icons metadata to Solr doc when corresponding schema attributes are
* enabled.
- *
+ *
* @param doc
* solr document to fill. Must not be null.
* @param allAttr
@@ -1044,13 +1044,13 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
* document icon entries.
*/
private void processIcons(SolrInputDocument doc, boolean allAttr, Collection<IconEntry> icons) {
- processIcons(doc, allAttr, null, null, icons);
+ this.processIcons(doc, allAttr, null, null, icons);
}
-
+
/**
* Add icons metadata to Solr doc when corresponding schema attributes are
* enabled. Remove icons urls from inboudLinks and outboundLinks.
- *
+ *
* @param doc
* solr document to fill. Must not be null.
* @param allAttr
@@ -1065,7 +1065,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
private void processIcons(SolrInputDocument doc, boolean allAttr, LinkedHashMap<DigestURL, String> inboundLinks,
LinkedHashMap<DigestURL, String> outboundLinks, Collection<IconEntry> icons) {
if (icons != null) {
- final List<String> protocols = new ArrayList<String>(icons.size());
+ final List<String> protocols = new ArrayList<>(icons.size());
final String[] sizes = new String[icons.size()];
final String[] stubs = new String[icons.size()];
final String[] rels = new String[icons.size()];
@@ -1081,7 +1081,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
outboundLinks.remove(url);
}
- String protocol = url.getProtocol();
+ final String protocol = url.getProtocol();
protocols.add(protocol);
/*
@@ -1095,23 +1095,23 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
i++;
}
- if (allAttr || contains(CollectionSchema.icons_protocol_sxt)) {
- add(doc, CollectionSchema.icons_protocol_sxt, protocolList2indexedList(protocols));
+ if (allAttr || this.contains(CollectionSchema.icons_protocol_sxt)) {
+ this.add(doc, CollectionSchema.icons_protocol_sxt, protocolList2indexedList(protocols));
}
- if (allAttr || contains(CollectionSchema.icons_urlstub_sxt)) {
- add(doc, CollectionSchema.icons_urlstub_sxt, stubs);
+ if (allAttr || this.contains(CollectionSchema.icons_urlstub_sxt)) {
+ this.add(doc, CollectionSchema.icons_urlstub_sxt, stubs);
}
- if (allAttr || contains(CollectionSchema.icons_rel_sxt)) {
- add(doc, CollectionSchema.icons_rel_sxt, rels);
+ if (allAttr || this.contains(CollectionSchema.icons_rel_sxt)) {
+ this.add(doc, CollectionSchema.icons_rel_sxt, rels);
}
- if (allAttr || contains(CollectionSchema.icons_sizes_sxt)) {
- add(doc, CollectionSchema.icons_sizes_sxt, sizes);
+ if (allAttr || this.contains(CollectionSchema.icons_sizes_sxt)) {
+ this.add(doc, CollectionSchema.icons_sizes_sxt, sizes);
}
}
}
/**
- * Add images metadata to Solr doc when corresponding schema attributes are enabled.
+ * Add images metadata to Solr doc when corresponding schema attributes are enabled.
* Remove images urls from inboudLinks and outboundLinks.
* @param doc solr document to fill
* @param allAttr all attributes are enabled
@@ -1121,7 +1121,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
*/
private void processImages(SolrVector doc, boolean allAttr, LinkedHashMap<DigestURL, String> inboundLinks,
LinkedHashMap<DigestURL, String> outboundLinks, List<ImageEntry> images) {
- final ArrayList<String> imgprots = new ArrayList<String>(images.size());
+ final ArrayList<String> imgprots = new ArrayList<>(images.size());
final Integer[] imgheights = new Integer[images.size()];
final Integer[] imgwidths = new Integer[images.size()];
final Integer[] imgpixels = new Integer[images.size()];
@@ -1129,7 +1129,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
final String[] imgalts = new String[images.size()];
int withalt = 0;
int i = 0;
- LinkedHashSet<String> images_text_map = new LinkedHashSet<String>();
+ final LinkedHashSet<String> images_text_map = new LinkedHashSet<>();
/* Prepare flat solr field values */
for (final ImageEntry ie: images) {
final MultiProtocolURL uri = ie.url();
@@ -1138,31 +1138,31 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
imgheights[i] = ie.height();
imgwidths[i] = ie.width();
imgpixels[i] = ie.height() < 0 || ie.width() < 0 ? -1 : ie.height() * ie.width();
- String protocol = uri.getProtocol();
+ final String protocol = uri.getProtocol();
imgprots.add(protocol);
imgstubs[i] = uri.toString().substring(protocol.length() + 3);
imgalts[i] = ie.alt();
- for (String it: CommonPattern.SPACE.split(uri.toTokens())) images_text_map.add(it);
+ for (final String it: CommonPattern.SPACE.split(uri.toTokens())) images_text_map.add(it);
if (ie.alt() != null && ie.alt().length() > 0) {
- SentenceReader sr = new SentenceReader(ie.alt());
+ final SentenceReader sr = new SentenceReader(ie.alt());
while (sr.hasNext()) images_text_map.add(sr.next().toString());
withalt++;
}
i++;
}
- StringBuilder images_text = new StringBuilder(images_text_map.size() * 6 + 1);
- for (String s: images_text_map) images_text.append(s.trim()).append(' ');
- if (allAttr || contains(CollectionSchema.imagescount_i)) add(doc, CollectionSchema.imagescount_i, images.size());
- if (allAttr || contains(CollectionSchema.images_protocol_sxt)) add(doc, CollectionSchema.images_protocol_sxt, protocolList2indexedList(imgprots));
- if (allAttr || contains(CollectionSchema.images_urlstub_sxt)) add(doc, CollectionSchema.images_urlstub_sxt, imgstubs);
- if (allAttr || contains(CollectionSchema.images_alt_sxt)) add(doc, CollectionSchema.images_alt_sxt, imgalts);
- if (allAttr || contains(CollectionSchema.images_height_val)) add(doc, CollectionSchema.images_height_val, imgheights);
- if (allAttr || contains(CollectionSchema.images_width_val)) add(doc, CollectionSchema.images_width_val, imgwidths);
- if (allAttr || contains(CollectionSchema.images_pixel_val)) add(doc, CollectionSchema.images_pixel_val, imgpixels);
- if (allAttr || contains(CollectionSchema.images_withalt_i)) add(doc, CollectionSchema.images_withalt_i, withalt);
- if (allAttr || contains(CollectionSchema.images_text_t)) add(doc, CollectionSchema.images_text_t, images_text.toString().trim());
+ final StringBuilder images_text = new StringBuilder(images_text_map.size() * 6 + 1);
+ for (final String s: images_text_map) images_text.append(s.trim()).append(' ');
+ if (allAttr || this.contains(CollectionSchema.imagescount_i)) this.add(doc, CollectionSchema.imagescount_i, images.size());
+ if (allAttr || this.contains(CollectionSchema.images_protocol_sxt)) this.add(doc, CollectionSchema.images_protocol_sxt, protocolList2indexedList(imgprots));
+ if (allAttr || this.contains(CollectionSchema.images_urlstub_sxt)) this.add(doc, CollectionSchema.images_urlstub_sxt, imgstubs);
+ if (allAttr || this.contains(CollectionSchema.images_alt_sxt)) this.add(doc, CollectionSchema.images_alt_sxt, imgalts);
+ if (allAttr || this.contains(CollectionSchema.images_height_val)) this.add(doc, CollectionSchema.images_height_val, imgheights);
+ if (allAttr || this.contains(CollectionSchema.images_width_val)) this.add(doc, CollectionSchema.images_width_val, imgwidths);
+ if (allAttr || this.contains(CollectionSchema.images_pixel_val)) this.add(doc, CollectionSchema.images_pixel_val, imgpixels);
+ if (allAttr || this.contains(CollectionSchema.images_withalt_i)) this.add(doc, CollectionSchema.images_withalt_i, withalt);
+ if (allAttr || this.contains(CollectionSchema.images_text_t)) this.add(doc, CollectionSchema.images_text_t, images_text.toString().trim());
}
-
+
/**
* attach additional information to the document to enable navigation features
* @param doc the document to be enriched
@@ -1170,45 +1170,45 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
* @param genericFacets a map where the key is the navigator name and the value is the set of attributes names
*/
public void enrich(SolrInputDocument doc, List<String> synonyms, Map<String, Set<String>> genericFacets) {
- remove(doc, CollectionSchema.vocabularies_sxt); // delete old values
- for (SolrInputField sif: doc) {
- if (sif.getName().startsWith(CollectionSchema.VOCABULARY_PREFIX)) remove(doc, sif.getName());
+ this.remove(doc, CollectionSchema.vocabularies_sxt); // delete old values
+ for (final SolrInputField sif: doc) {
+ if (sif.getName().startsWith(CollectionSchema.VOCABULARY_PREFIX)) this.remove(doc, sif.getName());
}
- if (this.isEmpty() || contains(CollectionSchema.vocabularies_sxt)) {
+ if (this.isEmpty() || this.contains(CollectionSchema.vocabularies_sxt)) {
// write generic navigation
// there are no pre-defined solr fields for navigation because the vocabulary is generic
// we use dynamically allocated solr fields for this.
// It must be a multi-value string/token field, therefore we use _sxt extensions for the field names
-
+
// add to genericFacets the probabilistic categories
- String text = (String) doc.getFieldValue(CollectionSchema.text_t.getSolrFieldName());
- Map<String, String> classification = ProbabilisticClassifier.getClassification(text);
- for (Map.Entry<String, String> entry: classification.entrySet()) {
- Set<String> facetAttrbutes = new HashSet<>();
+ final String text = (String) doc.getFieldValue(CollectionSchema.text_t.getSolrFieldName());
+ final Map<String, String> classification = ProbabilisticClassifier.getClassification(text);
+ for (final Map.Entry<String, String> entry: classification.entrySet()) {
+ final Set<String> facetAttrbutes = new HashSet<>();
facetAttrbutes.add(entry.getValue());
genericFacets.put(entry.getKey(), facetAttrbutes);
}
-
+
// compute the document field values
- List<String> vocabularies = new ArrayList<>();
- for (Map.Entry<String, Set<String>> facet: genericFacets.entrySet()) {
- String facetName = facet.getKey();
- Set<String> facetValues = facet.getValue();
- int count = facetValues.size();
+ final List<String> vocabularies = new ArrayList<>();
+ for (final Map.Entry<String, Set<String>> facet: genericFacets.entrySet()) {
+ final String facetName = facet.getKey();
+ final Set<String> facetValues = facet.getValue();
+ final int count = facetValues.size();
if (count == 0) continue;
- int logcount = (int) (Math.log(count) / Math.log(2));
- Integer[] counts = new Integer[logcount + 1]; for (int i = 0; i <= logcount; i++) counts[i] = i;
+ final int logcount = (int) (Math.log(count) / Math.log(2));
+ final Integer[] counts = new Integer[logcount + 1]; for (int i = 0; i <= logcount; i++) counts[i] = i;
doc.setField(CollectionSchema.VOCABULARY_PREFIX + facetName + CollectionSchema.VOCABULARY_TERMS_SUFFIX, facetValues.toArray(new String[count]));
doc.setField(CollectionSchema.VOCABULARY_PREFIX + facetName + CollectionSchema.VOCABULARY_COUNT_SUFFIX, facetValues.size());
doc.setField(CollectionSchema.VOCABULARY_PREFIX + facetName + CollectionSchema.VOCABULARY_LOGCOUNT_SUFFIX, logcount);
doc.setField(CollectionSchema.VOCABULARY_PREFIX + facetName + CollectionSchema.VOCABULARY_LOGCOUNTS_SUFFIX, counts);
vocabularies.add(facetName);
}
- if (vocabularies.size() > 0) add(doc, CollectionSchema.vocabularies_sxt, vocabularies);
+ if (vocabularies.size() > 0) this.add(doc, CollectionSchema.vocabularies_sxt, vocabularies);
}
- remove(doc, CollectionSchema.synonyms_sxt); // delete old values
- if (this.isEmpty() || contains(CollectionSchema.synonyms_sxt)) {
- if (synonyms.size() > 0) add(doc, CollectionSchema.synonyms_sxt, synonyms);
+ this.remove(doc, CollectionSchema.synonyms_sxt); // delete old values
+ if (this.isEmpty() || this.contains(CollectionSchema.synonyms_sxt)) {
+ if (synonyms.size() > 0) this.add(doc, CollectionSchema.synonyms_sxt, synonyms);
}
}
@@ -1229,7 +1229,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
"" : WebgraphSchema.harvestkey_s.getSolrFieldName() + ":\"" + harvestkey + "\" AND ") +
WebgraphSchema.process_sxt.getSolrFieldName() + AbstractSolrConnector.CATCHALL_DTERM;
}
-
+
/**
* Performs post-processing steps for all entries that have a process tag assigned
* @param segment Solr segment. Must not be null.
@@ -1246,10 +1246,10 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
if (segment.fulltext().useWebgraph()) segment.fulltext().getWebgraphConnector().commit(false);
final CollectionConfiguration collection = segment.fulltext().getDefaultConfiguration();
final WebgraphConfiguration webgraph = segment.fulltext().getWebgraphConfiguration();
-
+
// calculate the number of documents to be processed
- String collection1query = collection1query(segment, harvestkey);
- String webgraphquery = webgraphquery(segment, harvestkey);
+ final String collection1query = collection1query(segment, harvestkey);
+ final String webgraphquery = webgraphquery(segment, harvestkey);
postprocessingRunning = true;
postprocessingStartTime = System.currentTimeMillis();
postprocessingActivity = "collecting counts";
@@ -1257,14 +1257,14 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
try {
postprocessingCollection1Count = (int) collectionConnector.getCountByQuery("{!cache=false}" + collection1query);
postprocessingWebgraphCount = segment.fulltext().useWebgraph() ? (int) segment.fulltext().getWebgraphConnector().getCountByQuery("{!cache=false}" + webgraphquery) : 0;
- } catch (IOException e) {
+ } catch (final IOException e) {
postprocessingCollection1Count = -1;
postprocessingWebgraphCount = -1;
}
postprocessingActivity = "create ranking map";
ConcurrentLog.info("CollectionConfiguration", postprocessingActivity);
- boolean shallComputeCR = (segment.fulltext().useWebgraph() &&
+ final boolean shallComputeCR = (segment.fulltext().useWebgraph() &&
((webgraph.contains(WebgraphSchema.source_id_s) && webgraph.contains(WebgraphSchema.source_cr_host_norm_i)) ||
(webgraph.contains(WebgraphSchema.target_id_s) && webgraph.contains(WebgraphSchema.target_cr_host_norm_i))) ||
(collection.contains(CollectionSchema.cr_host_count_i) &&
@@ -1278,29 +1278,29 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
ConcurrentLog.info("CollectionConfiguration", postprocessingActivity);
ReversibleScoreMap<String> collection1hosts;
try {
- Map<String, ReversibleScoreMap<String>> hostfacet = collectionConnector.getFacets("{!cache=false}" + collection1query, 10000000, CollectionSchema.host_s.getSolrFieldName());
+ final Map<String, ReversibleScoreMap<String>> hostfacet = collectionConnector.getFacets("{!cache=false}" + collection1query, 10000000, CollectionSchema.host_s.getSolrFieldName());
collection1hosts = hostfacet.get(CollectionSchema.host_s.getSolrFieldName());
} catch (final IOException e2) {
ConcurrentLog.logException(e2);
- collection1hosts = new ClusteredScoreMap<String>(true);
+ collection1hosts = new ClusteredScoreMap<>(true);
}
-
- rankings = createRankingMap(segment, rrCache, collectionConnector, collection1hosts);
+
+ rankings = this.createRankingMap(segment, rrCache, collectionConnector, collection1hosts);
} else {
- rankings = new ConcurrentHashMap<String, CRV>();
+ rankings = new ConcurrentHashMap<>();
}
-
+
// process all documents at the webgraph for the outgoing links of this document
final AtomicInteger allcount = new AtomicInteger(0);
if (segment.fulltext().useWebgraph() && shallComputeCR) {
- postprocessWebgraph(segment, webgraph, webgraphquery, rankings, allcount);
+ this.postprocessWebgraph(segment, webgraph, webgraphquery, rankings, allcount);
}
-
+
// process all documents in collection
- postprocessDocuments(segment, rrCache, harvestkey, byPartialUpdate, collectionConnector, collection,
+ this.postprocessDocuments(segment, rrCache, harvestkey, byPartialUpdate, collectionConnector, collection,
collection1query, rankings, allcount);
-
-
+
+
postprocessingCollection1Count = 0;
postprocessingWebgraphCount = 0;
postprocessingActivity = "postprocessing terminated";
@@ -1325,9 +1325,9 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
final String harvestkey, final boolean byPartialUpdate, final SolrConnector collectionConnector,
final CollectionConfiguration collection, final String collection1query, final Map<String, CRV> rankings,
final AtomicInteger allcount) {
- final Map<String, Long> hostExtentCache = new HashMap<String, Long>(); // a mapping from the host id to the number of documents which contain this host-id
+ final Map<String, Long> hostExtentCache = new HashMap<>(); // a mapping from the host id to the number of documents which contain this host-id
final Set<String> uniqueURLs = ConcurrentHashMap.newKeySet(); // will be used in a concurrent environment
- final Set<String> localOmitFields = new HashSet<String>();
+ final Set<String> localOmitFields = new HashSet<>();
localOmitFields.add(CollectionSchema.process_sxt.getSolrFieldName());
localOmitFields.add(CollectionSchema.harvestkey_s.getSolrFieldName());
final Collection<String> failids = ConcurrentHashMap.newKeySet();
@@ -1338,22 +1338,22 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
try {
// partitioning of the index, get a facet for a partitioning key
final long count = collectionConnector.getCountByQuery("{!cache=false}" + collection1query);
- String partitioningKey = CollectionSchema.responsetime_i.getSolrFieldName();
+ final String partitioningKey = CollectionSchema.responsetime_i.getSolrFieldName();
postprocessingActivity = "collecting " + count + " documents from the collection for harvestkey " + harvestkey + ", partitioned by " + partitioningKey;
if (count > 0) {
- Map<String, ReversibleScoreMap<String>> partitioningFacet = collectionConnector.getFacets("{!cache=false}" + collection1query, 100000, partitioningKey);
- ReversibleScoreMap<String> partitioning = partitioningFacet.get(partitioningKey);
- long emptyCount = collectionConnector.getCountByQuery("{!cache=false}" + "-" + partitioningKey + AbstractSolrConnector.CATCHALL_DTERM + " AND (" + collection1query + ")");
+ final Map<String, ReversibleScoreMap<String>> partitioningFacet = collectionConnector.getFacets("{!cache=false}" + collection1query, 100000, partitioningKey);
+ final ReversibleScoreMap<String> partitioning = partitioningFacet.get(partitioningKey);
+ final long emptyCount = collectionConnector.getCountByQuery("{!cache=false}" + "-" + partitioningKey + AbstractSolrConnector.CATCHALL_DTERM + " AND (" + collection1query + ")");
if (emptyCount > 0) partitioning.inc("", (int) emptyCount);
final long start = System.currentTimeMillis();
- List<String> querystrings = new ArrayList<>(partitioning.size());
- for (String partitioningValue: partitioning) {
- String partitioningQuery = "{!cache=false}" + ((partitioningValue.length() == 0) ?
+ final List<String> querystrings = new ArrayList<>(partitioning.size());
+ for (final String partitioningValue: partitioning) {
+ final String partitioningQuery = "{!cache=false}" + ((partitioningValue.length() == 0) ?
"-" + partitioningKey + AbstractSolrConnector.CATCHALL_DTERM + " AND (" + collection1query + ")" :
partitioningKey + ":" + partitioningValue + " AND (" + collection1query + ")");
querystrings.add(partitioningQuery);
}
- // start collection of documents
+ // start collection of documents
final int concurrency = Math.max(1, Math.min((int) (MemoryControl.available() / (100L * 1024L * 1024L)), Runtime.getRuntime().availableProcessors()));
//final int concurrency = 1;
final boolean reference_computation = this.contains(CollectionSchema.references_i) &&
@@ -1368,7 +1368,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
CollectionSchema.url_protocol_s.getSolrFieldName() + " asc" // sort on protocol to get http before https; that gives an opportunity to set http_unique_b flag to false
: null, // null sort is faster!
0, 100000000, Long.MAX_VALUE, concurrency + 1, concurrency, true,
- byPartialUpdate ?
+ byPartialUpdate ?
new String[]{
// the following fields are needed to perform the postprocessing
// and should only be used for partial updates; for full updates use a
@@ -1401,7 +1401,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
try {
while ((doc = docs.take()) != AbstractSolrConnector.POISON_DOCUMENT) {
// for each to-be-processed entry work on the process tag
- Collection<Object> proctags = doc.getFieldValues(CollectionSchema.process_sxt.getSolrFieldName());
+ final Collection<Object> proctags = doc.getFieldValues(CollectionSchema.process_sxt.getSolrFieldName());
final String u = (String) doc.getFieldValue(CollectionSchema.sku.getSolrFieldName());
final String i = (String) doc.getFieldValue(CollectionSchema.id.getSolrFieldName());
if (proctags == null || proctags.size() == 0) {
@@ -1410,20 +1410,20 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
continue;
}
try {
- DigestURL url = new DigestURL(u, ASCII.getBytes(i));
- byte[] id = url.hash();
- SolrInputDocument sid = byPartialUpdate ? new SolrInputDocument() : collection.toSolrInputDocument(doc, localOmitFields);
+ final DigestURL url = new DigestURL(u, ASCII.getBytes(i));
+ final byte[] id = url.hash();
+ final SolrInputDocument sid = byPartialUpdate ? new SolrInputDocument() : collection.toSolrInputDocument(doc, localOmitFields);
sid.setField(CollectionSchema.id.getSolrFieldName(), i);
- for (Object tag: proctags) try {
-
+ for (final Object tag: proctags) try {
+
// switch over tag types
- ProcessType tagtype = ProcessType.valueOf((String) tag);
-
+ final ProcessType tagtype = ProcessType.valueOf((String) tag);
+
if (tagtype == ProcessType.CITATION &&
collection.contains(CollectionSchema.cr_host_count_i) &&
collection.contains(CollectionSchema.cr_host_chance_d) &&
collection.contains(CollectionSchema.cr_host_norm_i)) {
- CRV crv = rankings.remove(ASCII.String(id)); // instead of 'get'ting the CRV, we also remove it because we will not need it again and free some memory here
+ final CRV crv = rankings.remove(ASCII.String(id)); // instead of 'get'ting the CRV, we also remove it because we will not need it again and free some memory here
if (crv != null) {
sid.setField(CollectionSchema.cr_host_count_i.getSolrFieldName(), crv.count);
sid.setField(CollectionSchema.cr_host_chance_d.getSolrFieldName(), crv.cr);
@@ -1431,27 +1431,27 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
proccount_citationchange.incrementAndGet();
}
}
-
+
if (tagtype == ProcessType.UNIQUE) {
- postprocessing_http_unique(segment, doc, sid, url);
- postprocessing_www_unique(segment, doc, sid, url);
- postprocessing_doublecontent(segment, uniqueURLs, doc, sid, url);
+ CollectionConfiguration.this.postprocessing_http_unique(segment, doc, sid, url);
+ CollectionConfiguration.this.postprocessing_www_unique(segment, doc, sid, url);
+ CollectionConfiguration.this.postprocessing_doublecontent(segment, uniqueURLs, doc, sid, url);
}
-
- } catch (IllegalArgumentException e) {}
-
+
+ } catch (final IllegalArgumentException e) {}
+
// compute references
if (reference_computation) {
- String hosthash = url.hosthash();
+ final String hosthash = url.hosthash();
if (!hostExtentCache.containsKey(hosthash)) {
- StringBuilder q = new StringBuilder();
+ final StringBuilder q = new StringBuilder();
q.append(CollectionSchema.host_id_s.getSolrFieldName()).append(":\"").append(hosthash).append("\" AND ").append(CollectionSchema.httpstatus_i.getSolrFieldName()).append(":200");
- long hostExtentCount = segment.fulltext().getDefaultConnector().getCountByQuery(q.toString());
+ final long hostExtentCount = segment.fulltext().getDefaultConnector().getCountByQuery(q.toString());
hostExtentCache.put(hosthash, hostExtentCount);
}
- if (postprocessing_references(rrCache, sid, url, hostExtentCache)) proccount_referencechange.incrementAndGet();
+ if (CollectionConfiguration.this.postprocessing_references(rrCache, sid, url, hostExtentCache)) proccount_referencechange.incrementAndGet();
}
-
+
// all processing steps checked, remove the processing and harvesting key
if (byPartialUpdate) {
sid.setField(CollectionSchema.process_sxt.getSolrFieldName(), null); // setting this to null will cause a removal when doing a partial update
@@ -1463,7 +1463,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
// with standard solr fields selected, the sid now contains the fields
// id, http_unique_b, www_unique_b, references_i, references_internal_i, references_external_i, references_exthosts_i, host_extent_i
// and the value for host_extent_i is by default 2147483647
-
+
// send back to index
//collectionConnector.deleteById(i);
if (byPartialUpdate) {
@@ -1471,7 +1471,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
} else {
collectionConnector.add(sid);
}
- long thiscount = proccount.incrementAndGet(); allcount.incrementAndGet();
+ final long thiscount = proccount.incrementAndGet(); allcount.incrementAndGet();
if (thiscount % 100 == 0) {
postprocessingActivity = "postprocessed " + thiscount + " from " + count + " collection documents; " +
(thiscount * 60000L / (System.currentTimeMillis() - start)) + " ppm; " +
@@ -1484,7 +1484,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
}
countcheck.incrementAndGet();
}
- } catch (InterruptedException e) {
+ } catch (final InterruptedException e) {
ConcurrentLog.logException(e);
}
}
@@ -1493,7 +1493,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
}
// wait for termination
for (int rewrite_start = 0; rewrite_start < concurrency; rewrite_start++) rewriteThread[rewrite_start].join();
-
+
if (failids.size() > 0) {
ConcurrentLog.info("CollectionConfiguration", "cleanup_processing: deleting " + failids.size() + " documents which have permanent execution fails");
collectionConnector.deleteByIds(failids);
@@ -1503,10 +1503,10 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
proccount_referencechange + " reference-count changes, " +
proccount_citationchange + " citation ranking changes.");
}
-
+
} catch (final InterruptedException e2) {
ConcurrentLog.warn("CollectionConfiguration", e2.getMessage(), e2);
- } catch (IOException e3) {
+ } catch (final IOException e3) {
ConcurrentLog.warn("CollectionConfiguration", e3.getMessage(), e3);
}
collectionConnector.commit(true); // make changes available directly to prevent that the process repeats again
@@ -1524,30 +1524,30 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
final Map<String, CRV> rankings, final AtomicInteger allcount) {
postprocessingActivity = "collecting host facets for webgraph cr calculation";
ConcurrentLog.info("CollectionConfiguration", postprocessingActivity);
- final Set<String> omitFields = new HashSet<String>();
+ final Set<String> omitFields = new HashSet<>();
omitFields.add(WebgraphSchema.process_sxt.getSolrFieldName());
omitFields.add(WebgraphSchema.harvestkey_s.getSolrFieldName());
-
+
// collect hosts from index which shall take part in citation computation
ReversibleScoreMap<String> webgraphhosts;
try {
- Map<String, ReversibleScoreMap<String>> hostfacet = segment.fulltext().getWebgraphConnector().getFacets(webgraphquery, 10000000, WebgraphSchema.source_host_s.getSolrFieldName());
+ final Map<String, ReversibleScoreMap<String>> hostfacet = segment.fulltext().getWebgraphConnector().getFacets(webgraphquery, 10000000, WebgraphSchema.source_host_s.getSolrFieldName());
webgraphhosts = hostfacet.get(WebgraphSchema.source_host_s.getSolrFieldName());
} catch (final IOException e2) {
ConcurrentLog.logException(e2);
- webgraphhosts = new ClusteredScoreMap<String>(true);
+ webgraphhosts = new ClusteredScoreMap<>(true);
}
try {
final long start = System.currentTimeMillis();
- for (String host: webgraphhosts.keyList(true)) {
+ for (final String host: webgraphhosts.keyList(true)) {
if (webgraphhosts.get(host) <= 0) continue;
final String hostfinal = host;
// select all webgraph edges and modify their cr value
postprocessingActivity = "writing cr values to webgraph for host " + host;
ConcurrentLog.info("CollectionConfiguration", postprocessingActivity);
- String patchquery = WebgraphSchema.source_host_s.getSolrFieldName() + ":\"" + host + "\" AND " + WebgraphSchema.process_sxt.getSolrFieldName() + AbstractSolrConnector.CATCHALL_DTERM;
+ final String patchquery = WebgraphSchema.source_host_s.getSolrFieldName() + ":\"" + host + "\" AND " + WebgraphSchema.process_sxt.getSolrFieldName() + AbstractSolrConnector.CATCHALL_DTERM;
final long count = segment.fulltext().getWebgraphConnector().getCountByQuery("{!cache=false}" + patchquery);
- int concurrency = Math.min((int) count, Math.max(1, Runtime.getRuntime().availableProcessors() / 4));
+ final int concurrency = Math.min((int) count, Math.max(1, Runtime.getRuntime().availableProcessors() / 4));
ConcurrentLog.info("CollectionConfiguration", "collecting " + count + " documents from the webgraph, concurrency = " + concurrency);
final BlockingQueue<SolrDocument> docs = segment.fulltext().getWebgraphConnector().concurrentDocumentsByQuery(
patchquery,
@@ -1556,7 +1556,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
// TODO: add field list and do partial updates
);
final AtomicInteger proccount = new AtomicInteger(0);
- Thread[] t = new Thread[concurrency];
+ final Thread[] t = new Thread[concurrency];
for (int i = 0; i < t.length; i++) {
t[i] = new Thread("CollectionConfiguration.postprocessing.webgraph-" + i) {
@Override
@@ -1565,44 +1565,44 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
try {
processloop: while ((doc = docs.take()) != AbstractSolrConnector.POISON_DOCUMENT) {
try {
- SolrInputDocument sid = webgraph.toSolrInputDocument(doc, omitFields);
- Collection<Object> proctags = doc.getFieldValues(WebgraphSchema.process_sxt.getSolrFieldName());
-
- for (Object tag: proctags) try {
-
+ final SolrInputDocument sid = webgraph.toSolrInputDocument(doc, omitFields);
+ final Collection<Object> proctags = doc.getFieldValues(WebgraphSchema.process_sxt.getSolrFieldName());
+
+ for (final Object tag: proctags) try {
+
// switch over tag types
- ProcessType tagtype = ProcessType.valueOf((String) tag);
-
+ final ProcessType tagtype = ProcessType.valueOf((String) tag);
+
// set cr values
if (tagtype == ProcessType.CITATION) {
if (segment.fulltext().useWebgraph() && webgraph.contains(WebgraphSchema.source_id_s) && webgraph.contains(WebgraphSchema.source_cr_host_norm_i)) {
id = (String) doc.getFieldValue(WebgraphSchema.source_id_s.getSolrFieldName());
- CRV crv = rankings.get(id);
+ final CRV crv = rankings.get(id);
if (crv != null) {
sid.setField(WebgraphSchema.source_cr_host_norm_i.getSolrFieldName(), crv.crn);
}
}
if (webgraph.contains(WebgraphSchema.target_id_s) && webgraph.contains(WebgraphSchema.target_cr_host_norm_i)) {
id = (String) doc.getFieldValue(WebgraphSchema.target_id_s.getSolrFieldName());
- CRV crv = rankings.get(id);
+ final CRV crv = rankings.get(id);
if (crv != null) {
sid.setField(WebgraphSchema.target_cr_host_norm_i.getSolrFieldName(), crv.crn);
}
}
}
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
ConcurrentLog.logException(e);
}
-
+
// write document back to index
try {
sid.removeField(WebgraphSchema.process_sxt.getSolrFieldName());
sid.removeField(WebgraphSchema.harvestkey_s.getSolrFieldName());
//segment.fulltext().getWebgraphConnector().deleteById((String) sid.getFieldValue(WebgraphSchema.id.getSolrFieldName()));
segment.fulltext().getWebgraphConnector().add(sid);
- } catch (SolrException e) {
+ } catch (final SolrException e) {
ConcurrentLog.logException(e);
- } catch (IOException e) {
+ } catch (final IOException e) {
ConcurrentLog.logException(e);
}
proccount.incrementAndGet();
@@ -1613,12 +1613,12 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
((System.currentTimeMillis() - start) * (count - proccount.get()) / proccount.get() / 60000) + " minutes remaining";
ConcurrentLog.info("CollectionConfiguration", postprocessingActivity);
}
- } catch (Throwable e) {
+ } catch (final Throwable e) {
ConcurrentLog.logException(e);
continue processloop;
}
}
- } catch (InterruptedException e) {
+ } catch (final InterruptedException e) {
ConcurrentLog.warn("CollectionConfiguration", e.getMessage(), e);
}
}
@@ -1628,8 +1628,8 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
for (int i = 0; i < t.length; i++) try {
t[i].join(10000);
if (t[i].isAlive()) t[i].interrupt();
- } catch (InterruptedException e) {}
-
+ } catch (final InterruptedException e) {}
+
if (count != proccount.get()) ConcurrentLog.warn("CollectionConfiguration", "ambiguous webgraph document count for host " + host + ": expected=" + count + ", counted=" + proccount);
}
} catch (final IOException e2) {
@@ -1643,43 +1643,43 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
* @param rrCache reference report cache for the segment
* @param collectionConnector default connector to the Solr segment
* @param collection1hosts hosts from index which shall take part in citation computation
- * @return the ranking map
+ * @return the ranking map
*/
private Map<String, CRV> createRankingMap(final Segment segment, final ReferenceReportCache rrCache,
final SolrConnector collectionConnector, ReversibleScoreMap<String> collection1hosts) {
- final Map<String, CRV> rankings = new ConcurrentHashMap<String, CRV>();
+ final Map<String, CRV> rankings = new ConcurrentHashMap<>();
try {
- int concurrency = Math.min(collection1hosts.size(), Runtime.getRuntime().availableProcessors());
+ final int concurrency = Math.min(collection1hosts.size(), Runtime.getRuntime().availableProcessors());
postprocessingActivity = "collecting cr for " + collection1hosts.size() + " hosts, concurrency = " + concurrency;
ConcurrentLog.info("CollectionConfiguration", postprocessingActivity);
int countcheck = 0;
- for (String host: collection1hosts.keyList(true)) {
+ for (final String host: collection1hosts.keyList(true)) {
// Patch the citation index for links with canonical tags.
// This shall fulfill the following requirement:
// If a document A links to B and B contains a 'canonical C', then the citation rank computation shall consider that A links to C and B does not link to C.
// To do so, we first must collect all canonical links, find all references to them, get the anchor list of the documents and patch the citation reference of these links
- String patchquery = CollectionSchema.host_s.getSolrFieldName() + ":" + host + " AND " + CollectionSchema.canonical_s.getSolrFieldName() + AbstractSolrConnector.CATCHALL_DTERM;
- long patchquerycount = collectionConnector.getCountByQuery("{!cache=false}" + patchquery);
- BlockingQueue<SolrDocument> documents_with_canonical_tag = collectionConnector.concurrentDocumentsByQuery(patchquery, CollectionSchema.url_chars_i.getSolrFieldName() + " asc", 0, 100000000, Long.MAX_VALUE, 20, 1, true,
+ final String patchquery = CollectionSchema.host_s.getSolrFieldName() + ":" + host + " AND " + CollectionSchema.canonical_s.getSolrFieldName() + AbstractSolrConnector.CATCHALL_DTERM;
+ final long patchquerycount = collectionConnector.getCountByQuery("{!cache=false}" + patchquery);
+ final BlockingQueue<SolrDocument> documents_with_canonical_tag = collectionConnector.concurrentDocumentsByQuery(patchquery, CollectionSchema.url_chars_i.getSolrFieldName() + " asc", 0, 100000000, Long.MAX_VALUE, 20, 1, true,
CollectionSchema.id.getSolrFieldName(), CollectionSchema.sku.getSolrFieldName(), CollectionSchema.canonical_s.getSolrFieldName());
SolrDocument doc_B;
int patchquerycountcheck = 0;
try {
while ((doc_B = documents_with_canonical_tag.take()) != AbstractSolrConnector.POISON_DOCUMENT) {
// find all documents which link to the canonical doc
- DigestURL doc_C_url = new DigestURL((String) doc_B.getFieldValue(CollectionSchema.canonical_s.getSolrFieldName()));
- byte[] doc_B_id = ASCII.getBytes(((String) doc_B.getFieldValue(CollectionSchema.id.getSolrFieldName())));
+ final DigestURL doc_C_url = new DigestURL((String) doc_B.getFieldValue(CollectionSchema.canonical_s.getSolrFieldName()));
+ final byte[] doc_B_id = ASCII.getBytes(((String) doc_B.getFieldValue(CollectionSchema.id.getSolrFieldName())));
// we remove all references to B, because these become references to C
if (segment.connectedCitation()) {
- ReferenceContainer<CitationReference> doc_A_ids = segment.urlCitation().remove(doc_B_id);
+ final ReferenceContainer<CitationReference> doc_A_ids = segment.urlCitation().remove(doc_B_id);
if (doc_A_ids == null) {
//System.out.println("*** document with canonical but no referrer: " + doc_B.getFieldValue(CollectionSchema.sku.getSolrFieldName()));
continue; // the document has a canonical tag but no referrer?
}
- Iterator<CitationReference> doc_A_ids_iterator = doc_A_ids.entries();
+ final Iterator<CitationReference> doc_A_ids_iterator = doc_A_ids.entries();
// for each of the referrer A of B, set A as a referrer of C
while (doc_A_ids_iterator.hasNext()) {
- CitationReference doc_A_citation = doc_A_ids_iterator.next();
+ final CitationReference doc_A_citation = doc_A_ids_iterator.next();
segment.urlCitation().add(doc_C_url.hash(), doc_A_citation);
}
}
@@ -1689,17 +1689,17 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
break;
}
}
- } catch (InterruptedException e) {
+ } catch (final InterruptedException e) {
ConcurrentLog.logException(e);
- } catch (SpaceExceededException e) {
+ } catch (final SpaceExceededException e) {
ConcurrentLog.logException(e);
}
if (patchquerycount != patchquerycountcheck) ConcurrentLog.warn("CollectionConfiguration", "ambiguous patchquery count for host " + host + ": expected=" + patchquerycount + ", counted=" + patchquerycountcheck);
-
+
// do the citation rank computation
if (collection1hosts.get(host) <= 0) continue;
// select all documents for each host
- CRHost crh = new CRHost(segment, rrCache, host, 0.85d, 6);
+ final CRHost crh = new CRHost(segment, rrCache, host, 0.85d, 6);
int convergence_attempts = 0;
while (convergence_attempts++ < 30) {
ConcurrentLog.info("CollectionConfiguration", "convergence step " + convergence_attempts + " for host " + host + " ...");
@@ -1711,7 +1711,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
}
ConcurrentLog.info("CollectionConfiguration", "convergence for host " + host + " after " + convergence_attempts + " steps");
// we have now the cr for all documents of a specific host; we store them for later use
- Map<String, CRV> crn = crh.normalize();
+ final Map<String, CRV> crn = crh.normalize();
//crh.log(crn);
rankings.putAll(crn); // accumulate this here for usage in document update later
if (MemoryControl.shortStatus()) {
@@ -1723,7 +1723,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
if (collection1hosts.size() != countcheck) ConcurrentLog.warn("CollectionConfiguration", "ambiguous host count: expected=" + collection1hosts.size() + ", counted=" + countcheck);
} catch (final IOException e2) {
ConcurrentLog.logException(e2);
- collection1hosts = new ClusteredScoreMap<String>(true);
+ collection1hosts = new ClusteredScoreMap<>(true);
}
return rankings;
}
@@ -1740,14 +1740,14 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
if (!this.contains(CollectionSchema.http_unique_b)) return;
if (!url.isHTTPS() && !url.isHTTP()) return;
try {
- DigestURL u = new DigestURL((url.isHTTP() ? "https://" : "http://") + url.urlstub(true, true));
- SolrDocument d = segment.fulltext().getDefaultConnector().getDocumentById(ASCII.String(u.hash()), CollectionSchema.http_unique_b.getSolrFieldName());
- set_unique_flag(CollectionSchema.http_unique_b, doc, sid, d);
+ final DigestURL u = new DigestURL((url.isHTTP() ? "https://" : "http://") + url.urlstub(true, true));
+ final SolrDocument d = segment.fulltext().getDefaultConnector().getDocumentById(ASCII.String(u.hash()), CollectionSchema.http_unique_b.getSolrFieldName());
+ this.set_unique_flag(CollectionSchema.http_unique_b, doc, sid, d);
} catch (final IOException e) {
ConcurrentLog.warn("CollectionConfiguration", "Failed to postProcess http_unique_b field" + e.getMessage() != null ? " : " + e.getMessage() : ".");
}
}
-
+
/**
* Search in the segment any document having the same url as doc but with or without the www prefix.
* Then updates accordingly the document www_unique_b field.
@@ -1760,123 +1760,123 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
if (!this.contains(CollectionSchema.www_unique_b)) return;
final String us = url.urlstub(true, true);
try {
- DigestURL u = new DigestURL(url.getProtocol() + (us.startsWith("www.") ? "://" + us.substring(4) : "://www." + us));
- SolrDocument d = segment.fulltext().getDefaultConnector().getDocumentById(ASCII.String(u.hash()), CollectionSchema.www_unique_b.getSolrFieldName());
- set_unique_flag(CollectionSchema.www_unique_b, doc, sid, d);
+ final DigestURL u = new DigestURL(url.getProtocol() + (us.startsWith("www.") ? "://" + us.substring(4) : "://www." + us));
+ final SolrDocument d = segment.fulltext().getDefaultConnector().getDocumentById(ASCII.String(u.hash()), CollectionSchema.www_unique_b.getSolrFieldName());
+ this.set_unique_flag(CollectionSchema.www_unique_b, doc, sid, d);
} catch (final IOException e) {
ConcurrentLog.warn("CollectionConfiguration", "Failed to postProcess www_unique_b field" + e.getMessage() != null ? " : " + e.getMessage() : ".");
}
}
-
+
private void set_unique_flag(CollectionSchema field, final SolrDocument doc, final SolrInputDocument sid, final SolrDocument d) {
- Object sb = doc.getFieldValue(field.getSolrFieldName());
- boolean sbb = sb != null && ((Boolean) sb).booleanValue();
- Object ob = d == null ? null : d.getFieldValue(field.getSolrFieldName());
- boolean obb = ob != null && ((Boolean) ob).booleanValue();
+ final Object sb = doc.getFieldValue(field.getSolrFieldName());
+ final boolean sbb = sb != null && ((Boolean) sb).booleanValue();
+ final Object ob = d == null ? null : d.getFieldValue(field.getSolrFieldName());
+ final boolean obb = ob != null && ((Boolean) ob).booleanValue();
if (sbb == obb) sid.setField(field.getSolrFieldName(), !sbb);
}
-
+
public void postprocessing_doublecontent(Segment segment, Set<String> uniqueURLs, SolrDocument doc, final SolrInputDocument sid, final DigestURL url) {
// FIND OUT IF THIS IS A DOUBLE DOCUMENT
// term to describe documents which are indexable:
// - no noindex in meta oder x-robots
// - no canonical-tag
- Conjunction ValidDocTermTemplate = new Conjunction();
+ final Conjunction ValidDocTermTemplate = new Conjunction();
ValidDocTermTemplate.addOperand(new LongLiteral(CollectionSchema.httpstatus_i, 200));
ValidDocTermTemplate.addOperand(new Disjunction(new Negation(new CatchallLiteral(CollectionSchema.canonical_equal_sku_b)), new BooleanLiteral(CollectionSchema.canonical_equal_sku_b, true)));
ValidDocTermTemplate.addOperand(new Negation(new LongLiteral(CollectionSchema.robots_i, 8))); // bit 3 (noindex)
ValidDocTermTemplate.addOperand(new Negation(new LongLiteral(CollectionSchema.robots_i, 24))); // bit 3 + 4 (noindex + nofollow)
ValidDocTermTemplate.addOperand(new Negation(new LongLiteral(CollectionSchema.robots_i, 512))); // bit 9 (noindex)
ValidDocTermTemplate.addOperand(new Negation(new LongLiteral(CollectionSchema.robots_i, 1536))); // bit 9 + 10 (noindex + nofollow)
-
- String urlhash = ASCII.String(url.hash());
- String hostid = url.hosthash();
- Disjunction dnf = new Disjunction();
- CollectionSchema[][] doccheckschema = new CollectionSchema[][]{
+
+ final String urlhash = ASCII.String(url.hash());
+ final String hostid = url.hosthash();
+ final Disjunction dnf = new Disjunction();
+ final CollectionSchema[][] doccheckschema = new CollectionSchema[][]{
{CollectionSchema.exact_signature_l, CollectionSchema.exact_signature_unique_b, CollectionSchema.exact_signature_copycount_i},
{CollectionSchema.fuzzy_signature_l, CollectionSchema.fuzzy_signature_unique_b, CollectionSchema.fuzzy_signature_copycount_i}};
- uniquecheck: for (CollectionSchema[] checkfields: doccheckschema) {
- CollectionSchema signaturefield = checkfields[0];
- CollectionSchema uniquefield = checkfields[1];
- CollectionSchema countfield = checkfields[2];
+ uniquecheck: for (final CollectionSchema[] checkfields: doccheckschema) {
+ final CollectionSchema signaturefield = checkfields[0];
+ final CollectionSchema uniquefield = checkfields[1];
+ final CollectionSchema countfield = checkfields[2];
if (this.contains(signaturefield) && this.contains(uniquefield) && this.contains(countfield)) {
// lookup the document with the same signature
- Long signature = (Long) doc.getFieldValue(signaturefield.getSolrFieldName());
+ final Long signature = (Long) doc.getFieldValue(signaturefield.getSolrFieldName());
if (signature == null) continue uniquecheck;
//con.addOperand(new Negation(new Literal(CollectionSchema.id, urlhash)));
//con.addOperand(new Literal(CollectionSchema.host_id_s, hostid));
dnf.addOperand(new LongLiteral(signaturefield, signature));
}
}
- Conjunction con = (Conjunction) ValidDocTermTemplate.clone();
+ final Conjunction con = (Conjunction) ValidDocTermTemplate.clone();
con.addOperand(dnf);
con.addOperand(new Negation(new StringLiteral(CollectionSchema.id, urlhash)));
con.addOperand(new StringLiteral(CollectionSchema.host_id_s, hostid));
- String query = con.toString();
+ final String query = con.toString();
SolrDocumentList docsAkk;
try {
docsAkk = segment.fulltext().getDefaultConnector().getDocumentListByQuery(query, null, 0, 1000,
CollectionSchema.id.getSolrFieldName(), CollectionSchema.exact_signature_l.getSolrFieldName(), CollectionSchema.fuzzy_signature_l.getSolrFieldName());
} catch (final IOException e) {
ConcurrentLog.logException(e);
- docsAkk = new SolrDocumentList();
+ docsAkk = new SolrDocumentList();
}
- if (docsAkk.getNumFound() > 0) uniquecheck: for (CollectionSchema[] checkfields: doccheckschema) {
- CollectionSchema signaturefield = checkfields[0];
- CollectionSchema uniquefield = checkfields[1];
- CollectionSchema countfield = checkfields[2];
+ if (docsAkk.getNumFound() > 0) uniquecheck: for (final CollectionSchema[] checkfields: doccheckschema) {
+ final CollectionSchema signaturefield = checkfields[0];
+ final CollectionSchema uniquefield = checkfields[1];
+ final CollectionSchema countfield = checkfields[2];
if (this.contains(signaturefield) && this.contains(uniquefield) && this.contains(countfield)) {
// lookup the document with the same signature
- Long signature = (Long) doc.getFieldValue(signaturefield.getSolrFieldName());
+ final Long signature = (Long) doc.getFieldValue(signaturefield.getSolrFieldName());
if (signature == null) continue uniquecheck;
- SolrDocumentList docs = new StringLiteral(signaturefield, signature.toString()).apply(docsAkk);
+ final SolrDocumentList docs = new StringLiteral(signaturefield, signature.toString()).apply(docsAkk);
if (docs.getNumFound() == 0) {
sid.setField(uniquefield.getSolrFieldName(), true);
sid.setField(countfield.getSolrFieldName(), 1);
} else {
boolean firstappearance = true;
- for (SolrDocument d: docs) {if (uniqueURLs.contains(d.getFieldValue(CollectionSchema.id.getSolrFieldName()))) firstappearance = false; break;}
+ for (final SolrDocument d: docs) {if (uniqueURLs.contains(d.getFieldValue(CollectionSchema.id.getSolrFieldName()))) firstappearance = false; break;}
sid.setField(uniquefield.getSolrFieldName(), firstappearance);
sid.setField(countfield.getSolrFieldName(), docs.getNumFound() + 1); // the current url was excluded from search but is included in count
}
}
}
-
+
// CHECK IF TITLE AND DESCRIPTION IS UNIQUE (this is by default not switched on)
// in case that the document has no status code 200, has a noindex attribute
// or a canonical tag which does not point to the document itself,
// then the unique-field is not written at all!
- Integer robots_i = this.contains(CollectionSchema.robots_i) ? (Integer) doc.getFieldValue(CollectionSchema.robots_i.getSolrFieldName()) : null;
- Integer httpstatus_i = this.contains(CollectionSchema.httpstatus_i) ? (Integer) doc.getFieldValue(CollectionSchema.httpstatus_i.getSolrFieldName()) : null;
- String canonical_s = this.contains(CollectionSchema.canonical_s) ? (String) doc.getFieldValue(CollectionSchema.canonical_s.getSolrFieldName()) : null;
- Boolean canonical_equal_sku_b = this.contains(CollectionSchema.canonical_equal_sku_b) ? (Boolean) doc.getFieldValue(CollectionSchema.canonical_equal_sku_b.getSolrFieldName()) : null;
+ final Integer robots_i = this.contains(CollectionSchema.robots_i) ? (Integer) doc.getFieldValue(CollectionSchema.robots_i.getSolrFieldName()) : null;
+ final Integer httpstatus_i = this.contains(CollectionSchema.httpstatus_i) ? (Integer) doc.getFieldValue(CollectionSchema.httpstatus_i.getSolrFieldName()) : null;
+ final String canonical_s = this.contains(CollectionSchema.canonical_s) ? (String) doc.getFieldValue(CollectionSchema.canonical_s.getSolrFieldName()) : null;
+ final Boolean canonical_equal_sku_b = this.contains(CollectionSchema.canonical_equal_sku_b) ? (Boolean) doc.getFieldValue(CollectionSchema.canonical_equal_sku_b.getSolrFieldName()) : null;
- CollectionSchema[][] metadatacheckschema = new CollectionSchema[][]{
+ final CollectionSchema[][] metadatacheckschema = new CollectionSchema[][]{
{CollectionSchema.title, CollectionSchema.title_exact_signature_l, CollectionSchema.title_unique_b},
{CollectionSchema.description_txt, CollectionSchema.description_exact_signature_l, CollectionSchema.description_unique_b}};
if (segment.fulltext().getDefaultConfiguration().contains(CollectionSchema.host_id_s) &&
(robots_i == null || (robots_i.intValue() & (1 << 9)) == 0 /*noindex in http X-ROBOTS*/ && (robots_i.intValue() & (1 << 3)) == 0 /*noindex in html metas*/ ) &&
(canonical_s == null || canonical_s.length() == 0 || (canonical_equal_sku_b != null && canonical_equal_sku_b.booleanValue()) || url.toNormalform(true).equals(canonical_s)) &&
(httpstatus_i == null || httpstatus_i.intValue() == 200)) {
- uniquecheck: for (CollectionSchema[] checkfields: metadatacheckschema) {
- CollectionSchema checkfield = checkfields[0];
- CollectionSchema signaturefield = checkfields[1];
- CollectionSchema uniquefield = checkfields[2];
+ uniquecheck: for (final CollectionSchema[] checkfields: metadatacheckschema) {
+ final CollectionSchema checkfield = checkfields[0];
+ final CollectionSchema signaturefield = checkfields[1];
+ final CollectionSchema uniquefield = checkfields[2];
if (this.contains(checkfield) && this.contains(signaturefield) && this.contains(uniquefield)) {
// lookup in the index within the same hosts for the same title or description
//String checkstring = checkfield == CollectionSchema.title ? document.dc_title() : document.dc_description();
- Long signature = (Long) doc.getFieldValue(signaturefield.getSolrFieldName());
+ final Long signature = (Long) doc.getFieldValue(signaturefield.getSolrFieldName());
if (signature == null) {
continue uniquecheck;
}
try {
- Conjunction doccountterm = (Conjunction) ValidDocTermTemplate.clone();
+ final Conjunction doccountterm = (Conjunction) ValidDocTermTemplate.clone();
doccountterm.addOperand(new Negation(new StringLiteral(CollectionSchema.id, urlhash)));
doccountterm.addOperand(new StringLiteral(CollectionSchema.host_id_s, hostid));
doccountterm.addOperand(new LongLiteral(signaturefield, signature));
- long doccount = segment.fulltext().getDefaultConnector().getCountByQuery("{!cache=false}" + doccountterm.toString());
+ final long doccount = segment.fulltext().getDefaultConnector().getCountByQuery("{!cache=false}" + doccountterm.toString());
sid.setField(uniquefield.getSolrFieldName(), doccount == 0);
} catch (final IOException e) {}
}
@@ -1889,19 +1889,19 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
if (!(this.contains(CollectionSchema.references_i) ||
this.contains(CollectionSchema.references_internal_i) ||
this.contains(CollectionSchema.references_external_i) || this.contains(CollectionSchema.references_exthosts_i))) return false;
- Integer all_old = sid == null ? null : (Integer) sid.getFieldValue(CollectionSchema.references_i.getSolrFieldName());
- Integer internal_old = sid == null ? null : (Integer) sid.getFieldValue(CollectionSchema.references_internal_i.getSolrFieldName());
- Integer external_old = sid == null ? null : (Integer) sid.getFieldValue(CollectionSchema.references_external_i.getSolrFieldName());
- Integer exthosts_old = sid == null ? null : (Integer) sid.getFieldValue(CollectionSchema.references_exthosts_i.getSolrFieldName());
- Integer hostextc_old = sid == null ? null : (Integer) sid.getFieldValue(CollectionSchema.host_extent_i.getSolrFieldName());
+ final Integer all_old = sid == null ? null : (Integer) sid.getFieldValue(CollectionSchema.references_i.getSolrFieldName());
+ final Integer internal_old = sid == null ? null : (Integer) sid.getFieldValue(CollectionSchema.references_internal_i.getSolrFieldName());
+ final Integer external_old = sid == null ? null : (Integer) sid.getFieldValue(CollectionSchema.references_external_i.getSolrFieldName());
+ final Integer exthosts_old = sid == null ? null : (Integer) sid.getFieldValue(CollectionSchema.references_exthosts_i.getSolrFieldName());
+ final Integer hostextc_old = sid == null ? null : (Integer) sid.getFieldValue(CollectionSchema.host_extent_i.getSolrFieldName());
try {
- ReferenceReport rr = rrCache.getReferenceReport(ASCII.String(url.hash()), false);
- List<String> internalIDs = new ArrayList<String>();
- HandleSet iids = rr.getInternallIDs();
- for (byte[] b: iids) internalIDs.add(ASCII.String(b));
-
+ final ReferenceReport rr = rrCache.getReferenceReport(ASCII.String(url.hash()), false);
+ final List<String> internalIDs = new ArrayList<>();
+ final HandleSet iids = rr.getInternallIDs();
+ for (final byte[] b: iids) internalIDs.add(ASCII.String(b));
+
boolean change = false;
- int all = rr.getExternalCount() + rr.getInternalCount();
+ final int all = rr.getExternalCount() + rr.getInternalCount();
if (this.contains(CollectionSchema.references_i) &&
(all_old == null || all_old.intValue() != all)) {
sid.setField(CollectionSchema.references_i.getSolrFieldName(), all);
@@ -1922,7 +1922,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
sid.setField(CollectionSchema.references_exthosts_i.getSolrFieldName(), rr.getExternalHostIDs().size());
change = true;
}
- Long hostExtent = hostExtentCount == null ? Long.MAX_VALUE : hostExtentCount.get(url.hosthash());
+ final Long hostExtent = hostExtentCount == null ? Long.MAX_VALUE : hostExtentCount.get(url.hosthash());
if (this.contains(CollectionSchema.host_extent_i) &&
(hostextc_old == null || hostextc_old.intValue() != hostExtent)) {
sid.setField(CollectionSchema.host_extent_i.getSolrFieldName(), hostExtent.intValue());
@@ -1933,19 +1933,19 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
}
return false;
}
-
-
-
+
+
+
private static final class CRV {
public double cr;
public int crn, count;
public CRV(final int count, final double cr, final int crn) {this.count = count; this.cr = cr; this.crn = crn;}
@Override
public String toString() {
- return "count=" + count + ", cr=" + cr + ", crn=" + crn;
+ return "count=" + this.count + ", cr=" + this.cr + ", crn=" + this.crn;
}
}
-
+
/**
* The CRHost class is a container for all ranking values of a specific host.
* Objects of that class are needed as an environment for repeated convergenceStep() computations,
@@ -1959,19 +1959,19 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
private final Map<String, double[]> crt;
private final int cr_host_count;
private final RowHandleMap internal_links_counter;
- private double damping;
- private int converge_eq_factor;
- private ReferenceReportCache rrCache;
+ private final double damping;
+ private final int converge_eq_factor;
+ private final ReferenceReportCache rrCache;
public CRHost(final Segment segment, final ReferenceReportCache rrCache, final String host, final double damping, final int converge_digits) {
this.segment = segment;
this.damping = damping;
this.rrCache = rrCache;
this.converge_eq_factor = (int) Math.pow(10.0d, converge_digits);
- SolrConnector connector = segment.fulltext().getDefaultConnector();
- this.crt = new ConcurrentHashMap<String, double[]>();
+ final SolrConnector connector = segment.fulltext().getDefaultConnector();
+ this.crt = new ConcurrentHashMap<>();
try {
// select all documents for each host
- BlockingQueue<String> ids = connector.concurrentIDsByQuery("{!cache=false raw f=" + CollectionSchema.host_s.getSolrFieldName() + "}" + host, CollectionSchema.url_chars_i.getSolrFieldName() + " asc", 0, 100000000, 86400000, 200, 1);
+ final BlockingQueue<String> ids = connector.concurrentIDsByQuery("{!cache=false raw f=" + CollectionSchema.host_s.getSolrFieldName() + "}" + host, CollectionSchema.url_chars_i.getSolrFieldName() + " asc", 0, 100000000, 86400000, 200, 1);
String id;
while ((id = ids.take()) != AbstractSolrConnector.POISON_ID) {
this.crt.put(id, new double[]{0.0d,0.0d}); //{old value, new value}
@@ -1983,8 +1983,8 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
} catch (final InterruptedException e2) {
}
this.cr_host_count = this.crt.size();
- double initval = 1.0d / cr_host_count;
- for (Map.Entry<String, double[]> entry: this.crt.entrySet()) entry.getValue()[0] = initval;
+ final double initval = 1.0d / this.cr_host_count;
+ for (final Map.Entry<String, double[]> entry: this.crt.entrySet()) entry.getValue()[0] = initval;
this.internal_links_counter = new RowHandleMap(12, Base64Order.enhancedCoder, 8, 100, "internal_links_counter");
}
/**
@@ -1992,31 +1992,31 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
* @return
*/
public Map<String, CRV> normalize() {
- final TreeMap<Double, List<byte[]>> reorder = new TreeMap<Double, List<byte[]>>();
- for (Map.Entry<String, double[]> entry: this.crt.entrySet()) {
- Double d = entry.getValue()[0];
+ final TreeMap<Double, List<byte[]>> reorder = new TreeMap<>();
+ for (final Map.Entry<String, double[]> entry: this.crt.entrySet()) {
+ final Double d = entry.getValue()[0];
List<byte[]> ds = reorder.get(d);
- if (ds == null) {ds = new ArrayList<byte[]>(); reorder.put(d, ds);}
+ if (ds == null) {ds = new ArrayList<>(); reorder.put(d, ds);}
ds.add(ASCII.getBytes(entry.getKey()));
}
int nextcount = (this.cr_host_count + 1) / 2;
int nextcrn = 0;
- Map<String, CRV> r = new HashMap<String, CRV>();
+ final Map<String, CRV> r = new HashMap<>();
while (reorder.size() > 0) {
int count = nextcount;
while (reorder.size() > 0 && count > 0) {
- Map.Entry<Double, List<byte[]>> next = reorder.pollFirstEntry();
- List<byte[]> ids = next.getValue();
+ final Map.Entry<Double, List<byte[]>> next = reorder.pollFirstEntry();
+ final List<byte[]> ids = next.getValue();
count -= ids.size();
- double cr = next.getKey();
- for (byte[] id: ids) r.put(ASCII.String(id), new CRV(this.cr_host_count, cr, nextcrn));
+ final double cr = next.getKey();
+ for (final byte[] id: ids) r.put(ASCII.String(id), new CRV(this.cr_host_count, cr, nextcrn));
}
nextcrn++;
nextcount = Math.max(1, (nextcount + count + 1) / 2);
}
// finally, increase the crn number in such a way that the maximum is always 10
- int inc = 11 - nextcrn; // nextcrn is +1
- for (Map.Entry<String, CRV> entry: r.entrySet()) entry.getValue().crn += inc;
+ final int inc = 11 - nextcrn; // nextcrn is +1
+ for (final Map.Entry<String, CRV> entry: r.entrySet()) entry.getValue().crn += inc;
return r;
}
/**
@@ -2026,11 +2026,11 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
@SuppressWarnings("unused")
public void log(final Map<byte[], CRV> rm) {
// print out all urls with their cr-values
- SolrConnector connector = segment.fulltext().getDefaultConnector();
- for (Map.Entry<byte[], CRV> entry: rm.entrySet()) {
+ final SolrConnector connector = this.segment.fulltext().getDefaultConnector();
+ for (final Map.Entry<byte[], CRV> entry: rm.entrySet()) {
if (entry == null || entry.getValue() == null) continue;
try {
- LoadTimeURL md = connector.getLoadTimeURL(ASCII.String(entry.getKey()));
+ final LoadTimeURL md = connector.getLoadTimeURL(ASCII.String(entry.getKey()));
ConcurrentLog.info("CollectionConfiguration", "CR for " + md.url);
ConcurrentLog.info("CollectionConfiguration", ">> " + entry.getValue().toString());
} catch (final IOException e) {
@@ -2049,15 +2049,15 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
public int getInternalLinks(final byte[] id) {
int il = (int) this.internal_links_counter.get(id);
if (il >= 0) return il;
- SolrConnector connector = this.segment.fulltext().getDefaultConnector();
+ final SolrConnector connector = this.segment.fulltext().getDefaultConnector();
if (connector == null) return 0;
try {
- SolrDocument doc = connector.getDocumentById(ASCII.String(id), CollectionSchema.inboundlinkscount_i.getSolrFieldName());
+ final SolrDocument doc = connector.getDocumentById(ASCII.String(id), CollectionSchema.inboundlinkscount_i.getSolrFieldName());
if (doc == null) {
this.internal_links_counter.put(id, 0);
return 0;
}
- Object x = doc.getFieldValue(CollectionSchema.inboundlinkscount_i.getSolrFieldName());
+ final Object x = doc.getFieldValue(CollectionSchema.inboundlinkscount_i.getSolrFieldName());
il = (x == null) ? 0 : (x instanceof Integer) ? ((Integer) x).intValue() : (x instanceof Long) ? ((Long) x).intValue() : 0;
this.internal_links_counter.put(id, il);
return il;
@@ -2075,18 +2075,18 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
*/
public boolean convergenceStep() {
boolean convergence = true;
- double df = (1.0d - damping) / this.cr_host_count;
+ final double df = (1.0d - this.damping) / this.cr_host_count;
try {
- for (Map.Entry<String, double[]> entry: this.crt.entrySet()) {
- String id = entry.getKey();
- ReferenceReport rr = this.rrCache.getReferenceReport(id, false);
+ for (final Map.Entry<String, double[]> entry: this.crt.entrySet()) {
+ final String id = entry.getKey();
+ final ReferenceReport rr = this.rrCache.getReferenceReport(id, false);
// sum up the cr of the internal links
- HandleSet iids = rr.getInternallIDs();
+ final HandleSet iids = rr.getInternallIDs();
double ncr = 0.0d;
- for (byte[] iid: iids) {
- int ilc = getInternalLinks(iid);
+ for (final byte[] iid: iids) {
+ final int ilc = this.getInternalLinks(iid);
if (ilc > 0) { // if (ilc == 0) then the reference report is wrong!
- double[] d = this.crt.get(ASCII.String(iid));
+ final double[] d = this.crt.get(ASCII.String(iid));
// d[] could be empty at some situations
if (d != null && d.length > 0) {
ncr += d[0] / ilc;
@@ -2097,12 +2097,12 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
}
}
}
- ncr = df + damping * ncr;
- if (convergence && !eqd(ncr, entry.getValue()[0])) convergence = false;
+ ncr = df + this.damping * ncr;
+ if (convergence && !this.eqd(ncr, entry.getValue()[0])) convergence = false;
entry.getValue()[1] = ncr;
}
// after the loop, replace the old value with the new value in crt
- for (Map.Entry<String, double[]> entry: this.crt.entrySet()) {
+ for (final Map.Entry<String, double[]> entry: this.crt.entrySet()) {
entry.getValue()[0] = entry.getValue()[1];
}
} catch (final IOException e) {
@@ -2119,7 +2119,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
return ((int) (a * this.converge_eq_factor)) == ((int) (b * this.converge_eq_factor));
}
}
-
+
/**
* this method compresses a list of protocol names to an indexed list.
* To do this, all 'http' entries are removed and considered as default.
@@ -2130,7 +2130,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
* @return a list of indexed protocol entries
*/
public static List<String> protocolList2indexedList(final List<String> protocol) {
- List<String> a = new ArrayList<String>();
+ final List<String> a = new ArrayList<>();
String p;
for (int i = 0; i < protocol.size(); i++) {
p = protocol.get(i);
@@ -2142,7 +2142,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
}
return a;
}
-
+
/**
* Uncompress indexed iplist of protocol names to a list of specified dimension.
* @param iplist indexed list typically produced by protocolList2indexedList
@@ -2150,13 +2150,13 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
* @return a list of protocol names
*/
public static List<String> indexedList2protocolList(Collection<Object> iplist, int dimension) {
- List<String> a = new ArrayList<String>(dimension);
+ final List<String> a = new ArrayList<>(dimension);
for (int i = 0; i < dimension; i++) a.add("http");
if (iplist == null) return a;
- for (Object ip : iplist) {
+ for (final Object ip : iplist) {
// ip format is 001-https but can be 4 digits 1011-https
- String indexedProtocol = ((String) ip);
- int i = indexedProtocol.indexOf('-');
+ final String indexedProtocol = ((String) ip);
+ final int i = indexedProtocol.indexOf('-');
/* Silently ignore badly formatted entry */
if(i > 0 && indexedProtocol.length() > (i + 1)) {
a.set(Integer.parseInt(indexedProtocol.substring(0, i)), indexedProtocol.substring(i+1));
@@ -2164,7 +2164,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
}
return a;
}
-
+
// /**
// * encode a string containing attributes from anchor rel properties binary:
// * bit 0: "me" contained in rel
@@ -2206,75 +2206,75 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
public FailDoc(final SolrDocument doc) {
try {
this.digestURL = new DigestURL((String) doc.getFieldValue(CollectionSchema.sku.getSolrFieldName()));
- } catch (MalformedURLException e) {
+ } catch (final MalformedURLException e) {
this.digestURL = null;
}
- this.collections = new HashMap<String, Pattern>();
- Collection<Object> c = doc.getFieldValues(CollectionSchema.collection_sxt.getSolrFieldName());
- if (c != null) for (Object cn: c) if (cn != null) this.collections.put((String) cn, QueryParams.catchall_pattern);
+ this.collections = new HashMap<>();
+ final Collection<Object> c = doc.getFieldValues(CollectionSchema.collection_sxt.getSolrFieldName());
+ if (c != null) for (final Object cn: c) if (cn != null) this.collections.put((String) cn, QueryParams.catchall_pattern);
this.failReason = (String) doc.getFieldValue(CollectionSchema.failreason_s.getSolrFieldName());
- String fts = (String) doc.getFieldValue(CollectionSchema.failtype_s.getSolrFieldName());
+ final String fts = (String) doc.getFieldValue(CollectionSchema.failtype_s.getSolrFieldName());
if (fts == null) ConcurrentLog.warn("CollectionConfiguration", "no fail type given for URL " + this.digestURL.toNormalform(true));
this.failType = fts == null ? FailType.fail : FailType.valueOf(fts);
this.httpstatus = (Integer) doc.getFieldValue(CollectionSchema.httpstatus_i.getSolrFieldName());
this.failtime = (Date) doc.getFieldValue(CollectionSchema.load_date_dt.getSolrFieldName());
- Integer cd = (Integer) doc.getFieldValue(CollectionSchema.crawldepth_i.getSolrFieldName());
+ final Integer cd = (Integer) doc.getFieldValue(CollectionSchema.crawldepth_i.getSolrFieldName());
this.crawldepth = cd == null ? 0 : cd.intValue();
}
public DigestURL getDigestURL() {
- return digestURL;
+ return this.digestURL;
}
public Map<String, Pattern> getCollections() {
- return collections;
+ return this.collections;
}
public String getFailReason() {
- return failReason;
+ return this.failReason;
}
public FailType getFailType() {
- return failType;
+ return this.failType;
}
public Date getFailDate() {
return this.failtime;
}
public int getHttpstatus() {
- return httpstatus;
+ return this.httpstatus;
}
public SolrInputDocument toSolr(CollectionConfiguration configuration) {
- boolean allAttr = configuration.isEmpty();
+ final boolean allAttr = configuration.isEmpty();
assert allAttr || configuration.contains(CollectionSchema.failreason_s);
-
+
final SolrInputDocument doc = new SolrInputDocument();
- String url = configuration.addURIAttributes(doc, allAttr, this.getDigestURL());
+ final String url = configuration.addURIAttributes(doc, allAttr, this.getDigestURL());
// content_type (mime) is defined a schema field and we rely on it in some queries like imagequery (makes it mandatory, no need to check)
CollectionSchema.content_type.add(doc, new String[]{Classification.url2mime(this.digestURL)});
- if (allAttr || configuration.contains(CollectionSchema.load_date_dt)) configuration.add(doc, CollectionSchema.load_date_dt, getFailDate());
+ if (allAttr || configuration.contains(CollectionSchema.load_date_dt)) configuration.add(doc, CollectionSchema.load_date_dt, this.getFailDate());
if (allAttr || configuration.contains(CollectionSchema.crawldepth_i)) configuration.add(doc, CollectionSchema.crawldepth_i, this.crawldepth);
-
+
// fail reason and status
if (allAttr || configuration.contains(CollectionSchema.failreason_s)) configuration.add(doc, CollectionSchema.failreason_s, this.getFailReason());
if (allAttr || configuration.contains(CollectionSchema.failtype_s)) configuration.add(doc, CollectionSchema.failtype_s, this.getFailType().name());
if (allAttr || configuration.contains(CollectionSchema.httpstatus_i)) configuration.add(doc, CollectionSchema.httpstatus_i, this.getHttpstatus());
if (allAttr || configuration.contains(CollectionSchema.collection_sxt) && this.getCollections() != null && this.getCollections().size() > 0) {
- List<String> cs = new ArrayList<String>();
- for (Map.Entry<String, Pattern> e: this.getCollections().entrySet()) {
+ final List<String> cs = new ArrayList<>();
+ for (final Map.Entry<String, Pattern> e: this.getCollections().entrySet()) {
if (e.getValue().matcher(url).matches()) cs.add(e.getKey());
}
configuration.add(doc, CollectionSchema.collection_sxt, cs);
}
// cr and postprocessing
- Set<ProcessType> processTypes = new LinkedHashSet<ProcessType>();
+ final Set<ProcessType> processTypes = new LinkedHashSet<>();
if (allAttr || (configuration.contains(CollectionSchema.cr_host_chance_d) && configuration.contains(CollectionSchema.cr_host_count_i) && configuration.contains(CollectionSchema.cr_host_norm_i))) {
processTypes.add(ProcessType.CITATION); // postprocessing needed
}
if (allAttr || configuration.contains(CollectionSchema.process_sxt)) {
- List<String> p = new ArrayList<String>();
- for (ProcessType t: processTypes) p.add(t.name());
+ final List<String> p = new ArrayList<>();
+ for (final ProcessType t: processTypes) p.add(t.name());
configuration.add(doc, CollectionSchema.process_sxt, p);
}
return doc;
}
-
+
}
-
+
}