类org.apache.commons.lang3.tuple.ImmutablePair源码实例Demo

下面列出了怎么用org.apache.commons.lang3.tuple.ImmutablePair的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: cs-actions   文件: DeployOvfTemplateService.java
public void deployOvfTemplate(final HttpInputs httpInputs, final VmInputs vmInputs, final String templatePath,
                              final Map<String, String> ovfNetworkMap, final Map<String, String> ovfPropertyMap)
        throws Exception {
    final ConnectionResources connectionResources = new ConnectionResources(httpInputs, vmInputs);
    try {
        final ImmutablePair<ManagedObjectReference, OvfCreateImportSpecResult> pair = createLeaseSetup(connectionResources, vmInputs, templatePath, ovfNetworkMap, ovfPropertyMap);
        final ManagedObjectReference httpNfcLease = pair.getLeft();
        final OvfCreateImportSpecResult importSpecResult = pair.getRight();

        final HttpNfcLeaseInfo httpNfcLeaseInfo = getHttpNfcLeaseInfoWhenReady(connectionResources, httpNfcLease);
        final List<HttpNfcLeaseDeviceUrl> deviceUrls = httpNfcLeaseInfo.getDeviceUrl();
        final ProgressUpdater progressUpdater = executor.isParallel() ?
                new AsyncProgressUpdater(getDisksTotalNoBytes(importSpecResult), httpNfcLease, connectionResources) :
                new SyncProgressUpdater(getDisksTotalNoBytes(importSpecResult), httpNfcLease, connectionResources);

        executor.execute(progressUpdater);
        transferVmdkFiles(templatePath, importSpecResult, deviceUrls, progressUpdater);
        executor.shutdown();
    } finally {
        if (httpInputs.isCloseSession()) {
            connectionResources.getConnection().disconnect();
            clearConnectionFromContext(httpInputs.getGlobalSessionObject());
        }
    }
}
 
源代码2 项目: azure-cosmosdb-java   文件: ClientSideMetrics.java
/**
 * Constructor
 *
 * @param retries             The number of retries required to execute the query.
 * @param requestCharge       The request charge incurred from executing the query.
 * @param executionRanges     The fetch execution ranges from executing the query.
 * @param schedulingTimeSpans The partition scheduling timespans from the query.
 */
public ClientSideMetrics(int retries, double requestCharge, List<FetchExecutionRange> executionRanges,
                         List<ImmutablePair<String, SchedulingTimeSpan>> schedulingTimeSpans) {
    if (executionRanges == null || executionRanges.contains(null)) {
        throw new NullPointerException("executionRanges");
    }
    if (schedulingTimeSpans == null || schedulingTimeSpans.contains(null)) {
        throw new NullPointerException("schedulingTimeSpans");
    }
    if (retries < 0) {
        throw new IllegalArgumentException("retries must not be negative");
    }
    if (requestCharge < 0) {
        throw new IllegalArgumentException("requestCharge must not be negative");
    }

    this.retries = retries;
    this.requestCharge = requestCharge;
    this.fetchExecutionRanges = executionRanges;
    this.partitionSchedulingTimeSpans = schedulingTimeSpans;
}
 
private ImmutablePair<Integer, FormattedFilterInfo> GetFiltersForPartitions(
        OrderByContinuationToken orderByContinuationToken,
        List<PartitionKeyRange> partitionKeyRanges,
        List<SortOrder> sortOrders,
        Collection<String> orderByExpressions) throws DocumentClientException {
    // Find the partition key range we left off on
    int startIndex = this.FindTargetRangeAndExtractContinuationTokens(partitionKeyRanges,
            orderByContinuationToken.getCompositeContinuationToken().getRange());

    // Get the filters.
    FormattedFilterInfo formattedFilterInfo = this.GetFormattedFilters(orderByExpressions,
            orderByContinuationToken.getOrderByItems(),
            sortOrders,
            orderByContinuationToken.getInclusive());

    return new ImmutablePair<Integer, FormattedFilterInfo>(startIndex,
            formattedFilterInfo);
}
 
源代码4 项目: symbolicautomata   文件: SlowExample.java
/**
 * allCharsExcept() builds a CharPred predicate that accepts any character
 * except for "excluded".  If "excluded" is null, it returns the TRUE
 * predicate.
 *
 * @param excluded the character to exclude
 * @param returnPred whether or not we should generate a return predicate
 * @return the predicate
 */
