refactoring

pull/1/head
Michael Peter Christen 11 years ago
parent 95780eed32
commit a37d067692

@ -30,6 +30,7 @@ import net.yacy.search.index.Fulltext;
import net.yacy.search.index.Segment.ReferenceReportCache;
import net.yacy.search.schema.HyperlinkEdge;
import net.yacy.search.schema.HyperlinkGraph;
import net.yacy.search.schema.HyperlinkType;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
import net.yacy.server.servletProperties;
@ -96,7 +97,7 @@ public class linkstructure {
int c = 0;
for (HyperlinkEdge e: hlg) {
prop.putJSON("edges_" + c + "_source", e.source.getPath());
prop.putJSON("edges_" + c + "_target", e.type.equals(HyperlinkEdge.Type.Outbound) ? e.target.toNormalform(true) : e.target.getPath());
prop.putJSON("edges_" + c + "_target", e.type.equals(HyperlinkType.Outbound) ? e.target.toNormalform(true) : e.target.getPath());
prop.putJSON("edges_" + c + "_type", e.type.name());
Integer depth_source = hlg.getDepth(e.source);
Integer depth_target = hlg.getDepth(e.target);

@ -23,15 +23,11 @@ package net.yacy.search.schema;
import net.yacy.cora.document.id.DigestURL;
public class HyperlinkEdge {
public static enum Type {
Inbound, InboundNofollow, Outbound, Dead;
}
public DigestURL source, target;
public Type type;
public HyperlinkType type;
public HyperlinkEdge(DigestURL source, DigestURL target, Type type) {
public HyperlinkEdge(DigestURL source, DigestURL target, HyperlinkType type) {
this.source = source;
this.target = target;
this.type = type;

@ -99,7 +99,7 @@ public class HyperlinkGraph implements Iterable<HyperlinkEdge> {
try {
DigestURL linkurl = new DigestURL(link, null);
String edgehash = ids + ASCII.String(linkurl.hash());
inboundEdges.put(edgehash, new HyperlinkEdge(from, linkurl, HyperlinkEdge.Type.Inbound));
inboundEdges.put(edgehash, new HyperlinkEdge(from, linkurl, HyperlinkType.Inbound));
if (stopURL != null && linkurl.equals(stopURL)) break retrieval;
} catch (MalformedURLException e) {}
}
@ -109,7 +109,7 @@ public class HyperlinkGraph implements Iterable<HyperlinkEdge> {
try {
DigestURL linkurl = new DigestURL(link, null);
String edgehash = ids + ASCII.String(linkurl.hash());
outboundEdges.put(edgehash, new HyperlinkEdge(from, linkurl, HyperlinkEdge.Type.Outbound));
outboundEdges.put(edgehash, new HyperlinkEdge(from, linkurl, HyperlinkType.Outbound));
if (stopURL != null && linkurl.equals(stopURL)) break retrieval;
} catch (MalformedURLException e) {}
}
@ -128,7 +128,7 @@ public class HyperlinkGraph implements Iterable<HyperlinkEdge> {
edge = i.next();
if (errorDocs.containsKey(edge.getValue().target.toNormalform(true))) {
i.remove();
edge.getValue().type = HyperlinkEdge.Type.Dead;
edge.getValue().type = HyperlinkType.Dead;
errorEdges.put(edge.getKey(), edge.getValue());
}
}
@ -137,7 +137,7 @@ public class HyperlinkGraph implements Iterable<HyperlinkEdge> {
edge = i.next();
if (errorDocs.containsKey(edge.getValue().target.toNormalform(true))) {
i.remove();
edge.getValue().type = HyperlinkEdge.Type.Dead;
edge.getValue().type = HyperlinkType.Dead;
errorEdges.put(edge.getKey(), edge.getValue());
}
}
@ -170,7 +170,7 @@ public class HyperlinkGraph implements Iterable<HyperlinkEdge> {
String path = edge.source.getPath();
if (ROOTFNS.contains(path)) {
if (!this.depths.containsKey(edge.source)) this.depths.put(edge.source, 0);
if (edge.type == HyperlinkEdge.Type.Inbound && !this.depths.containsKey(edge.target)) this.depths.put(edge.target, 1);
if (edge.type == HyperlinkType.Inbound && !this.depths.containsKey(edge.target)) this.depths.put(edge.target, 1);
nodes.add(edge.source);
nextnodes.add(edge.target);
remaining--;
@ -187,7 +187,7 @@ public class HyperlinkGraph implements Iterable<HyperlinkEdge> {
for (HyperlinkEdge edge: this.edges.values()) {
if (nodes.contains(edge.source)) {
if (!this.depths.containsKey(edge.source)) this.depths.put(edge.source, depth);
if (edge.type == HyperlinkEdge.Type.Inbound && !this.depths.containsKey(edge.target)) this.depths.put(edge.target, depth + 1);
if (edge.type == HyperlinkType.Inbound && !this.depths.containsKey(edge.target)) this.depths.put(edge.target, depth + 1);
nextnodes.add(edge.target);
remaining--;
found = true;

@ -0,0 +1,25 @@
/**
* HyperlinkType
* Copyright 2014 by Michael Peter Christen
* First released 04.04.2014 at http://yacy.net
*
* This library is free software; you can redistribute it and/or
* 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/>.
*/
package net.yacy.search.schema;
public enum HyperlinkType {
Inbound, InboundNofollow, Outbound, Dead;
}
Loading…
Cancel
Save