- * Software Heritage
+ * Software Heritage
* graph contains multiple node types (contents, directories, revisions, ...) and restricting
- * the traversal to specific node types is necessary for many querying operations: use cases.
+ * the traversal to specific node types is necessary for many querying operations:
+ * use cases.
*
* @author The Software Heritage developers
*/
@@ -16,8 +16,8 @@
public class AllowedEdges {
/**
* 2D boolean matrix storing access rights for all combination of src/dst node types (first
- * dimension is source, second dimension is destination), when edge restriction is not enforced
- * this array is set to null for early bypass.
+ * dimension is source, second dimension is destination), when edge restriction is not enforced this
+ * array is set to null for early bypass.
*/
public boolean[][] restrictedTo;
/** Graph on which edge restriction is performed */
@@ -27,8 +27,9 @@
* Constructor.
*
* @param graph the graph on which to perform edge restriction
- * @param edgesFmt a formatted string describing allowed edges
+ * @param edgesFmt a formatted string describing allowed
+ * edges
*/
public AllowedEdges(Graph graph, String edgesFmt) {
this.graph = graph;
diff --git a/java/src/main/java/org/softwareheritage/graph/Entry.java b/java/src/main/java/org/softwareheritage/graph/Entry.java
--- a/java/src/main/java/org/softwareheritage/graph/Entry.java
+++ b/java/src/main/java/org/softwareheritage/graph/Entry.java
@@ -140,16 +140,14 @@
close();
}
- public void visit_paths(String direction, String edgesFmt,
- long srcNodeId) {
+ public void visit_paths(String direction, String edgesFmt, long srcNodeId) {
open();
Traversal t = new Traversal(this.graph, direction, edgesFmt);
t.visitPathsVisitor(srcNodeId, this::writePath);
close();
}
- public void walk(String direction, String edgesFmt, String algorithm,
- long srcNodeId, long dstNodeId) {
+ public void walk(String direction, String edgesFmt, String algorithm, long srcNodeId, long dstNodeId) {
open();
Traversal t = new Traversal(this.graph, direction, edgesFmt);
for (Long nodeId : t.walk(srcNodeId, dstNodeId, algorithm)) {
@@ -158,8 +156,7 @@
close();
}
- public void walk_type(String direction, String edgesFmt, String algorithm,
- long srcNodeId, String dst) {
+ public void walk_type(String direction, String edgesFmt, String algorithm, long srcNodeId, String dst) {
open();
Node.Type dstType = Node.Type.fromStr(dst);
Traversal t = new Traversal(this.graph, direction, edgesFmt);
@@ -169,8 +166,7 @@
close();
}
- public void random_walk(String direction, String edgesFmt, int retries,
- long srcNodeId, long dstNodeId) {
+ public void random_walk(String direction, String edgesFmt, int retries, long srcNodeId, long dstNodeId) {
open();
Traversal t = new Traversal(this.graph, direction, edgesFmt);
for (Long nodeId : t.randomWalk(srcNodeId, dstNodeId, retries)) {
@@ -179,8 +175,7 @@
close();
}
- public void random_walk_type(String direction, String edgesFmt, int retries,
- long srcNodeId, String dst) {
+ public void random_walk_type(String direction, String edgesFmt, int retries, long srcNodeId, String dst) {
open();
Node.Type dstType = Node.Type.fromStr(dst);
Traversal t = new Traversal(this.graph, direction, edgesFmt);
diff --git a/java/src/main/java/org/softwareheritage/graph/Graph.java b/java/src/main/java/org/softwareheritage/graph/Graph.java
--- a/java/src/main/java/org/softwareheritage/graph/Graph.java
+++ b/java/src/main/java/org/softwareheritage/graph/Graph.java
@@ -13,13 +13,13 @@
* Main class storing the compressed graph and node id mappings.
*
* The compressed graph is stored using the WebGraph
- * ecosystem. Additional mappings are necessary because Software Heritage uses string based persistent
- * identifiers (SWHID) while WebGraph uses integers internally. These two mappings (long id ↔
- * SWHID) are used for the input (users refer to the graph using SWHID) and the output (convert back to
- * SWHID for users results). However, since graph traversal can be restricted depending on the node
- * type (see {@link AllowedEdges}), a long id → node type map is stored as well to avoid a full
- * SWHID lookup.
+ * ecosystem. Additional mappings are necessary because Software Heritage uses string based persistent
+ * identifiers (SWHID) while WebGraph uses integers internally. These two mappings (long id
+ * ↔ SWHID) are used for the input (users refer to the graph using SWHID) and the output
+ * (convert back to SWHID for users results). However, since graph traversal can be restricted
+ * depending on the node type (see {@link AllowedEdges}), a long id → node type map is stored
+ * as well to avoid a full SWHID lookup.
*
* @author The Software Heritage developers
* @see org.softwareheritage.graph.AllowedEdges
@@ -59,8 +59,8 @@
this.nodeIdMap = new NodeIdMap(path, numNodes());
}
- protected Graph(ImmutableGraph graph, ImmutableGraph graphTransposed,
- String path, NodeIdMap nodeIdMap, NodeTypesMap nodeTypesMap) {
+ protected Graph(ImmutableGraph graph, ImmutableGraph graphTransposed, String path, NodeIdMap nodeIdMap,
+ NodeTypesMap nodeTypesMap) {
this.graph = graph;
this.graphTransposed = graphTransposed;
this.path = path;
@@ -127,8 +127,8 @@
* Returns lazy iterator of successors of a node.
*
* @param nodeId node specified as a long id
- * @return lazy iterator of successors of the node, specified as a WebGraph LazyLongIterator
+ * @return lazy iterator of successors of the node, specified as a
+ * WebGraph LazyLongIterator
*/
@Override
public LazyLongIterator successors(long nodeId) {
@@ -140,8 +140,8 @@
*
* @param nodeId node specified as a long id
* @param allowedEdges the specification of which edges can be traversed
- * @return lazy iterator of successors of the node, specified as a WebGraph LazyLongIterator
+ * @return lazy iterator of successors of the node, specified as a
+ * WebGraph LazyLongIterator
*/
public LazyLongIterator successors(long nodeId, AllowedEdges allowedEdges) {
if (allowedEdges.restrictedTo == null) {
@@ -164,7 +164,8 @@
@Override
public long skip(final long n) {
long i;
- for (i = 0; i < n && nextLong() != -1; i++) ;
+ for (i = 0; i < n && nextLong() != -1; i++)
+ ;
return i;
}
};
@@ -186,8 +187,8 @@
* Returns lazy iterator of predecessors of a node.
*
* @param nodeId node specified as a long id
- * @return lazy iterator of predecessors of the node, specified as a WebGraph LazyLongIterator
+ * @return lazy iterator of predecessors of the node, specified as a
+ * WebGraph LazyLongIterator
*/
public LazyLongIterator predecessors(long nodeId) {
return this.transpose().successors(nodeId);
diff --git a/java/src/main/java/org/softwareheritage/graph/Node.java b/java/src/main/java/org/softwareheritage/graph/Node.java
--- a/java/src/main/java/org/softwareheritage/graph/Node.java
+++ b/java/src/main/java/org/softwareheritage/graph/Node.java
@@ -13,7 +13,7 @@
public class Node {
/**
* Software Heritage graph node types, as described in the
- * data model.
+ * data model.
*/
public enum Type {
/** Content node */
@@ -93,8 +93,8 @@
}
/**
- * Parses SWH node type possible values from formatted string (see the API
+ * Parses SWH node type possible values from formatted string (see the
+ * API
* syntax).
*
* @param strFmtType node types represented as a formatted string
diff --git a/java/src/main/java/org/softwareheritage/graph/SWHID.java b/java/src/main/java/org/softwareheritage/graph/SWHID.java
--- a/java/src/main/java/org/softwareheritage/graph/SWHID.java
+++ b/java/src/main/java/org/softwareheritage/graph/SWHID.java
@@ -5,8 +5,8 @@
import org.apache.commons.codec.binary.Hex;
/**
- * A Software Heritage persistent identifier (SWHID), see persistent
+ * A Software Heritage persistent identifier (SWHID), see persistent
* identifier documentation.
*
* @author The Software Heritage developers
@@ -43,19 +43,14 @@
/**
* Creates a SWHID from a compact binary representation.
*
- * The binary format is specified in the Python module
- * swh.graph.swhid:str_to_bytes .
+ * The binary format is specified in the Python module swh.graph.swhid:str_to_bytes .
*/
public static SWHID fromBytes(byte[] input) {
byte[] digest = new byte[20];
System.arraycopy(input, 2, digest, 0, digest.length);
- String swhidStr = String.format(
- "swh:%d:%s:%s",
- input[0],
- Node.Type.fromInt(input[1]).toString().toLowerCase(),
- Hex.encodeHexString(digest)
- );
+ String swhidStr = String.format("swh:%d:%s:%s", input[0], Node.Type.fromInt(input[1]).toString().toLowerCase(),
+ Hex.encodeHexString(digest));
return new SWHID(swhidStr);
}
@@ -83,17 +78,16 @@
/**
* Converts SWHID to a compact binary representation.
*
- * The binary format is specified in the Python module
- * swh.graph.swhid:str_to_bytes .
+ * The binary format is specified in the Python module swh.graph.swhid:str_to_bytes .
*/
public byte[] toBytes() {
byte[] bytes = new byte[22];
byte[] digest;
- bytes[0] = (byte) 1; // namespace version
- bytes[1] = (byte) Node.Type.toInt(this.type); // SWHID type
+ bytes[0] = (byte) 1; // namespace version
+ bytes[1] = (byte) Node.Type.toInt(this.type); // SWHID type
try {
- digest = Hex.decodeHex(this.swhid.substring(10)); // SHA1 hash
+ digest = Hex.decodeHex(this.swhid.substring(10)); // SHA1 hash
System.arraycopy(digest, 0, bytes, 2, digest.length);
} catch (DecoderException e) {
throw new IllegalArgumentException("invalid hex sequence in SWHID: " + this.swhid);
diff --git a/java/src/main/java/org/softwareheritage/graph/Stats.java b/java/src/main/java/org/softwareheritage/graph/Stats.java
--- a/java/src/main/java/org/softwareheritage/graph/Stats.java
+++ b/java/src/main/java/org/softwareheritage/graph/Stats.java
@@ -7,8 +7,8 @@
/**
* Statistics on the compressed graph.
*
- * These statistics are not computed but directly read from WebGraph generated .stats and .properties files.
+ * These statistics are not computed but directly read from
+ * WebGraph generated .stats and .properties files.
*
* @author The Software Heritage developers
*/
diff --git a/java/src/main/java/org/softwareheritage/graph/Traversal.java b/java/src/main/java/org/softwareheritage/graph/Traversal.java
--- a/java/src/main/java/org/softwareheritage/graph/Traversal.java
+++ b/java/src/main/java/org/softwareheritage/graph/Traversal.java
@@ -38,8 +38,9 @@
*
* @param graph graph used in the traversal
* @param direction a string (either "forward" or "backward") specifying edge orientation
- * @param edgesFmt a formatted string describing allowed edges
+ * @param edgesFmt a formatted string describing allowed
+ * edges
*/
public Traversal(Graph graph, String direction, String edgesFmt) {
if (!direction.matches("forward|backward")) {
@@ -93,7 +94,7 @@
long neighborsCnt = 0;
nbEdgesAccessed += graph.outdegree(currentNodeId);
LazyLongIterator it = graph.successors(currentNodeId, edges);
- for (long neighborNodeId; (neighborNodeId = it.nextLong()) != -1; ) {
+ for (long neighborNodeId; (neighborNodeId = it.nextLong()) != -1;) {
neighborsCnt++;
if (!visited.contains(neighborNodeId)) {
stack.push(neighborNodeId);
@@ -120,13 +121,12 @@
}
/**
- * Push version of {@link #neighbors}: will fire passed callback on each
- * neighbor.
+ * Push version of {@link #neighbors}: will fire passed callback on each neighbor.
*/
public void neighborsVisitor(long srcNodeId, NodeIdConsumer cb) {
this.nbEdgesAccessed = graph.outdegree(srcNodeId);
LazyLongIterator it = graph.successors(srcNodeId, edges);
- for (long neighborNodeId; (neighborNodeId = it.nextLong()) != -1; ) {
+ for (long neighborNodeId; (neighborNodeId = it.nextLong()) != -1;) {
cb.accept(neighborNodeId);
}
}
@@ -144,8 +144,7 @@
}
/**
- * Push version of {@link #visitNodes}: will fire passed callback on each
- * visited node.
+ * Push version of {@link #visitNodes}: will fire passed callback on each visited node.
*/
public void visitNodesVisitor(long srcNodeId, NodeIdConsumer nodeCb, EdgeIdConsumer edgeCb) {
Stack stack = new Stack<>();
@@ -162,7 +161,7 @@
nbEdgesAccessed += graph.outdegree(currentNodeId);
LazyLongIterator it = graph.successors(currentNodeId, edges);
- for (long neighborNodeId; (neighborNodeId = it.nextLong()) != -1; ) {
+ for (long neighborNodeId; (neighborNodeId = it.nextLong()) != -1;) {
if (edgeCb != null) {
edgeCb.accept(currentNodeId, neighborNodeId);
}
@@ -192,8 +191,8 @@
}
/**
- * Push version of {@link #visitPaths}: will fire passed callback on each
- * discovered (complete) path.
+ * Push version of {@link #visitPaths}: will fire passed callback on each discovered (complete)
+ * path.
*/
public void visitPathsVisitor(long srcNodeId, PathConsumer cb) {
Stack currentPath = new Stack<>();
@@ -213,15 +212,13 @@
return paths;
}
- private void visitPathsInternalVisitor(long currentNodeId,
- Stack currentPath,
- PathConsumer cb) {
+ private void visitPathsInternalVisitor(long currentNodeId, Stack currentPath, PathConsumer cb) {
currentPath.push(currentNodeId);
long visitedNeighbors = 0;
nbEdgesAccessed += graph.outdegree(currentNodeId);
LazyLongIterator it = graph.successors(currentNodeId, edges);
- for (long neighborNodeId; (neighborNodeId = it.nextLong()) != -1; ) {
+ for (long neighborNodeId; (neighborNodeId = it.nextLong()) != -1;) {
visitPathsInternalVisitor(neighborNodeId, currentPath, cb);
visitedNeighbors++;
}
@@ -235,8 +232,8 @@
}
/**
- * Performs a graph traversal with backtracking, and returns the first
- * found path from source to destination.
+ * Performs a graph traversal with backtracking, and returns the first found path from source to
+ * destination.
*
* @param srcNodeId source node
* @param dst destination (either a node or a node type)
@@ -260,29 +257,27 @@
}
/**
- * Performs a random walk (picking a random successor at each step) from
- * source to destination.
+ * Performs a random walk (picking a random successor at each step) from source to destination.
*
* @param srcNodeId source node
* @param dst destination (either a node or a node type)
- * @return found path as a list of node ids or an empty path to indicate
- * that no suitable path have been found
+ * @return found path as a list of node ids or an empty path to indicate that no suitable path have
+ * been found
*/
public ArrayList randomWalk(long srcNodeId, T dst) {
return randomWalk(srcNodeId, dst, 0);
}
/**
- * Performs a stubborn random walk (picking a random successor at each
- * step) from source to destination. The walk is "stubborn" in the sense
- * that it will not give up the first time if a satisfying target node is
- * found, but it will retry up to a limited amount of times.
+ * Performs a stubborn random walk (picking a random successor at each step) from source to
+ * destination. The walk is "stubborn" in the sense that it will not give up the first time if a
+ * satisfying target node is found, but it will retry up to a limited amount of times.
*
* @param srcNodeId source node
* @param dst destination (either a node or a node type)
* @param retries number of times to retry; 0 means no retries (single walk)
- * @return found path as a list of node ids or an empty path to indicate
- * that no suitable path have been found
+ * @return found path as a list of node ids or an empty path to indicate that no suitable path have
+ * been found
*/
public ArrayList randomWalk(long srcNodeId, T dst, int retries) {
long curNodeId = srcNodeId;
@@ -311,17 +306,16 @@
if (found) {
return path;
- } else if (retries > 0) { // try again
+ } else if (retries > 0) { // try again
return randomWalk(srcNodeId, dst, retries - 1);
- } else { // not found and no retries left
+ } else { // not found and no retries left
path.clear();
return path;
}
}
/**
- * Randomly choose an element from an iterator over Longs using reservoir
- * sampling
+ * Randomly choose an element from an iterator over Longs using reservoir sampling
*
* @param elements iterator over selection domain
* @return randomly chosen element or -1 if no suitable element was found
@@ -330,7 +324,7 @@
long curPick = -1;
long seenCandidates = 0;
- for (long element; (element = elements.nextLong()) != -1; ) {
+ for (long element; (element = elements.nextLong()) != -1;) {
seenCandidates++;
if (Math.round(rng.nextFloat() * (seenCandidates - 1)) == 0) {
curPick = element;
@@ -362,7 +356,7 @@
nbEdgesAccessed += graph.outdegree(currentNodeId);
LazyLongIterator it = graph.successors(currentNodeId, edges);
- for (long neighborNodeId; (neighborNodeId = it.nextLong()) != -1; ) {
+ for (long neighborNodeId; (neighborNodeId = it.nextLong()) != -1;) {
if (!visited.contains(neighborNodeId)) {
stack.push(neighborNodeId);
visited.add(neighborNodeId);
@@ -396,7 +390,7 @@
nbEdgesAccessed += graph.outdegree(currentNodeId);
LazyLongIterator it = graph.successors(currentNodeId, edges);
- for (long neighborNodeId; (neighborNodeId = it.nextLong()) != -1; ) {
+ for (long neighborNodeId; (neighborNodeId = it.nextLong()) != -1;) {
if (!visited.contains(neighborNodeId)) {
queue.add(neighborNodeId);
visited.add(neighborNodeId);
@@ -471,7 +465,7 @@
curNode = lhsStack.poll();
nbEdgesAccessed += graph.outdegree(curNode);
LazyLongIterator it = graph.successors(curNode, edges);
- for (long neighborNodeId; (neighborNodeId = it.nextLong()) != -1; ) {
+ for (long neighborNodeId; (neighborNodeId = it.nextLong()) != -1;) {
if (!lhsVisited.contains(neighborNodeId)) {
if (rhsVisited.contains(neighborNodeId))
return neighborNodeId;
@@ -485,7 +479,7 @@
curNode = rhsStack.poll();
nbEdgesAccessed += graph.outdegree(curNode);
LazyLongIterator it = graph.successors(curNode, edges);
- for (long neighborNodeId; (neighborNodeId = it.nextLong()) != -1; ) {
+ for (long neighborNodeId; (neighborNodeId = it.nextLong()) != -1;) {
if (!rhsVisited.contains(neighborNodeId)) {
if (lhsVisited.contains(neighborNodeId))
return neighborNodeId;
@@ -501,24 +495,21 @@
public interface NodeIdConsumer extends LongConsumer {
/**
- * Callback for incrementally receiving node identifiers during a graph
- * visit.
+ * Callback for incrementally receiving node identifiers during a graph visit.
*/
void accept(long nodeId);
}
public interface EdgeIdConsumer {
/**
- * Callback for incrementally receiving edge identifiers during a graph
- * visit.
+ * Callback for incrementally receiving edge identifiers during a graph visit.
*/
void accept(long srcId, long dstId);
}
public interface PathConsumer extends Consumer> {
/**
- * Callback for incrementally receiving node paths (made of node
- * identifiers) during a graph visit.
+ * Callback for incrementally receiving node paths (made of node identifiers) during a graph visit.
*/
void accept(ArrayList path);
}
diff --git a/java/src/main/java/org/softwareheritage/graph/benchmark/BFS.java b/java/src/main/java/org/softwareheritage/graph/benchmark/BFS.java
--- a/java/src/main/java/org/softwareheritage/graph/benchmark/BFS.java
+++ b/java/src/main/java/org/softwareheritage/graph/benchmark/BFS.java
@@ -15,7 +15,6 @@
import java.io.File;
import java.io.IOException;
-
public class BFS {
private final static Logger LOGGER = LoggerFactory.getLogger(BFS.class);
private final ImmutableGraph graph;
@@ -27,17 +26,13 @@
private static JSAPResult parse_args(String[] args) {
JSAPResult config = null;
try {
- SimpleJSAP jsap = new SimpleJSAP(
- BFS.class.getName(),
- "",
+ SimpleJSAP jsap = new SimpleJSAP(BFS.class.getName(), "",
new Parameter[]{
- new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'g', "graph", "Basename of the compressed graph"),
+ new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'g',
+ "graph", "Basename of the compressed graph"),
- new FlaggedOption("useTransposed", JSAP.BOOLEAN_PARSER, "false", JSAP.NOT_REQUIRED,
- 'T', "transposed", "Use transposed graph (default: false)"),
- }
- );
+ new FlaggedOption("useTransposed", JSAP.BOOLEAN_PARSER, "false", JSAP.NOT_REQUIRED, 'T',
+ "transposed", "Use transposed graph (default: false)"),});
config = jsap.parse(args);
if (jsap.messagePrinted()) {
@@ -84,7 +79,8 @@
pl.start("Starting breadth-first visit...");
for (long i = 0; i < n; i++) {
- if (visited.getBoolean(i)) continue;
+ if (visited.getBoolean(i))
+ continue;
queue.enqueue(Longs.toByteArray(i));
visited.set(i);
diff --git a/java/src/main/java/org/softwareheritage/graph/benchmark/Benchmark.java b/java/src/main/java/org/softwareheritage/graph/benchmark/Benchmark.java
--- a/java/src/main/java/org/softwareheritage/graph/benchmark/Benchmark.java
+++ b/java/src/main/java/org/softwareheritage/graph/benchmark/Benchmark.java
@@ -48,9 +48,8 @@
"nb-nodes", "Number of random nodes used to do the benchmark."),
new FlaggedOption("logFile", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'l',
"log-file", "File name to output CSV format benchmark log."),
- new FlaggedOption("seed", JSAP.LONG_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 's',
- "seed", "Random generator seed."),
- });
+ new FlaggedOption("seed", JSAP.LONG_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 's', "seed",
+ "Random generator seed."),});
JSAPResult config = jsap.parse(args);
if (jsap.messagePrinted()) {
@@ -69,12 +68,8 @@
public void createCSVLogFile() throws IOException {
try (Writer csvLog = new BufferedWriter(new FileWriter(args.logFile))) {
StringJoiner csvHeader = new StringJoiner(CSV_SEPARATOR);
- csvHeader.add("use case name")
- .add("SWHID")
- .add("number of edges accessed")
- .add("traversal timing")
- .add("swhid2node timing")
- .add("node2swhid timing");
+ csvHeader.add("use case name").add("SWHID").add("number of edges accessed").add("traversal timing")
+ .add("swhid2node timing").add("node2swhid timing");
csvLog.write(csvHeader.toString() + "\n");
}
}
@@ -86,13 +81,12 @@
* @param graph compressed graph used in the benchmark
* @param nodeIds node ids to use as starting point for the endpoint traversal
* @param operation endpoint function to benchmark
- * @param dstFmt destination formatted string as described in the API
+ * @param dstFmt destination formatted string as described in the
+ * API
* @param algorithm traversal algorithm used in endpoint call (either "dfs" or "bfs")
*/
public void timeEndpoint(String useCaseName, Graph graph, long[] nodeIds,
- Function operation, String dstFmt, String algorithm)
- throws IOException {
+ Function operation, String dstFmt, String algorithm) throws IOException {
ArrayList timings = new ArrayList<>();
ArrayList timingsNormalized = new ArrayList<>();
ArrayList nbEdgesAccessed = new ArrayList<>();
@@ -107,9 +101,7 @@
: operation.apply(new Endpoint.Input(swhid, dstFmt, algorithm));
StringJoiner csvLine = new StringJoiner(CSV_SEPARATOR);
- csvLine.add(useCaseName)
- .add(swhid.toString())
- .add(Long.toString(output.meta.nbEdgesAccessed))
+ csvLine.add(useCaseName).add(swhid.toString()).add(Long.toString(output.meta.nbEdgesAccessed))
.add(Double.toString(output.meta.timings.traversal))
.add(Double.toString(output.meta.timings.swhid2node))
.add(Double.toString(output.meta.timings.node2swhid));
@@ -142,7 +134,7 @@
* Same as {@link #timeEndpoint} but without destination or algorithm specified to endpoint call.
*/
public void timeEndpoint(String useCaseName, Graph graph, long[] nodeIds,
- Function operation) throws IOException {
+ Function operation) throws IOException {
timeEndpoint(useCaseName, graph, nodeIds, operation, null, null);
}
diff --git a/java/src/main/java/org/softwareheritage/graph/benchmark/Browsing.java b/java/src/main/java/org/softwareheritage/graph/benchmark/Browsing.java
--- a/java/src/main/java/org/softwareheritage/graph/benchmark/Browsing.java
+++ b/java/src/main/java/org/softwareheritage/graph/benchmark/Browsing.java
@@ -8,8 +8,8 @@
import java.io.IOException;
/**
- * Benchmark Software Heritage browsing
+ * Benchmark Software Heritage
+ * browsing
* use-cases scenarios.
*
* @author The Software Heritage developers
@@ -27,10 +27,8 @@
Graph graph = new Graph(bench.args.graphPath);
- long[] dirNodeIds =
- bench.args.random.generateNodeIdsOfType(graph, bench.args.nbNodes, Node.Type.DIR);
- long[] revNodeIds =
- bench.args.random.generateNodeIdsOfType(graph, bench.args.nbNodes, Node.Type.REV);
+ long[] dirNodeIds = bench.args.random.generateNodeIdsOfType(graph, bench.args.nbNodes, Node.Type.DIR);
+ long[] revNodeIds = bench.args.random.generateNodeIdsOfType(graph, bench.args.nbNodes, Node.Type.REV);
Endpoint dirEndpoint = new Endpoint(graph, "forward", "dir:cnt,dir:dir");
Endpoint revEndpoint = new Endpoint(graph, "forward", "rev:rev");
diff --git a/java/src/main/java/org/softwareheritage/graph/benchmark/Provenance.java b/java/src/main/java/org/softwareheritage/graph/benchmark/Provenance.java
--- a/java/src/main/java/org/softwareheritage/graph/benchmark/Provenance.java
+++ b/java/src/main/java/org/softwareheritage/graph/benchmark/Provenance.java
@@ -7,8 +7,8 @@
import java.io.IOException;
/**
- * Benchmark Software Heritage provenance
+ * Benchmark Software Heritage
+ * provenance
* use-cases scenarios.
*
* @author The Software Heritage developers
@@ -34,18 +34,12 @@
System.out.println("Used " + bench.args.nbNodes + " random nodes (results are in seconds):");
bench.createCSVLogFile();
- bench.timeEndpoint(
- "commit provenance (dfs)", graph, nodeIds, commitProvenanceEndpoint::walk, "rev", "dfs");
- bench.timeEndpoint(
- "commit provenance (bfs)", graph, nodeIds, commitProvenanceEndpoint::walk, "rev", "bfs");
- bench.timeEndpoint(
- "complete commit provenance", graph, nodeIds, commitProvenanceEndpoint::leaves);
-
- bench.timeEndpoint(
- "origin provenance (dfs)", graph, nodeIds, originProvenanceEndpoint::walk, "ori", "dfs");
- bench.timeEndpoint(
- "origin provenance (bfs)", graph, nodeIds, originProvenanceEndpoint::walk, "ori", "bfs");
- bench.timeEndpoint(
- "complete origin provenance", graph, nodeIds, originProvenanceEndpoint::leaves);
+ bench.timeEndpoint("commit provenance (dfs)", graph, nodeIds, commitProvenanceEndpoint::walk, "rev", "dfs");
+ bench.timeEndpoint("commit provenance (bfs)", graph, nodeIds, commitProvenanceEndpoint::walk, "rev", "bfs");
+ bench.timeEndpoint("complete commit provenance", graph, nodeIds, commitProvenanceEndpoint::leaves);
+
+ bench.timeEndpoint("origin provenance (dfs)", graph, nodeIds, originProvenanceEndpoint::walk, "ori", "dfs");
+ bench.timeEndpoint("origin provenance (bfs)", graph, nodeIds, originProvenanceEndpoint::walk, "ori", "bfs");
+ bench.timeEndpoint("complete origin provenance", graph, nodeIds, originProvenanceEndpoint::leaves);
}
}
diff --git a/java/src/main/java/org/softwareheritage/graph/benchmark/Vault.java b/java/src/main/java/org/softwareheritage/graph/benchmark/Vault.java
--- a/java/src/main/java/org/softwareheritage/graph/benchmark/Vault.java
+++ b/java/src/main/java/org/softwareheritage/graph/benchmark/Vault.java
@@ -7,9 +7,9 @@
import java.io.IOException;
/**
- * Benchmark Software Heritage vault
- * use-case scenario.
+ * Benchmark Software Heritage
+ * vault use-case
+ * scenario.
*
* @author The Software Heritage developers
*/
diff --git a/java/src/main/java/org/softwareheritage/graph/experiments/forks/FindCommonAncestor.java b/java/src/main/java/org/softwareheritage/graph/experiments/forks/FindCommonAncestor.java
--- a/java/src/main/java/org/softwareheritage/graph/experiments/forks/FindCommonAncestor.java
+++ b/java/src/main/java/org/softwareheritage/graph/experiments/forks/FindCommonAncestor.java
@@ -19,16 +19,12 @@
private static JSAPResult parse_args(String[] args) {
JSAPResult config = null;
try {
- SimpleJSAP jsap = new SimpleJSAP(
- FindCommonAncestor.class.getName(),
- "",
- new Parameter[] {
- new FlaggedOption("edgesFmt", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'e', "edges", "Edges constraints"),
- new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'g', "graph", "Basename of the compressed graph"),
- }
- );
+ SimpleJSAP jsap = new SimpleJSAP(FindCommonAncestor.class.getName(), "",
+ new Parameter[]{
+ new FlaggedOption("edgesFmt", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'e',
+ "edges", "Edges constraints"),
+ new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'g',
+ "graph", "Basename of the compressed graph"),});
config = jsap.parse(args);
if (jsap.messagePrinted()) {
diff --git a/java/src/main/java/org/softwareheritage/graph/experiments/forks/FindPath.java b/java/src/main/java/org/softwareheritage/graph/experiments/forks/FindPath.java
--- a/java/src/main/java/org/softwareheritage/graph/experiments/forks/FindPath.java
+++ b/java/src/main/java/org/softwareheritage/graph/experiments/forks/FindPath.java
@@ -22,14 +22,9 @@
private static JSAPResult parse_args(String[] args) {
JSAPResult config = null;
try {
- SimpleJSAP jsap = new SimpleJSAP(
- FindPath.class.getName(),
- "",
- new Parameter[] {
- new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'g', "graph", "Basename of the compressed graph"),
- }
- );
+ SimpleJSAP jsap = new SimpleJSAP(FindPath.class.getName(), "",
+ new Parameter[]{new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
+ 'g', "graph", "Basename of the compressed graph"),});
config = jsap.parse(args);
if (jsap.messagePrinted()) {
@@ -42,8 +37,7 @@
}
private boolean nodeIsEmptySnapshot(Long node) {
- if (this.emptySnapshot == null
- && this.graph.getNodeType(node) == Node.Type.SNP
+ if (this.emptySnapshot == null && this.graph.getNodeType(node) == Node.Type.SNP
&& this.graph.outdegree(node) == 0) {
System.err.println("Found empty snapshot: " + node);
this.emptySnapshot = node;
@@ -51,10 +45,9 @@
return node.equals(this.emptySnapshot);
}
- private Boolean shouldVisit(Long node){
+ private Boolean shouldVisit(Long node) {
Node.Type nt = this.graph.getNodeType(node);
- if (nt != Node.Type.REV && nt != Node.Type.REL
- && nt != Node.Type.SNP && nt != Node.Type.ORI) {
+ if (nt != Node.Type.REV && nt != Node.Type.REL && nt != Node.Type.SNP && nt != Node.Type.ORI) {
return false;
}
if (this.nodeIsEmptySnapshot(node))
@@ -76,7 +69,8 @@
final LazyLongIterator iterator = graph.successors(currentNode);
long succ;
while ((succ = iterator.nextLong()) != -1) {
- if (!shouldVisit(succ) || visited.contains(succ)) continue;
+ if (!shouldVisit(succ) || visited.contains(succ))
+ continue;
visited.add(succ);
queue.add(succ);
parentNode.put(succ, currentNode);
@@ -121,8 +115,7 @@
System.out.format("%d ", n);
}
System.out.println();
- }
- else {
+ } else {
System.out.println("null");
}
}
diff --git a/java/src/main/java/org/softwareheritage/graph/experiments/forks/ForkCC.java b/java/src/main/java/org/softwareheritage/graph/experiments/forks/ForkCC.java
--- a/java/src/main/java/org/softwareheritage/graph/experiments/forks/ForkCC.java
+++ b/java/src/main/java/org/softwareheritage/graph/experiments/forks/ForkCC.java
@@ -9,7 +9,6 @@
import it.unimi.dsi.logging.ProgressLogger;
import org.softwareheritage.graph.Graph;
import org.softwareheritage.graph.Node;
-import org.softwareheritage.graph.benchmark.BFS;
import java.io.File;
import java.io.FileNotFoundException;
@@ -26,20 +25,16 @@
private static JSAPResult parse_args(String[] args) {
JSAPResult config = null;
try {
- SimpleJSAP jsap = new SimpleJSAP(
- ForkCC.class.getName(),
- "",
- new Parameter[] {
- new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'g', "graph", "Basename of the compressed graph"),
- new FlaggedOption("whitelistPath", JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED,
- 't', "whitelist", "Whitelist of origins"),
- new FlaggedOption("includeRootDir", JSAP.BOOLEAN_PARSER, "false", JSAP.NOT_REQUIRED,
- 'R', "includerootdir", "Include root directory (default: false)"),
- new FlaggedOption("outdir", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'o', "outdir", "Directory where to put the results"),
- }
- );
+ SimpleJSAP jsap = new SimpleJSAP(ForkCC.class.getName(), "",
+ new Parameter[]{
+ new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'g',
+ "graph", "Basename of the compressed graph"),
+ new FlaggedOption("whitelistPath", JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED, 't',
+ "whitelist", "Whitelist of origins"),
+ new FlaggedOption("includeRootDir", JSAP.BOOLEAN_PARSER, "false", JSAP.NOT_REQUIRED, 'R',
+ "includerootdir", "Include root directory (default: false)"),
+ new FlaggedOption("outdir", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'o',
+ "outdir", "Directory where to put the results"),});
config = jsap.parse(args);
if (jsap.messagePrinted()) {
@@ -86,8 +81,7 @@
}
private boolean nodeIsEmptySnapshot(Long node) {
- if (this.emptySnapshot == null
- && this.graph.getNodeType(node) == Node.Type.SNP
+ if (this.emptySnapshot == null && this.graph.getNodeType(node) == Node.Type.SNP
&& this.graph.outdegree(node) == 0) {
System.err.println("Found empty snapshot: " + node);
this.emptySnapshot = node;
@@ -128,7 +122,8 @@
ArrayList> components = new ArrayList<>();
for (long i = 0; i < n; i++) {
- if (!shouldVisit(i) || this.graph.getNodeType(i) == Node.Type.DIR) continue;
+ if (!shouldVisit(i) || this.graph.getNodeType(i) == Node.Type.DIR)
+ continue;
ArrayList component = new ArrayList<>();
@@ -139,8 +134,7 @@
queue.dequeue(byteBuf);
final long currentNode = Longs.fromByteArray(byteBuf);
Node.Type cur_nt = this.graph.getNodeType(currentNode);
- if (cur_nt == Node.Type.ORI
- && (this.whitelist == null || this.whitelist.getBoolean(currentNode))) {
+ if (cur_nt == Node.Type.ORI && (this.whitelist == null || this.whitelist.getBoolean(currentNode))) {
// TODO: add a check that the origin has >=1 non-empty snapshot
component.add(currentNode);
}
@@ -148,8 +142,10 @@
final LazyLongIterator iterator = graph.successors(currentNode);
long succ;
while ((succ = iterator.nextLong()) != -1) {
- if (!shouldVisit(succ)) continue;
- if (this.graph.getNodeType(succ) == Node.Type.DIR && cur_nt != Node.Type.REV) continue;
+ if (!shouldVisit(succ))
+ continue;
+ if (this.graph.getNodeType(succ) == Node.Type.DIR && cur_nt != Node.Type.REV)
+ continue;
visited.set(succ);
queue.enqueue(Longs.toByteArray(succ));
}
@@ -238,7 +234,7 @@
}
ProgressLogger logger = new ProgressLogger();
- //noinspection ResultOfMethodCallIgnored
+ // noinspection ResultOfMethodCallIgnored
new File(outdirPath).mkdirs();
try {
ArrayList> components = forkCc.compute(logger);
diff --git a/java/src/main/java/org/softwareheritage/graph/experiments/forks/ForkCliques.java b/java/src/main/java/org/softwareheritage/graph/experiments/forks/ForkCliques.java
--- a/java/src/main/java/org/softwareheritage/graph/experiments/forks/ForkCliques.java
+++ b/java/src/main/java/org/softwareheritage/graph/experiments/forks/ForkCliques.java
@@ -32,18 +32,14 @@
private static JSAPResult parse_args(String[] args) {
JSAPResult config = null;
try {
- SimpleJSAP jsap = new SimpleJSAP(
- ForkCliques.class.getName(),
- "",
+ SimpleJSAP jsap = new SimpleJSAP(ForkCliques.class.getName(), "",
new Parameter[]{
- new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'g', "graph", "Basename of the compressed graph"),
- new FlaggedOption("whitelistPath", JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED,
- 't', "whitelist", "Whitelist of origins"),
- new FlaggedOption("outdir", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'o', "outdir", "Directory where to put the results"),
- }
- );
+ new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'g',
+ "graph", "Basename of the compressed graph"),
+ new FlaggedOption("whitelistPath", JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED, 't',
+ "whitelist", "Whitelist of origins"),
+ new FlaggedOption("outdir", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'o',
+ "outdir", "Directory where to put the results"),});
config = jsap.parse(args);
if (jsap.messagePrinted()) {
@@ -72,8 +68,7 @@
Node.Type nt = this.graph.getNodeType(succ);
if (nt == Node.Type.DIR || nt == Node.Type.CNT)
continue;
- if (nt == Node.Type.ORI
- && (this.whitelist == null || this.whitelist.getBoolean(succ))) {
+ if (nt == Node.Type.ORI && (this.whitelist == null || this.whitelist.getBoolean(succ))) {
res.add(succ);
} else {
stack.push(succ);
@@ -97,7 +92,7 @@
if (this.graph.getNodeType(succ) == Node.Type.REV)
return false;
}
- return true;
+ return true;
}
static private String fingerprint(ArrayList cluster) {
@@ -180,7 +175,7 @@
Scanner scanner;
try {
scanner = new Scanner(new File(path));
- while(scanner.hasNextLong()) {
+ while (scanner.hasNextLong()) {
whitelist.set(scanner.nextLong());
}
System.err.println("Whitelist loaded.");
@@ -214,7 +209,7 @@
ProgressLogger logger = new ProgressLogger(rootLogger);
ArrayList> components = forkCliques.compute(logger);
- //noinspection ResultOfMethodCallIgnored
+ // noinspection ResultOfMethodCallIgnored
new File(outdirPath).mkdirs();
try {
printDistribution(components, new Formatter(outdirPath + "/distribution.txt"));
diff --git a/java/src/main/java/org/softwareheritage/graph/experiments/forks/ListEmptyOrigins.java b/java/src/main/java/org/softwareheritage/graph/experiments/forks/ListEmptyOrigins.java
--- a/java/src/main/java/org/softwareheritage/graph/experiments/forks/ListEmptyOrigins.java
+++ b/java/src/main/java/org/softwareheritage/graph/experiments/forks/ListEmptyOrigins.java
@@ -16,14 +16,9 @@
private static JSAPResult parse_args(String[] args) {
JSAPResult config = null;
try {
- SimpleJSAP jsap = new SimpleJSAP(
- ListEmptyOrigins.class.getName(),
- "",
- new Parameter[]{
- new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'g', "graph", "Basename of the compressed graph"),
- }
- );
+ SimpleJSAP jsap = new SimpleJSAP(ListEmptyOrigins.class.getName(), "",
+ new Parameter[]{new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
+ 'g', "graph", "Basename of the compressed graph"),});
config = jsap.parse(args);
if (jsap.messagePrinted()) {
@@ -61,8 +56,7 @@
private boolean nodeIsEmptySnapshot(Long node) {
System.err.println(this.graph.getNodeType(node) + " " + this.graph.outdegree(node) + " " + node);
- if (this.emptySnapshot == null
- && this.graph.getNodeType(node) == Node.Type.SNP
+ if (this.emptySnapshot == null && this.graph.getNodeType(node) == Node.Type.SNP
&& this.graph.outdegree(node) == 0) {
System.err.println("Found empty snapshot: " + node);
this.emptySnapshot = node;
@@ -75,7 +69,8 @@
ArrayList bad = new ArrayList<>();
for (long i = 0; i < n; i++) {
Node.Type nt = this.graph.getNodeType(i);
- if (nt != Node.Type.ORI) continue;
+ if (nt != Node.Type.ORI)
+ continue;
final LazyLongIterator iterator = graph.successors(i);
long succ;
diff --git a/java/src/main/java/org/softwareheritage/graph/experiments/multiplicationfactor/GenDistribution.java b/java/src/main/java/org/softwareheritage/graph/experiments/multiplicationfactor/GenDistribution.java
--- a/java/src/main/java/org/softwareheritage/graph/experiments/multiplicationfactor/GenDistribution.java
+++ b/java/src/main/java/org/softwareheritage/graph/experiments/multiplicationfactor/GenDistribution.java
@@ -18,23 +18,19 @@
private static JSAPResult parse_args(String[] args) {
JSAPResult config = null;
try {
- SimpleJSAP jsap = new SimpleJSAP(
- GenDistribution.class.getName(),
- "",
+ SimpleJSAP jsap = new SimpleJSAP(GenDistribution.class.getName(), "",
new Parameter[]{
- new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'g', "graph", "Basename of the compressed graph"),
- new FlaggedOption("srcType", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 's', "srctype", "Source node type"),
- new FlaggedOption("dstType", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'd', "dsttype", "Destination node type"),
- new FlaggedOption("edgesFmt", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'e', "edges", "Edges constraints"),
-
- new FlaggedOption("numThreads", JSAP.INTEGER_PARSER, "128", JSAP.NOT_REQUIRED,
- 't', "numthreads", "Number of threads"),
- }
- );
+ new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'g',
+ "graph", "Basename of the compressed graph"),
+ new FlaggedOption("srcType", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 's',
+ "srctype", "Source node type"),
+ new FlaggedOption("dstType", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'd',
+ "dsttype", "Destination node type"),
+ new FlaggedOption("edgesFmt", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'e',
+ "edges", "Edges constraints"),
+
+ new FlaggedOption("numThreads", JSAP.INTEGER_PARSER, "128", JSAP.NOT_REQUIRED, 't',
+ "numthreads", "Number of threads"),});
config = jsap.parse(args);
if (jsap.messagePrinted()) {
@@ -117,10 +113,8 @@
}
});
totalTime = Timing.stop(startTime);
- System.out.format("%d %d %d %d %f\n",
- node, count[0], t.getNbNodesAccessed(),
- t.getNbEdgesAccessed(), totalTime
- );
+ System.out.format("%d %d %d %d %f\n", node, count[0], t.getNbNodesAccessed(),
+ t.getNbEdgesAccessed(), totalTime);
}
});
}
diff --git a/java/src/main/java/org/softwareheritage/graph/experiments/topology/ClusteringCoefficient.java b/java/src/main/java/org/softwareheritage/graph/experiments/topology/ClusteringCoefficient.java
--- a/java/src/main/java/org/softwareheritage/graph/experiments/topology/ClusteringCoefficient.java
+++ b/java/src/main/java/org/softwareheritage/graph/experiments/topology/ClusteringCoefficient.java
@@ -5,7 +5,6 @@
import com.martiansoftware.jsap.*;
import it.unimi.dsi.big.webgraph.ImmutableGraph;
import it.unimi.dsi.big.webgraph.LazyLongIterator;
-import it.unimi.dsi.big.webgraph.Transform;
import it.unimi.dsi.logging.ProgressLogger;
import org.slf4j.LoggerFactory;
import org.softwareheritage.graph.Graph;
@@ -28,16 +27,12 @@
private static JSAPResult parse_args(String[] args) {
JSAPResult config = null;
try {
- SimpleJSAP jsap = new SimpleJSAP(
- ClusteringCoefficient.class.getName(),
- "",
+ SimpleJSAP jsap = new SimpleJSAP(ClusteringCoefficient.class.getName(), "",
new Parameter[]{
- new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'g', "graph", "Basename of the compressed graph"),
- new FlaggedOption("outdir", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'o', "outdir", "Directory where to put the results"),
- }
- );
+ new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'g',
+ "graph", "Basename of the compressed graph"),
+ new FlaggedOption("outdir", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'o',
+ "outdir", "Directory where to put the results"),});
config = jsap.parse(args);
if (jsap.messagePrinted()) {
@@ -155,7 +150,7 @@
trials++;
if (trials % 100 == 0 || true) {
- double gC = (double)triangles / (double)trials;
+ double gC = (double) triangles / (double) trials;
out_global.format("C: %f (triangles: %d, trials: %d)\n", gC, triangles, trials);
System.out.format("C: %f (triangles: %d, trials: %d)\n", gC, triangles, trials);
}
@@ -182,16 +177,10 @@
new File(outdirPath).mkdirs();
try {
- ccoef.compute_approx(
- new Formatter(outdirPath + "/local.txt")
- );
+ ccoef.compute_approx(new Formatter(outdirPath + "/local.txt"));
/*
- ccoef.compute(
- symmetric,
- new ProgressLogger(rootLogger),
- new Formatter(outdirPath + "/local.txt"),
- new Formatter(outdirPath + "/global.txt")
- );
+ * ccoef.compute( symmetric, new ProgressLogger(rootLogger), new Formatter(outdirPath +
+ * "/local.txt"), new Formatter(outdirPath + "/global.txt") );
*/
} catch (FileNotFoundException e) {
e.printStackTrace();
diff --git a/java/src/main/java/org/softwareheritage/graph/experiments/topology/ConnectedComponents.java b/java/src/main/java/org/softwareheritage/graph/experiments/topology/ConnectedComponents.java
--- a/java/src/main/java/org/softwareheritage/graph/experiments/topology/ConnectedComponents.java
+++ b/java/src/main/java/org/softwareheritage/graph/experiments/topology/ConnectedComponents.java
@@ -2,9 +2,7 @@
import com.google.common.primitives.Longs;
import com.martiansoftware.jsap.*;
-import it.unimi.dsi.big.webgraph.ImmutableGraph;
import it.unimi.dsi.big.webgraph.LazyLongIterator;
-import it.unimi.dsi.big.webgraph.Transform;
import it.unimi.dsi.bits.LongArrayBitVector;
import it.unimi.dsi.fastutil.Arrays;
import it.unimi.dsi.io.ByteDiskQueue;
@@ -27,16 +25,12 @@
private static JSAPResult parse_args(String[] args) {
JSAPResult config = null;
try {
- SimpleJSAP jsap = new SimpleJSAP(
- ConnectedComponents.class.getName(),
- "",
- new Parameter[] {
- new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'g', "graph", "Basename of the compressed graph"),
- new FlaggedOption("outdir", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'o', "outdir", "Directory where to put the results"),
- }
- );
+ SimpleJSAP jsap = new SimpleJSAP(ConnectedComponents.class.getName(), "",
+ new Parameter[]{
+ new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'g',
+ "graph", "Basename of the compressed graph"),
+ new FlaggedOption("outdir", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'o',
+ "outdir", "Directory where to put the results"),});
config = jsap.parse(args);
if (jsap.messagePrinted()) {
@@ -52,7 +46,7 @@
final long n = graph.numNodes();
// Allow enough memory to behave like in-memory queue
- int bufferSize = (int)Math.min(Arrays.MAX_ARRAY_SIZE & ~0x7, 8L * n);
+ int bufferSize = (int) Math.min(Arrays.MAX_ARRAY_SIZE & ~0x7, 8L * n);
// Use a disk based queue to store BFS frontier
final File queueFile = File.createTempFile(ConnectedComponents.class.getSimpleName(), "queue");
@@ -148,7 +142,7 @@
}
ProgressLogger logger = new ProgressLogger();
- //noinspection ResultOfMethodCallIgnored
+ // noinspection ResultOfMethodCallIgnored
new File(outdirPath).mkdirs();
try {
ArrayList> components = connectedComponents.compute(logger);
diff --git a/java/src/main/java/org/softwareheritage/graph/maps/LabelMapBuilder.java b/java/src/main/java/org/softwareheritage/graph/maps/LabelMapBuilder.java
--- a/java/src/main/java/org/softwareheritage/graph/maps/LabelMapBuilder.java
+++ b/java/src/main/java/org/softwareheritage/graph/maps/LabelMapBuilder.java
@@ -4,7 +4,6 @@
import it.unimi.dsi.big.webgraph.LazyLongIterator;
import it.unimi.dsi.big.webgraph.labelling.ArcLabelledImmutableGraph;
import it.unimi.dsi.big.webgraph.labelling.BitStreamArcLabelledImmutableGraph;
-import it.unimi.dsi.big.webgraph.labelling.FixedWidthIntLabel;
import it.unimi.dsi.big.webgraph.labelling.FixedWidthIntListLabel;
import it.unimi.dsi.fastutil.BigArrays;
import it.unimi.dsi.fastutil.Size64;
@@ -35,20 +34,15 @@
private static JSAPResult parse_args(String[] args) {
JSAPResult config = null;
try {
- SimpleJSAP jsap = new SimpleJSAP(
- LabelMapBuilder.class.getName(),
- "",
- new Parameter[] {
- new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
- 'g', "graph", "Basename of the compressed graph"),
- new FlaggedOption("debugPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED,
- 'd', "debug-path",
- "Store the intermediate representation here for debug"),
-
- new FlaggedOption("tmpDir", JSAP.STRING_PARSER, "tmp", JSAP.NOT_REQUIRED,
- 't', "tmp", "Temporary directory path"),
- }
- );
+ SimpleJSAP jsap = new SimpleJSAP(LabelMapBuilder.class.getName(), "",
+ new Parameter[]{
+ new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'g',
+ "graph", "Basename of the compressed graph"),
+ new FlaggedOption("debugPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'd',
+ "debug-path", "Store the intermediate representation here for debug"),
+
+ new FlaggedOption("tmpDir", JSAP.STRING_PARSER, "tmp", JSAP.NOT_REQUIRED, 't', "tmp",
+ "Temporary directory path"),});
config = jsap.parse(args);
if (jsap.messagePrinted()) {
@@ -85,21 +79,18 @@
return mphMap;
}
- static long getMPHSize(Object2LongFunction mph)
- {
+ static long getMPHSize(Object2LongFunction mph) {
return (mph instanceof Size64) ? ((Size64) mph).size64() : mph.size();
}
- static long SwhIDToNode(String strSWHID, Object2LongFunction mphMap, long[][] orderMap)
- {
+ static long SwhIDToNode(String strSWHID, Object2LongFunction mphMap, long[][] orderMap) {
long mphId = mphMap.getLong(strSWHID);
return BigArrays.get(orderMap, mphId);
}
- static void computeLabelMap(String graphPath, String debugPath, String tmpDir)
- throws IOException
- {
- // Compute intermediate representation in the format "