Example usage for org.apache.commons.lang3.tuple Pair getLeft

List of usage examples for org.apache.commons.lang3.tuple Pair getLeft

Introduction

In this page you can find the example usage for org.apache.commons.lang3.tuple Pair getLeft.

Prototype

public abstract L getLeft();

Source Link

Document

Gets the left element from this pair.

When treated as a key-value pair, this is the key.

Usage

From source file:io.knotx.launcher.KnotxStarterVerticle.java

private StringBuilder collectDeployment(StringBuilder accumulator, Pair<String, String> deploymentId) {
    return accumulator
            .append(String.format("\t\tDeployed %s [%s]", deploymentId.getRight(), deploymentId.getLeft()))
            .append(System.lineSeparator());
}

From source file:com.mirth.connect.client.ui.codetemplate.ContextTreeTableCellEditor.java

@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row,
        int column) {
    Pair<Integer, ?> pair = (Pair<Integer, ?>) value;
    if (pair != null) {
        checkBox.setState(pair.getLeft());
        if (pair.getRight() instanceof String) {
            contextType = null;/*  w  ww .j  ava2s.com*/
            checkBox.setText((String) pair.getRight());
        } else {
            contextType = (ContextType) pair.getRight();
            checkBox.setText(contextType.getDisplayName());
        }
    }

    MirthTreeTable treeTable = (MirthTreeTable) table;
    JTree tree = (JTree) treeTable.getCellRenderer(0, treeTable.getHierarchicalColumn());
    panel.setOffset(tree.getRowBounds(row).x);
    panel.setBackground(row % 2 == 0 ? UIConstants.HIGHLIGHTER_COLOR : UIConstants.BACKGROUND_COLOR);
    checkBox.setBackground(panel.getBackground());
    return panel;
}

From source file:fr.cnrs.sharp.test.UnificationRuleTest.java

@Test
public void testUnification() {
    Model data = ModelFactory.createDefaultModel();
    InputStream stream = new ByteArrayInputStream(inputGraph.getBytes(StandardCharsets.UTF_8));
    RDFDataMgr.read(data, stream, Lang.TTL);
    data.write(System.out, "TTL");
    logger.info("Graph size / BNodes : " + data.size() + "/" + Unification.countBN(data));

    Assert.assertEquals(13, data.size());
    Assert.assertEquals(3, Unification.countBN(data));

    int nbSubst = 1;
    while (nbSubst > 0) {
        // UNIFICATION : 1. select substitutions
        List<Pair<RDFNode, RDFNode>> toBeMerged = Unification.selectSubstitutions(data);
        nbSubst = toBeMerged.size();/*from   w  ww  .ja va 2s  .  co m*/
        logger.info("Found substitutions: " + nbSubst);

        // UNIFICATION : 2. effectively replacing blank nodes by matching nodes
        for (Pair<RDFNode, RDFNode> p : toBeMerged) {
            Unification.mergeNodes(p.getLeft(), p.getRight().asResource());
        }
        logger.info("Graph size / BNodes with unified PROV inferences: " + data.size() + "/"
                + Unification.countBN(data));

        nbSubst = Unification.selectSubstitutions(data).size();
        logger.info("Found substitutions: " + nbSubst + " after merging");
    }
    data.write(System.out, "TTL");

    Assert.assertEquals(10, data.size());
    Assert.assertEquals(1, Unification.countBN(data));
}

From source file:com.facebook.presto.accumulo.AccumuloClient.java

private static List<AccumuloColumnHandle> getColumnHandles(ConnectorTableMetadata meta, String rowIdColumn) {
    // Get the column mappings from the table property or auto-generate columns if not defined
    Map<String, Pair<String, String>> mapping = AccumuloTableProperties.getColumnMapping(meta.getProperties())
            .orElse(autoGenerateMapping(meta.getColumns(),
                    AccumuloTableProperties.getLocalityGroups(meta.getProperties())));

    // The list of indexed columns
    Optional<List<String>> indexedColumns = AccumuloTableProperties.getIndexColumns(meta.getProperties());

    // And now we parse the configured columns and create handles for the metadata manager
    ImmutableList.Builder<AccumuloColumnHandle> cBuilder = ImmutableList.builder();
    for (int ordinal = 0; ordinal < meta.getColumns().size(); ++ordinal) {
        ColumnMetadata cm = meta.getColumns().get(ordinal);

        // Special case if this column is the row ID
        if (cm.getName().equalsIgnoreCase(rowIdColumn)) {
            cBuilder.add(new AccumuloColumnHandle(rowIdColumn, Optional.empty(), Optional.empty(), cm.getType(),
                    ordinal, "Accumulo row ID", false));
        } else {/*from w w  w  .  ja v  a2s.  co m*/
            if (!mapping.containsKey(cm.getName())) {
                throw new InvalidParameterException(
                        format("Misconfigured mapping for presto column %s", cm.getName()));
            }

            // Get the mapping for this column
            Pair<String, String> famqual = mapping.get(cm.getName());
            boolean indexed = indexedColumns.isPresent()
                    && indexedColumns.get().contains(cm.getName().toLowerCase(Locale.ENGLISH));
            String comment = format("Accumulo column %s:%s. Indexed: %b", famqual.getLeft(), famqual.getRight(),
                    indexed);

            // Create a new AccumuloColumnHandle object
            cBuilder.add(new AccumuloColumnHandle(cm.getName(), Optional.of(famqual.getLeft()),
                    Optional.of(famqual.getRight()), cm.getType(), ordinal, comment, indexed));
        }
    }

    return cBuilder.build();
}