private static CharPred allCharsExcept(Character excluded,
                                       boolean returnPred){
  if(excluded == null){
    if(returnPred)
      return(SlowExample.TRUE_RET);
    else
      return(StdCharPred.TRUE);
  }

  // weird stuff to avoid Java errors for increment/decrementing chars
  char prev = excluded; prev--;
  char next = excluded; next++;

  return(new CharPred(ImmutableList.of(ImmutablePair.of(CharPred.MIN_CHAR,
                                                        prev),
                                       ImmutablePair.of(next,
                                                        CharPred.MAX_CHAR)),
                                       returnPred));
}
 
源代码5 项目: product-ei   文件: RedeliveryDelayTestCase.java
/**
 * Validates message content of redelivered messages against original message. Validate that the redelivery delay
 * has occurred.
 *
 * @param receivedMessages        The received message list.
 * @param originalMessageIndex    The index of the origin message in the received message list.
 * @param redeliveredMessageIndex The index of the redelivered message in the received message list.
 * @param expectedMessageContent  The expected message content.
 */
private void validateMessageContentAndDelay(
        List<ImmutablePair<String, Calendar>> receivedMessages,
        int originalMessageIndex,
        int redeliveredMessageIndex,
        String expectedMessageContent) {
    // Validate message content
    String messageContent = receivedMessages.get(redeliveredMessageIndex).getLeft();
    Assert.assertEquals(messageContent, expectedMessageContent, "Invalid messages received.");

    // Validate delay
    Calendar originalMessageCalendar = receivedMessages.get(originalMessageIndex).getRight();
    log.info("Original message timestamp for " + messageContent + " : " +
             originalMessageCalendar.getTimeInMillis());
    originalMessageCalendar.add(Calendar.SECOND, 10);
    log.info("Minimum redelivered timestamp for " + messageContent + " : " +
             originalMessageCalendar.getTimeInMillis());
    Calendar redeliveredMessageCalendar = receivedMessages.get(redeliveredMessageIndex).getRight();
    log.info("Timestamp of redelivered for " + messageContent + " message : " +
             redeliveredMessageCalendar.getTimeInMillis());
    Assert.assertTrue(originalMessageCalendar.compareTo(redeliveredMessageCalendar) <= 0,
            "Message received before the redelivery delay");
}
 
public static void SetExpectedMap(String fieldName, String[] expectedResults, String[] expectedReversResults,
                Multimap<String,NormalizedContentInterface> fields, Multimap<String,NormalizedContentInterface> index,
                Multimap<String,NormalizedContentInterface> reverse, Multimap<String,Pair<String,Integer>> tfValues) {
    NormalizedContentInterface template = new NormalizedFieldAndValue();
    template.setFieldName(fieldName);
    
    for (int i = 0; i < expectedResults.length; i++) {
        template.setIndexedFieldValue(expectedResults[i]);
        template.setEventFieldValue(null);
        fields.put(fieldName, new NormalizedFieldAndValue(template));
        index.put(fieldName, new NormalizedFieldAndValue(template));
        
        template.setIndexedFieldValue(expectedReversResults[i]);
        template.setEventFieldValue(expectedReversResults[i]);
        reverse.put(fieldName, new NormalizedFieldAndValue(template));
        
        tfValues.put(fieldName, new ImmutablePair<>(expectedResults[i], i));
    }
}
 
源代码7 项目: sqlg   文件: EdgeLabel.java
public void ensurePropertiesExist(Map<String, PropertyType> columns) {
    for (Map.Entry<String, PropertyType> column : columns.entrySet()) {
        if (!this.properties.containsKey(column.getKey())) {
            Preconditions.checkState(!this.getSchema().isSqlgSchema(), "schema may not be %s", SQLG_SCHEMA);
            this.sqlgGraph.getSqlDialect().validateColumnName(column.getKey());
            if (!this.uncommittedProperties.containsKey(column.getKey())) {
                this.getSchema().getTopology().lock();
                if (!getProperty(column.getKey()).isPresent()) {
                    TopologyManager.addEdgeColumn(this.sqlgGraph, this.getSchema().getName(), EDGE_PREFIX + getLabel(), column, new ListOrderedSet<>());
                    addColumn(this.getSchema().getName(), EDGE_PREFIX + getLabel(), ImmutablePair.of(column.getKey(), column.getValue()));
                    PropertyColumn propertyColumn = new PropertyColumn(this, column.getKey(), column.getValue());
                    propertyColumn.setCommitted(false);
                    this.uncommittedProperties.put(column.getKey(), propertyColumn);
                    this.getSchema().getTopology().fire(propertyColumn, "", TopologyChangeAction.CREATE);
                }
            }
        }
    }
}
 
