List of usage examples for org.apache.commons.lang3.tuple Pair getRight
public abstract R getRight();
Gets the right element from this pair.
When treated as a key-value pair, this is the value.
From source file:com.github.blindpirate.gogradle.util.MapUtils.java
private static <K, V> Map<K, V> asMap(Pair<K, V>... entries) { Map<K, V> ret = new HashMap<>(); for (Pair<K, V> entry : entries) { ret.put(entry.getLeft(), entry.getRight()); }/*from ww w . ja v a 2s .co m*/ return ret; }
From source file:edu.umd.umiacs.clip.tools.math.CorrelationUtils.java
public static double pr(final double[] xUnsorted, final double[] yUnsorted) { Pair<double[], double[]> pairs = sort(xUnsorted, yUnsorted); double[] x = minMaxScale(pairs.getLeft()); double[] y = minMaxScale(pairs.getRight()); return range(1, x.length).parallel() .mapToDouble(i -> x[i] * (range(0, i).mapToDouble(j -> (x[j] - x[i]) * (y[j] - y[i])).sum()) / (Math.sqrt((range(0, i).mapToDouble(j -> Math.pow(x[j] - x[i], 2)).sum()) * (range(0, i).mapToDouble(j -> Math.pow(y[j] - y[i], 2)).sum())))) .sum() / range(1, x.length).mapToDouble(i -> x[i]).sum(); }
From source file:com.github.blindpirate.gogradle.util.MapUtils.java
private static <K, V> Map<K, V> asMapWithoutNull(Pair<K, V>... entries) { Map<K, V> ret = new HashMap<>(); for (Pair<K, V> entry : entries) { if (entry.getLeft() != null && entry.getRight() != null) { ret.put(entry.getLeft(), entry.getRight()); }/* w w w.ja v a2s.com*/ } return ret; }
From source file:gobblin.ingestion.google.webmaster.UrlTriePrefixGrouper.java
/** * Get the detailed pages under this group *//*from w ww . j a v a 2 s .c o m*/ public static ArrayList<String> groupToPages( Triple<String, GoogleWebmasterFilter.FilterOperator, UrlTrieNode> group) { ArrayList<String> ret = new ArrayList<>(); if (group.getMiddle().equals(GoogleWebmasterFilter.FilterOperator.EQUALS)) { if (group.getRight().isExist()) { ret.add(group.getLeft()); } } else if (group.getMiddle().equals(GoogleWebmasterFilter.FilterOperator.CONTAINS)) { UrlTrie trie = new UrlTrie(group.getLeft(), group.getRight()); Iterator<Pair<String, UrlTrieNode>> iterator = new UrlTriePostOrderIterator(trie, 1); while (iterator.hasNext()) { Pair<String, UrlTrieNode> next = iterator.next(); if (next.getRight().isExist()) { ret.add(next.getLeft()); } } } return ret; }
From source file:edu.uci.ics.hyracks.control.cc.partitions.PartitionUtils.java
public static void reportPartitionMatch(ClusterControllerService ccs, final PartitionId pid, Pair<PartitionDescriptor, PartitionRequest> match) throws Exception { PartitionDescriptor desc = match.getLeft(); PartitionRequest req = match.getRight(); NodeControllerState producerNCS = ccs.getNodeMap().get(desc.getNodeId()); NodeControllerState requestorNCS = ccs.getNodeMap().get(req.getNodeId()); final NetworkAddress dataport = producerNCS.getDataPort(); final INodeController requestorNC = requestorNCS.getNodeController(); requestorNC.reportPartitionAvailability(pid, dataport); }
From source file:ivorius.ivtoolkit.tools.Pairs.java
public static <T> Function<Pair<T, T>, T> rightFunction() { return new Function<Pair<T, T>, T>() { @Nullable//from w w w.j ava 2 s .co m @Override public T apply(@Nullable Pair<T, T> input) { return input.getRight(); } }; }
From source file:net.mindengine.blogix.tests.RequestSampleParser.java
public static String[][] loadSamplesAsDataProvider(File file) throws IOException, URISyntaxException { List<Pair<String, String>> checks = loadRequestChecksFromFile(file); String[][] arr = new String[checks.size()][]; int i = -1;//from w w w . j a va 2 s .c om for (Pair<String, String> check : checks) { i++; arr[i] = new String[] { check.getLeft(), check.getRight() }; } return arr; }
From source file:com.twitter.distributedlog.ZooKeeperClusterTestCase.java
@BeforeClass public static void setupZooKeeper() throws Exception { zkDir = IOUtils.createTempDir("zookeeper", ZooKeeperClusterTestCase.class.getName()); Pair<ZooKeeperServerShim, Integer> serverAndPort = LocalDLMEmulator.runZookeeperOnAnyPort(zkDir); zks = serverAndPort.getLeft();//from www .j a va 2 s .c o m zkPort = serverAndPort.getRight(); zkServers = "127.0.0.1:" + zkPort; }
From source file:fr.cnrs.sharp.reasoning.Harmonization.java
public static Model harmonizeProv(Model inputProvGraph) { logger.info("Asserted graph : Graph size / BNodes : " + inputProvGraph.size() + "/" + Unification.countBN(inputProvGraph)); // Util.dumpPredStats(inputProvGraph); /// STEP 1 : OWL sameAs inferences Model schema = ModelFactory.createDefaultModel(); RDFDataMgr.read(schema, Harmonization.class.getClassLoader().getResourceAsStream("provo.ttl"), Lang.TURTLE); Reasoner owlReasoner = ReasonerRegistry.getOWLMiniReasoner(); owlReasoner = owlReasoner.bindSchema(schema); InfModel owlModel = ModelFactory.createInfModel(owlReasoner, inputProvGraph); // logger.info("OWL entail : Graph size / BNodes : " + owlModel.size() + "/" + Unification.countBN(owlModel)); // Util.dumpPredStats(owlModel); /// STEP 2.1 : PROV inferences TGD == saturation List rules = Rule.rulesFromURL("provRules_all.jena"); GenericRuleReasoner reasoner = new GenericRuleReasoner(rules); InfModel inferredModel = ModelFactory.createInfModel(reasoner, owlModel); /// STEP 2.2 : PROV inferences EGD == unification Model harmonizedModel = ModelFactory.createDefaultModel().add(inferredModel); int nbSubstitution = 1; while (nbSubstitution > 0) { // UNIFICATION : 1. finding substitution of existential variables List<Pair<RDFNode, RDFNode>> toBeMerged = Unification.selectSubstitutions(harmonizedModel); nbSubstitution = toBeMerged.size(); if (toBeMerged.size() > 0) { // UNIFICATION : 2. effectively replacing blank nodes by matching nodes for (Pair<RDFNode, RDFNode> p : toBeMerged) { Unification.mergeNodes(p.getLeft(), p.getRight().asResource()); }/*from w ww. j a v a 2s . c o m*/ nbSubstitution = Unification.selectSubstitutions(harmonizedModel).size(); } } logger.info("OWL + PROV inferences + blank nodes unification : Graph size / BNodes : " + harmonizedModel.size() + "/" + Unification.countBN(harmonizedModel)); // Util.dumpPredStats(harmonizedModel); return harmonizedModel; }
From source file:blusunrize.immersiveengineering.api.tool.RailgunHandler.java
public static RailgunProjectileProperties getProjectileProperties(ItemStack stack) { for (Pair<IngredientStack, RailgunProjectileProperties> pair : projectilePropertyMap) if (pair.getLeft().matchesItemStack(stack)) return pair.getRight(); return null;//from ww w. ja v a 2 s . co m }