diff --git a/java/README.md b/java/README.md
--- a/java/README.md
+++ b/java/README.md
@@ -27,7 +27,8 @@
-----
Unit tests rely on test data that are already available in the Git repository
-(under `src/swh/graph/tests/dataset/`). You generally only need to run them using Maven:
+(under `src/swh/graph/tests/dataset/`). You generally only need to run them
+using Maven:
```bash
$ mvn test
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
@@ -15,11 +15,11 @@
* The compressed graph is stored using the WebGraph
* ecosystem. Additional mappings are necessary because Software Heritage uses string based persistent
- * identifiers (PID) while WebGraph uses integers internally. These two mappings (long id ↔
- * PID) are used for the input (users refer to the graph using PID) and the output (convert back to
- * PID for users results). However, since graph traversal can be restricted depending on the node
+ * identifiers (SWHID) while WebGraph uses integers internally. These two mappings (long id ↔
+ * SWHID) are used for the input (users refer to the graph using SWHID) and the output (convert back to
+ * SWHID for users results). However, since graph traversal can be restricted depending on the node
* type (see {@link AllowedEdges}), a long id → node type map is stored as well to avoid a full
- * PID lookup.
+ * SWHID lookup.
*
* @author The Software Heritage developers
* @see org.softwareheritage.graph.AllowedEdges
@@ -28,10 +28,10 @@
*/
public class Graph extends ImmutableGraph {
- /** File extension for the SWH PID to long node id map */
- public static final String PID_TO_NODE = ".pid2node.bin";
- /** File extension for the long node id to SWH PID map */
- public static final String NODE_TO_PID = ".node2pid.bin";
+ /** File extension for the SWHID to long node id map */
+ public static final String SWHID_TO_NODE = ".swhid2node.bin";
+ /** File extension for the long node id to SWHID map */
+ public static final String NODE_TO_SWHID = ".node2swhid.bin";
/** File extension for the long node id to node type map */
public static final String NODE_TO_TYPE = ".node2type.map";
@@ -41,7 +41,7 @@
ImmutableGraph graphTransposed;
/** Path and basename of the compressed graph */
String path;
- /** Mapping long id ↔ SWH PIDs */
+ /** Mapping long id ↔ SWHIDs */
NodeIdMap nodeIdMap;
/** Mapping long id → node types */
NodeTypesMap nodeTypesMap;
@@ -222,25 +222,25 @@
}
/**
- * Converts {@link SwhPID} node to long.
+ * Converts {@link SWHID} node to long.
*
- * @param swhPID node specified as a {@link SwhPID}
+ * @param swhid node specified as a {@link SWHID}
* @return internal long node id
- * @see org.softwareheritage.graph.SwhPID
+ * @see SWHID
*/
- public long getNodeId(SwhPID swhPID) {
- return nodeIdMap.getNodeId(swhPID);
+ public long getNodeId(SWHID swhid) {
+ return nodeIdMap.getNodeId(swhid);
}
/**
- * Converts long id node to {@link SwhPID}.
+ * Converts long id node to {@link SWHID}.
*
* @param nodeId node specified as a long id
- * @return external SWH PID
- * @see org.softwareheritage.graph.SwhPID
+ * @return external SWHID
+ * @see SWHID
*/
- public SwhPID getSwhPID(long nodeId) {
- return nodeIdMap.getSwhPID(nodeId);
+ public SWHID getSWHID(long nodeId) {
+ return nodeIdMap.getSWHID(nodeId);
}
/**
diff --git a/java/src/main/java/org/softwareheritage/graph/SwhPID.java b/java/src/main/java/org/softwareheritage/graph/SWHID.java
rename from java/src/main/java/org/softwareheritage/graph/SwhPID.java
rename to java/src/main/java/org/softwareheritage/graph/SWHID.java
--- a/java/src/main/java/org/softwareheritage/graph/SwhPID.java
+++ b/java/src/main/java/org/softwareheritage/graph/SWHID.java
@@ -5,117 +5,117 @@
import org.apache.commons.codec.binary.Hex;
/**
- * A Software Heritage PID, see persistent
* identifier documentation.
*
* @author The Software Heritage developers
*/
-public class SwhPID {
- /** Fixed hash length of the PID */
+public class SWHID {
+ /** Fixed hash length of the SWHID */
public static final int HASH_LENGTH = 40;
- /** Full PID as a string */
- String swhPID;
- /** PID node type */
+ /** Full SWHID as a string */
+ String swhid;
+ /** SWHID node type */
Node.Type type;
/**
* Constructor.
*
- * @param swhPID full PID as a string
+ * @param swhid full SWHID as a string
*/
- public SwhPID(String swhPID) {
- this.swhPID = swhPID;
+ public SWHID(String swhid) {
+ this.swhid = swhid;
- // PID format: 'swh:1:type:hash'
- String[] parts = swhPID.split(":");
+ // SWHID format: 'swh:1:type:hash'
+ String[] parts = swhid.split(":");
if (parts.length != 4 || !parts[0].equals("swh") || !parts[1].equals("1")) {
- throw new IllegalArgumentException("malformed SWH PID: " + swhPID);
+ throw new IllegalArgumentException("malformed SWHID: " + swhid);
}
this.type = Node.Type.fromStr(parts[2]);
if (!parts[3].matches("[0-9a-f]{" + HASH_LENGTH + "}")) {
- throw new IllegalArgumentException("malformed SWH PID: " + swhPID);
+ throw new IllegalArgumentException("malformed SWHID: " + swhid);
}
}
/**
- * Creates a SwhPID from a compact binary representation.
+ * Creates a SWHID from a compact binary representation.
*
* The binary format is specified in the Python module
- * swh.graph.pid:str_to_bytes .
+ * swh.graph.swhid:str_to_bytes .
*/
- public static SwhPID fromBytes(byte[] input) {
+ public static SWHID fromBytes(byte[] input) {
byte[] digest = new byte[20];
System.arraycopy(input, 2, digest, 0, digest.length);
- String pidStr = String.format(
+ String swhidStr = String.format(
"swh:%d:%s:%s",
input[0],
Node.Type.fromInt(input[1]).toString().toLowerCase(),
Hex.encodeHexString(digest)
);
- return new SwhPID(pidStr);
+ return new SWHID(swhidStr);
}
@Override
public boolean equals(Object otherObj) {
if (otherObj == this)
return true;
- if (!(otherObj instanceof SwhPID))
+ if (!(otherObj instanceof SWHID))
return false;
- SwhPID other = (SwhPID) otherObj;
- return swhPID.equals(other.getSwhPID());
+ SWHID other = (SWHID) otherObj;
+ return swhid.equals(other.getSWHID());
}
@Override
public int hashCode() {
- return swhPID.hashCode();
+ return swhid.hashCode();
}
@Override
public String toString() {
- return swhPID;
+ return swhid;
}
/**
- * Converts PID to a compact binary representation.
+ * Converts SWHID to a compact binary representation.
*
* The binary format is specified in the Python module
- * swh.graph.pid:str_to_bytes .
+ * 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); // PID type
+ bytes[1] = (byte) Node.Type.toInt(this.type); // SWHID type
try {
- digest = Hex.decodeHex(this.swhPID.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 PID: " + this.swhPID);
+ throw new IllegalArgumentException("invalid hex sequence in SWHID: " + this.swhid);
}
return bytes;
}
/**
- * Returns full PID as a string.
+ * Returns full SWHID as a string.
*
- * @return full PID string
+ * @return full SWHID string
*/
@JsonValue
- public String getSwhPID() {
- return swhPID;
+ public String getSWHID() {
+ return swhid;
}
/**
- * Returns PID node type.
+ * Returns SWHID node type.
*
- * @return PID corresponding {@link Node.Type}
+ * @return SWHID corresponding {@link Node.Type}
* @see org.softwareheritage.graph.Node.Type
*/
public Node.Type getType() {
diff --git a/java/src/main/java/org/softwareheritage/graph/SwhPath.java b/java/src/main/java/org/softwareheritage/graph/SwhPath.java
--- a/java/src/main/java/org/softwareheritage/graph/SwhPath.java
+++ b/java/src/main/java/org/softwareheritage/graph/SwhPath.java
@@ -5,15 +5,15 @@
import java.util.ArrayList;
/**
- * Wrapper class to store a list of {@link SwhPID}.
+ * Wrapper class to store a list of {@link SWHID}.
*
* @author The Software Heritage developers
- * @see org.softwareheritage.graph.SwhPID
+ * @see SWHID
*/
public class SwhPath {
- /** Internal list of {@link SwhPID} */
- ArrayList path;
+ /** Internal list of {@link SWHID} */
+ ArrayList path;
/**
* Constructor.
@@ -25,57 +25,57 @@
/**
* Constructor.
*
- * @param swhPIDs variable number of string PIDs to initialize this path with
+ * @param swhids variable number of string SWHIDs to initialize this path with
*/
- public SwhPath(String... swhPIDs) {
+ public SwhPath(String... swhids) {
this();
- for (String swhPID : swhPIDs) {
- add(new SwhPID(swhPID));
+ for (String swhid : swhids) {
+ add(new SWHID(swhid));
}
}
/**
* Constructor.
*
- * @param swhPIDs variable number of {@link SwhPID} to initialize this path with
- * @see org.softwareheritage.graph.SwhPID
+ * @param swhids variable number of {@link SWHID} to initialize this path with
+ * @see SWHID
*/
- public SwhPath(SwhPID... swhPIDs) {
+ public SwhPath(SWHID... swhids) {
this();
- for (SwhPID swhPID : swhPIDs) {
- add(swhPID);
+ for (SWHID swhid : swhids) {
+ add(swhid);
}
}
/**
- * Returns this path as a list of {@link SwhPID}.
+ * Returns this path as a list of {@link SWHID}.
*
- * @return list of {@link SwhPID} constituting the path
- * @see org.softwareheritage.graph.SwhPID
+ * @return list of {@link SWHID} constituting the path
+ * @see SWHID
*/
@JsonValue
- public ArrayList getPath() {
+ public ArrayList getPath() {
return path;
}
/**
- * Adds a {@link SwhPID} to this path.
+ * Adds a {@link SWHID} to this path.
*
- * @param swhPID {@link SwhPID} to add to this path
- * @see org.softwareheritage.graph.SwhPID
+ * @param swhid {@link SWHID} to add to this path
+ * @see SWHID
*/
- public void add(SwhPID swhPID) {
- path.add(swhPID);
+ public void add(SWHID swhid) {
+ path.add(swhid);
}
/**
- * Returns the {@link SwhPID} at the specified position in this path.
+ * Returns the {@link SWHID} at the specified position in this path.
*
- * @param index position of the {@link SwhPID} to return
- * @return {@link SwhPID} at the specified position
- * @see org.softwareheritage.graph.SwhPID
+ * @param index position of the {@link SWHID} to return
+ * @return {@link SWHID} at the specified position
+ * @see SWHID
*/
- public SwhPID get(int index) {
+ public SWHID get(int index) {
return path.get(index);
}
@@ -101,9 +101,9 @@
}
for (int i = 0; i < size(); i++) {
- SwhPID thisSwhPID = get(i);
- SwhPID otherSwhPID = other.get(i);
- if (!thisSwhPID.equals(otherSwhPID)) {
+ SWHID thisSWHID = get(i);
+ SWHID otherSWHID = other.get(i);
+ if (!thisSWHID.equals(otherSWHID)) {
return false;
}
}
@@ -114,8 +114,8 @@
@Override
public String toString() {
StringBuilder str = new StringBuilder();
- for (SwhPID swhPID : path) {
- str.append(swhPID).append("/");
+ for (SWHID swhid : path) {
+ str.append(swhid).append("/");
}
return str.toString();
}
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
@@ -11,8 +11,7 @@
* Traversal algorithms on the compressed graph.
*
* Internal implementation of the traversal API endpoints. These methods only input/output internal
- * long ids, which are converted in the {@link Endpoint} higher-level class to Software Heritage
- * PID.
+ * long ids, which are converted in the {@link Endpoint} higher-level class to {@link SWHID}.
*
* @author The Software Heritage developers
* @see Endpoint
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
@@ -2,7 +2,7 @@
import com.martiansoftware.jsap.*;
import org.softwareheritage.graph.Graph;
-import org.softwareheritage.graph.SwhPID;
+import org.softwareheritage.graph.SWHID;
import org.softwareheritage.graph.benchmark.utils.Random;
import org.softwareheritage.graph.benchmark.utils.Statistics;
import org.softwareheritage.graph.server.Endpoint;
@@ -70,11 +70,11 @@
try (Writer csvLog = new BufferedWriter(new FileWriter(args.logFile))) {
StringJoiner csvHeader = new StringJoiner(CSV_SEPARATOR);
csvHeader.add("use case name")
- .add("SWH PID")
+ .add("SWHID")
.add("number of edges accessed")
.add("traversal timing")
- .add("pid2node timing")
- .add("node2pid timing");
+ .add("swhid2node timing")
+ .add("node2swhid timing");
csvLog.write(csvHeader.toString() + "\n");
}
}
@@ -100,19 +100,19 @@
final boolean append = true;
try (Writer csvLog = new BufferedWriter(new FileWriter(args.logFile, append))) {
for (long nodeId : nodeIds) {
- SwhPID swhPID = graph.getSwhPID(nodeId);
+ SWHID swhid = graph.getSWHID(nodeId);
Endpoint.Output output = (dstFmt == null)
- ? operation.apply(new Endpoint.Input(swhPID))
- : operation.apply(new Endpoint.Input(swhPID, dstFmt, algorithm));
+ ? operation.apply(new Endpoint.Input(swhid))
+ : operation.apply(new Endpoint.Input(swhid, dstFmt, algorithm));
StringJoiner csvLine = new StringJoiner(CSV_SEPARATOR);
csvLine.add(useCaseName)
- .add(swhPID.toString())
+ .add(swhid.toString())
.add(Long.toString(output.meta.nbEdgesAccessed))
.add(Double.toString(output.meta.timings.traversal))
- .add(Double.toString(output.meta.timings.pid2node))
- .add(Double.toString(output.meta.timings.node2pid));
+ .add(Double.toString(output.meta.timings.swhid2node))
+ .add(Double.toString(output.meta.timings.node2swhid));
csvLog.write(csvLine.toString() + "\n");
timings.add(output.meta.timings.traversal);
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
@@ -1,12 +1,12 @@
package org.softwareheritage.graph.maps;
import org.softwareheritage.graph.Graph;
-import org.softwareheritage.graph.SwhPID;
+import org.softwareheritage.graph.SWHID;
import java.io.IOException;
/**
- * Mapping between internal long node id and external SWH PID.
+ * Mapping between internal long node id and external SWHID.
*
* Mappings in both directions are pre-computed and dumped on disk in the
* {@link NodeMapBuilder} class, then they are loaded here using mmap().
@@ -16,13 +16,13 @@
*/
public class NodeIdMap {
- /** Fixed length of full SWH PID */
- public static final int SWH_ID_LENGTH = 50;
+ /** Fixed length of full SWHID */
+ public static final int SWHID_LENGTH = 50;
/** Fixed length of long node id */
public static final int NODE_ID_LENGTH = 20;
- /** Fixed length of binary SWH PID buffer */
- public static final int SWH_ID_BIN_SIZE = 22;
+ /** Fixed length of binary SWHID buffer */
+ public static final int SWHID_BIN_SIZE = 22;
/** Fixed length of binary node id buffer */
public static final int NODE_ID_BIN_SIZE = 8;
@@ -30,9 +30,9 @@
String graphPath;
/** Number of ids to map */
long nbIds;
- /** mmap()-ed PID_TO_NODE file */
+ /** mmap()-ed SWHID_TO_NODE file */
MapFile swhToNodeMap;
- /** mmap()-ed NODE_TO_PID file */
+ /** mmap()-ed NODE_TO_SWHID file */
MapFile nodeToSwhMap;
/**
@@ -45,19 +45,19 @@
this.graphPath = graphPath;
this.nbIds = nbNodes;
- this.swhToNodeMap = new MapFile(graphPath + Graph.PID_TO_NODE, SWH_ID_BIN_SIZE + NODE_ID_BIN_SIZE);
- this.nodeToSwhMap = new MapFile(graphPath + Graph.NODE_TO_PID, SWH_ID_BIN_SIZE);
+ this.swhToNodeMap = new MapFile(graphPath + Graph.SWHID_TO_NODE, SWHID_BIN_SIZE + NODE_ID_BIN_SIZE);
+ this.nodeToSwhMap = new MapFile(graphPath + Graph.NODE_TO_SWHID, SWHID_BIN_SIZE);
}
/**
- * Converts SWH PID to corresponding long node id.
+ * Converts SWHID to corresponding long node id.
*
- * @param swhPID node represented as a {@link SwhPID}
+ * @param swhid node represented as a {@link SWHID}
* @return corresponding node as a long id
- * @see org.softwareheritage.graph.SwhPID
+ * @see SWHID
*/
- public long getNodeId(SwhPID swhPID) {
- // The file is sorted by swhPID, hence we can binary search on swhPID to get corresponding
+ public long getNodeId(SWHID swhid) {
+ // The file is sorted by swhid, hence we can binary search on swhid to get corresponding
// nodeId
long start = 0;
long end = nbIds - 1;
@@ -65,15 +65,15 @@
while (start <= end) {
long lineNumber = (start + end) / 2L;
byte[] buffer = swhToNodeMap.readAtLine(lineNumber);
- byte[] pidBuffer = new byte[SWH_ID_BIN_SIZE];
+ byte[] swhidBuffer = new byte[SWHID_BIN_SIZE];
byte[] nodeBuffer = new byte[NODE_ID_BIN_SIZE];
- System.arraycopy(buffer, 0, pidBuffer, 0, SWH_ID_BIN_SIZE);
- System.arraycopy(buffer, SWH_ID_BIN_SIZE, nodeBuffer, 0, NODE_ID_BIN_SIZE);
+ System.arraycopy(buffer, 0, swhidBuffer, 0, SWHID_BIN_SIZE);
+ System.arraycopy(buffer, SWHID_BIN_SIZE, nodeBuffer, 0, NODE_ID_BIN_SIZE);
- String currentSwhPID = SwhPID.fromBytes(pidBuffer).getSwhPID();
+ String currentSWHID = SWHID.fromBytes(swhidBuffer).getSWHID();
long currentNodeId = java.nio.ByteBuffer.wrap(nodeBuffer).getLong();
- int cmp = currentSwhPID.compareTo(swhPID.toString());
+ int cmp = currentSWHID.compareTo(swhid.toString());
if (cmp == 0) {
return currentNodeId;
} else if (cmp < 0) {
@@ -83,25 +83,25 @@
}
}
- throw new IllegalArgumentException("Unknown SWH PID: " + swhPID);
+ throw new IllegalArgumentException("Unknown SWHID: " + swhid);
}
/**
- * Converts a node long id to corresponding SWH PID.
+ * Converts a node long id to corresponding SWHID.
*
* @param nodeId node as a long id
- * @return corresponding node as a {@link SwhPID}
- * @see org.softwareheritage.graph.SwhPID
+ * @return corresponding node as a {@link SWHID}
+ * @see SWHID
*/
- public SwhPID getSwhPID(long nodeId) {
- // Each line in NODE_TO_PID is formatted as: swhPID
- // The file is ordered by nodeId, meaning node0's swhPID is at line 0, hence we can read the
- // nodeId-th line to get corresponding swhPID
+ 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
+ // nodeId-th line to get corresponding swhid
if (nodeId < 0 || nodeId >= nbIds) {
throw new IllegalArgumentException("Node id " + nodeId + " should be between 0 and " + nbIds);
}
- return SwhPID.fromBytes(nodeToSwhMap.readAtLine(nodeId));
+ return SWHID.fromBytes(nodeToSwhMap.readAtLine(nodeId));
}
/**
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
@@ -14,7 +14,7 @@
import org.slf4j.LoggerFactory;
import org.softwareheritage.graph.Graph;
import org.softwareheritage.graph.Node;
-import org.softwareheritage.graph.SwhPID;
+import org.softwareheritage.graph.SWHID;
import java.io.*;
import java.nio.charset.StandardCharsets;
@@ -24,8 +24,8 @@
/**
* Create maps needed at runtime by the graph service, in particular:
*
- * - SWH PID → WebGraph long node id
- * - WebGraph long node id → SWH PID (converse of the former)
+ * - 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
@@ -63,16 +63,16 @@
@SuppressWarnings("unchecked")
static void precomputeNodeIdMap(String graphPath, String tmpDir)
throws IOException {
- ProgressLogger plPid2Node = new ProgressLogger(logger, 10, TimeUnit.SECONDS);
- ProgressLogger plNode2Pid = new ProgressLogger(logger, 10, TimeUnit.SECONDS);
- plPid2Node.itemsName = "pid→node";
- plNode2Pid.itemsName = "node→pid";
+ ProgressLogger plSWHID2Node = new ProgressLogger(logger, 10, TimeUnit.SECONDS);
+ ProgressLogger plNode2SWHID = new ProgressLogger(logger, 10, TimeUnit.SECONDS);
+ plSWHID2Node.itemsName = "swhid→node";
+ plNode2SWHID.itemsName = "node→swhid";
- // avg speed for pid→node is sometime skewed due to write to the sort
+ // avg speed for swhid→node is sometime skewed due to write to the sort
// pipe hanging when sort is sorting; hence also desplay local speed
- plPid2Node.displayLocalSpeed = true;
+ plSWHID2Node.displayLocalSpeed = true;
- // first half of PID->node mapping: PID -> WebGraph MPH (long)
+ // first half of SWHID->node mapping: SWHID -> WebGraph MPH (long)
Object2LongFunction mphMap = null;
try {
logger.info("loading MPH function...");
@@ -83,10 +83,10 @@
System.exit(2);
}
long nbIds = (mphMap instanceof Size64) ? ((Size64) mphMap).size64() : mphMap.size();
- plPid2Node.expectedUpdates = nbIds;
- plNode2Pid.expectedUpdates = nbIds;
+ plSWHID2Node.expectedUpdates = nbIds;
+ plNode2SWHID.expectedUpdates = nbIds;
- // second half of PID->node mapping: WebGraph MPH (long) -> BFS order (long)
+ // second half of SWHID->node mapping: WebGraph MPH (long) -> BFS order (long)
long[][] bfsMap = LongBigArrays.newBigArray(nbIds);
logger.info("loading BFS order file...");
long loaded = BinIO.loadLongs(graphPath + ".order", bfsMap);
@@ -96,15 +96,15 @@
System.exit(2);
}
- // Create mapping SWH PID -> WebGraph node id, by sequentially reading
+ // 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));
- LineIterator swhPIDIterator = new LineIterator(buffer);
+ LineIterator swhidIterator = new LineIterator(buffer);
- // The WebGraph node id -> SWH PID mapping can be obtained from the
- // PID->node one by numerically sorting on node id and sequentially
- // writing obtained PIDs to a binary map. Delegates the sorting job to
+ // The WebGraph node id -> SWHID mapping can be obtained from the
+ // SWHID->node one by numerically sorting on node id and sequentially
+ // 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",
@@ -114,15 +114,15 @@
BufferedOutputStream sort_stdin = new BufferedOutputStream(sort.getOutputStream());
BufferedInputStream sort_stdout = new BufferedInputStream(sort.getInputStream());
- // for the binary format of pidToNodeMap, see Python module swh.graph.pid:PidToIntMap
- // for the binary format of nodeToPidMap, see Python module swh.graph.pid:IntToPidMap
- try (DataOutputStream pidToNodeMap = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(graphPath + Graph.PID_TO_NODE)));
- BufferedOutputStream nodeToPidMap = new BufferedOutputStream(new FileOutputStream(graphPath + Graph.NODE_TO_PID))) {
+ // 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 PID/node
- // pairs while pidToNodeMap is being filled, and will itself fill
- // nodeToPidMap as soon as data from sort is ready
- SortOutputHandler outputHandler = new SortOutputHandler(sort_stdout, nodeToPidMap, plNode2Pid);
+ // background handler for sort output, it will be fed SWHID/node
+ // pairs while swhidToNodeMap is being filled, and will itself fill
+ // nodeToSwhidMap as soon as data from sort is ready
+ SortOutputHandler outputHandler = new SortOutputHandler(sort_stdout, nodeToSwhidMap, plNode2SWHID);
outputHandler.start();
// Type map from WebGraph node ID to SWH type. Used at runtime by
@@ -135,24 +135,24 @@
LongArrayBitVector.ofLength(nbBitsPerNodeType * nbIds);
LongBigList nodeTypesMap = nodeTypesBitVector.asLongBigList(nbBitsPerNodeType);
- plPid2Node.start("filling pid2node map");
- for (long iNode = 0; iNode < nbIds && swhPIDIterator.hasNext(); iNode++) {
- String strSwhPID = swhPIDIterator.next().toString();
- SwhPID swhPID = new SwhPID(strSwhPID);
- byte[] swhPIDBin = swhPID.toBytes();
+ plSWHID2Node.start("filling swhid2node map");
+ for (long iNode = 0; iNode < nbIds && swhidIterator.hasNext(); iNode++) {
+ String swhidStr = swhidIterator.next().toString();
+ SWHID swhid = new SWHID(swhidStr);
+ byte[] swhidBin = swhid.toBytes();
- long mphId = mphMap.getLong(strSwhPID);
+ long mphId = mphMap.getLong(swhidStr);
long nodeId = BigArrays.get(bfsMap, mphId);
- pidToNodeMap.write(swhPIDBin, 0, swhPIDBin.length);
- pidToNodeMap.writeLong(nodeId);
- sort_stdin.write((strSwhPID + "\t" + nodeId + "\n")
+ swhidToNodeMap.write(swhidBin, 0, swhidBin.length);
+ swhidToNodeMap.writeLong(nodeId);
+ sort_stdin.write((swhidStr + "\t" + nodeId + "\n")
.getBytes(StandardCharsets.US_ASCII));
- nodeTypesMap.set(nodeId, swhPID.getType().ordinal());
- plPid2Node.lightUpdate();
+ nodeTypesMap.set(nodeId, swhid.getType().ordinal());
+ plSWHID2Node.lightUpdate();
}
- plPid2Node.done();
+ plSWHID2Node.done();
sort_stdin.close();
// write type map
@@ -160,9 +160,9 @@
BinIO.storeObject(nodeTypesMap, graphPath + Graph.NODE_TO_TYPE);
logger.info("type map stored");
- // wait for nodeToPidMap filling
+ // wait for nodeToSwhidMap filling
try {
- logger.info("waiting for node2pid map...");
+ logger.info("waiting for node2swhid map...");
int sortExitCode = sort.waitFor();
if (sortExitCode != 0) {
logger.error("sort returned non-zero exit code: " + sortExitCode);
@@ -190,18 +190,18 @@
public void run() {
boolean sortDone = false;
- logger.info("node2pid: waiting for sort output...");
+ logger.info("node2swhid: waiting for sort output...");
while (input.hasNextLine()) {
if (!sortDone) {
sortDone = true;
- this.pl.start("filling node2pid map");
+ this.pl.start("filling node2swhid map");
}
- String line = input.nextLine(); // format: SWH_PID NODE_ID
- SwhPID swhPID = new SwhPID(line.split("\\t")[0]); // get PID
+ String line = input.nextLine(); // format: SWHID NODE_ID
+ SWHID swhid = new SWHID(line.split("\\t")[0]); // get SWHID
try {
- output.write((byte[]) swhPID.toBytes());
+ output.write((byte[]) swhid.toBytes());
} catch (IOException e) {
- logger.error("writing to node->PID map failed with: " + e);
+ logger.error("writing to node->SWHID map failed with: " + e);
}
this.pl.lightUpdate();
}
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
@@ -8,7 +8,7 @@
import io.javalin.plugin.json.JavalinJackson;
import org.softwareheritage.graph.Graph;
import org.softwareheritage.graph.Stats;
-import org.softwareheritage.graph.SwhPID;
+import org.softwareheritage.graph.SWHID;
import java.io.IOException;
import java.util.List;
@@ -103,7 +103,7 @@
// By default the traversal is a forward DFS using all edges
app.get("/leaves/:src", ctx -> {
- SwhPID src = new SwhPID(ctx.pathParam("src"));
+ SWHID src = new SWHID(ctx.pathParam("src"));
String direction = ctx.queryParam("direction", "forward");
String edgesFmt = ctx.queryParam("edges", "*");
@@ -113,7 +113,7 @@
});
app.get("/neighbors/:src", ctx -> {
- SwhPID src = new SwhPID(ctx.pathParam("src"));
+ SWHID src = new SWHID(ctx.pathParam("src"));
String direction = ctx.queryParam("direction", "forward");
String edgesFmt = ctx.queryParam("edges", "*");
@@ -123,7 +123,7 @@
});
app.get("/visit/nodes/:src", ctx -> {
- SwhPID src = new SwhPID(ctx.pathParam("src"));
+ SWHID src = new SWHID(ctx.pathParam("src"));
String direction = ctx.queryParam("direction", "forward");
String edgesFmt = ctx.queryParam("edges", "*");
@@ -133,7 +133,7 @@
});
app.get("/visit/paths/:src", ctx -> {
- SwhPID src = new SwhPID(ctx.pathParam("src"));
+ SWHID src = new SWHID(ctx.pathParam("src"));
String direction = ctx.queryParam("direction", "forward");
String edgesFmt = ctx.queryParam("edges", "*");
@@ -143,7 +143,7 @@
});
app.get("/walk/:src/:dst", ctx -> {
- SwhPID src = new SwhPID(ctx.pathParam("src"));
+ SWHID src = new SWHID(ctx.pathParam("src"));
String dstFmt = ctx.pathParam("dst");
String direction = ctx.queryParam("direction", "forward");
String edgesFmt = ctx.queryParam("edges", "*");
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
@@ -36,17 +36,17 @@
}
/**
- * Converts a list of (internal) long node ids to a list of corresponding (external) SWH PIDs.
+ * Converts a list of (internal) long node ids to a list of corresponding (external) SWHIDs.
*
* @param nodeIds the list of long node ids
- * @return a list of corresponding SWH PIDs
+ * @return a list of corresponding SWHIDs
*/
- private ArrayList convertNodesToSwhPIDs(ArrayList nodeIds) {
- ArrayList swhPIDs = new ArrayList<>();
+ private ArrayList convertNodesToSWHIDs(ArrayList nodeIds) {
+ ArrayList swhids = new ArrayList<>();
for (long nodeId : nodeIds) {
- swhPIDs.add(graph.getSwhPID(nodeId));
+ swhids.add(graph.getSWHID(nodeId));
}
- return swhPIDs;
+ return swhids;
}
/**
@@ -59,7 +59,7 @@
private SwhPath convertNodesToSwhPath(ArrayList nodeIds) {
SwhPath path = new SwhPath();
for (long nodeId : nodeIds) {
- path.add(graph.getSwhPID(nodeId));
+ path.add(graph.getSWHID(nodeId));
}
return path;
}
@@ -71,7 +71,7 @@
* @return a list of corresponding {@link SwhPath}
* @see org.softwareheritage.graph.SwhPath
*/
- private ArrayList convertPathsToSwhPIDs(ArrayList> pathsNodeId) {
+ private ArrayList convertPathsToSWHIDs(ArrayList> pathsNodeId) {
ArrayList paths = new ArrayList<>();
for (ArrayList path : pathsNodeId) {
paths.add(convertNodesToSwhPath(path));
@@ -83,17 +83,17 @@
* Leaves endpoint wrapper.
*
* @param input input parameters for the underlying endpoint call
- * @return the resulting list of {@link SwhPID} from endpoint call and operation metadata
- * @see org.softwareheritage.graph.SwhPID
+ * @return the resulting list of {@link SWHID} from endpoint call and operation metadata
+ * @see SWHID
* @see Traversal#leaves(long)
*/
public Output leaves(Input input) {
- Output> output = new Output<>();
+ Output> output = new Output<>();
long startTime;
startTime = Timing.start();
long srcNodeId = graph.getNodeId(input.src);
- output.meta.timings.pid2node = Timing.stop(startTime);
+ output.meta.timings.swhid2node = Timing.stop(startTime);
startTime = Timing.start();
ArrayList nodeIds = traversal.leaves(srcNodeId);
@@ -101,8 +101,8 @@
output.meta.nbEdgesAccessed = traversal.getNbEdgesAccessed();
startTime = Timing.start();
- output.result = convertNodesToSwhPIDs(nodeIds);
- output.meta.timings.node2pid = Timing.stop(startTime);
+ output.result = convertNodesToSWHIDs(nodeIds);
+ output.meta.timings.node2swhid = Timing.stop(startTime);
return output;
}
@@ -111,17 +111,17 @@
* Neighbors endpoint wrapper.
*
* @param input input parameters for the underlying endpoint call
- * @return the resulting list of {@link SwhPID} from endpoint call and operation metadata
- * @see org.softwareheritage.graph.SwhPID
+ * @return the resulting list of {@link SWHID} from endpoint call and operation metadata
+ * @see SWHID
* @see Traversal#neighbors(long)
*/
public Output neighbors(Input input) {
- Output> output = new Output<>();
+ Output> output = new Output<>();
long startTime;
startTime = Timing.start();
long srcNodeId = graph.getNodeId(input.src);
- output.meta.timings.pid2node = Timing.stop(startTime);
+ output.meta.timings.swhid2node = Timing.stop(startTime);
startTime = Timing.start();
ArrayList nodeIds = traversal.neighbors(srcNodeId);
@@ -129,8 +129,8 @@
output.meta.nbEdgesAccessed = traversal.getNbEdgesAccessed();
startTime = Timing.start();
- output.result = convertNodesToSwhPIDs(nodeIds);
- output.meta.timings.node2pid = Timing.stop(startTime);
+ output.result = convertNodesToSWHIDs(nodeIds);
+ output.meta.timings.node2swhid = Timing.stop(startTime);
return output;
}
@@ -140,7 +140,7 @@
*
* @param input input parameters for the underlying endpoint call
* @return the resulting {@link SwhPath} from endpoint call and operation metadata
- * @see org.softwareheritage.graph.SwhPID
+ * @see SWHID
* @see org.softwareheritage.graph.SwhPath
* @see Traversal#walk
*/
@@ -150,14 +150,14 @@
startTime = Timing.start();
long srcNodeId = graph.getNodeId(input.src);
- output.meta.timings.pid2node = Timing.stop(startTime);
+ output.meta.timings.swhid2node = Timing.stop(startTime);
ArrayList nodeIds = new ArrayList();
- // Destination is either a SWH PID or a node type
+ // Destination is either a SWHID or a node type
try {
- SwhPID dstSwhPID = new SwhPID(input.dstFmt);
- long dstNodeId = graph.getNodeId(dstSwhPID);
+ SWHID dstSWHID = new SWHID(input.dstFmt);
+ long dstNodeId = graph.getNodeId(dstSWHID);
startTime = Timing.start();
nodeIds = traversal.walk(srcNodeId, dstNodeId, input.algorithm);
@@ -177,7 +177,7 @@
startTime = Timing.start();
output.result = convertNodesToSwhPath(nodeIds);
- output.meta.timings.node2pid = Timing.stop(startTime);
+ output.meta.timings.node2swhid = Timing.stop(startTime);
return output;
}
@@ -186,17 +186,17 @@
* VisitNodes endpoint wrapper.
*
* @param input input parameters for the underlying endpoint call
- * @return the resulting list of {@link SwhPID} from endpoint call and operation metadata
- * @see org.softwareheritage.graph.SwhPID
+ * @return the resulting list of {@link SWHID} from endpoint call and operation metadata
+ * @see SWHID
* @see Traversal#visitNodes(long)
*/
public Output visitNodes(Input input) {
- Output> output = new Output<>();
+ Output> output = new Output<>();
long startTime;
startTime = Timing.start();
long srcNodeId = graph.getNodeId(input.src);
- output.meta.timings.pid2node = Timing.stop(startTime);
+ output.meta.timings.swhid2node = Timing.stop(startTime);
startTime = Timing.start();
ArrayList nodeIds = traversal.visitNodes(srcNodeId);
@@ -204,8 +204,8 @@
output.meta.nbEdgesAccessed = traversal.getNbEdgesAccessed();
startTime = Timing.start();
- output.result = convertNodesToSwhPIDs(nodeIds);
- output.meta.timings.node2pid = Timing.stop(startTime);
+ output.result = convertNodesToSWHIDs(nodeIds);
+ output.meta.timings.node2swhid = Timing.stop(startTime);
return output;
}
@@ -215,7 +215,7 @@
*
* @param input input parameters for the underlying endpoint call
* @return the resulting list of {@link SwhPath} from endpoint call and operation metadata
- * @see org.softwareheritage.graph.SwhPID
+ * @see SWHID
* @see org.softwareheritage.graph.SwhPath
* @see Traversal#visitPaths(long)
*/
@@ -225,7 +225,7 @@
startTime = Timing.start();
long srcNodeId = graph.getNodeId(input.src);
- output.meta.timings.pid2node = Timing.stop(startTime);
+ output.meta.timings.swhid2node = Timing.stop(startTime);
startTime = Timing.start();
ArrayList> paths = traversal.visitPaths(srcNodeId);
@@ -233,8 +233,8 @@
output.meta.nbEdgesAccessed = traversal.getNbEdgesAccessed();
startTime = Timing.start();
- output.result = convertPathsToSwhPIDs(paths);
- output.meta.timings.node2pid = Timing.stop(startTime);
+ output.result = convertPathsToSWHIDs(paths);
+ output.meta.timings.node2swhid = Timing.stop(startTime);
return output;
}
@@ -243,8 +243,8 @@
* Wrapper class to unify traversal methods input signatures.
*/
public static class Input {
- /** Source node of endpoint call specified as a {@link SwhPID} */
- public SwhPID src;
+ /** Source node of endpoint call specified as a {@link SWHID} */
+ public SWHID src;
/**
* Destination formatted string as described in the API
@@ -253,11 +253,11 @@
/** Traversal algorithm used in endpoint call (either "dfs" or "bfs") */
public String algorithm;
- public Input(SwhPID src) {
+ public Input(SWHID src) {
this.src = src;
}
- public Input(SwhPID src, String dstFmt, String algorithm) {
+ public Input(SWHID src, String dstFmt, String algorithm) {
this.src = src;
this.dstFmt = dstFmt;
this.algorithm = algorithm;
@@ -298,10 +298,10 @@
public class Timings {
/** Time in seconds to do the traversal */
public double traversal;
- /** Time in seconds to convert input SWH PID to node id */
- public double pid2node;
- /** Time in seconds to convert output node ids to SWH PIDs */
- public double node2pid;
+ /** Time in seconds to convert input SWHID to node id */
+ public double swhid2node;
+ /** Time in seconds to convert output node ids to SWHIDs */
+ public double node2swhid;
}
}
}
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
@@ -22,8 +22,8 @@
while ((dstNode = s.nextLong()) >= 0) {
System.out.format(
"%s %s\n",
- nodeMap.getSwhPID(srcNode),
- nodeMap.getSwhPID(dstNode)
+ 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
@@ -29,16 +29,16 @@
for (int label : labels) {
System.out.format(
"%s %s %s\n",
- nodeMap.getSwhPID(srcNode),
- nodeMap.getSwhPID(dstNode),
+ nodeMap.getSWHID(srcNode),
+ nodeMap.getSWHID(dstNode),
labelMap.get(label)
);
}
} else {
System.out.format(
"%s %s\n",
- nodeMap.getSwhPID(srcNode),
- nodeMap.getSwhPID(dstNode)
+ nodeMap.getSWHID(srcNode),
+ nodeMap.getSWHID(dstNode)
);
}
}
diff --git a/java/src/test/java/org/softwareheritage/graph/LeavesTest.java b/java/src/test/java/org/softwareheritage/graph/LeavesTest.java
--- a/java/src/test/java/org/softwareheritage/graph/LeavesTest.java
+++ b/java/src/test/java/org/softwareheritage/graph/LeavesTest.java
@@ -12,35 +12,35 @@
@Test
public void forwardFromSnp() {
Graph graph = getGraph();
- SwhPID src = new SwhPID("swh:1:snp:0000000000000000000000000000000000000020");
+ SWHID src = new SWHID("swh:1:snp:0000000000000000000000000000000000000020");
Endpoint endpoint = new Endpoint(graph, "forward", "*");
- ArrayList expectedLeaves = new ArrayList<>();
- expectedLeaves.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000001"));
- expectedLeaves.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000004"));
- expectedLeaves.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000005"));
- expectedLeaves.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000007"));
+ ArrayList expectedLeaves = new ArrayList<>();
+ expectedLeaves.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000001"));
+ expectedLeaves.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000004"));
+ expectedLeaves.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000005"));
+ expectedLeaves.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000007"));
- ArrayList actualLeaves = (ArrayList) endpoint.leaves(new Endpoint.Input(src)).result;
+ ArrayList actualLeaves = (ArrayList) endpoint.leaves(new Endpoint.Input(src)).result;
GraphTest.assertEqualsAnyOrder(expectedLeaves, actualLeaves);
}
@Test
public void forwardFromRel() {
Graph graph = getGraph();
- SwhPID src = new SwhPID("swh:1:rel:0000000000000000000000000000000000000019");
+ SWHID src = new SWHID("swh:1:rel:0000000000000000000000000000000000000019");
Endpoint endpoint = new Endpoint(graph, "forward", "*");
- ArrayList expectedLeaves = new ArrayList<>();
- expectedLeaves.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000015"));
- expectedLeaves.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000014"));
- expectedLeaves.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000001"));
- expectedLeaves.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000004"));
- expectedLeaves.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000005"));
- expectedLeaves.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000007"));
- expectedLeaves.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000011"));
+ ArrayList expectedLeaves = new ArrayList<>();
+ expectedLeaves.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000015"));
+ expectedLeaves.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000014"));
+ expectedLeaves.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000001"));
+ expectedLeaves.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000004"));
+ expectedLeaves.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000005"));
+ expectedLeaves.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000007"));
+ expectedLeaves.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000011"));
- ArrayList actualLeaves = (ArrayList) endpoint.leaves(new Endpoint.Input(src)).result;
+ ArrayList actualLeaves = (ArrayList) endpoint.leaves(new Endpoint.Input(src)).result;
GraphTest.assertEqualsAnyOrder(expectedLeaves, actualLeaves);
}
@@ -49,60 +49,60 @@
Graph graph = getGraph();
Endpoint endpoint1 = new Endpoint(graph, "backward", "*");
- SwhPID src1 = new SwhPID("swh:1:cnt:0000000000000000000000000000000000000015");
- ArrayList expectedLeaves1 = new ArrayList<>();
- expectedLeaves1.add(new SwhPID("swh:1:rel:0000000000000000000000000000000000000019"));
- ArrayList actualLeaves1 = (ArrayList) endpoint1.leaves(new Endpoint.Input(src1)).result;
+ SWHID src1 = new SWHID("swh:1:cnt:0000000000000000000000000000000000000015");
+ ArrayList expectedLeaves1 = new ArrayList<>();
+ expectedLeaves1.add(new SWHID("swh:1:rel:0000000000000000000000000000000000000019"));
+ ArrayList actualLeaves1 = (ArrayList) endpoint1.leaves(new Endpoint.Input(src1)).result;
GraphTest.assertEqualsAnyOrder(expectedLeaves1, actualLeaves1);
Endpoint endpoint2 = new Endpoint(graph, "backward", "*");
- SwhPID src2 = new SwhPID("swh:1:cnt:0000000000000000000000000000000000000004");
- ArrayList expectedLeaves2 = new ArrayList<>();
- expectedLeaves2.add(new SwhPID("swh:1:ori:0000000000000000000000000000000000000021"));
- expectedLeaves2.add(new SwhPID("swh:1:rel:0000000000000000000000000000000000000019"));
- ArrayList actualLeaves2 = (ArrayList) endpoint2.leaves(new Endpoint.Input(src2)).result;
+ SWHID src2 = new SWHID("swh:1:cnt:0000000000000000000000000000000000000004");
+ ArrayList expectedLeaves2 = new ArrayList<>();
+ expectedLeaves2.add(new SWHID("swh:1:ori:0000000000000000000000000000000000000021"));
+ expectedLeaves2.add(new SWHID("swh:1:rel:0000000000000000000000000000000000000019"));
+ ArrayList actualLeaves2 = (ArrayList) endpoint2.leaves(new Endpoint.Input(src2)).result;
GraphTest.assertEqualsAnyOrder(expectedLeaves2, actualLeaves2);
}
@Test
public void forwardRevToRevOnly() {
Graph graph = getGraph();
- SwhPID src = new SwhPID("swh:1:rev:0000000000000000000000000000000000000018");
+ SWHID src = new SWHID("swh:1:rev:0000000000000000000000000000000000000018");
Endpoint endpoint = new Endpoint(graph, "forward", "rev:rev");
- ArrayList expectedLeaves = new ArrayList<>();
- expectedLeaves.add(new SwhPID("swh:1:rev:0000000000000000000000000000000000000003"));
+ ArrayList expectedLeaves = new ArrayList<>();
+ expectedLeaves.add(new SWHID("swh:1:rev:0000000000000000000000000000000000000003"));
- ArrayList actualLeaves = (ArrayList) endpoint.leaves(new Endpoint.Input(src)).result;
+ ArrayList actualLeaves = (ArrayList) endpoint.leaves(new Endpoint.Input(src)).result;
GraphTest.assertEqualsAnyOrder(expectedLeaves, actualLeaves);
}
@Test
public void forwardDirToAll() {
Graph graph = getGraph();
- SwhPID src = new SwhPID("swh:1:dir:0000000000000000000000000000000000000008");
+ SWHID src = new SWHID("swh:1:dir:0000000000000000000000000000000000000008");
Endpoint endpoint = new Endpoint(graph, "forward", "dir:*");
- ArrayList expectedLeaves = new ArrayList<>();
- expectedLeaves.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000004"));
- expectedLeaves.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000005"));
- expectedLeaves.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000001"));
- expectedLeaves.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000007"));
+ ArrayList expectedLeaves = new ArrayList<>();
+ expectedLeaves.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000004"));
+ expectedLeaves.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000005"));
+ expectedLeaves.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000001"));
+ expectedLeaves.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000007"));
- ArrayList actualLeaves = (ArrayList) endpoint.leaves(new Endpoint.Input(src)).result;
+ ArrayList actualLeaves = (ArrayList) endpoint.leaves(new Endpoint.Input(src)).result;
GraphTest.assertEqualsAnyOrder(expectedLeaves, actualLeaves);
}
@Test
public void backwardCntToDirDirToDir() {
Graph graph = getGraph();
- SwhPID src = new SwhPID("swh:1:cnt:0000000000000000000000000000000000000005");
+ SWHID src = new SWHID("swh:1:cnt:0000000000000000000000000000000000000005");
Endpoint endpoint = new Endpoint(graph, "backward", "cnt:dir,dir:dir");
- ArrayList expectedLeaves = new ArrayList<>();
- expectedLeaves.add(new SwhPID("swh:1:dir:0000000000000000000000000000000000000012"));
+ ArrayList expectedLeaves = new ArrayList<>();
+ expectedLeaves.add(new SWHID("swh:1:dir:0000000000000000000000000000000000000012"));
- ArrayList actualLeaves = (ArrayList) endpoint.leaves(new Endpoint.Input(src)).result;
+ ArrayList actualLeaves = (ArrayList) endpoint.leaves(new Endpoint.Input(src)).result;
GraphTest.assertEqualsAnyOrder(expectedLeaves, actualLeaves);
}
}
diff --git a/java/src/test/java/org/softwareheritage/graph/NeighborsTest.java b/java/src/test/java/org/softwareheritage/graph/NeighborsTest.java
--- a/java/src/test/java/org/softwareheritage/graph/NeighborsTest.java
+++ b/java/src/test/java/org/softwareheritage/graph/NeighborsTest.java
@@ -12,31 +12,31 @@
@Test
public void zeroNeighbor() {
Graph graph = getGraph();
- ArrayList expectedNodes = new ArrayList<>();
+ ArrayList expectedNodes = new ArrayList<>();
- SwhPID src1 = new SwhPID("swh:1:ori:0000000000000000000000000000000000000021");
+ SWHID src1 = new SWHID("swh:1:ori:0000000000000000000000000000000000000021");
Endpoint endpoint1 = new Endpoint(graph, "backward", "*");
- ArrayList actuals1 = (ArrayList) endpoint1.neighbors(new Endpoint.Input(src1)).result;
+ ArrayList actuals1 = (ArrayList) endpoint1.neighbors(new Endpoint.Input(src1)).result;
GraphTest.assertEqualsAnyOrder(expectedNodes, actuals1);
- SwhPID src2 = new SwhPID("swh:1:cnt:0000000000000000000000000000000000000004");
+ SWHID src2 = new SWHID("swh:1:cnt:0000000000000000000000000000000000000004");
Endpoint endpoint2 = new Endpoint(graph, "forward", "*");
- ArrayList actuals2 = (ArrayList) endpoint2.neighbors(new Endpoint.Input(src2)).result;
+ ArrayList actuals2 = (ArrayList) endpoint2.neighbors(new Endpoint.Input(src2)).result;
GraphTest.assertEqualsAnyOrder(expectedNodes, actuals2);
- SwhPID src3 = new SwhPID("swh:1:cnt:0000000000000000000000000000000000000015");
+ SWHID src3 = new SWHID("swh:1:cnt:0000000000000000000000000000000000000015");
Endpoint endpoint3 = new Endpoint(graph, "forward", "*");
- ArrayList actuals3 = (ArrayList) endpoint3.neighbors(new Endpoint.Input(src3)).result;
+ ArrayList actuals3 = (ArrayList) endpoint3.neighbors(new Endpoint.Input(src3)).result;
GraphTest.assertEqualsAnyOrder(expectedNodes, actuals3);
- SwhPID src4 = new SwhPID("swh:1:rel:0000000000000000000000000000000000000019");
+ SWHID src4 = new SWHID("swh:1:rel:0000000000000000000000000000000000000019");
Endpoint endpoint4 = new Endpoint(graph, "backward", "*");
- ArrayList actuals4 = (ArrayList) endpoint4.neighbors(new Endpoint.Input(src4)).result;
+ ArrayList actuals4 = (ArrayList) endpoint4.neighbors(new Endpoint.Input(src4)).result;
GraphTest.assertEqualsAnyOrder(expectedNodes, actuals4);
- SwhPID src5 = new SwhPID("swh:1:dir:0000000000000000000000000000000000000008");
+ SWHID src5 = new SWHID("swh:1:dir:0000000000000000000000000000000000000008");
Endpoint endpoint5 = new Endpoint(graph, "forward", "snp:*,rev:*,rel:*");
- ArrayList actuals5 = (ArrayList) endpoint5.neighbors(new Endpoint.Input(src5)).result;
+ ArrayList actuals5 = (ArrayList) endpoint5.neighbors(new Endpoint.Input(src5)).result;
GraphTest.assertEqualsAnyOrder(expectedNodes, actuals5);
}
@@ -44,39 +44,39 @@
public void oneNeighbor() {
Graph graph = getGraph();
- SwhPID src1 = new SwhPID("swh:1:rev:0000000000000000000000000000000000000003");
+ SWHID src1 = new SWHID("swh:1:rev:0000000000000000000000000000000000000003");
Endpoint endpoint1 = new Endpoint(graph, "forward", "*");
- ArrayList expectedNodes1 = new ArrayList<>();
- expectedNodes1.add(new SwhPID("swh:1:dir:0000000000000000000000000000000000000002"));
- ArrayList actuals1 = (ArrayList) endpoint1.neighbors(new Endpoint.Input(src1)).result;
+ ArrayList expectedNodes1 = new ArrayList<>();
+ expectedNodes1.add(new SWHID("swh:1:dir:0000000000000000000000000000000000000002"));
+ ArrayList actuals1 = (ArrayList) endpoint1.neighbors(new Endpoint.Input(src1)).result;
GraphTest.assertEqualsAnyOrder(expectedNodes1, actuals1);
- SwhPID src2 = new SwhPID("swh:1:dir:0000000000000000000000000000000000000017");
+ SWHID src2 = new SWHID("swh:1:dir:0000000000000000000000000000000000000017");
Endpoint endpoint2 = new Endpoint(graph, "forward", "dir:cnt");
- ArrayList expectedNodes2 = new ArrayList<>();
- expectedNodes2.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000014"));
- ArrayList actuals2 = (ArrayList) endpoint2.neighbors(new Endpoint.Input(src2)).result;
+ ArrayList expectedNodes2 = new ArrayList<>();
+ expectedNodes2.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000014"));
+ ArrayList actuals2 = (ArrayList) endpoint2.neighbors(new Endpoint.Input(src2)).result;
GraphTest.assertEqualsAnyOrder(expectedNodes2, actuals2);
- SwhPID src3 = new SwhPID("swh:1:dir:0000000000000000000000000000000000000012");
+ SWHID src3 = new SWHID("swh:1:dir:0000000000000000000000000000000000000012");
Endpoint endpoint3 = new Endpoint(graph, "backward", "*");
- ArrayList expectedNodes3 = new ArrayList<>();
- expectedNodes3.add(new SwhPID("swh:1:rev:0000000000000000000000000000000000000013"));
- ArrayList actuals3 = (ArrayList) endpoint3.neighbors(new Endpoint.Input(src3)).result;
+ ArrayList expectedNodes3 = new ArrayList<>();
+ expectedNodes3.add(new SWHID("swh:1:rev:0000000000000000000000000000000000000013"));
+ ArrayList actuals3 = (ArrayList) endpoint3.neighbors(new Endpoint.Input(src3)).result;
GraphTest.assertEqualsAnyOrder(expectedNodes3, actuals3);
- SwhPID src4 = new SwhPID("swh:1:rev:0000000000000000000000000000000000000009");
+ SWHID src4 = new SWHID("swh:1:rev:0000000000000000000000000000000000000009");
Endpoint endpoint4 = new Endpoint(graph, "backward", "rev:rev");
- ArrayList expectedNodes4 = new ArrayList<>();
- expectedNodes4.add(new SwhPID("swh:1:rev:0000000000000000000000000000000000000013"));
- ArrayList actuals4 = (ArrayList) endpoint4.neighbors(new Endpoint.Input(src4)).result;
+ ArrayList expectedNodes4 = new ArrayList<>();
+ expectedNodes4.add(new SWHID("swh:1:rev:0000000000000000000000000000000000000013"));
+ ArrayList actuals4 = (ArrayList) endpoint4.neighbors(new Endpoint.Input(src4)).result;
GraphTest.assertEqualsAnyOrder(expectedNodes4, actuals4);
- SwhPID src5 = new SwhPID("swh:1:snp:0000000000000000000000000000000000000020");
+ SWHID src5 = new SWHID("swh:1:snp:0000000000000000000000000000000000000020");
Endpoint endpoint5 = new Endpoint(graph, "backward", "*");
- ArrayList expectedNodes5 = new ArrayList<>();
- expectedNodes5.add(new SwhPID("swh:1:ori:0000000000000000000000000000000000000021"));
- ArrayList actuals5 = (ArrayList) endpoint5.neighbors(new Endpoint.Input(src5)).result;
+ ArrayList expectedNodes5 = new ArrayList<>();
+ expectedNodes5.add(new SWHID("swh:1:ori:0000000000000000000000000000000000000021"));
+ ArrayList actuals5 = (ArrayList) endpoint5.neighbors(new Endpoint.Input(src5)).result;
GraphTest.assertEqualsAnyOrder(expectedNodes5, actuals5);
}
@@ -84,36 +84,36 @@
public void twoNeighbors() {
Graph graph = getGraph();
- SwhPID src1 = new SwhPID("swh:1:snp:0000000000000000000000000000000000000020");
+ SWHID src1 = new SWHID("swh:1:snp:0000000000000000000000000000000000000020");
Endpoint endpoint1 = new Endpoint(graph, "forward", "*");
- ArrayList expectedNodes1 = new ArrayList<>();
- expectedNodes1.add(new SwhPID("swh:1:rel:0000000000000000000000000000000000000010"));
- expectedNodes1.add(new SwhPID("swh:1:rev:0000000000000000000000000000000000000009"));
- ArrayList actuals1 = (ArrayList) endpoint1.neighbors(new Endpoint.Input(src1)).result;
+ ArrayList expectedNodes1 = new ArrayList<>();
+ expectedNodes1.add(new SWHID("swh:1:rel:0000000000000000000000000000000000000010"));
+ expectedNodes1.add(new SWHID("swh:1:rev:0000000000000000000000000000000000000009"));
+ ArrayList actuals1 = (ArrayList) endpoint1.neighbors(new Endpoint.Input(src1)).result;
GraphTest.assertEqualsAnyOrder(expectedNodes1, actuals1);
- SwhPID src2 = new SwhPID("swh:1:dir:0000000000000000000000000000000000000008");
+ SWHID src2 = new SWHID("swh:1:dir:0000000000000000000000000000000000000008");
Endpoint endpoint2 = new Endpoint(graph, "forward", "dir:cnt");
- ArrayList expectedNodes2 = new ArrayList<>();
- expectedNodes2.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000001"));
- expectedNodes2.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000007"));
- ArrayList actuals2 = (ArrayList) endpoint2.neighbors(new Endpoint.Input(src2)).result;
+ ArrayList expectedNodes2 = new ArrayList<>();
+ expectedNodes2.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000001"));
+ expectedNodes2.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000007"));
+ ArrayList actuals2 = (ArrayList) endpoint2.neighbors(new Endpoint.Input(src2)).result;
GraphTest.assertEqualsAnyOrder(expectedNodes2, actuals2);
- SwhPID src3 = new SwhPID("swh:1:cnt:0000000000000000000000000000000000000001");
+ SWHID src3 = new SWHID("swh:1:cnt:0000000000000000000000000000000000000001");
Endpoint endpoint3 = new Endpoint(graph, "backward", "*");
- ArrayList expectedNodes3 = new ArrayList<>();
- expectedNodes3.add(new SwhPID("swh:1:dir:0000000000000000000000000000000000000008"));
- expectedNodes3.add(new SwhPID("swh:1:dir:0000000000000000000000000000000000000002"));
- ArrayList actuals3 = (ArrayList) endpoint3.neighbors(new Endpoint.Input(src3)).result;
+ ArrayList expectedNodes3 = new ArrayList<>();
+ expectedNodes3.add(new SWHID("swh:1:dir:0000000000000000000000000000000000000008"));
+ expectedNodes3.add(new SWHID("swh:1:dir:0000000000000000000000000000000000000002"));
+ ArrayList actuals3 = (ArrayList) endpoint3.neighbors(new Endpoint.Input(src3)).result;
GraphTest.assertEqualsAnyOrder(expectedNodes3, actuals3);
- SwhPID src4 = new SwhPID("swh:1:rev:0000000000000000000000000000000000000009");
+ SWHID src4 = new SWHID("swh:1:rev:0000000000000000000000000000000000000009");
Endpoint endpoint4 = new Endpoint(graph, "backward", "rev:snp,rev:rel");
- ArrayList expectedNodes4 = new ArrayList<>();
- expectedNodes4.add(new SwhPID("swh:1:snp:0000000000000000000000000000000000000020"));
- expectedNodes4.add(new SwhPID("swh:1:rel:0000000000000000000000000000000000000010"));
- ArrayList actuals4 = (ArrayList) endpoint4.neighbors(new Endpoint.Input(src4)).result;
+ ArrayList expectedNodes4 = new ArrayList<>();
+ expectedNodes4.add(new SWHID("swh:1:snp:0000000000000000000000000000000000000020"));
+ expectedNodes4.add(new SWHID("swh:1:rel:0000000000000000000000000000000000000010"));
+ ArrayList actuals4 = (ArrayList) endpoint4.neighbors(new Endpoint.Input(src4)).result;
GraphTest.assertEqualsAnyOrder(expectedNodes4, actuals4);
}
@@ -121,22 +121,22 @@
public void threeNeighbors() {
Graph graph = getGraph();
- SwhPID src1 = new SwhPID("swh:1:dir:0000000000000000000000000000000000000008");
+ SWHID src1 = new SWHID("swh:1:dir:0000000000000000000000000000000000000008");
Endpoint endpoint1 = new Endpoint(graph, "forward", "*");
- ArrayList expectedNodes1 = new ArrayList<>();
- expectedNodes1.add(new SwhPID("swh:1:dir:0000000000000000000000000000000000000006"));
- expectedNodes1.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000001"));
- expectedNodes1.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000007"));
- ArrayList actuals1 = (ArrayList) endpoint1.neighbors(new Endpoint.Input(src1)).result;
+ ArrayList expectedNodes1 = new ArrayList<>();
+ expectedNodes1.add(new SWHID("swh:1:dir:0000000000000000000000000000000000000006"));
+ expectedNodes1.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000001"));
+ expectedNodes1.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000007"));
+ ArrayList actuals1 = (ArrayList) endpoint1.neighbors(new Endpoint.Input(src1)).result;
GraphTest.assertEqualsAnyOrder(expectedNodes1, actuals1);
- SwhPID src2 = new SwhPID("swh:1:rev:0000000000000000000000000000000000000009");
+ SWHID src2 = new SWHID("swh:1:rev:0000000000000000000000000000000000000009");
Endpoint endpoint2 = new Endpoint(graph, "backward", "*");
- ArrayList expectedNodes2 = new ArrayList<>();
- expectedNodes2.add(new SwhPID("swh:1:snp:0000000000000000000000000000000000000020"));
- expectedNodes2.add(new SwhPID("swh:1:rel:0000000000000000000000000000000000000010"));
- expectedNodes2.add(new SwhPID("swh:1:rev:0000000000000000000000000000000000000013"));
- ArrayList actuals2 = (ArrayList) endpoint2.neighbors(new Endpoint.Input(src2)).result;
+ ArrayList expectedNodes2 = new ArrayList<>();
+ expectedNodes2.add(new SWHID("swh:1:snp:0000000000000000000000000000000000000020"));
+ expectedNodes2.add(new SWHID("swh:1:rel:0000000000000000000000000000000000000010"));
+ expectedNodes2.add(new SWHID("swh:1:rev:0000000000000000000000000000000000000013"));
+ ArrayList actuals2 = (ArrayList) endpoint2.neighbors(new Endpoint.Input(src2)).result;
GraphTest.assertEqualsAnyOrder(expectedNodes2, actuals2);
}
}
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
@@ -11,10 +11,10 @@
// Avoid warnings concerning Endpoint.Output.result manual cast
@SuppressWarnings("unchecked")
public class VisitTest extends GraphTest {
- private void assertSameNodesFromPaths(ArrayList paths, ArrayList nodes) {
- Set expectedNodes = new HashSet();
+ private void assertSameNodesFromPaths(ArrayList paths, ArrayList nodes) {
+ Set expectedNodes = new HashSet();
for (SwhPath path : paths) {
- for (SwhPID node : path.getPath()) {
+ for (SWHID node : path.getPath()) {
expectedNodes.add(node);
}
}
@@ -24,11 +24,11 @@
@Test
public void forwardFromRoot() {
Graph graph = getGraph();
- SwhPID swhPID = new SwhPID("swh:1:ori:0000000000000000000000000000000000000021");
+ SWHID swhid = new SWHID("swh:1:ori:0000000000000000000000000000000000000021");
Endpoint endpoint1 = new Endpoint(graph, "forward", "*");
- ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhPID)).result;
+ ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhid)).result;
Endpoint endpoint2 = new Endpoint(graph, "forward", "*");
- ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhPID)).result;
+ ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
@@ -130,11 +130,11 @@
@Test
public void forwardFromMiddle() {
Graph graph = getGraph();
- SwhPID swhPID = new SwhPID("swh:1:dir:0000000000000000000000000000000000000012");
+ SWHID swhid = new SWHID("swh:1:dir:0000000000000000000000000000000000000012");
Endpoint endpoint1 = new Endpoint(graph, "forward", "*");
- ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhPID)).result;
+ ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhid)).result;
Endpoint endpoint2 = new Endpoint(graph, "forward", "*");
- ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhPID)).result;
+ ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
@@ -176,11 +176,11 @@
@Test
public void forwardFromLeaf() {
Graph graph = getGraph();
- SwhPID swhPID = new SwhPID("swh:1:cnt:0000000000000000000000000000000000000004");
+ SWHID swhid = new SWHID("swh:1:cnt:0000000000000000000000000000000000000004");
Endpoint endpoint1 = new Endpoint(graph, "forward", "*");
- ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhPID)).result;
+ ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhid)).result;
Endpoint endpoint2 = new Endpoint(graph, "forward", "*");
- ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhPID)).result;
+ ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
@@ -195,11 +195,11 @@
@Test
public void backwardFromRoot() {
Graph graph = getGraph();
- SwhPID swhPID = new SwhPID("swh:1:ori:0000000000000000000000000000000000000021");
+ SWHID swhid = new SWHID("swh:1:ori:0000000000000000000000000000000000000021");
Endpoint endpoint1 = new Endpoint(graph, "backward", "*");
- ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhPID)).result;
+ ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhid)).result;
Endpoint endpoint2 = new Endpoint(graph, "backward", "*");
- ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhPID)).result;
+ ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
@@ -214,11 +214,11 @@
@Test
public void backwardFromMiddle() {
Graph graph = getGraph();
- SwhPID swhPID = new SwhPID("swh:1:dir:0000000000000000000000000000000000000012");
+ SWHID swhid = new SWHID("swh:1:dir:0000000000000000000000000000000000000012");
Endpoint endpoint1 = new Endpoint(graph, "backward", "*");
- ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhPID)).result;
+ ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhid)).result;
Endpoint endpoint2 = new Endpoint(graph, "backward", "*");
- ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhPID)).result;
+ ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
@@ -236,11 +236,11 @@
@Test
public void backwardFromLeaf() {
Graph graph = getGraph();
- SwhPID swhPID = new SwhPID("swh:1:cnt:0000000000000000000000000000000000000004");
+ SWHID swhid = new SWHID("swh:1:cnt:0000000000000000000000000000000000000004");
Endpoint endpoint1 = new Endpoint(graph, "backward", "*");
- ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhPID)).result;
+ ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhid)).result;
Endpoint endpoint2 = new Endpoint(graph, "backward", "*");
- ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhPID)).result;
+ ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
@@ -290,11 +290,11 @@
@Test
public void forwardSnpToRev() {
Graph graph = getGraph();
- SwhPID swhPID = new SwhPID("swh:1:snp:0000000000000000000000000000000000000020");
+ SWHID swhid = new SWHID("swh:1:snp:0000000000000000000000000000000000000020");
Endpoint endpoint1 = new Endpoint(graph, "forward", "snp:rev");
- ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhPID)).result;
+ ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhid)).result;
Endpoint endpoint2 = new Endpoint(graph, "forward", "snp:rev");
- ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhPID)).result;
+ ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
@@ -310,11 +310,11 @@
@Test
public void forwardRelToRevRevToRev() {
Graph graph = getGraph();
- SwhPID swhPID = new SwhPID("swh:1:rel:0000000000000000000000000000000000000010");
+ SWHID swhid = new SWHID("swh:1:rel:0000000000000000000000000000000000000010");
Endpoint endpoint1 = new Endpoint(graph, "forward", "rel:rev,rev:rev");
- ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhPID)).result;
+ ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhid)).result;
Endpoint endpoint2 = new Endpoint(graph, "forward", "rel:rev,rev:rev");
- ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhPID)).result;
+ ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
@@ -331,11 +331,11 @@
@Test
public void forwardRevToAllDirToAll() {
Graph graph = getGraph();
- SwhPID swhPID = new SwhPID("swh:1:rev:0000000000000000000000000000000000000013");
+ SWHID swhid = new SWHID("swh:1:rev:0000000000000000000000000000000000000013");
Endpoint endpoint1 = new Endpoint(graph, "forward", "rev:*,dir:*");
- ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhPID)).result;
+ ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhid)).result;
Endpoint endpoint2 = new Endpoint(graph, "forward", "rev:*,dir:*");
- ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhPID)).result;
+ ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
@@ -420,11 +420,11 @@
@Test
public void forwardSnpToAllRevToAll() {
Graph graph = getGraph();
- SwhPID swhPID = new SwhPID("swh:1:snp:0000000000000000000000000000000000000020");
+ SWHID swhid = new SWHID("swh:1:snp:0000000000000000000000000000000000000020");
Endpoint endpoint1 = new Endpoint(graph, "forward", "snp:*,rev:*");
- ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhPID)).result;
+ ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhid)).result;
Endpoint endpoint2 = new Endpoint(graph, "forward", "snp:*,rev:*");
- ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhPID)).result;
+ ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
@@ -453,11 +453,11 @@
@Test
public void forwardNoEdges() {
Graph graph = getGraph();
- SwhPID swhPID = new SwhPID("swh:1:snp:0000000000000000000000000000000000000020");
+ SWHID swhid = new SWHID("swh:1:snp:0000000000000000000000000000000000000020");
Endpoint endpoint1 = new Endpoint(graph, "forward", "");
- ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhPID)).result;
+ ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhid)).result;
Endpoint endpoint2 = new Endpoint(graph, "forward", "");
- ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhPID)).result;
+ ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
@@ -472,11 +472,11 @@
@Test
public void backwardRevToRevRevToRel() {
Graph graph = getGraph();
- SwhPID swhPID = new SwhPID("swh:1:rev:0000000000000000000000000000000000000003");
+ SWHID swhid = new SWHID("swh:1:rev:0000000000000000000000000000000000000003");
Endpoint endpoint1 = new Endpoint(graph, "backward", "rev:rev,rev:rel");
- ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhPID)).result;
+ ArrayList paths = (ArrayList) endpoint1.visitPaths(new Endpoint.Input(swhid)).result;
Endpoint endpoint2 = new Endpoint(graph, "backward", "rev:rev,rev:rel");
- ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhPID)).result;
+ ArrayList nodes = (ArrayList) endpoint2.visitNodes(new Endpoint.Input(swhid)).result;
ArrayList expectedPaths = new ArrayList();
expectedPaths.add(
@@ -501,23 +501,23 @@
@Test
public void forwardFromRootNodesOnly() {
Graph graph = getGraph();
- SwhPID swhPID = new SwhPID("swh:1:ori:0000000000000000000000000000000000000021");
+ SWHID swhid = new SWHID("swh:1:ori:0000000000000000000000000000000000000021");
Endpoint endpoint = new Endpoint(graph, "forward", "*");
- ArrayList nodes = (ArrayList) endpoint.visitNodes(new Endpoint.Input(swhPID)).result;
-
- ArrayList expectedNodes = new ArrayList();
- expectedNodes.add(new SwhPID("swh:1:ori:0000000000000000000000000000000000000021"));
- expectedNodes.add(new SwhPID("swh:1:snp:0000000000000000000000000000000000000020"));
- expectedNodes.add(new SwhPID("swh:1:rel:0000000000000000000000000000000000000010"));
- expectedNodes.add(new SwhPID("swh:1:rev:0000000000000000000000000000000000000009"));
- expectedNodes.add(new SwhPID("swh:1:rev:0000000000000000000000000000000000000003"));
- expectedNodes.add(new SwhPID("swh:1:dir:0000000000000000000000000000000000000002"));
- expectedNodes.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000001"));
- expectedNodes.add(new SwhPID("swh:1:dir:0000000000000000000000000000000000000008"));
- expectedNodes.add(new SwhPID("swh:1:dir:0000000000000000000000000000000000000006"));
- expectedNodes.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000004"));
- expectedNodes.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000005"));
- expectedNodes.add(new SwhPID("swh:1:cnt:0000000000000000000000000000000000000007"));
+ ArrayList nodes = (ArrayList) endpoint.visitNodes(new Endpoint.Input(swhid)).result;
+
+ ArrayList expectedNodes = new ArrayList();
+ expectedNodes.add(new SWHID("swh:1:ori:0000000000000000000000000000000000000021"));
+ expectedNodes.add(new SWHID("swh:1:snp:0000000000000000000000000000000000000020"));
+ expectedNodes.add(new SWHID("swh:1:rel:0000000000000000000000000000000000000010"));
+ expectedNodes.add(new SWHID("swh:1:rev:0000000000000000000000000000000000000009"));
+ expectedNodes.add(new SWHID("swh:1:rev:0000000000000000000000000000000000000003"));
+ expectedNodes.add(new SWHID("swh:1:dir:0000000000000000000000000000000000000002"));
+ expectedNodes.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000001"));
+ expectedNodes.add(new SWHID("swh:1:dir:0000000000000000000000000000000000000008"));
+ expectedNodes.add(new SWHID("swh:1:dir:0000000000000000000000000000000000000006"));
+ expectedNodes.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000004"));
+ expectedNodes.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000005"));
+ expectedNodes.add(new SWHID("swh:1:cnt:0000000000000000000000000000000000000007"));
GraphTest.assertEqualsAnyOrder(expectedNodes, nodes);
}
@@ -525,18 +525,18 @@
@Test
public void backwardRevToAllNodesOnly() {
Graph graph = getGraph();
- SwhPID swhPID = new SwhPID("swh:1:rev:0000000000000000000000000000000000000003");
+ SWHID swhid = new SWHID("swh:1:rev:0000000000000000000000000000000000000003");
Endpoint endpoint = new Endpoint(graph, "backward", "rev:*");
- ArrayList nodes = (ArrayList) endpoint.visitNodes(new Endpoint.Input(swhPID)).result;
-
- ArrayList expectedNodes = new ArrayList();
- expectedNodes.add(new SwhPID("swh:1:rev:0000000000000000000000000000000000000003"));
- expectedNodes.add(new SwhPID("swh:1:rev:0000000000000000000000000000000000000009"));
- expectedNodes.add(new SwhPID("swh:1:snp:0000000000000000000000000000000000000020"));
- expectedNodes.add(new SwhPID("swh:1:rel:0000000000000000000000000000000000000010"));
- expectedNodes.add(new SwhPID("swh:1:rev:0000000000000000000000000000000000000013"));
- expectedNodes.add(new SwhPID("swh:1:rev:0000000000000000000000000000000000000018"));
- expectedNodes.add(new SwhPID("swh:1:rel:0000000000000000000000000000000000000019"));
+ ArrayList nodes = (ArrayList) endpoint.visitNodes(new Endpoint.Input(swhid)).result;
+
+ ArrayList expectedNodes = new ArrayList();
+ expectedNodes.add(new SWHID("swh:1:rev:0000000000000000000000000000000000000003"));
+ expectedNodes.add(new SWHID("swh:1:rev:0000000000000000000000000000000000000009"));
+ expectedNodes.add(new SWHID("swh:1:snp:0000000000000000000000000000000000000020"));
+ expectedNodes.add(new SWHID("swh:1:rel:0000000000000000000000000000000000000010"));
+ expectedNodes.add(new SWHID("swh:1:rev:0000000000000000000000000000000000000013"));
+ expectedNodes.add(new SWHID("swh:1:rev:0000000000000000000000000000000000000018"));
+ expectedNodes.add(new SWHID("swh:1:rel:0000000000000000000000000000000000000019"));
GraphTest.assertEqualsAnyOrder(expectedNodes, 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
@@ -12,7 +12,7 @@
@Test
public void forwardRootToLeaf() {
Graph graph = getGraph();
- SwhPID src = new SwhPID("swh:1:snp:0000000000000000000000000000000000000020");
+ SWHID src = new SWHID("swh:1:snp:0000000000000000000000000000000000000020");
String dstFmt = "swh:1:cnt:0000000000000000000000000000000000000005";
SwhPath solution1 =
@@ -46,7 +46,7 @@
@Test
public void forwardLeafToLeaf() {
Graph graph = getGraph();
- SwhPID src = new SwhPID("swh:1:cnt:0000000000000000000000000000000000000007");
+ SWHID src = new SWHID("swh:1:cnt:0000000000000000000000000000000000000007");
String dstFmt = "cnt";
SwhPath expectedPath =
@@ -66,7 +66,7 @@
@Test
public void forwardRevToRev() {
Graph graph = getGraph();
- SwhPID src = new SwhPID("swh:1:rev:0000000000000000000000000000000000000018");
+ SWHID src = new SWHID("swh:1:rev:0000000000000000000000000000000000000018");
String dstFmt = "swh:1:rev:0000000000000000000000000000000000000003";
SwhPath expectedPath =
@@ -89,7 +89,7 @@
@Test
public void backwardRevToRev() {
Graph graph = getGraph();
- SwhPID src = new SwhPID("swh:1:rev:0000000000000000000000000000000000000003");
+ SWHID src = new SWHID("swh:1:rev:0000000000000000000000000000000000000003");
String dstFmt = "swh:1:rev:0000000000000000000000000000000000000018";
SwhPath expectedPath =
@@ -112,7 +112,7 @@
@Test
public void backwardCntToFirstSnp() {
Graph graph = getGraph();
- SwhPID src = new SwhPID("swh:1:cnt:0000000000000000000000000000000000000001");
+ SWHID src = new SWHID("swh:1:cnt:0000000000000000000000000000000000000001");
String dstFmt = "snp";
SwhPath solution1 =
@@ -161,7 +161,7 @@
@Test
public void forwardRevToFirstCnt() {
Graph graph = getGraph();
- SwhPID src = new SwhPID("swh:1:rev:0000000000000000000000000000000000000009");
+ SWHID src = new SWHID("swh:1:rev:0000000000000000000000000000000000000009");
String dstFmt = "cnt";
SwhPath solution1 =
@@ -212,7 +212,7 @@
@Test
public void backwardDirToFirstRel() {
Graph graph = getGraph();
- SwhPID src = new SwhPID("swh:1:dir:0000000000000000000000000000000000000016");
+ SWHID src = new SWHID("swh:1:dir:0000000000000000000000000000000000000016");
String dstFmt = "rel";
SwhPath expectedPath =