List of usage examples for org.apache.commons.lang3.tuple Pair getLeft
public abstract L getLeft();
Gets the left element from this pair.
When treated as a key-value pair, this is the key.
From source file:com.garethahealy.quotalimitsgenerator.cli.parsers.CLIOptions.java
public QuotaLimitModel calculate() { Pair<Integer, Integer> instanceTypeLine = lines.get(instanceType); Integer instanceCoreInMillis = instanceTypeLine.getLeft() * 1000; Integer instanceMemoryInMb = instanceTypeLine.getRight() * 1000; QuotaLimitModel quotaLimitModel = new QuotaLimitModel(); quotaLimitModel.setInstanceType(instanceType); quotaLimitModel.setQualityOfService(qualityOfService); quotaLimitModel.setAllocatableNodeCores(instanceCoreInMillis); quotaLimitModel.setAllocatableNodeMemory(instanceMemoryInMb); quotaLimitModel/*from w w w . java2 s. co m*/ .setMaxPods(Double.valueOf(Math.floor((instanceMemoryInMb / 500) * nodeWorkerCount)).intValue()); quotaLimitModel.setTerminatingPodCPU(Double.valueOf(Math.floor(instanceCoreInMillis * 0.5)).intValue()); quotaLimitModel.setTerminatingPodMemory(Double.valueOf(Math.floor(instanceMemoryInMb * 0.5)).intValue()); quotaLimitModel.setMaxOrNotTerminatingPodLimitCPU(instanceCoreInMillis * requestRatio); quotaLimitModel.setMaxOrNotTerminatingPodLimitMemory(instanceMemoryInMb * requestRatio); quotaLimitModel.setMaxOrNotTerminatingPodRequestCPU(instanceCoreInMillis); quotaLimitModel.setMaxOrNotTerminatingPodRequestMemory(instanceMemoryInMb); quotaLimitModel.setIsTeamNamespace(isTeamNamespace); quotaLimitModel.setCpuRequestRatio(requestRatio); quotaLimitModel.setMemoryRequestRatio(requestRatio); quotaLimitModel.setOutputPath(outputPath); return quotaLimitModel; }
From source file:io.github.autsia.crowly.tests.SentimentTests.java
@Test public void analyzeNeutral() throws Exception { Pair<Sentiment, Float> opinion = crowlySentimentAnalyzer.analyze("This movie contains of three parts."); Assert.assertEquals(Sentiment.NEUTRAL, opinion.getLeft()); }
From source file:com.minlia.cloud.framework.client.template.AbstractBaseClientRestTemplate.java
protected HttpHeaders readHeadersWithAuth(final Pair<String, String> credentials) { if (credentials == null) { final Pair<String, String> readCredentials = getReadCredentials(); return readHeadersWithAuth(readCredentials.getLeft(), readCredentials.getRight()); }//from w w w . j a v a 2 s .c om return readHeadersWithAuth(credentials.getLeft(), credentials.getRight()); }
From source file:cc.recommenders.evaluation.OverviewOfSizeLambdas.java
private void visualizeResults() { for (Double lambda : results.keySet()) { System.out.println("## Lambda: " + lambda); System.out.println("best options: " + lambdaOptions.get(lambda)); Pair<Boxplot, Integer> pair = results.get(lambda); System.out.println("avg. f1: " + pair.getLeft()); System.out.println("avg. size: " + pair.getRight()); System.out.println();// w ww . ja v a 2s. c o m } }
From source file:com.act.lcms.CompareTwoNetCDFAroundMass.java
private double extractMZ(double mzWanted, List<Pair<Double, Double>> intensities, double time) { double intensityFound = 0; int numWithinPrecision = 0; double mzLowRange = mzWanted - mzTolerance; double mzHighRange = mzWanted + mzTolerance; // we expect there to be pretty much only one intensity value in the precision // range we are looking at. But if a lot of masses show up then complain for (Pair<Double, Double> mz_int : intensities) { double mz = mz_int.getLeft(); double intensity = mz_int.getRight(); if (mz > mzLowRange && mz < mzHighRange) { intensityFound += intensity; numWithinPrecision++;/*from ww w. j a v a 2 s . c o m*/ if (intensity > 100000) System.out.format("time: %f\tmz: %f\t intensity: %f\n", time, mz, intensity); } } if (numWithinPrecision > maxNumMzTolerated) { System.out.format("Only expected %d, but found %d in the mz range [%f, %f]\n", maxNumMzTolerated, numWithinPrecision, mzLowRange, mzHighRange); } return intensityFound; }
From source file:com.vmware.identity.openidconnect.server.AuthorizationController.java
@RequestMapping(value = "/oidc/authorize/{tenant:.*}", method = { RequestMethod.GET, RequestMethod.POST }) public ModelAndView authorize(Model model, Locale locale, HttpServletRequest request, HttpServletResponse response, @PathVariable("tenant") String tenant) throws IOException { ModelAndView page = null;// www .ja va 2s . c om IDiagnosticsContextScope context = null; try { HttpRequest httpRequest = HttpRequest.create(request); context = DiagnosticsContextFactory.createContext(CorrelationID.get(httpRequest).getValue(), tenant); AuthenticationRequestProcessor p = new AuthenticationRequestProcessor(this.idmClient, this.authzCodeManager, this.sessionManager, this.messageSource, model, locale, httpRequest, tenant); Pair<ModelAndView, HttpResponse> result = p.process(); page = result.getLeft(); HttpResponse httpResponse = result.getRight(); if (httpResponse != null) { httpResponse.applyTo(response); } } catch (Exception e) { logger.error("unhandled exception", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "unhandled exception: " + e.getClass().getName()); } finally { if (context != null) { context.close(); } } return page; }
From source file:hu.ppke.itk.nlpg.purepos.common.lemma.AbstractLemmaTransformation.java
@Override public IToken convert(String word, IVocabulary<String, Integer> vocab) { Pair<String, Integer> anal = this.analyze(word); String tag = vocab.getWord(anal.getRight()); return token(word, anal.getLeft(), tag); }
From source file:com.minlia.cloud.framework.client.template.AbstractBaseClientRestTemplate.java
protected HttpHeaders writeHeadersWithAuth(final Pair<String, String> credentials) { if (credentials == null) { final Pair<String, String> writeCredentials = getWriteCredentials(); return writeHeadersWithAuth(writeCredentials.getLeft(), writeCredentials.getRight()); }/*from w w w . j a v a2s . c o m*/ return writeHeadersWithAuth(credentials.getLeft(), credentials.getRight()); }
From source file:com.muk.ext.core.jackson.PairSerializer.java
@Override public void serialize(Pair value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException { gen.writeStartArray(2);/*w ww.ja va 2 s .c o m*/ gen.writeObject(value.getLeft()); gen.writeObject(value.getRight()); gen.writeEndArray(); }
From source file:flens.input.SocketInput.java
@Override public void readAndProcess(Pair<String, DataInputStream> inx) throws IOException { DataInputStream in = inx.getRight(); String host = inx.getLeft(); int line = in.readInt(); byte[] block = new byte[line]; IOUtils.readFully(in, block);/*w ww .jav a 2 s . c o m*/ Map<String, Object> values = new HashMap<String, Object>(); values.put(Constants.BODY, block); Record r = Record.createWithTimeHostAndValues(System.currentTimeMillis(), host, values); dispatch(r); }