源代码8 项目: yauaa   文件: Splitter.java
public List<Pair<Integer, Integer>> createSplitList(char[] characters){
    List<Pair<Integer, Integer>> result = new ArrayList<>(8);

    int offset = findSplitStart(characters, 1);
    if (offset == -1) {
        return result; // Nothing at all. So we are already done
    }
    while(offset != -1) {

        int start = offset;
        int end= findSplitEnd(characters, start);

        result.add(new ImmutablePair<>(start, end));
        offset = findNextSplitStart(characters, end);
    }
    return result;
}
 
源代码9 项目: gatk   文件: SomaticClusteringModel.java
public List<Pair<String, String>> clusteringMetadata() {
    final List<Pair<String, String>> result = new ArrayList<>();
    IntStream.range(-MAX_INDEL_SIZE_IN_PRIOR_MAP, MAX_INDEL_SIZE_IN_PRIOR_MAP + 1).forEach(n -> {
        final double logPrior = logVariantPriors.get(n);
        final String type = n == 0 ? "SNV" :
                (n < 0 ? "deletion" : "insertion") + " of length " + Math.abs(n);
        result.add(ImmutablePair.of("Ln prior of " + type, Double.toString(logPrior)));
    });

    result.add(ImmutablePair.of("Background beta-binomial cluster",
            String.format("weight = %.4f, %s", Math.exp(logClusterWeights[0]), clusters.get(0).toString())));
    result.add(ImmutablePair.of("High-AF beta-binomial cluster",
            String.format("weight = %.4f, %s", Math.exp(logClusterWeights[1]), clusters.get(1).toString())));

    IntStream.range(2, clusters.size()).boxed()
            .sorted(Comparator.comparingDouble(c -> -logClusterWeights[c]))
            .forEach(c -> result.add(ImmutablePair.of("Binomial cluster",
                    String.format("weight = %.4f, %s", Math.exp(logClusterWeights[c]), clusters.get(c).toString()))));
    return result;
}
 
源代码10 项目: ghidra   文件: WithBlockTest.java
protected Pair<DisjointPattern, Constructor> findConstructor(String table, String firstPrint) {
	AtomicReference<DisjointPattern> fpat = new AtomicReference<>(null);
	AtomicReference<Constructor> fcon = new AtomicReference<>(null);
	SleighLanguages.traverseConstructors(lang, new ConstructorEntryVisitor() {
		@Override
		public int visit(SubtableSymbol subtable, DisjointPattern pattern, Constructor cons) {
			if (table.equals(subtable.getName()) &&
				firstPrint.equals(cons.getPrintPieces().get(0))) {
				if (null != fpat.get()) {
					throw new AssertionError("Multiple constructors found. " +
						"Write the test slaspec such that no two constructors in the same " +
						"table share the same first printpiece.");
				}
				fpat.set(pattern);
				fcon.set(cons);
			}
			return CONTINUE;
		}
	});
	if (null == fpat.get()) {
		throw new AssertionError(
			"No such constructor found: " + table + ":" + firstPrint + "...");
	}
	return new ImmutablePair<>(fpat.get(), fcon.get());
}
 
源代码11 项目: arcusplatform   文件: AlexaPlatformService.java
public ListenableFuture<PlatformMessage> request(PlatformMessage msg, Predicate<PlatformMessage> matcher, int timeoutSecs) {
   if(timeoutSecs < 0) {
      timeoutSecs = defaultTimeoutSecs;
   }

   final Address addr = msg.getDestination();
   final SettableFuture<PlatformMessage> future = SettableFuture.create();
   future.addListener(() -> { futures.remove(addr); }, workerPool);

   Predicate<PlatformMessage> pred = (pm) -> { return Objects.equals(msg.getCorrelationId(), pm.getCorrelationId()) && msg.isError(); };
   pred = matcher.or(pred);

   Pair<Predicate<PlatformMessage>, SettableFuture<PlatformMessage>> pair = new ImmutablePair<>(matcher, future);
   futures.put(addr, pair);
   bus.send(msg);
   timeoutPool.newTimeout((timer) -> {
      if(!future.isDone()) {
         future.setException(new TimeoutException("future timed out"));
      }
   }, timeoutSecs, TimeUnit.SECONDS);
   return future;
}
 
