package org.softwareheritage.graph.utils; import it.unimi.dsi.big.webgraph.NodeIterator; import org.softwareheritage.graph.SwhUnidirectionalGraph; import org.softwareheritage.graph.labels.DirEntry; import java.io.IOException; public class DumpProperties { public static void main(String[] args) throws IOException { String graphPath = args[0]; SwhUnidirectionalGraph graph = SwhUnidirectionalGraph.loadLabelled(graphPath); graph.properties.loadContentLength(); graph.properties.loadContentIsSkipped(); graph.properties.loadPersonIds(); graph.properties.loadAuthorTimestamps(); graph.properties.loadCommitterTimestamps(); graph.properties.loadMessages(); graph.properties.loadTagNames(); graph.properties.loadLabelNames(); NodeIterator it = graph.nodeIterator(); while (it.hasNext()) { long node = it.nextLong(); System.out.format("%s: %s\n", node, graph.getSWHID(node)); var s = graph.labelledSuccessors(node); long succ; System.out.println(" successors:"); while ((succ = s.nextLong()) >= 0) { DirEntry[] labels = (DirEntry[]) s.label().get(); if (labels.length > 0) { for (DirEntry label : labels) { System.out.format( " %s %s [perms: %s]\n", graph.getSWHID(succ), new String(graph.properties.getLabelName(label.filenameId)), label.permission ); } } else { System.out.format(" %s\n", graph.getSWHID(succ)); } } System.out.println(); switch (graph.getNodeType(node)) { case CNT: System.out.format(" length: %s\n", graph.properties.getContentLength(node)); System.out.format(" is_skipped: %s\n", graph.properties.isContentSkipped(node)); break; case REV: System.out.format(" author: %s\n", graph.properties.getAuthorId(node)); System.out.format(" committer: %s\n", graph.properties.getCommitterId(node)); System.out.format(" date: %s (offset: %s)\n", graph.properties.getAuthorTimestamp(node), graph.properties.getAuthorTimestampOffset(node)); System.out.format(" committer_date: %s (offset: %s)\n", graph.properties.getCommitterTimestamp(node), graph.properties.getCommitterTimestampOffset(node)); System.out.format(" message: %s\n", (new String(graph.properties.getMessage(node))).replace("\n", "\\n")); break; case REL: System.out.format(" author: %s\n", graph.properties.getAuthorId(node)); System.out.format(" date: %s (offset: %s)\n", graph.properties.getTimestamp(node), graph.properties.getTimestampOffset(node)); System.out.format(" message: %s\n", (new String(graph.properties.getMessage(node))).replace("\n", "\\n")); System.out.format(" tag name: %s\n", new String(graph.properties.getTagName(node))); break; } System.out.println(); } } }