Page MenuHomeSoftware Heritage

D4028.id14208.diff
No OneTemporary

D4028.id14208.diff

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -37,6 +37,15 @@
hooks:
- id: black
+- repo: local
+ hooks:
+ - id: java-coding-style
+ name: java style
+ entry: mvn
+ args: ["-f", "java/pom.xml", "spotless:apply"]
+ pass_filenames: false
+ language: system
+
# unfortunately, we are far from being able to enable this...
# - repo: https://github.com/PyCQA/pydocstyle.git
# rev: 4.0.0
diff --git a/java/.clang-format b/java/.clang-format
deleted file mode 100644
--- a/java/.clang-format
+++ /dev/null
@@ -1,4 +0,0 @@
----
-BasedOnStyle: Google
----
-Language: Java
diff --git a/java/.coding-style.xml b/java/.coding-style.xml
new file mode 100644
--- /dev/null
+++ b/java/.coding-style.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<profiles version="20">
+ <profile kind="CodeFormatterProfile" name="Spotless" version="20">
+ <setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
+ <setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
+ <setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
+ <setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
+ <setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="100"/>
+ <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
+ <setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
+ </profile>
+</profiles>
diff --git a/java/pom.xml b/java/pom.xml
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -176,7 +176,36 @@
</goals>
</execution>
</executions>
- </plugin>
+ </plugin>
+ <!-- Spotless code formatting tool -->
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>2.4.1</version>
+ <configuration>
+ <formats>
+ <format>
+ <includes>
+ <include>*.md</include>
+ <include>.gitignore</include>
+ </includes>
+ <trimTrailingWhitespace/>
+ <endWithNewline/>
+ <indent>
+ <spaces>true</spaces>
+ <spacesPerTab>4</spacesPerTab>
+ </indent>
+ </format>
+ </formats>
+ <java>
+ <removeUnusedImports/>
+ <eclipse>
+ <version>4.16.0</version>
+ <file>.coding-style.xml</file>
+ </eclipse>
+ </java>
+ </configuration>
+ </plugin>
</plugins>
</pluginManagement>
<plugins>
diff --git a/java/src/main/java/org/softwareheritage/graph/AllowedEdges.java b/java/src/main/java/org/softwareheritage/graph/AllowedEdges.java
--- a/java/src/main/java/org/softwareheritage/graph/AllowedEdges.java
+++ b/java/src/main/java/org/softwareheritage/graph/AllowedEdges.java
@@ -5,10 +5,10 @@
/**
* Edge restriction based on node types, used when visiting the graph.
* <p>
- * <a href="https://docs.softwareheritage.org/devel/swh-model/data-model.html">Software Heritage
+ * <a href= "https://docs.softwareheritage.org/devel/swh-model/data-model.html">Software Heritage
* graph</a> contains multiple node types (contents, directories, revisions, ...) and restricting
- * the traversal to specific node types is necessary for many querying operations: <a
- * href="https://docs.softwareheritage.org/devel/swh-graph/use-cases.html">use cases</a>.
+ * the traversal to specific node types is necessary for many querying operations:
+ * <a href= "https://docs.softwareheritage.org/devel/swh-graph/use-cases.html">use cases</a>.
*
* @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 <a
- * href="https://docs.softwareheritage.org/devel/swh-graph/api.html#terminology">allowed edges</a>
+ * @param edgesFmt a formatted string describing <a href=
+ * "https://docs.softwareheritage.org/devel/swh-graph/api.html#terminology">allowed
+ * edges</a>
*/
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.
* <p>
* The compressed graph is stored using the <a href="http://webgraph.di.unimi.it/">WebGraph</a>
- * ecosystem. Additional mappings are necessary because Software Heritage uses string based <a
- * href="https://docs.softwareheritage.org/devel/swh-model/persistent-identifiers.html">persistent
- * identifiers</a> (SWHID) while WebGraph uses integers internally. These two mappings (long id &harr;
- * 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 &rarr; node type map is stored as well to avoid a full
- * SWHID lookup.
+ * ecosystem. Additional mappings are necessary because Software Heritage uses string based <a href=
+ * "https://docs.softwareheritage.org/devel/swh-model/persistent-identifiers.html">persistent
+ * identifiers</a> (SWHID) while WebGraph uses integers internally. These two mappings (long id
+ * &harr; 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 &rarr; 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 <a
- * href="http://webgraph.di.unimi.it/">WebGraph</a> LazyLongIterator
+ * @return lazy iterator of successors of the node, specified as a
+ * <a href="http://webgraph.di.unimi.it/">WebGraph</a> 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 <a
- * href="http://webgraph.di.unimi.it/">WebGraph</a> LazyLongIterator
+ * @return lazy iterator of successors of the node, specified as a
+ * <a href="http://webgraph.di.unimi.it/">WebGraph</a> 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 <a
- * href="http://webgraph.di.unimi.it/">WebGraph</a> LazyLongIterator
+ * @return lazy iterator of predecessors of the node, specified as a
+ * <a href="http://webgraph.di.unimi.it/">WebGraph</a> 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
- * <a href="https://docs.softwareheritage.org/devel/swh-model/data-model.html">data model</a>.
+ * <a href= "https://docs.softwareheritage.org/devel/swh-model/data-model.html">data model</a>.
*/
public enum Type {
/** Content node */
@@ -93,8 +93,8 @@
}
/**
- * Parses SWH node type possible values from formatted string (see the <a
- * href="https://docs.softwareheritage.org/devel/swh-graph/api.html#terminology">API
+ * Parses SWH node type possible values from formatted string (see the
+ * <a href= "https://docs.softwareheritage.org/devel/swh-graph/api.html#terminology">API
* syntax</a>).
*
* @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 <a
- * href="https://docs.softwareheritage.org/devel/swh-model/persistent-identifiers.html#persistent-identifiers">persistent
+ * A Software Heritage persistent identifier (SWHID), see <a href=
+ * "https://docs.softwareheritage.org/devel/swh-model/persistent-identifiers.html#persistent-identifiers">persistent
* identifier documentation</a>.
*
* @author The Software Heritage developers
@@ -43,19 +43,14 @@
/**
* Creates a SWHID from a compact binary representation.
* <p>
- * 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.
* <p>
- * 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.
* <p>
- * These statistics are not computed but directly read from <a
- * href="http://webgraph.di.unimi.it/">WebGraph</a> generated .stats and .properties files.
+ * These statistics are not computed but directly read from
+ * <a href="http://webgraph.di.unimi.it/">WebGraph</a> 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 <a
- * href="https://docs.softwareheritage.org/devel/swh-graph/api.html#terminology">allowed edges</a>
+ * @param edgesFmt a formatted string describing <a href=
+ * "https://docs.softwareheritage.org/devel/swh-graph/api.html#terminology">allowed
+ * edges</a>
*/
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<Long> 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<Long> currentPath = new Stack<>();
@@ -213,15 +212,13 @@
return paths;
}
- private void visitPathsInternalVisitor(long currentNodeId,
- Stack<Long> currentPath,
- PathConsumer cb) {
+ private void visitPathsInternalVisitor(long currentNodeId, Stack<Long> 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 <T> ArrayList<Long> 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 <T> ArrayList<Long> 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<ArrayList<Long>> {
/**
- * 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<Long> 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 <a
- * href="https://docs.softwareheritage.org/devel/swh-graph/api.html#walk">API</a>
+ * @param dstFmt destination formatted string as described in the
+ * <a href= "https://docs.softwareheritage.org/devel/swh-graph/api.html#walk">API</a>
* @param algorithm traversal algorithm used in endpoint call (either "dfs" or "bfs")
*/
public void timeEndpoint(String useCaseName, Graph graph, long[] nodeIds,
- Function<Endpoint.Input, Endpoint.Output> operation, String dstFmt, String algorithm)
- throws IOException {
+ Function<Endpoint.Input, Endpoint.Output> operation, String dstFmt, String algorithm) throws IOException {
ArrayList<Double> timings = new ArrayList<>();
ArrayList<Double> timingsNormalized = new ArrayList<>();
ArrayList<Double> 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<Endpoint.Input, Endpoint.Output> operation) throws IOException {
+ Function<Endpoint.Input, Endpoint.Output> 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 <a
- * href="https://docs.softwareheritage.org/devel/swh-graph/use-cases.html#browsing">browsing
+ * Benchmark Software Heritage
+ * <a href= "https://docs.softwareheritage.org/devel/swh-graph/use-cases.html#browsing">browsing
* use-cases scenarios</a>.
*
* @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 <a
- * href="https://docs.softwareheritage.org/devel/swh-graph/use-cases.html#provenance">provenance
+ * Benchmark Software Heritage
+ * <a href= "https://docs.softwareheritage.org/devel/swh-graph/use-cases.html#provenance">provenance
* use-cases scenarios</a>.
*
* @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 <a
- * href="https://docs.softwareheritage.org/devel/swh-graph/use-cases.html#vault">vault
- * use-case scenario</a>.
+ * Benchmark Software Heritage
+ * <a href= "https://docs.softwareheritage.org/devel/swh-graph/use-cases.html#vault">vault use-case
+ * scenario</a>.
*
* @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<ArrayList<Long>> 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<Long> 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<ArrayList<Long>> 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<Long> 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<ArrayList<Long>> 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<Long> 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<ArrayList<Long>> 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<String> mph)
- {
+ static long getMPHSize(Object2LongFunction<String> mph) {
return (mph instanceof Size64) ? ((Size64) mph).size64() : mph.size();
}
- static long SwhIDToNode(String strSWHID, Object2LongFunction<String> mphMap, long[][] orderMap)
- {
+ static long SwhIDToNode(String strSWHID, Object2LongFunction<String> 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 "<src node id> <dst node id> <label ids>\n"
+ static void computeLabelMap(String graphPath, String debugPath, String tmpDir) throws IOException {
+ // Compute intermediate representation in the format "<src node id> <dst node
+ // id> <label ids>\n"
ImmutableGraph graph = BVGraph.loadMapped(graphPath);
Object2LongFunction<String> swhIdMph = loadMPH(graphPath);
@@ -118,22 +109,17 @@
plInter.itemsName = "edges";
plInter.expectedUpdates = graph.numArcs();
- // Pass the intermediate representation to sort(1) so that we see the labels in the
+ // Pass the intermediate representation to sort(1) so that we see the labels in
+ // the
// order they will appear in the label file.
ProcessBuilder processBuilder = new ProcessBuilder();
- processBuilder.command(
- "sort",
- "-k1,1n", "-k2,2n", "-k3,3n", // Numerical sort on all fields
- "--numeric-sort",
- "--buffer-size", SORT_BUFFER_SIZE,
- "--temporary-directory", tmpDir
- );
+ processBuilder.command("sort", "-k1,1n", "-k2,2n", "-k3,3n", // Numerical sort on all fields
+ "--numeric-sort", "--buffer-size", SORT_BUFFER_SIZE, "--temporary-directory", tmpDir);
Process sort = processBuilder.start();
BufferedOutputStream sort_stdin = new BufferedOutputStream(sort.getOutputStream());
BufferedInputStream sort_stdout = new BufferedInputStream(sort.getInputStream());
- FastBufferedReader buffer = new FastBufferedReader(new InputStreamReader(
- System.in, StandardCharsets.US_ASCII));
+ FastBufferedReader buffer = new FastBufferedReader(new InputStreamReader(System.in, StandardCharsets.US_ASCII));
LineIterator edgeIterator = new LineIterator(buffer);
plInter.start("Piping intermediate representation to sort(1)");
@@ -146,8 +132,7 @@
long dstNode = SwhIDToNode(edge[1], swhIdMph, orderMap);
long labelId = labelMPH.getLong(edge[2]);
- sort_stdin.write((srcNode + "\t" + dstNode + "\t" + labelId + "\n")
- .getBytes(StandardCharsets.US_ASCII));
+ sort_stdin.write((srcNode + "\t" + dstNode + "\t" + labelId + "\n").getBytes(StandardCharsets.US_ASCII));
plInter.lightUpdate();
}
plInter.done();
@@ -163,12 +148,10 @@
debugFile = new FileWriter(debugPath);
}
- OutputBitStream labels = new OutputBitStream(new File(
- graphPath + "-labelled"
- + BitStreamArcLabelledImmutableGraph.LABELS_EXTENSION));
- OutputBitStream offsets = new OutputBitStream(new File(
- graphPath + "-labelled"
- + BitStreamArcLabelledImmutableGraph.LABEL_OFFSETS_EXTENSION));
+ OutputBitStream labels = new OutputBitStream(
+ new File(graphPath + "-labelled" + BitStreamArcLabelledImmutableGraph.LABELS_EXTENSION));
+ OutputBitStream offsets = new OutputBitStream(
+ new File(graphPath + "-labelled" + BitStreamArcLabelledImmutableGraph.LABEL_OFFSETS_EXTENSION));
offsets.writeGamma(0);
Scanner sortOutput = new Scanner(sort_stdout, StandardCharsets.US_ASCII);
@@ -185,11 +168,7 @@
HashMap<Long, List<Long>> successorsLabels = new HashMap<>();
while (labelSrcNode <= srcNode) {
if (labelSrcNode == srcNode) {
- successorsLabels
- .computeIfAbsent(
- labelDstNode,
- k -> new ArrayList<>()
- ).add(labelId);
+ successorsLabels.computeIfAbsent(labelDstNode, k -> new ArrayList<>()).add(labelId);
if (debugFile != null) {
debugFile.write(labelSrcNode + " " + labelDstNode + " " + labelId + "\n");
}
@@ -226,9 +205,10 @@
debugFile.close();
}
- PrintWriter pw = new PrintWriter(new FileWriter((new File(graphPath)).getName() + "-labelled.properties" ));
+ PrintWriter pw = new PrintWriter(new FileWriter((new File(graphPath)).getName() + "-labelled.properties"));
pw.println(ImmutableGraph.GRAPHCLASS_PROPERTY_KEY + " = " + BitStreamArcLabelledImmutableGraph.class.getName());
- pw.println(BitStreamArcLabelledImmutableGraph.LABELSPEC_PROPERTY_KEY + " = " + FixedWidthIntListLabel.class.getName() + "(TEST," + labelWidth + ")" );
+ pw.println(BitStreamArcLabelledImmutableGraph.LABELSPEC_PROPERTY_KEY + " = "
+ + FixedWidthIntListLabel.class.getName() + "(TEST," + labelWidth + ")");
pw.println(ArcLabelledImmutableGraph.UNDERLYINGGRAPH_PROPERTY_KEY + " = " + graphPath);
pw.close();
}
diff --git a/java/src/main/java/org/softwareheritage/graph/maps/MapFile.java b/java/src/main/java/org/softwareheritage/graph/maps/MapFile.java
--- a/java/src/main/java/org/softwareheritage/graph/maps/MapFile.java
+++ b/java/src/main/java/org/softwareheritage/graph/maps/MapFile.java
@@ -10,9 +10,9 @@
/**
* Wrapper class around very big mmap()-ed file.
* <p>
- * Java has a limit for mmap()-ed files because of unsupported 64-bit indexing. The <a
- * href="http://dsiutils.di.unimi.it/">dsiutils</a> ByteBufferInputStream is used to overcome this
- * Java limit.
+ * Java has a limit for mmap()-ed files because of unsupported 64-bit indexing. The
+ * <a href="http://dsiutils.di.unimi.it/">dsiutils</a> ByteBufferInputStream is used to overcome
+ * this Java limit.
*
* @author The Software Heritage developers
*/
diff --git a/java/src/main/java/org/softwareheritage/graph/maps/NodeIdMap.java b/java/src/main/java/org/softwareheritage/graph/maps/NodeIdMap.java
--- a/java/src/main/java/org/softwareheritage/graph/maps/NodeIdMap.java
+++ b/java/src/main/java/org/softwareheritage/graph/maps/NodeIdMap.java
@@ -8,8 +8,8 @@
/**
* Mapping between internal long node id and external SWHID.
* <p>
- * Mappings in both directions are pre-computed and dumped on disk in the
- * {@link NodeMapBuilder} class, then they are loaded here using mmap().
+ * Mappings in both directions are pre-computed and dumped on disk in the {@link NodeMapBuilder}
+ * class, then they are loaded here using mmap().
*
* @author The Software Heritage developers
* @see NodeMapBuilder
@@ -57,7 +57,8 @@
* @see SWHID
*/
public long getNodeId(SWHID swhid) {
- // The file is sorted by swhid, hence we can binary search on swhid to get corresponding
+ // The file is sorted by swhid, hence we can binary search on swhid to get
+ // corresponding
// nodeId
long start = 0;
long end = nbIds - 1;
@@ -95,7 +96,8 @@
*/
public SWHID getSWHID(long nodeId) {
// Each line in NODE_TO_SWHID is formatted as: swhid
- // The file is ordered by nodeId, meaning node0's swhid is at line 0, hence we can read the
+ // The file is ordered by nodeId, meaning node0's swhid is at line 0, hence we
+ // can read the
// nodeId-th line to get corresponding swhid
if (nodeId < 0 || nodeId >= nbIds) {
throw new IllegalArgumentException("Node id " + nodeId + " should be between 0 and " + nbIds);
diff --git a/java/src/main/java/org/softwareheritage/graph/maps/NodeMapBuilder.java b/java/src/main/java/org/softwareheritage/graph/maps/NodeMapBuilder.java
--- a/java/src/main/java/org/softwareheritage/graph/maps/NodeMapBuilder.java
+++ b/java/src/main/java/org/softwareheritage/graph/maps/NodeMapBuilder.java
@@ -24,9 +24,8 @@
/**
* Create maps needed at runtime by the graph service, in particular:
* <p>
- * - SWHID → WebGraph long node id
- * - WebGraph long node id → SWHID (converse of the former)
- * - WebGraph long node id → SWH node type (enum)
+ * - SWHID → WebGraph long node id - WebGraph long node id → SWHID (converse of the former) -
+ * WebGraph long node id → SWH node type (enum)
*
* @author The Software Heritage developers
*/
@@ -61,8 +60,7 @@
*/
// Suppress warning for Object2LongFunction cast
@SuppressWarnings("unchecked")
- static void precomputeNodeIdMap(String graphPath, String tmpDir)
- throws IOException {
+ static void precomputeNodeIdMap(String graphPath, String tmpDir) throws IOException {
ProgressLogger plSWHID2Node = new ProgressLogger(logger, 10, TimeUnit.SECONDS);
ProgressLogger plNode2SWHID = new ProgressLogger(logger, 10, TimeUnit.SECONDS);
plSWHID2Node.itemsName = "swhid→node";
@@ -98,8 +96,7 @@
// Create mapping SWHID -> WebGraph node id, by sequentially reading
// nodes, hashing them with MPH, and permuting according to BFS order
- FastBufferedReader buffer = new FastBufferedReader(new InputStreamReader(System.in,
- StandardCharsets.US_ASCII));
+ FastBufferedReader buffer = new FastBufferedReader(new InputStreamReader(System.in, StandardCharsets.US_ASCII));
LineIterator swhidIterator = new LineIterator(buffer);
// The WebGraph node id -> SWHID mapping can be obtained from the
@@ -107,17 +104,20 @@
// writing obtained SWHIDs to a binary map. Delegates the sorting job to
// /usr/bin/sort via pipes
ProcessBuilder processBuilder = new ProcessBuilder();
- processBuilder.command("sort", "--numeric-sort", "--key", "2",
- "--buffer-size", SORT_BUFFER_SIZE,
+ processBuilder.command("sort", "--numeric-sort", "--key", "2", "--buffer-size", SORT_BUFFER_SIZE,
"--temporary-directory", tmpDir);
Process sort = processBuilder.start();
BufferedOutputStream sort_stdin = new BufferedOutputStream(sort.getOutputStream());
BufferedInputStream sort_stdout = new BufferedInputStream(sort.getInputStream());
- // for the binary format of swhidToNodeMap, see Python module swh.graph.swhid:SwhidToIntMap
- // for the binary format of nodeToSwhidMap, see Python module swh.graph.swhid:IntToSwhidMap
- try (DataOutputStream swhidToNodeMap = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(graphPath + Graph.SWHID_TO_NODE)));
- BufferedOutputStream nodeToSwhidMap = new BufferedOutputStream(new FileOutputStream(graphPath + Graph.NODE_TO_SWHID))) {
+ // for the binary format of swhidToNodeMap, see Python module
+ // swh.graph.swhid:SwhidToIntMap
+ // for the binary format of nodeToSwhidMap, see Python module
+ // swh.graph.swhid:IntToSwhidMap
+ try (DataOutputStream swhidToNodeMap = new DataOutputStream(
+ new BufferedOutputStream(new FileOutputStream(graphPath + Graph.SWHID_TO_NODE)));
+ BufferedOutputStream nodeToSwhidMap = new BufferedOutputStream(
+ new FileOutputStream(graphPath + Graph.NODE_TO_SWHID))) {
// background handler for sort output, it will be fed SWHID/node
// pairs while swhidToNodeMap is being filled, and will itself fill
@@ -128,11 +128,9 @@
// Type map from WebGraph node ID to SWH type. Used at runtime by
// pure Java graph traversals to efficiently check edge
// restrictions.
- final int log2NbTypes = (int) Math.ceil(Math.log(Node.Type.values().length)
- / Math.log(2));
+ final int log2NbTypes = (int) Math.ceil(Math.log(Node.Type.values().length) / Math.log(2));
final int nbBitsPerNodeType = log2NbTypes;
- LongArrayBitVector nodeTypesBitVector =
- LongArrayBitVector.ofLength(nbBitsPerNodeType * nbIds);
+ LongArrayBitVector nodeTypesBitVector = LongArrayBitVector.ofLength(nbBitsPerNodeType * nbIds);
LongBigList nodeTypesMap = nodeTypesBitVector.asLongBigList(nbBitsPerNodeType);
plSWHID2Node.start("filling swhid2node map");
@@ -146,8 +144,7 @@
swhidToNodeMap.write(swhidBin, 0, swhidBin.length);
swhidToNodeMap.writeLong(nodeId);
- sort_stdin.write((swhidStr + "\t" + nodeId + "\n")
- .getBytes(StandardCharsets.US_ASCII));
+ sort_stdin.write((swhidStr + "\t" + nodeId + "\n").getBytes(StandardCharsets.US_ASCII));
nodeTypesMap.set(nodeId, swhid.getType().ordinal());
plSWHID2Node.lightUpdate();
@@ -196,8 +193,8 @@
sortDone = true;
this.pl.start("filling node2swhid map");
}
- String line = input.nextLine(); // format: SWHID <TAB> NODE_ID
- SWHID swhid = new SWHID(line.split("\\t")[0]); // get SWHID
+ String line = input.nextLine(); // format: SWHID <TAB> NODE_ID
+ SWHID swhid = new SWHID(line.split("\\t")[0]); // get SWHID
try {
output.write((byte[]) swhid.toBytes());
} catch (IOException e) {
diff --git a/java/src/main/java/org/softwareheritage/graph/maps/NodeTypesMap.java b/java/src/main/java/org/softwareheritage/graph/maps/NodeTypesMap.java
--- a/java/src/main/java/org/softwareheritage/graph/maps/NodeTypesMap.java
+++ b/java/src/main/java/org/softwareheritage/graph/maps/NodeTypesMap.java
@@ -8,15 +8,13 @@
import java.io.IOException;
/**
- * Mapping between long node id and SWH node type as described in the <a
- * href="https://docs.softwareheritage.org/devel/swh-model/data-model.html">data
- * model</a>.
+ * Mapping between long node id and SWH node type as described in the
+ * <a href= "https://docs.softwareheritage.org/devel/swh-model/data-model.html">data model</a>.
* <p>
- * The type mapping is pre-computed and dumped on disk in the {@link NodeMapBuilder}
- * class, then it is loaded in-memory here using
- * <a href="http://fastutil.di.unimi.it/">fastutil</a> LongBigList. To be
- * space-efficient, the mapping is stored as a bitmap using minimum number of
- * bits per {@link Node.Type}.
+ * The type mapping is pre-computed and dumped on disk in the {@link NodeMapBuilder} class, then it
+ * is loaded in-memory here using <a href="http://fastutil.di.unimi.it/">fastutil</a> LongBigList.
+ * To be space-efficient, the mapping is stored as a bitmap using minimum number of bits per
+ * {@link Node.Type}.
*
* @author The Software Heritage developers
*/
diff --git a/java/src/main/java/org/softwareheritage/graph/server/App.java b/java/src/main/java/org/softwareheritage/graph/server/App.java
--- a/java/src/main/java/org/softwareheritage/graph/server/App.java
+++ b/java/src/main/java/org/softwareheritage/graph/server/App.java
@@ -34,8 +34,7 @@
"Binding port of the server."),
new UnflaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED,
JSAP.NOT_GREEDY, "The basename of the compressed graph."),
- new Switch("timings", 't', "timings", "Show timings in API result metadata."),
- });
+ new Switch("timings", 't', "timings", "Show timings in API result metadata."),});
JSAPResult config = jsap.parse(args);
if (jsap.messagePrinted()) {
@@ -56,8 +55,7 @@
* @param port binding port of the server
* @param showTimings true if timings should be in results metadata, false otherwise
*/
- private static void startServer(String graphPath, int port, boolean showTimings)
- throws IOException {
+ private static void startServer(String graphPath, int port, boolean showTimings) throws IOException {
Graph graph = new Graph(graphPath);
Stats stats = new Stats(graphPath);
diff --git a/java/src/main/java/org/softwareheritage/graph/server/Endpoint.java b/java/src/main/java/org/softwareheritage/graph/server/Endpoint.java
--- a/java/src/main/java/org/softwareheritage/graph/server/Endpoint.java
+++ b/java/src/main/java/org/softwareheritage/graph/server/Endpoint.java
@@ -27,8 +27,9 @@
*
* @param graph the graph used for traversal endpoint
* @param direction a string (either "forward" or "backward") specifying edge orientation
- * @param edgesFmt a formatted string describing <a
- * href="https://docs.softwareheritage.org/devel/swh-graph/api.html#terminology">allowed edges</a>
+ * @param edgesFmt a formatted string describing <a href=
+ * "https://docs.softwareheritage.org/devel/swh-graph/api.html#terminology">allowed
+ * edges</a>
*/
public Endpoint(Graph graph, String direction, String edgesFmt) {
this.graph = graph;
@@ -246,8 +247,8 @@
/** Source node of endpoint call specified as a {@link SWHID} */
public SWHID src;
/**
- * Destination formatted string as described in the <a
- * href="https://docs.softwareheritage.org/devel/swh-graph/api.html#walk">API</a>
+ * Destination formatted string as described in the
+ * <a href= "https://docs.softwareheritage.org/devel/swh-graph/api.html#walk">API</a>
*/
public String dstFmt;
/** Traversal algorithm used in endpoint call (either "dfs" or "bfs") */
diff --git a/java/src/main/java/org/softwareheritage/graph/utils/MPHTranslate.java b/java/src/main/java/org/softwareheritage/graph/utils/MPHTranslate.java
--- a/java/src/main/java/org/softwareheritage/graph/utils/MPHTranslate.java
+++ b/java/src/main/java/org/softwareheritage/graph/utils/MPHTranslate.java
@@ -14,14 +14,9 @@
private static JSAPResult parse_args(String[] args) {
JSAPResult config = null;
try {
- SimpleJSAP jsap = new SimpleJSAP(
- MPHTranslate.class.getName(),
- "",
- new Parameter[]{
- new UnflaggedOption("function", JSAP.STRING_PARSER, JSAP.REQUIRED,
- "Filename of the serialized MPH"),
- }
- );
+ SimpleJSAP jsap = new SimpleJSAP(MPHTranslate.class.getName(), "",
+ new Parameter[]{new UnflaggedOption("function", JSAP.STRING_PARSER, JSAP.REQUIRED,
+ "Filename of the serialized MPH"),});
config = jsap.parse(args);
if (jsap.messagePrinted()) {
@@ -34,20 +29,17 @@
}
@SuppressWarnings("unchecked") // Suppress warning for Object2LongFunction cast
- static Object2LongFunction<String> loadMPH(String mphPath)
- throws IOException, ClassNotFoundException {
+ static Object2LongFunction<String> loadMPH(String mphPath) throws IOException, ClassNotFoundException {
return (Object2LongFunction<String>) BinIO.loadObject(mphPath);
}
- public static void main(String[] args)
- throws IOException, ClassNotFoundException {
+ public static void main(String[] args) throws IOException, ClassNotFoundException {
JSAPResult config = parse_args(args);
String mphPath = config.getString("function");
Object2LongFunction<String> mphMap = loadMPH(mphPath);
- FastBufferedReader buffer = new FastBufferedReader(
- new InputStreamReader(System.in, StandardCharsets.US_ASCII));
+ FastBufferedReader buffer = new FastBufferedReader(new InputStreamReader(System.in, StandardCharsets.US_ASCII));
LineIterator lineIterator = new LineIterator(buffer);
while (lineIterator.hasNext()) {
diff --git a/java/src/main/java/org/softwareheritage/graph/utils/ReadGraph.java b/java/src/main/java/org/softwareheritage/graph/utils/ReadGraph.java
--- a/java/src/main/java/org/softwareheritage/graph/utils/ReadGraph.java
+++ b/java/src/main/java/org/softwareheritage/graph/utils/ReadGraph.java
@@ -20,13 +20,8 @@
var s = it.successors();
long dstNode;
while ((dstNode = s.nextLong()) >= 0) {
- System.out.format(
- "%s %s\n",
- nodeMap.getSWHID(srcNode),
- nodeMap.getSWHID(dstNode)
- );
+ System.out.format("%s %s\n", nodeMap.getSWHID(srcNode), nodeMap.getSWHID(dstNode));
}
}
}
}
-
diff --git a/java/src/main/java/org/softwareheritage/graph/utils/ReadLabelledGraph.java b/java/src/main/java/org/softwareheritage/graph/utils/ReadLabelledGraph.java
--- a/java/src/main/java/org/softwareheritage/graph/utils/ReadLabelledGraph.java
+++ b/java/src/main/java/org/softwareheritage/graph/utils/ReadLabelledGraph.java
@@ -15,7 +15,8 @@
ArcLabelledImmutableGraph graph = BitStreamArcLabelledImmutableGraph.loadOffline(graphPath + "-labelled");
NodeIdMap nodeMap = new NodeIdMap(graphPath, graph.numNodes());
- PermutedFrontCodedStringList labelMap = (PermutedFrontCodedStringList) BinIO.loadObject(graphPath + "-labels.fcl");
+ PermutedFrontCodedStringList labelMap = (PermutedFrontCodedStringList) BinIO
+ .loadObject(graphPath + "-labels.fcl");
ArcLabelledNodeIterator it = graph.nodeIterator();
while (it.hasNext()) {
@@ -27,22 +28,13 @@
int[] labels = (int[]) s.label().get();
if (labels.length > 0) {
for (int label : labels) {
- System.out.format(
- "%s %s %s\n",
- nodeMap.getSWHID(srcNode),
- nodeMap.getSWHID(dstNode),
- labelMap.get(label)
- );
+ System.out.format("%s %s %s\n", nodeMap.getSWHID(srcNode), nodeMap.getSWHID(dstNode),
+ labelMap.get(label));
}
} else {
- System.out.format(
- "%s %s\n",
- nodeMap.getSWHID(srcNode),
- nodeMap.getSWHID(dstNode)
- );
+ System.out.format("%s %s\n", nodeMap.getSWHID(srcNode), nodeMap.getSWHID(dstNode));
}
}
}
}
}
-
diff --git a/java/src/test/java/org/softwareheritage/graph/AllowedEdgesTest.java b/java/src/test/java/org/softwareheritage/graph/AllowedEdgesTest.java
--- a/java/src/test/java/org/softwareheritage/graph/AllowedEdgesTest.java
+++ b/java/src/test/java/org/softwareheritage/graph/AllowedEdgesTest.java
@@ -5,10 +5,6 @@
import org.junit.Test;
import org.junit.Assert;
-import org.softwareheritage.graph.AllowedEdges;
-import org.softwareheritage.graph.GraphTest;
-import org.softwareheritage.graph.Node;
-
public class AllowedEdgesTest extends GraphTest {
class EdgeType {
Node.Type src;
@@ -21,8 +17,10 @@
@Override
public boolean equals(Object otherObj) {
- if (otherObj == this) return true;
- if (!(otherObj instanceof EdgeType)) return false;
+ if (otherObj == this)
+ return true;
+ if (!(otherObj instanceof EdgeType))
+ return false;
EdgeType other = (EdgeType) otherObj;
return src == other.src && dst == other.dst;
diff --git a/java/src/test/java/org/softwareheritage/graph/GraphTest.java b/java/src/test/java/org/softwareheritage/graph/GraphTest.java
--- a/java/src/test/java/org/softwareheritage/graph/GraphTest.java
+++ b/java/src/test/java/org/softwareheritage/graph/GraphTest.java
@@ -9,8 +9,6 @@
import org.junit.BeforeClass;
import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
-import org.softwareheritage.graph.Graph;
-
public class GraphTest {
static Graph graph;
diff --git a/java/src/test/java/org/softwareheritage/graph/VisitTest.java b/java/src/test/java/org/softwareheritage/graph/VisitTest.java
--- a/java/src/test/java/org/softwareheritage/graph/VisitTest.java
+++ b/java/src/test/java/org/softwareheritage/graph/VisitTest.java
@@ -31,97 +31,67 @@
ArrayList<SWHID> nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
- expectedPaths.add(
- new SwhPath(
- "swh:1:ori:0000000000000000000000000000000000000021",
+ expectedPaths.add(new SwhPath("swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:cnt:0000000000000000000000000000000000000007"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:ori:0000000000000000000000000000000000000021",
+ "swh:1:cnt:0000000000000000000000000000000000000007"));
+ expectedPaths.add(new SwhPath("swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:cnt:0000000000000000000000000000000000000001"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:ori:0000000000000000000000000000000000000021",
+ "swh:1:cnt:0000000000000000000000000000000000000001"));
+ expectedPaths.add(new SwhPath("swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
- "swh:1:cnt:0000000000000000000000000000000000000004"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:ori:0000000000000000000000000000000000000021",
+ "swh:1:cnt:0000000000000000000000000000000000000004"));
+ expectedPaths.add(new SwhPath("swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
- "swh:1:cnt:0000000000000000000000000000000000000005"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:ori:0000000000000000000000000000000000000021",
+ "swh:1:cnt:0000000000000000000000000000000000000005"));
+ expectedPaths.add(new SwhPath("swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:rev:0000000000000000000000000000000000000003",
"swh:1:dir:0000000000000000000000000000000000000002",
- "swh:1:cnt:0000000000000000000000000000000000000001"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:ori:0000000000000000000000000000000000000021",
+ "swh:1:cnt:0000000000000000000000000000000000000001"));
+ expectedPaths.add(new SwhPath("swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rel:0000000000000000000000000000000000000010",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:cnt:0000000000000000000000000000000000000007"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:ori:0000000000000000000000000000000000000021",
+ "swh:1:cnt:0000000000000000000000000000000000000007"));
+ expectedPaths.add(new SwhPath("swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rel:0000000000000000000000000000000000000010",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:cnt:0000000000000000000000000000000000000001"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:ori:0000000000000000000000000000000000000021",
+ "swh:1:cnt:0000000000000000000000000000000000000001"));
+ expectedPaths.add(new SwhPath("swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rel:0000000000000000000000000000000000000010",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
- "swh:1:cnt:0000000000000000000000000000000000000004"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:ori:0000000000000000000000000000000000000021",
+ "swh:1:cnt:0000000000000000000000000000000000000004"));
+ expectedPaths.add(new SwhPath("swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rel:0000000000000000000000000000000000000010",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
- "swh:1:cnt:0000000000000000000000000000000000000005"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:ori:0000000000000000000000000000000000000021",
+ "swh:1:cnt:0000000000000000000000000000000000000005"));
+ expectedPaths.add(new SwhPath("swh:1:ori:0000000000000000000000000000000000000021",
"swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rel:0000000000000000000000000000000000000010",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:rev:0000000000000000000000000000000000000003",
"swh:1:dir:0000000000000000000000000000000000000002",
- "swh:1:cnt:0000000000000000000000000000000000000001"
- ));
+ "swh:1:cnt:0000000000000000000000000000000000000001"));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
@@ -137,37 +107,22 @@
ArrayList<SWHID> nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
- expectedPaths.add(
- new SwhPath(
- "swh:1:dir:0000000000000000000000000000000000000012",
+ expectedPaths.add(new SwhPath("swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:cnt:0000000000000000000000000000000000000007"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:dir:0000000000000000000000000000000000000012",
+ "swh:1:cnt:0000000000000000000000000000000000000007"));
+ expectedPaths.add(new SwhPath("swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:cnt:0000000000000000000000000000000000000001"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:dir:0000000000000000000000000000000000000012",
+ "swh:1:cnt:0000000000000000000000000000000000000001"));
+ expectedPaths.add(new SwhPath("swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
- "swh:1:cnt:0000000000000000000000000000000000000004"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:dir:0000000000000000000000000000000000000012",
+ "swh:1:cnt:0000000000000000000000000000000000000004"));
+ expectedPaths.add(new SwhPath("swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
- "swh:1:cnt:0000000000000000000000000000000000000005"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:dir:0000000000000000000000000000000000000012",
- "swh:1:cnt:0000000000000000000000000000000000000011"
- ));
+ "swh:1:cnt:0000000000000000000000000000000000000005"));
+ expectedPaths.add(new SwhPath("swh:1:dir:0000000000000000000000000000000000000012",
+ "swh:1:cnt:0000000000000000000000000000000000000011"));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
@@ -183,10 +138,7 @@
ArrayList<SWHID> nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
- expectedPaths.add(
- new SwhPath(
- "swh:1:cnt:0000000000000000000000000000000000000004"
- ));
+ expectedPaths.add(new SwhPath("swh:1:cnt:0000000000000000000000000000000000000004"));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
@@ -202,10 +154,7 @@
ArrayList<SWHID> nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
- expectedPaths.add(
- new SwhPath(
- "swh:1:ori:0000000000000000000000000000000000000021"
- ));
+ expectedPaths.add(new SwhPath("swh:1:ori:0000000000000000000000000000000000000021"));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
@@ -221,13 +170,10 @@
ArrayList<SWHID> nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
- expectedPaths.add(
- new SwhPath(
- "swh:1:dir:0000000000000000000000000000000000000012",
+ expectedPaths.add(new SwhPath("swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000018",
- "swh:1:rel:0000000000000000000000000000000000000019"
- ));
+ "swh:1:rel:0000000000000000000000000000000000000019"));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
@@ -243,45 +189,33 @@
ArrayList<SWHID> nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
- expectedPaths.add(
- new SwhPath(
- "swh:1:cnt:0000000000000000000000000000000000000004",
+ expectedPaths.add(new SwhPath("swh:1:cnt:0000000000000000000000000000000000000004",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000018",
- "swh:1:rel:0000000000000000000000000000000000000019"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:cnt:0000000000000000000000000000000000000004",
+ "swh:1:rel:0000000000000000000000000000000000000019"));
+ expectedPaths.add(new SwhPath("swh:1:cnt:0000000000000000000000000000000000000004",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000018",
- "swh:1:rel:0000000000000000000000000000000000000019"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:cnt:0000000000000000000000000000000000000004",
+ "swh:1:rel:0000000000000000000000000000000000000019"));
+ expectedPaths.add(new SwhPath("swh:1:cnt:0000000000000000000000000000000000000004",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:snp:0000000000000000000000000000000000000020",
- "swh:1:ori:0000000000000000000000000000000000000021"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:cnt:0000000000000000000000000000000000000004",
+ "swh:1:ori:0000000000000000000000000000000000000021"));
+ expectedPaths.add(new SwhPath("swh:1:cnt:0000000000000000000000000000000000000004",
"swh:1:dir:0000000000000000000000000000000000000006",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:rel:0000000000000000000000000000000000000010",
"swh:1:snp:0000000000000000000000000000000000000020",
- "swh:1:ori:0000000000000000000000000000000000000021"
- ));
+ "swh:1:ori:0000000000000000000000000000000000000021"));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
@@ -297,11 +231,8 @@
ArrayList<SWHID> nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
- expectedPaths.add(
- new SwhPath(
- "swh:1:snp:0000000000000000000000000000000000000020",
- "swh:1:rev:0000000000000000000000000000000000000009"
- ));
+ expectedPaths.add(new SwhPath("swh:1:snp:0000000000000000000000000000000000000020",
+ "swh:1:rev:0000000000000000000000000000000000000009"));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
@@ -317,12 +248,9 @@
ArrayList<SWHID> nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
- expectedPaths.add(
- new SwhPath(
- "swh:1:rel:0000000000000000000000000000000000000010",
+ expectedPaths.add(new SwhPath("swh:1:rel:0000000000000000000000000000000000000010",
"swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:rev:0000000000000000000000000000000000000003"
- ));
+ "swh:1:rev:0000000000000000000000000000000000000003"));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
@@ -338,80 +266,50 @@
ArrayList<SWHID> nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
- expectedPaths.add(
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000013",
+ expectedPaths.add(new SwhPath("swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
- "swh:1:cnt:0000000000000000000000000000000000000005"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000013",
+ "swh:1:cnt:0000000000000000000000000000000000000005"));
+ expectedPaths.add(new SwhPath("swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
- "swh:1:cnt:0000000000000000000000000000000000000005"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000013",
+ "swh:1:cnt:0000000000000000000000000000000000000005"));
+ expectedPaths.add(new SwhPath("swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
- "swh:1:cnt:0000000000000000000000000000000000000004"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000013",
+ "swh:1:cnt:0000000000000000000000000000000000000004"));
+ expectedPaths.add(new SwhPath("swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:dir:0000000000000000000000000000000000000008",
"swh:1:dir:0000000000000000000000000000000000000006",
- "swh:1:cnt:0000000000000000000000000000000000000004"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000013",
+ "swh:1:cnt:0000000000000000000000000000000000000004"));
+ expectedPaths.add(new SwhPath("swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:cnt:0000000000000000000000000000000000000007"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000013",
+ "swh:1:cnt:0000000000000000000000000000000000000007"));
+ expectedPaths.add(new SwhPath("swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:cnt:0000000000000000000000000000000000000007"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000013",
+ "swh:1:cnt:0000000000000000000000000000000000000007"));
+ expectedPaths.add(new SwhPath("swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:dir:0000000000000000000000000000000000000012",
- "swh:1:cnt:0000000000000000000000000000000000000011"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000013",
+ "swh:1:cnt:0000000000000000000000000000000000000011"));
+ expectedPaths.add(new SwhPath("swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:rev:0000000000000000000000000000000000000003",
"swh:1:dir:0000000000000000000000000000000000000002",
- "swh:1:cnt:0000000000000000000000000000000000000001"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000013",
+ "swh:1:cnt:0000000000000000000000000000000000000001"));
+ expectedPaths.add(new SwhPath("swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:cnt:0000000000000000000000000000000000000001"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000013",
+ "swh:1:cnt:0000000000000000000000000000000000000001"));
+ expectedPaths.add(new SwhPath("swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:dir:0000000000000000000000000000000000000012",
"swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:cnt:0000000000000000000000000000000000000001"
- ));
+ "swh:1:cnt:0000000000000000000000000000000000000001"));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
@@ -427,24 +325,15 @@
ArrayList<SWHID> nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
- expectedPaths.add(
- new SwhPath(
- "swh:1:snp:0000000000000000000000000000000000000020",
+ expectedPaths.add(new SwhPath("swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:rev:0000000000000000000000000000000000000003",
- "swh:1:dir:0000000000000000000000000000000000000002"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:snp:0000000000000000000000000000000000000020",
+ "swh:1:dir:0000000000000000000000000000000000000002"));
+ expectedPaths.add(new SwhPath("swh:1:snp:0000000000000000000000000000000000000020",
"swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:dir:0000000000000000000000000000000000000008"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:snp:0000000000000000000000000000000000000020",
- "swh:1:rel:0000000000000000000000000000000000000010"
- ));
+ "swh:1:dir:0000000000000000000000000000000000000008"));
+ expectedPaths.add(new SwhPath("swh:1:snp:0000000000000000000000000000000000000020",
+ "swh:1:rel:0000000000000000000000000000000000000010"));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
@@ -460,10 +349,7 @@
ArrayList<SWHID> nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
- expectedPaths.add(
- new SwhPath(
- "swh:1:snp:0000000000000000000000000000000000000020"
- ));
+ expectedPaths.add(new SwhPath("swh:1:snp:0000000000000000000000000000000000000020"));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
@@ -479,20 +365,14 @@
ArrayList<SWHID> nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList<SwhPath> expectedPaths = new ArrayList<SwhPath>();
- expectedPaths.add(
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000003",
+ expectedPaths.add(new SwhPath("swh:1:rev:0000000000000000000000000000000000000003",
"swh:1:rev:0000000000000000000000000000000000000009",
"swh:1:rev:0000000000000000000000000000000000000013",
"swh:1:rev:0000000000000000000000000000000000000018",
- "swh:1:rel:0000000000000000000000000000000000000019"
- ));
- expectedPaths.add(
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000003",
+ "swh:1:rel:0000000000000000000000000000000000000019"));
+ expectedPaths.add(new SwhPath("swh:1:rev:0000000000000000000000000000000000000003",
"swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:rel:0000000000000000000000000000000000000010"
- ));
+ "swh:1:rel:0000000000000000000000000000000000000010"));
GraphTest.assertEqualsAnyOrder(expectedPaths, paths);
assertSameNodesFromPaths(expectedPaths, nodes);
diff --git a/java/src/test/java/org/softwareheritage/graph/WalkTest.java b/java/src/test/java/org/softwareheritage/graph/WalkTest.java
--- a/java/src/test/java/org/softwareheritage/graph/WalkTest.java
+++ b/java/src/test/java/org/softwareheritage/graph/WalkTest.java
@@ -15,23 +15,17 @@
SWHID src = new SWHID("swh:1:snp:0000000000000000000000000000000000000020");
String dstFmt = "swh:1:cnt:0000000000000000000000000000000000000005";
- SwhPath solution1 =
- new SwhPath(
- "swh:1:snp:0000000000000000000000000000000000000020",
- "swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:dir:0000000000000000000000000000000000000006",
- "swh:1:cnt:0000000000000000000000000000000000000005"
- );
- SwhPath solution2 =
- new SwhPath(
- "swh:1:snp:0000000000000000000000000000000000000020",
- "swh:1:rel:0000000000000000000000000000000000000010",
- "swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:dir:0000000000000000000000000000000000000006",
- "swh:1:cnt:0000000000000000000000000000000000000005"
- );
+ SwhPath solution1 = new SwhPath("swh:1:snp:0000000000000000000000000000000000000020",
+ "swh:1:rev:0000000000000000000000000000000000000009",
+ "swh:1:dir:0000000000000000000000000000000000000008",
+ "swh:1:dir:0000000000000000000000000000000000000006",
+ "swh:1:cnt:0000000000000000000000000000000000000005");
+ SwhPath solution2 = new SwhPath("swh:1:snp:0000000000000000000000000000000000000020",
+ "swh:1:rel:0000000000000000000000000000000000000010",
+ "swh:1:rev:0000000000000000000000000000000000000009",
+ "swh:1:dir:0000000000000000000000000000000000000008",
+ "swh:1:dir:0000000000000000000000000000000000000006",
+ "swh:1:cnt:0000000000000000000000000000000000000005");
Endpoint endpoint1 = new Endpoint(graph, "forward", "*");
SwhPath dfsPath = (SwhPath) endpoint1.walk(new Endpoint.Input(src, dstFmt, "dfs")).result;
@@ -49,10 +43,7 @@
SWHID src = new SWHID("swh:1:cnt:0000000000000000000000000000000000000007");
String dstFmt = "cnt";
- SwhPath expectedPath =
- new SwhPath(
- "swh:1:cnt:0000000000000000000000000000000000000007"
- );
+ SwhPath expectedPath = new SwhPath("swh:1:cnt:0000000000000000000000000000000000000007");
Endpoint endpoint1 = new Endpoint(graph, "forward", "*");
SwhPath dfsPath = (SwhPath) endpoint1.walk(new Endpoint.Input(src, dstFmt, "dfs")).result;
@@ -69,13 +60,10 @@
SWHID src = new SWHID("swh:1:rev:0000000000000000000000000000000000000018");
String dstFmt = "swh:1:rev:0000000000000000000000000000000000000003";
- SwhPath expectedPath =
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000018",
- "swh:1:rev:0000000000000000000000000000000000000013",
- "swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:rev:0000000000000000000000000000000000000003"
- );
+ SwhPath expectedPath = new SwhPath("swh:1:rev:0000000000000000000000000000000000000018",
+ "swh:1:rev:0000000000000000000000000000000000000013",
+ "swh:1:rev:0000000000000000000000000000000000000009",
+ "swh:1:rev:0000000000000000000000000000000000000003");
Endpoint endpoint1 = new Endpoint(graph, "forward", "rev:rev");
SwhPath dfsPath = (SwhPath) endpoint1.walk(new Endpoint.Input(src, dstFmt, "dfs")).result;
@@ -92,13 +80,10 @@
SWHID src = new SWHID("swh:1:rev:0000000000000000000000000000000000000003");
String dstFmt = "swh:1:rev:0000000000000000000000000000000000000018";
- SwhPath expectedPath =
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000003",
- "swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:rev:0000000000000000000000000000000000000013",
- "swh:1:rev:0000000000000000000000000000000000000018"
- );
+ SwhPath expectedPath = new SwhPath("swh:1:rev:0000000000000000000000000000000000000003",
+ "swh:1:rev:0000000000000000000000000000000000000009",
+ "swh:1:rev:0000000000000000000000000000000000000013",
+ "swh:1:rev:0000000000000000000000000000000000000018");
Endpoint endpoint1 = new Endpoint(graph, "backward", "rev:rev");
SwhPath dfsPath = (SwhPath) endpoint1.walk(new Endpoint.Input(src, dstFmt, "dfs")).result;
@@ -115,38 +100,26 @@
SWHID src = new SWHID("swh:1:cnt:0000000000000000000000000000000000000001");
String dstFmt = "snp";
- SwhPath solution1 =
- new SwhPath(
- "swh:1:cnt:0000000000000000000000000000000000000001",
- "swh:1:dir:0000000000000000000000000000000000000002",
- "swh:1:rev:0000000000000000000000000000000000000003",
- "swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:snp:0000000000000000000000000000000000000020"
- );
- SwhPath solution2 =
- new SwhPath(
- "swh:1:cnt:0000000000000000000000000000000000000001",
- "swh:1:dir:0000000000000000000000000000000000000002",
- "swh:1:rev:0000000000000000000000000000000000000003",
- "swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:rel:0000000000000000000000000000000000000010",
- "swh:1:snp:0000000000000000000000000000000000000020"
- );
- SwhPath solution3 =
- new SwhPath(
- "swh:1:cnt:0000000000000000000000000000000000000001",
- "swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:snp:0000000000000000000000000000000000000020"
- );
- SwhPath solution4 =
- new SwhPath(
- "swh:1:cnt:0000000000000000000000000000000000000001",
- "swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:rel:0000000000000000000000000000000000000010",
- "swh:1:snp:0000000000000000000000000000000000000020"
- );
+ SwhPath solution1 = new SwhPath("swh:1:cnt:0000000000000000000000000000000000000001",
+ "swh:1:dir:0000000000000000000000000000000000000002",
+ "swh:1:rev:0000000000000000000000000000000000000003",
+ "swh:1:rev:0000000000000000000000000000000000000009",
+ "swh:1:snp:0000000000000000000000000000000000000020");
+ SwhPath solution2 = new SwhPath("swh:1:cnt:0000000000000000000000000000000000000001",
+ "swh:1:dir:0000000000000000000000000000000000000002",
+ "swh:1:rev:0000000000000000000000000000000000000003",
+ "swh:1:rev:0000000000000000000000000000000000000009",
+ "swh:1:rel:0000000000000000000000000000000000000010",
+ "swh:1:snp:0000000000000000000000000000000000000020");
+ SwhPath solution3 = new SwhPath("swh:1:cnt:0000000000000000000000000000000000000001",
+ "swh:1:dir:0000000000000000000000000000000000000008",
+ "swh:1:rev:0000000000000000000000000000000000000009",
+ "swh:1:snp:0000000000000000000000000000000000000020");
+ SwhPath solution4 = new SwhPath("swh:1:cnt:0000000000000000000000000000000000000001",
+ "swh:1:dir:0000000000000000000000000000000000000008",
+ "swh:1:rev:0000000000000000000000000000000000000009",
+ "swh:1:rel:0000000000000000000000000000000000000010",
+ "swh:1:snp:0000000000000000000000000000000000000020");
Endpoint endpoint1 = new Endpoint(graph, "backward", "*");
SwhPath dfsPath = (SwhPath) endpoint1.walk(new Endpoint.Input(src, dstFmt, "dfs")).result;
@@ -164,47 +137,31 @@
SWHID src = new SWHID("swh:1:rev:0000000000000000000000000000000000000009");
String dstFmt = "cnt";
- SwhPath solution1 =
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:cnt:0000000000000000000000000000000000000007"
- );
- SwhPath solution2 =
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:dir:0000000000000000000000000000000000000006",
- "swh:1:cnt:0000000000000000000000000000000000000005"
- );
- SwhPath solution3 =
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:dir:0000000000000000000000000000000000000006",
- "swh:1:cnt:0000000000000000000000000000000000000004"
- );
- SwhPath solution4 =
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:dir:0000000000000000000000000000000000000008",
- "swh:1:cnt:0000000000000000000000000000000000000001"
- );
- SwhPath solution5 =
- new SwhPath(
- "swh:1:rev:0000000000000000000000000000000000000009",
- "swh:1:rev:0000000000000000000000000000000000000003",
- "swh:1:dir:0000000000000000000000000000000000000002",
- "swh:1:cnt:0000000000000000000000000000000000000001"
- );
+ SwhPath solution1 = new SwhPath("swh:1:rev:0000000000000000000000000000000000000009",
+ "swh:1:dir:0000000000000000000000000000000000000008",
+ "swh:1:cnt:0000000000000000000000000000000000000007");
+ SwhPath solution2 = new SwhPath("swh:1:rev:0000000000000000000000000000000000000009",
+ "swh:1:dir:0000000000000000000000000000000000000008",
+ "swh:1:dir:0000000000000000000000000000000000000006",
+ "swh:1:cnt:0000000000000000000000000000000000000005");
+ SwhPath solution3 = new SwhPath("swh:1:rev:0000000000000000000000000000000000000009",
+ "swh:1:dir:0000000000000000000000000000000000000008",
+ "swh:1:dir:0000000000000000000000000000000000000006",
+ "swh:1:cnt:0000000000000000000000000000000000000004");
+ SwhPath solution4 = new SwhPath("swh:1:rev:0000000000000000000000000000000000000009",
+ "swh:1:dir:0000000000000000000000000000000000000008",
+ "swh:1:cnt:0000000000000000000000000000000000000001");
+ SwhPath solution5 = new SwhPath("swh:1:rev:0000000000000000000000000000000000000009",
+ "swh:1:rev:0000000000000000000000000000000000000003",
+ "swh:1:dir:0000000000000000000000000000000000000002",
+ "swh:1:cnt:0000000000000000000000000000000000000001");
Endpoint endpoint1 = new Endpoint(graph, "forward", "rev:*,dir:*");
SwhPath dfsPath = (SwhPath) endpoint1.walk(new Endpoint.Input(src, dstFmt, "dfs")).result;
Endpoint endpoint2 = new Endpoint(graph, "forward", "rev:*,dir:*");
SwhPath bfsPath = (SwhPath) endpoint2.walk(new Endpoint.Input(src, dstFmt, "bfs")).result;
- List<SwhPath> possibleSolutions =
- Arrays.asList(solution1, solution2, solution3, solution4, solution5);
+ List<SwhPath> possibleSolutions = Arrays.asList(solution1, solution2, solution3, solution4, solution5);
Assert.assertTrue(possibleSolutions.contains(dfsPath));
Assert.assertTrue(possibleSolutions.contains(bfsPath));
}
@@ -215,13 +172,10 @@
SWHID src = new SWHID("swh:1:dir:0000000000000000000000000000000000000016");
String dstFmt = "rel";
- SwhPath expectedPath =
- new SwhPath(
- "swh:1:dir:0000000000000000000000000000000000000016",
- "swh:1:dir:0000000000000000000000000000000000000017",
- "swh:1:rev:0000000000000000000000000000000000000018",
- "swh:1:rel:0000000000000000000000000000000000000019"
- );
+ SwhPath expectedPath = new SwhPath("swh:1:dir:0000000000000000000000000000000000000016",
+ "swh:1:dir:0000000000000000000000000000000000000017",
+ "swh:1:rev:0000000000000000000000000000000000000018",
+ "swh:1:rel:0000000000000000000000000000000000000019");
Endpoint endpoint1 = new Endpoint(graph, "backward", "dir:dir,dir:rev,rev:*");
SwhPath dfsPath = (SwhPath) endpoint1.walk(new Endpoint.Input(src, dstFmt, "dfs")).result;

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 18, 8:43 AM (20 h, 52 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3235084

Event Timeline