源代码12 项目: bullet-core   文件: QueryManagerTest.java
@Test
public void testCategorizingAll() {
    QueryManager manager = new QueryManager(new BulletConfig());
    Query queryA = getQuery(ImmutablePair.of("A", "foo"));
    Query queryB = getQuery(ImmutablePair.of("A", "foo"), ImmutablePair.of("B", "bar"));
    Querier querierA = getQuerier(queryA);
    Querier querierB = getQuerier(queryB);
    manager.addQuery("idA", querierA);
    manager.addQuery("idB", querierB);

    QueryCategorizer categorizer = manager.categorize();
    Assert.assertEquals(categorizer.getDone().size(), 0);
    Assert.assertEquals(categorizer.getClosed().size(), 0);
    Assert.assertEquals(categorizer.getRateLimited().size(), 0);
    verify(querierA, times(1)).isDone();
    verify(querierA, times(1)).isClosed();
    verify(querierA, times(1)).isExceedingRateLimit();
    verify(querierB, times(1)).isDone();
    verify(querierB, times(1)).isClosed();
    verify(querierB, times(1)).isExceedingRateLimit();
}
 
private Genotype buildAndAnnotateTruthOverlappingGenotype(final String sample, final VariantContext truth, final List<VariantContext> calls,
                                                          final TargetCollection<Target> targets) {
    final Genotype truthGenotype = truth.getGenotype(sample);
    // if there is no truth genotype for that sample, we output the "empty" genotype.
    if (truthGenotype == null) {
        return GenotypeBuilder.create(sample, Collections.emptyList());
    }
    final int truthCopyNumber = GATKProtectedVariantContextUtils.getAttributeAsInt(truthGenotype,
            GS_COPY_NUMBER_FORMAT_KEY, truthNeutralCopyNumber);
    final CopyNumberTriStateAllele truthAllele = copyNumberToTrueAllele(truthCopyNumber);

    final List<Pair<VariantContext, Genotype>> allCalls = calls.stream()
            .map(vc -> new ImmutablePair<>(vc, vc.getGenotype(sample)))
            .filter(pair -> pair.getRight() != null)
            .filter(pair -> GATKProtectedVariantContextUtils.getAttributeAsString(pair.getRight(), XHMMSegmentGenotyper.DISCOVERY_KEY,
                    XHMMSegmentGenotyper.DISCOVERY_FALSE).equals(XHMMSegmentGenotyper.DISCOVERY_TRUE))
            .collect(Collectors.toList());

    final List<Pair<VariantContext, Genotype>> qualifiedCalls = composeQualifyingCallsList(targets, allCalls);

    return buildAndAnnotateTruthOverlappingGenotype(sample, targets, truthGenotype, truthCopyNumber,
                truthAllele, qualifiedCalls);
}
 
源代码14 项目: angelix   文件: Cardinality.java
private static Pair<List<Node>, List<? extends Variable>> makeSortingNetwork(List<? extends Variable> bits) {
    int n = bits.size();
    if (n == 1) {
        return new ImmutablePair<>(new ArrayList<>(), bits);
    }
    if (n == 2) {
        return twoComp(bits.get(0), bits.get(1));
    }
    List<Node> algorithm = new ArrayList<>();
    List<Variable> sorted = new ArrayList<>();

    int l = n/2;
    List<? extends Variable> left = bits.subList(0, l);
    List<? extends Variable> right = bits.subList(l, n);
    Pair<List<Node>, List<? extends Variable>> leftNetwork = makeSortingNetwork(left);
    Pair<List<Node>, List<? extends Variable>> rightNetwork = makeSortingNetwork(right);
    algorithm.addAll(leftNetwork.getLeft());
    algorithm.addAll(rightNetwork.getLeft());
    Pair<List<Node>, List<? extends Variable>> mergeResult = merge(leftNetwork.getRight(), rightNetwork.getRight());
    algorithm.addAll(mergeResult.getLeft());
    sorted.addAll(mergeResult.getRight());

    return new ImmutablePair<>(algorithm, sorted);
}
 
源代码15 项目: HubTurbo   文件: UpdateService.java
/**
 * Gets a list of ETags for all pages returned from an API request and
 * also return the connection used to get the ETags so that their last check time
 * can be recorded elsewhere
 *
 * @param request
 * @param client
 * @return a Optional list of ETags for all pages returned from an API request and
 * corresponding HTTP connection or an empty Optional if an error occurs
 */
private Optional<ImmutablePair<List<String>, HttpURLConnection>> getPagedEtags(
        GitHubRequest request, GitHubClientEx client) {

    PageHeaderIterator iter = new PageHeaderIterator(request, client, "ETag");
    List<String> etags = new ArrayList<>();
    HttpURLConnection connection = null;

    while (iter.hasNext()) {
        try {
            etags.add(Utility.stripQuotes(iter.next()));
            if (connection == null) {
                connection = iter.getLastConnection();
            }
        } catch (NoSuchPageException e) {
            logger.error("No such page exception at " + iter.getRequest().generateUri());
            return Optional.empty();
        }
    }

    return Optional.of(new ImmutablePair<>(etags, connection));
}
 
