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:cherry.sqlman.tool.clause.SqlClauseControllerImpl.java
@Override public ModelAndView execute(SqlClauseForm form, BindingResult binding, Authentication auth, Locale locale, SitePreference sitePref, NativeWebRequest request) { if (hasErrors(form, binding)) { return withViewname(viewnameOfStart).build(); }//from w ww .j av a 2s.co m try { Pair<PageSet, ResultSet> pair = search(form); return withViewname(viewnameOfStart).addObject(pair.getLeft()).addObject(pair.getRight()).build(); } catch (BadSqlGrammarException ex) { LogicalErrorUtil.reject(binding, LogicError.BadSqlGrammer, Util.getRootCause(ex).getMessage()); return withViewname(viewnameOfStart).build(); } }
From source file:com.github.steveash.jg2p.train.JointEncoderTrainer.java
private int collectGoodAligns(Collection<Alignment> crfExamples, PhonemeCrfModel crfModel, ProbTable goodAligns, Set<Alignment> goodExamples) { int goodAlignCount = 0; for (Alignment crfExample : crfExamples) { List<PhonemeCrfModel.TagResult> predicts = crfModel.tag(crfExample.getAllXTokensAsList(), 1); if (predicts.size() > 0) { if (predicts.get(0).isEqualTo(crfExample.getYTokens())) { // good example, let's increment all of its transitions for (Pair<String, String> graphone : crfExample) { goodAligns.addProb(graphone.getLeft(), graphone.getRight(), 1.0); }/*from w ww . j av a2 s .co m*/ goodAlignCount += 1; goodExamples.add(crfExample); } } } return goodAlignCount; }
From source file:ca.on.oicr.pde.workflows.GATKGenotypeGVCFsWorkflow.java
private <S, T> Set<T> getRightCollection(Collection<Pair<S, T>> pairs) { LinkedHashSet<T> ts = new LinkedHashSet<>(); for (Pair<S, T> p : pairs) { ts.add(p.getRight()); }/*ww w. j a v a 2 s.c o m*/ return ts; }
From source file:com.streamsets.pipeline.stage.processor.kv.redis.RedisStore.java
@SuppressWarnings("unchecked") public void put(Pair<String, DataType> key, LookupValue value) { // Persist any new keys to Redis. Jedis jedis = pool.getResource();/* w w w . java 2 s .c o m*/ switch (key.getRight()) { case STRING: jedis.set(key.getLeft(), (String) value.getValue()); break; case LIST: for (String element : (List<String>) value.getValue()) jedis.lpush(key.getLeft(), element); break; case HASH: Map<String, String> map = (Map<String, String>) value.getValue(); jedis.hmset(key.getLeft(), map); break; case SET: for (String element : (Set<String>) value.getValue()) jedis.lpush(key.getLeft(), element); break; default: throw new IllegalStateException(Errors.REDIS_LOOKUP_04.getMessage()); } jedis.close(); }
From source file:com.epam.ngb.cli.manager.command.handler.http.ReferenceRegistrationHandler.java
/** * Verifies that input arguments contain the required parameters: * first and the only argument must be path to the reference file. * @param arguments command line arguments for 'register_reference' command * @param options to specify a reference name and output options *//*from www.ja va 2 s .c o m*/ @Override public void parseAndVerifyArguments(List<String> arguments, ApplicationOptions options) { if (arguments.isEmpty() || arguments.size() != 1) { throw new IllegalArgumentException( MessageConstants.getMessage(ILLEGAL_COMMAND_ARGUMENTS, getCommand(), 1, arguments.size())); } referencePath = arguments.get(0); if (options.getName() != null) { referenceName = options.getName(); } if (options.getGeneFile() != null) { try { geneFileId = loadFileByNameOrBioID(options.getGeneFile()).getId(); } catch (ApplicationException e) { LOGGER.debug(e.getMessage(), e); Pair<String, String> path = parseAndVerifyFilePath(options.getGeneFile()); geneFilePath = path.getLeft(); geneIndexPath = path.getRight(); } } printJson = options.isPrintJson(); printTable = options.isPrintTable(); noGCContent = options.isNoGCContent(); prettyName = options.getPrettyName(); }
From source file:com.github.steveash.jg2p.align.AlignerTrainer.java
private double minAllowedCount() { double min = Double.POSITIVE_INFINITY; for (Pair<String, String> xy : allowed) { double p = counts.prob(xy.getLeft(), xy.getRight()); if (p > 0 && p < min) { min = p;// ww w. j a va 2 s.c om } } return min; }
From source file:com.github.steveash.jg2p.align.AlignerTrainer.java
private void smoothCounts() { if (allowed == null) return;/* w w w . j a v a 2 s. c om*/ // do some kind of discounted smoothing where we add 0.5 * c / k * smallest entry) to every entry in the counts // where c is the count of good transitions and k is the total count of transitions. And we're just going to // take half of that (arbitrarily) double c = allowed.size(); double k = blocked.size(); double discount = 0.5d * c / k; double toAdd = minAllowedCount() * discount; for (Pair<String, String> xy : allowed) { counts.addProb(xy.getLeft(), xy.getRight(), toAdd); } for (Pair<String, String> xy : blocked) { // we're forcing the blocked ones to be this small mass, whereas we're just adding the extra to the good xy counts.setProb(xy.getLeft(), xy.getRight(), toAdd); } }
From source file:com.streamsets.pipeline.stage.processor.kv.redis.RedisStore.java
public LookupValue get(Pair<String, DataType> pair) { Jedis jedis = pool.getResource();/*from www . j av a 2 s . c om*/ LookupValue values; // check the type DataType type = pair.getRight(); String key = pair.getLeft(); switch (type) { case STRING: values = new LookupValue(jedis.get(key), type); break; case LIST: values = new LookupValue(jedis.lrange(key, 0, jedis.llen(key)), type); break; case HASH: values = new LookupValue(jedis.hgetAll(key), type); break; case SET: values = new LookupValue(jedis.smembers(key), type); break; default: values = null; } jedis.close(); return values; }
From source file:com.hortonworks.registries.schemaregistry.HAServerNotificationManager.java
private void notify(String urlPath, Object postBody) { // If Schema Registry was not started in HA mode then serverURL would be null, in case don't bother making POST calls if (serverUrl != null) { PriorityQueue<Pair<Integer, String>> queue = new PriorityQueue<>(); synchronized (UPDATE_ITERATE_LOCK) { hostIps.stream().forEach(hostIp -> { queue.add(Pair.of(1, hostIp)); });/*from w w w.j av a2s. c o m*/ } while (!queue.isEmpty()) { Pair<Integer, String> priorityWithHostIp = queue.remove(); WebTarget target = ClientBuilder.newClient() .target(String.format("%s%s", priorityWithHostIp.getRight(), urlPath)); Response response = null; try { response = target.request().post(Entity.json(postBody)); } catch (Exception e) { LOG.warn("Failed to notify the peer server '{}' about the current host debut.", priorityWithHostIp.getRight()); } if ((response == null || response.getStatus() != Response.Status.OK.getStatusCode()) && priorityWithHostIp.getLeft() < MAX_RETRY) { queue.add(Pair.of(priorityWithHostIp.getLeft() + 1, priorityWithHostIp.getRight())); } else if (priorityWithHostIp.getLeft() < MAX_RETRY) { LOG.info("Notified the peer server '{}' about the current host debut.", priorityWithHostIp.getRight()); } else if (priorityWithHostIp.getLeft() >= MAX_RETRY) { LOG.warn( "Failed to notify the peer server '{}' about the current host debut, giving up after {} attempts.", priorityWithHostIp.getRight(), MAX_RETRY); } try { Thread.sleep(priorityWithHostIp.getLeft() * 100); } catch (InterruptedException e) { LOG.warn("Failed to notify the peer server '{}'", priorityWithHostIp.getRight(), e); } } } }
From source file:additionalpipes.pipes.PipeFluidsTeleport.java
@Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { if (CoreProxy.proxy.isRenderWorld(container.worldObj)) { return 0; }// ww w . j ava2 s. c om FluidStack fluid = resource.copy(); List<PipeFluidsTeleport> connectedPipes = logic.getConnectedPipes(true); connectedPipes = Lists.newArrayList(connectedPipes); Collections.shuffle(connectedPipes, container.worldObj.rand); OUTER: for (PipeFluidsTeleport destPipe : connectedPipes) { List<Pair<ForgeDirection, IFluidHandler>> fluidsList = destPipe.getPossibleFluidsMovements(); Collections.shuffle(fluidsList, container.worldObj.rand); for (Pair<ForgeDirection, IFluidHandler> fluids : fluidsList) { ForgeDirection side = fluids.getLeft(); IFluidHandler tank = fluids.getRight(); int usedSingle = tank.fill(side, fluid, false); if (usedSingle > 0) { int energy = APUtils.divideAndCeil(usedSingle, AdditionalPipes.unitFluids); if (doFill ? logic.useEnergy(energy) : logic.canUseEnergy(energy)) { if (doFill) { tank.fill(side, fluid, doFill); } fluid.amount -= usedSingle; if (fluid.amount <= 0) { break OUTER; } } } } } return resource.amount - fluid.amount; }