From source file:com.pinterest.terrapin.client.ReplicatedTerrapinClient.java

public Future<TerrapinSingleResponse> getOne(final String fileSet, final ByteBuffer key,
        RequestOptions options) {/*from  ww  w.j av a  2  s . c  om*/
    Pair<TerrapinClient, TerrapinClient> clientPair = getClientTuple(options);
    final TerrapinClient firstClient = clientPair.getLeft();
    final TerrapinClient secondClient = clientPair.getRight();

    // We perform the request on the primary cluster with retries to second replica.
    if (secondClient == null) {
        return firstClient.getOne(fileSet, key);
    }
    return FutureUtil.getSpeculativeFuture(firstClient.getOne(fileSet, key),
            new Function0<Future<TerrapinSingleResponse>>() {
                @Override
                public Future<TerrapinSingleResponse> apply() {
                    return secondClient.getOneNoRetries(fileSet, key);
                }
            }, options.speculativeTimeoutMillis, "terrapin-get-one");
}

From source file:com.pinterest.terrapin.client.ReplicatedTerrapinClient.java

public Future<TerrapinResponse> getMany(final String fileSet, final Set<ByteBuffer> keys,
        RequestOptions options) {/*from w  w w  .  ja v  a 2  s .  c om*/
    Pair<TerrapinClient, TerrapinClient> clientPair = getClientTuple(options);
    final TerrapinClient firstClient = clientPair.getLeft();
    final TerrapinClient secondClient = clientPair.getRight();

    // We perform the request on the primary cluster with retries to second replica.
    if (secondClient == null) {
        return firstClient.getMany(fileSet, keys);
    }
    return FutureUtil.getSpeculativeFuture(firstClient.getMany(fileSet, keys),
            new Function0<Future<TerrapinResponse>>() {
                @Override
                public Future<TerrapinResponse> apply() {
                    return secondClient.getManyNoRetries(fileSet, keys);
                }
            }, options.speculativeTimeoutMillis, "terrapin-get-many");
}

From source file:idc.storyalbum.fetcher.FilterService.java

public Set<Photo> filter(Set<Photo> photos, Set<String> tags)
        throws ExecutionException, InterruptedException, FlickrException {
    log.info("Removing from {} photos photos without tags {}", photos.size(), tags);
    ExecutorService executorService = Executors.newFixedThreadPool(20);
    List<Future<Pair<Photo, Photo>>> futures = new ArrayList<>();
    for (Photo photo : photos) {
        futures.add(executorService.submit(new FilterTagTask(photo, tags)));
    }/*from   w w  w . ja  v a  2 s. co m*/
    executorService.shutdown();
    Set<Photo> result = new HashSet<>();
    for (Future<Pair<Photo, Photo>> future : futures) {
        Pair<Photo, Photo> photoBooleanPair = future.get();
        Photo photo = photoBooleanPair.getLeft();
        String url;
        try {
            url = photo.getOriginalUrl();
        } catch (Exception e) {
            url = photo.getUrl();
        }
        Photo detailedPhoto = photoBooleanPair.getRight();
        if (detailedPhoto == null) {
            log.info("Filtered {}", url);
            photos.remove(photo);
        } else {
            result.add(detailedPhoto);
        }
    }
    return result;

}

From source file:com.newlandframework.avatarmq.core.SendMessageCache.java

public void parallelDispatch(LinkedList<MessageDispatchTask> list) {
    List<Callable<Void>> tasks = new ArrayList<Callable<Void>>();
    int startPosition = 0;
    Pair<Integer, Integer> pair = calculateBlocks(list.size(), list.size());
    int numberOfThreads = pair.getRight();
    int blocks = pair.getLeft();

    for (int i = 0; i < numberOfThreads; i++) {
        MessageDispatchTask[] task = new MessageDispatchTask[blocks];
        phaser.register();/*from   w w  w .  j  a va  2  s  . co  m*/
        System.arraycopy(list.toArray(), startPosition, task, 0, blocks);
        tasks.add(new SendMessageTask(phaser, task));
        startPosition += blocks;
    }

    ExecutorService executor = Executors.newFixedThreadPool(numberOfThreads);
    for (Callable<Void> element : tasks) {
        executor.submit(element);
    }
}

From source file:edu.wpi.checksims.util.threading.SimilarityDetectionWorker.java

/**
 * Construct a Callable to perform pairwise similarity detection for one pair of assignments.
 *
 * @param algorithm Algorithm to use/*from  w  w w  .j  a  v a2  s  .  co  m*/
 * @param submissions Assignments to compare
 */
public SimilarityDetectionWorker(SimilarityDetector algorithm, Pair<Submission, Submission> submissions) {
    checkNotNull(algorithm);
    checkNotNull(submissions);
    checkNotNull(submissions.getLeft());
    checkNotNull(submissions.getRight());

    this.algorithm = algorithm;
    this.submissions = submissions;
}

From source file:mase.deprecated.HybridGroupController.java

public HybridGroupController(Pair<AgentController, List<Integer>>[] controllers) {
    //this.allocations = controllers;
    AgentController[] temp = new AgentController[100];
    int count = 0;
    for (Pair<AgentController, List<Integer>> p : controllers) {
        for (Integer i : p.getRight()) {
            //System.out.println(i);
            temp[i] = p.getLeft().clone();
            count++;//from  w  w  w.j  a v a2 s  . com
        }
    }

    acs = Arrays.copyOf(temp, count);
}