源代码16 项目: aion   文件: InFlightConfigReceiverTest.java
@Test(expected = RollbackException.class)
public void testApplyNewConfigUnsuccessfulApplierThenRollbackUnsuccessful() throws Exception {
    TestApplier cannotRollbackApplier =
            new TestApplier(TestApplier.Behaviour.THROW_ON_UNDO_ONLY);

    registryMap.put(
            "good.key",
            ImmutablePair.of(cfg -> cfg.getId(), Optional.of(cannotRollbackApplier)));
    registryMap.put(
            "bad.key", ImmutablePair.of(cfg -> cfg.getId(), Optional.of(failingApplier)));
    when(oldCfg.getId()).thenReturn("old");
    when(newCfg.getId()).thenReturn("new");

    InFlightConfigReceiver unit = new InFlightConfigReceiver(oldCfg, registry);
    unit.applyNewConfig(newCfg);
}
 
源代码17 项目: find   文件: TopicMapView.java
private List<ImmutablePair<WebElement, Integer>> childConcepts(final int clusterIndex) {
    //((lowestX,highestX),(lowestY,highestY))
    final Double[][] boundariesOfChosenCluster = nthConceptCluster(clusterIndex).getBoundaries();

    final Point mapCoordinates = map().getLocation();
    //L:Concept; Y:Index
    final List<ImmutablePair<WebElement, Integer>> childConceptsOfChosenCluster = new ArrayList<>();

    int entityIndex = 0;
    for(final WebElement concepts : concepts()) {
        final Dimension entitySize = concepts.getSize();
        final Point absolutePosition = concepts.getLocation();

        final int centreX = absolutePosition.x - mapCoordinates.x + entitySize.getWidth() / 2;
        final int centreY = absolutePosition.y - mapCoordinates.y + entitySize.getHeight() / 2;
        final Point centre = new Point(centreX, centreY);

        if(boundariesOfChosenCluster[0][0] <= centre.x && centre.x <= boundariesOfChosenCluster[0][1]
            && boundariesOfChosenCluster[1][0] <= centre.y && centre.y <= boundariesOfChosenCluster[1][1]) {
            childConceptsOfChosenCluster.add(new ImmutablePair<>(concepts, entityIndex));
        }

        entityIndex++;
    }
    return childConceptsOfChosenCluster;
}
 
private void testManyEquationsInstance(final int numEquations) throws InterruptedException {
    final Function<Map<Integer, Double>, Map<Integer, Double>> func = arg ->
            arg.entrySet().stream()
                    .map(entry -> {
                        final int index = entry.getKey();
                        final double x = entry.getValue();
                        return ImmutablePair.of(index, FastMath.pow(x, index) - index);
                    }).collect(Collectors.toMap(p -> p.left, p -> p.right));
    final SynchronizedUnivariateSolver solver = new SynchronizedUnivariateSolver(func, SOLVER_FACTORY, numEquations);
    for (int n = 1; n <= numEquations; n++) {
        solver.add(n, 0, 2, 0.5, 1e-7, 1e-7, 100);
    }
    final Map<Integer, SynchronizedUnivariateSolver.UnivariateSolverSummary> sol = solver.solve();
    for (int n = 1; n <= numEquations; n++) {
        Assert.assertEquals(sol.get(n).x, FastMath.pow(n, 1.0/n), 1e-6);
    }
}
 
源代码19 项目: product-ei   文件: RedeliveryDelayTestCase.java
/**
 * Gets the received messages to a list.
 *
 * @param receivedMessages The list of received messages as a pair of message content and time received.
 * @return A list of message content.
 */
private List<String> getMessageList(List<ImmutablePair<String, Calendar>> receivedMessages) {
    List<String> messages = new ArrayList<>();
    for (ImmutablePair<String, Calendar> receivedMessage : receivedMessages) {
        messages.add(receivedMessage.getLeft());
    }
    return messages;
}
 
源代码20 项目: rapidminer-studio   文件: ExampleSetHdf5Writer.java
/**
 * Write example set or metadata file from {@link ExampleSet} as a source
 */
