Differential D4006 Diff 19063 java/src/main/java/org/softwareheritage/graph/utils/ReadLabelledGraph.java
Changeset View
Changeset View
Standalone View
Standalone View
java/src/main/java/org/softwareheritage/graph/utils/ReadLabelledGraph.java
package org.softwareheritage.graph.utils; | package org.softwareheritage.graph.utils; | ||||
import it.unimi.dsi.big.util.PermutedFrontCodedStringBigList; | |||||
import it.unimi.dsi.big.webgraph.labelling.ArcLabelledImmutableGraph; | import it.unimi.dsi.big.webgraph.labelling.ArcLabelledImmutableGraph; | ||||
import it.unimi.dsi.big.webgraph.labelling.ArcLabelledNodeIterator; | import it.unimi.dsi.big.webgraph.labelling.ArcLabelledNodeIterator; | ||||
import it.unimi.dsi.big.webgraph.labelling.BitStreamArcLabelledImmutableGraph; | import it.unimi.dsi.big.webgraph.labelling.BitStreamArcLabelledImmutableGraph; | ||||
import it.unimi.dsi.fastutil.io.BinIO; | import it.unimi.dsi.fastutil.io.BinIO; | ||||
import it.unimi.dsi.util.PermutedFrontCodedStringList; | import org.softwareheritage.graph.labels.DirEntry; | ||||
import org.softwareheritage.graph.maps.NodeIdMap; | import org.softwareheritage.graph.maps.NodeIdMap; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
public class ReadLabelledGraph { | public class ReadLabelledGraph { | ||||
public static void main(String[] args) throws IOException, ClassNotFoundException { | public static void main(String[] args) throws IOException, ClassNotFoundException { | ||||
String graphPath = args[0]; | String graphPath = args[0]; | ||||
ArcLabelledImmutableGraph graph = BitStreamArcLabelledImmutableGraph.loadOffline(graphPath + "-labelled"); | ArcLabelledImmutableGraph graph = BitStreamArcLabelledImmutableGraph.loadOffline(graphPath + "-labelled"); | ||||
NodeIdMap nodeMap = new NodeIdMap(graphPath, graph.numNodes()); | NodeIdMap nodeMap = new NodeIdMap(graphPath, graph.numNodes()); | ||||
PermutedFrontCodedStringList labelMap = (PermutedFrontCodedStringList) BinIO | PermutedFrontCodedStringBigList filenameMap = (PermutedFrontCodedStringBigList) BinIO.loadObject(graphPath + "-filename-labels.fcl"); | ||||
.loadObject(graphPath + "-labels.fcl"); | |||||
ArcLabelledNodeIterator it = graph.nodeIterator(); | ArcLabelledNodeIterator it = graph.nodeIterator(); | ||||
while (it.hasNext()) { | while (it.hasNext()) { | ||||
long srcNode = it.nextLong(); | long srcNode = it.nextLong(); | ||||
ArcLabelledNodeIterator.LabelledArcIterator s = it.successors(); | ArcLabelledNodeIterator.LabelledArcIterator s = it.successors(); | ||||
long dstNode; | long dstNode; | ||||
while ((dstNode = s.nextLong()) >= 0) { | while ((dstNode = s.nextLong()) >= 0) { | ||||
int[] labels = (int[]) s.label().get(); | DirEntry[] labels = (DirEntry[]) s.label().get(); | ||||
if (labels.length > 0) { | if (labels.length > 0) { | ||||
seirl: Just use label.permission here. | |||||
for (int label : labels) { | for (DirEntry label : labels) { | ||||
Done Inline ActionsAccording to Seba, there is now a big version of PermutedFrontCodedStringList. We probably want to use that to be able to use more than 2**32 labels. seirl: According to Seba, there is now a big version of PermutedFrontCodedStringList. We probably want… | |||||
System.out.format("%s %s %s\n", nodeMap.getSWHID(srcNode), nodeMap.getSWHID(dstNode), | System.out.format( | ||||
labelMap.get(label)); | "%s %s %s %d\n", | ||||
nodeMap.getSWHID(srcNode), | |||||
nodeMap.getSWHID(dstNode), | |||||
filenameMap.get(label.filenameId), | |||||
label.permission | |||||
); | |||||
} | } | ||||
} else { | } 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)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } |
Just use label.permission here.