Differential D4821 Diff 17075 java/src/main/java/org/softwareheritage/graph/utils/ComposePermutations.java
Changeset View
Changeset View
Standalone View
Standalone View
java/src/main/java/org/softwareheritage/graph/utils/ComposePermutations.java
- This file was added.
package org.softwareheritage.graph.utils; | |||||
vlorentz: you should add a copyright header to all Java files in the repo, btw | |||||
import com.martiansoftware.jsap.*; | |||||
import it.unimi.dsi.Util; | |||||
import it.unimi.dsi.fastutil.io.BinIO; | |||||
import java.io.File; | |||||
import java.io.IOException; | |||||
public class ComposePermutations { | |||||
private static JSAPResult parse_args(String[] args) { | |||||
JSAPResult config = null; | |||||
zackUnsubmitted Done Inline ActionsA docstring stating what this is used for in the context of swh-graph would be nice to have here. zack: A docstring stating what this is used for in the context of swh-graph would be nice to have… | |||||
try { | |||||
SimpleJSAP jsap = new SimpleJSAP(ComposePermutations.class.getName(), "", new Parameter[]{ | |||||
new UnflaggedOption("firstPermutation", JSAP.STRING_PARSER, JSAP.REQUIRED, "The first permutation"), | |||||
new UnflaggedOption("secondPermutation", JSAP.STRING_PARSER, JSAP.REQUIRED, | |||||
"The second permutation"), | |||||
new UnflaggedOption("outputPermutation", JSAP.STRING_PARSER, JSAP.REQUIRED, | |||||
"The output permutation"),}); | |||||
config = jsap.parse(args); | |||||
if (jsap.messagePrinted()) { | |||||
System.exit(1); | |||||
} | |||||
} catch (JSAPException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
return config; | |||||
} | |||||
public static void main(String[] args) throws IOException, ClassNotFoundException { | |||||
JSAPResult config = parse_args(args); | |||||
String firstPermFilename = config.getString("firstPermutation"); | |||||
String secondPermFilename = config.getString("secondPermutation"); | |||||
String outputPermFilename = config.getString("outputPermutation"); | |||||
long[][] firstPerm = BinIO.loadLongsBig(new File(firstPermFilename)); | |||||
long[][] secondPerm = BinIO.loadLongsBig(new File(secondPermFilename)); | |||||
long[][] outputPerm = Util.composePermutationsInPlace(firstPerm, secondPerm); | |||||
BinIO.storeLongs(outputPerm, outputPermFilename); | |||||
} | |||||
} |
you should add a copyright header to all Java files in the repo, btw