private void writeFromExampleSet(Path path, boolean writeStatistics) throws IOException {
	Attributes attributes = exampleSet.getAttributes();
	int allAttributeCount = attributes.allSize();
	int rowCount = exampleSet.size();
	boolean isMetaData = isNullDataSpace();
	Iterator<AttributeRole> iterator = attributes.allAttributeRoles();
	boolean wasShortened = false;
	if (shortenMD) {
		int maxAtt = ExampleSetMetaData.getMaximumNumberOfAttributes();
		if (maxAtt < allAttributeCount) {
			wasShortened = true;
			allAttributeCount = maxAtt;
		}
	}
	ColumnInfo[] columnInfos = new ColumnInfo[allAttributeCount];
	for (int i = 0; i < columnInfos.length; i++) {
		AttributeRole next = iterator.next();
		columnInfos[i] = ColumnInfoCreator.create(next, writeStatistics ? exampleSet : null, isMetaData && shortenMD);
		if (!isMetaData) {
			columnInfos[i].getAdditionalAttributes().remove(ATTRIBUTE_SET_RELATION);
		}
	}
	Map<String, Pair<Class<?>, Object>> additionalRootAttributes = new LinkedHashMap<>();
	additionalRootAttributes.put(ATTRIBUTE_HAS_STATISTICS, new ImmutablePair<>(byte.class, writeStatistics ? (byte) 1 : (byte) 0));
	if (isMetaData) {
		additionalRootAttributes.put(ATTRIBUTE_IS_METADATA, new ImmutablePair<>(byte.class, (byte) 1));
		additionalRootAttributes.put(ATTRIBUTE_SET_RELATION, new ImmutablePair<>(String.class,
				(wasShortened ? SetRelation.SUPERSET : SetRelation.EQUAL).toString()));
		additionalRootAttributes.put(ATTRIBUTE_ROW_RELATION, new ImmutablePair<>(String.class, Relation.EQUAL.getRepresentation()));
	}
	write(columnInfos, exampleSet.getAnnotations(), rowCount, additionalRootAttributes, path);
}
 
源代码21 项目: api-layer   文件: AbstractApiDocServiceTest.java
@Test
public void shouldGetEndpointPairs() {
    RoutedService routedService = new RoutedService("api_v1", "api/v1", "/apicatalog/api/v1");
    Pair endpointPairs = abstractApiDocService.getEndPointPairs("/apicatalog", "apicatalog", routedService);
    ImmutablePair expectedPairs = new ImmutablePair("/apicatalog", "/api/v1/apicatalog/apicatalog");
    assertEquals(expectedPairs, endpointPairs);
}
 
源代码22 项目: terrapin   文件: TerrapinUtil.java
static public List<Pair<Path, Long>> getS3FileList(AWSCredentials credentials,
    String s3Bucket, String s3KeyPrefix) {
  List<Pair<Path, Long>> fileSizePairList = Lists.newArrayListWithCapacity(
      Constants.MAX_ALLOWED_SHARDS);
  AmazonS3Client s3Client = new AmazonS3Client(credentials);
  // List files and build the path using the s3n: prefix.
  // Note that keys > marker are retrieved where the > is by lexicographic order.
  String prefix = s3KeyPrefix;
  String marker = prefix;
  while (true) {
    boolean reachedEnd = false;
    ObjectListing listing = s3Client.listObjects(new ListObjectsRequest().
        withBucketName(s3Bucket).
        withMarker(marker));
    List<S3ObjectSummary> summaries = listing.getObjectSummaries();

    if (summaries.isEmpty()) {
      break;
    }

    for (S3ObjectSummary summary: summaries) {
      if (summary.getKey().startsWith(prefix)) {
        fileSizePairList.add(new ImmutablePair(new Path("s3n", s3Bucket, "/" + summary.getKey()),
            summary.getSize()));
        if (fileSizePairList.size() > Constants.MAX_ALLOWED_SHARDS) {
          throw new RuntimeException("Too many files " + fileSizePairList.size());
        }
      } else {
        // We found a key which does not match the prefix, stop.
        reachedEnd = true;
        break;
      }
    }
    if (reachedEnd) {
      break;
    }
    marker = summaries.get(summaries.size() - 1).getKey();
  }
  return fileSizePairList;
}
 
源代码23 项目: p3-batchrefine   文件: SynchronousTransformer.java
@Override
public Entity transform(HttpRequestEntity entity) throws IOException {
    logMessage(entity.getRequest());

    final HttpRequestEntity request = cast(entity);

    final ImmutablePair<MimeType, Properties> options = exporterOptions(request);
    options.right.putAll(transformerConfig);
    final File input = downloadInput(entity);
    final File output = File.createTempFile("reply", "tmp");

    final ITransformEngine engine = getEngine();

    return new WritingEntity() {
        @Override
        public void writeData(OutputStream out) throws IOException {
            try {
                // Can't allow more than one transform at a time as OpenRefine is not
                // designed for that.
                synchronized (SynchronousTransformer.this) {
                    engine.transform(input.toURI(), fetchTransform(request), output.toURI(),
                            options.right);
                }

                try (FileInputStream stream = new FileInputStream(output)) {
                    IOUtils.copy(stream, out);
                }
            } finally {
                input.delete();
                output.delete();
            }
        }

        @Override
        public MimeType getType() {
            return options.left;
        }
    };
}
 
