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:name.martingeisse.phunky.runtime.code.expression.array.ArrayElementExpression.java
@Override public AssignmentTarget resolveAssignmentTarget(Environment environment) { Pair<Variable, String> variableArrayAndKey = obtainArrayVariableAndKey(environment); if (variableArrayAndKey == null) { environment.getRuntime().triggerError("trying to get element of non-array value", getLocation()); return null; } else {/*from w w w. ja v a2s. com*/ Variable arrayVariable = variableArrayAndKey.getLeft(); String key = variableArrayAndKey.getRight(); return new ArrayElementAssignmentTarget(array, key); } }
From source file:eu.stratosphere.nephele.streaming.taskmanager.chaining.TaskChainer.java
/** * Splits up the chain at the given index into two chains with the goal of * having one remainder chain that never uses more than one CPU core and * another remainder chain that uses as little CPU as possible. The idea * behind this is for the latter remainder chain to be split up later on (if * it is uses a lot of CPU) or be merged with another chain (if it uses * little CPU) at a later point.//from ww w . j a v a 2 s . c o m */ private Pair<TaskChain, TaskChain> splitChain(TaskChain flow) { // pair contains: <noOfTasksToUnchain, estimatedRemainingCPUUtilization> Pair<Integer, Double> beginUnchainProposal = computeUnchainingProposal(flow, true); Pair<Integer, Double> endUnchainProposal = computeUnchainingProposal(flow, false); // The remainder CPU util x is 0%<x<99% in both unchaining proposals. We // will choose the proposal with the higher x. int splitIndex; if (beginUnchainProposal.getRight() >= endUnchainProposal.getRight()) { splitIndex = beginUnchainProposal.getLeft(); } else { splitIndex = flow.getNumberOfChainedTasks() - endUnchainProposal.getLeft(); } return TaskChain.splitAndAnnounceChain(flow, splitIndex, this.backgroundWorkers, this.configCenter); }
From source file:com.vmware.photon.controller.api.frontend.commands.steps.DeploymentPushSecurityGroupsStepCmd.java
@Override protected void execute() throws ExternalException { List<DeploymentEntity> deploymentEntities = step.getTransientResourceEntities(null); checkArgument(deploymentEntities.size() == 1); DeploymentEntity deploymentEntity = deploymentEntities.get(0); logger.info("Propagating the security groups of deployment {}", deploymentEntity.getId()); ResourceList<Tenant> tenants = tenantBackend.filter(Optional.absent(), Optional.of(PaginationConfig.DEFAULT_DEFAULT_PAGE_SIZE)); ResourceList<Tenant> currentPage; List<String> deploymentSecurityGroups = deploymentEntity.getOauthSecurityGroups(); do {/*from w w w.ja v a2s . c om*/ for (Tenant tenant : tenants.getItems()) { logger.info("Updating the security groups of tenant {} using the ones from deployment {}", tenant.getId(), deploymentEntity.getId()); List<SecurityGroup> currSecurityGroups = tenant.getSecurityGroups(); Pair<List<SecurityGroup>, List<String>> result = SecurityGroupUtils .mergeParentSecurityGroups(currSecurityGroups, deploymentSecurityGroups); tenantBackend.setSecurityGroups(tenant.getId(), result.getLeft()); // Needs to change the securityGroupsAlreadyInhertiedException // Currently it does not identify which entity these SGs are for. if (result.getRight() != null && !result.getRight().isEmpty()) { step.addWarning(new SecurityGroupsAlreadyInheritedException(result.getRight())); } } currentPage = tenants; if (tenants.getNextPageLink() != null && !tenants.getNextPageLink().isEmpty()) { tenants = tenantBackend.getPage(tenants.getNextPageLink()); } } while (currentPage.getNextPageLink() != null && !currentPage.getNextPageLink().isEmpty()); }
From source file:models.Document.java
/** * @return The JSON source for this document as compact JSON-LD with an * extracted, external context, or null if conversion failed. *///from w ww . j ava2 s . com public String getSource() { try { final Pair<URL, String> localAndPublicContextUrls = getContextUrls(); final Map<String, Object> contextObject = (Map<String, Object>) JSONUtils .fromURL(localAndPublicContextUrls.getLeft()); final Map<String, Object> compactJsonLd = (Map<String, Object>) JSONLD .compact(JSONUtils.fromString(source), contextObject); compactJsonLd.put("@context", localAndPublicContextUrls.getRight()); final String result = JSONUtils.toString(compactJsonLd); return this.field.isEmpty() ? result : findField(result); } catch (JSONLDProcessingError | IOException e) { e.printStackTrace(); return null; } }
From source file:at.gridtec.lambda4j.function.bi.to.ToByteBiFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Pair *///from w ww . j a v a2s .c o m default byte applyAsByte(@Nonnull Pair<T, U> tuple) { Objects.requireNonNull(tuple); return applyAsByte(tuple.getLeft(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.bi.to.ToCharBiFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Pair *//*from w w w . j a va 2 s . c o m*/ default char applyAsChar(@Nonnull Pair<T, U> tuple) { Objects.requireNonNull(tuple); return applyAsChar(tuple.getLeft(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.bi.to.ToFloatBiFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Pair *//*from w w w . j av a 2 s . c om*/ default float applyAsFloat(@Nonnull Pair<T, U> tuple) { Objects.requireNonNull(tuple); return applyAsFloat(tuple.getLeft(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.bi.to.ToShortBiFunction.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Pair *//*from w w w . j a v a 2 s .c o m*/ default short applyAsShort(@Nonnull Pair<T, U> tuple) { Objects.requireNonNull(tuple); return applyAsShort(tuple.getLeft(), tuple.getRight()); }
From source file:at.gridtec.lambda4j.function.bi.to.ToIntBiFunction2.java
/** * Applies this function to the given tuple. * * @param tuple The tuple to be applied to the function * @return The return value from the function, which is its result. * @throws NullPointerException If given argument is {@code null} * @see org.apache.commons.lang3.tuple.Pair *//*w ww.ja v a 2s .c o m*/ default int applyAsInt(@Nonnull Pair<T, U> tuple) { Objects.requireNonNull(tuple); return applyAsInt(tuple.getLeft(), tuple.getRight()); }
From source file:edu.uci.ics.hyracks.api.job.JobSpecification.java
public IOperatorDescriptor getConsumer(IConnectorDescriptor conn) { Pair<Pair<IOperatorDescriptor, Integer>, Pair<IOperatorDescriptor, Integer>> connInfo = connectorOpMap .get(conn.getConnectorId()); return connInfo.getRight().getLeft(); }