源代码24 项目: gatk-protected   文件: JointAFCRSegmenter.java
private static JointAFCRSegmenter createJointSegmenter(final CopyRatioSegmenter copyRatioSegmenter, final AlleleFractionSegmenter alleleFractionSegmenter) {
    List<IntervalDatumIndex> positionsWithData = collateTargetAndHetData(copyRatioSegmenter, alleleFractionSegmenter);
    final List<SimpleInterval> allPositions = positionsWithData.stream().map(IntervalDatumIndex::getInterval).collect(Collectors.toList());
    final List<JointSegmentationDatum> allData = positionsWithData.stream().map(IntervalDatumIndex::getDatum).collect(Collectors.toList());

    final List<ImmutablePair<Integer, Integer>> neighboringTargetHetIndices =
            getConsecutiveIndicesWhereOneIsTargetAndOneIsHet(positionsWithData, allData);

    final double[][] cooccurrence = calculateOverlapMatrixOfCRAndAFHiddenStates(copyRatioSegmenter, alleleFractionSegmenter, neighboringTargetHetIndices);

    final int numCopyRatioStates = copyRatioSegmenter.numStates();
    final int numAlleleFractionStates = alleleFractionSegmenter.numStates();
    final List<ImmutablePair<AFCRHiddenState, Double>> jointStatesAndWeights = new ArrayList<>();
    for (int i = 0; i < numCopyRatioStates; i++) {
        for (int j = 0; j < numAlleleFractionStates; j++) {
            jointStatesAndWeights.add(new ImmutablePair<>(
                    new AFCRHiddenState(alleleFractionSegmenter.getState(j), copyRatioSegmenter.getState(i)), cooccurrence[i][j]));
        }
    }

    // descending order by cooccurrence score
    Collections.sort(jointStatesAndWeights, (jsaw1, jsaw2) -> Doubles.compare(jsaw2.getRight(), jsaw1.getRight()));
    final List<ImmutablePair<AFCRHiddenState, Double>> bestJointStatesAndWeights =
            jointStatesAndWeights.subList(0, Math.min(MAX_NUM_STATES, jointStatesAndWeights.size()));
    final List<AFCRHiddenState> hiddenStates = bestJointStatesAndWeights.stream()
            .map(jsaw -> jsaw.getLeft()).collect(Collectors.toList());
    final double[] unnormalizedWeights = bestJointStatesAndWeights.stream()
            .mapToDouble(jsaw -> jsaw.getRight()).toArray();
    final List<Double> weights = Doubles.asList(MathUtils.normalizeFromRealSpace(unnormalizedWeights));
    final double concentration = geometricMean(copyRatioSegmenter.getConcentration(), alleleFractionSegmenter.getConcentration());
    final double memoryLength = geometricMean(copyRatioSegmenter.getMemoryLength(), alleleFractionSegmenter.getMemoryLength());
    return new JointAFCRSegmenter(allPositions, allData, hiddenStates, weights, concentration, memoryLength,
            alleleFractionSegmenter.getGlobalParameters(), alleleFractionSegmenter.getAllelicPoN(), copyRatioSegmenter.getLogCoverageCauchyWidth());
}
 
源代码25 项目: james-project   文件: ImapRequestLineReader.java
/**
 * @return the literal data and its expected size
 */
public ImmutablePair<Integer, InputStream> consumeLiteral(boolean extraCRLF) throws DecodingException {
    // The 1st character must be '{'
    consumeChar('{');

    StringBuilder digits = new StringBuilder();
    char next = nextChar();
    while (next != '}' && next != '+') {
        digits.append(next);
        consume();
        next = nextChar();
    }

    // If the number is *not* suffixed with a '+', we *are* using a
    // synchronized literal, and we need to send command continuation
    // request before reading data.
    boolean synchronizedLiteral = true;
    // '+' indicates a non-synchronized literal (no command continuation
    // request)
    if (next == '+') {
        synchronizedLiteral = false;
        consumeChar('+');
    }

    // Consume the '}' and the newline
    consumeChar('}');
    consumeCRLF();

    if (synchronizedLiteral) {
        commandContinuationRequest();
    }

    int size = Integer.parseInt(digits.toString());
    return ImmutablePair.of(size, read(size, extraCRLF));
}
 
源代码26 项目: hadoop-ozone   文件: DummyReconDBTask.java
@Override
public Pair<String, Boolean> reprocess(OMMetadataManager omMetadataManager) {
  if (++callCtr <= numFailuresAllowed) {
    return new ImmutablePair<>(getTaskName(), false);
  } else {
    return new ImmutablePair<>(getTaskName(), true);
  }
}
 
源代码27 项目: Asqatasun   文件: Rgaa32016Rule010602.java
/**
 * Default constructor
 */
public Rgaa32016Rule010602 () {
    super(
            new ImageElementSelector(OBJECT_TYPE_IMG_NOT_IN_LINK_CSS_LIKE_QUERY),

            // the informative images are part of the scope
            INFORMATIVE_IMAGE_MARKER, 

            // the decorative images are not part of the scope
            DECORATIVE_IMAGE_MARKER, 

            // checker for elements identified by marker
            new ElementPresenceChecker(
                // solution when at least one element is found
                new ImmutablePair(TestSolution.NEED_MORE_INFO,CHECK_DETAILED_DESC_DEFINITION_OF_INFORMATIVE_IMG_MSG),
                // solution when no element is found
                new ImmutablePair(TestSolution.NOT_APPLICABLE,""), 
                // evidence elements
                TEXT_ELEMENT2,
                DATA_ATTR), 
            
            // checker for elements not identified by marker
            new ElementPresenceChecker(
                // solution when at least one element is found
                new ImmutablePair(TestSolution.NEED_MORE_INFO,CHECK_NATURE_OF_IMAGE_AND_DETAILED_DESC_AVAILABILITY_MSG),
                // solution when no element is found
                new ImmutablePair(TestSolution.NOT_APPLICABLE,""), 
                // evidence elements
                TEXT_ELEMENT2,
                DATA_ATTR)
        );
}
 
@Test
public void testSchemaCreated() throws Exception {

  Connection connection = getConnection();
  // Verify table definition
  DatabaseMetaData metaData = connection.getMetaData();
  ResultSet resultSet = metaData.getColumns(null, null,
      RECON_TASK_STATUS_TABLE_NAME, null);

  List<Pair<String, Integer>> expectedPairs = new ArrayList<>();

  expectedPairs.add(new ImmutablePair<>("task_name", Types.VARCHAR));
  expectedPairs.add(new ImmutablePair<>("last_updated_timestamp",
      Types.BIGINT));
  expectedPairs.add(new ImmutablePair<>("last_updated_seq_number",
      Types.BIGINT));

  List<Pair<String, Integer>> actualPairs = new ArrayList<>();

  while (resultSet.next()) {
    actualPairs.add(new ImmutablePair<>(
        resultSet.getString("COLUMN_NAME"),
        resultSet.getInt("DATA_TYPE")));
  }

  Assert.assertEquals(3, actualPairs.size());
  Assert.assertEquals(expectedPairs, actualPairs);
}
 
源代码29 项目: Asqatasun   文件: Rgaa32016Rule050701.java
/**
 * Default constructor
 */
public Rgaa32016Rule050701 () {
    super(
            new SimpleElementSelector(TABLE_WITH_TH_CSS_LIKE_QUERY),

            // the data and complex tables are part of the scope
            new String[]{DATA_TABLE_MARKER, COMPLEX_TABLE_MARKER},

            // the presentation tables are not part of the scope
            new String[]{PRESENTATION_TABLE_MARKER},

            // checker for elements identified by marker
            new ElementPresenceChecker(
                // nmi when element is found
                new ImmutablePair(TestSolution.NEED_MORE_INFO, CHECK_DEFINITION_OF_HEADERS_FOR_DATA_TABLE_MSG),
                // na when element is not found
                new ImmutablePair(TestSolution.NOT_APPLICABLE, "")
            ), 
            
            // checker for elements not identified by marker
            new ElementPresenceChecker(
                // nmi when element is found
                new ImmutablePair(TestSolution.NEED_MORE_INFO, CHECK_NATURE_OF_TABLE_AND_HEADERS_DEFINITION_MSG),
                // na when element is not found
                new ImmutablePair(TestSolution.NOT_APPLICABLE, "")
            )
        );
}
 
源代码30 项目: attic-apex-malhar   文件: GenericSerde.java
@SuppressWarnings({ "unchecked", "rawtypes" })
public void registerDefaultSerdes()
{
  registerSerde(String.class, new StringSerde());
  registerSerde(Long.class, new LongSerde());
  registerSerde(Integer.class, new IntSerde());
  registerSerde(ImmutablePair.class, new ImmutablePairSerde());
  registerSerde(Window.TimeWindow.class, new TimeWindowSerde());
}
 
 类所在包
 同包方法