当前位置: 首页>>代码示例>>Java>>正文


Java Tuple2类代码示例

本文整理汇总了Java中org.jooq.lambda.tuple.Tuple2的典型用法代码示例。如果您正苦于以下问题:Java Tuple2类的具体用法?Java Tuple2怎么用?Java Tuple2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Tuple2类属于org.jooq.lambda.tuple包,在下文中一共展示了Tuple2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: selectPipelines

import org.jooq.lambda.tuple.Tuple2; //导入依赖的package包/类
private ImmutableSet<Pipeline> selectPipelines(InterpreterListener interpreterListener,
                                               Set<Tuple2<String, String>> processingBlacklist,
                                               Message message,
                                               Set<String> initialStreamIds,
                                               ImmutableSetMultimap<String, Pipeline> streamConnection) {
    final String msgId = message.getId();

    // if a message-stream combination has already been processed (is in the set), skip that execution
    final Set<String> streamsIds = initialStreamIds.stream()
            .filter(streamId -> !processingBlacklist.contains(tuple(msgId, streamId)))
            .filter(streamConnection::containsKey)
            .collect(Collectors.toSet());
    final ImmutableSet<Pipeline> pipelinesToRun = streamsIds.stream()
            .flatMap(streamId -> streamConnection.get(streamId).stream())
            .collect(ImmutableSet.toImmutableSet());
    interpreterListener.processStreams(message, pipelinesToRun, streamsIds);
    log.debug("[{}] running pipelines {} for streams {}", msgId, pipelinesToRun, streamsIds);
    return pipelinesToRun;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:20,代码来源:PipelineInterpreter.java

示例2: processLine

import org.jooq.lambda.tuple.Tuple2; //导入依赖的package包/类
@Override
public boolean processLine(@Nonnull String line) throws IOException {
    final String[] strings = csvParser.parseLine(line);
    if (strings == null) {
        return false;
    }
    if (firstLine) {
        fieldNames = strings;
        firstLine = false;
        return true;
    }

    final Map<String, Object> fields = Seq.of(fieldNames)
            .zipWithIndex()
            .map(nameAndIndex -> nameAndIndex.map2(index -> strings[Math.toIntExact(index)]))
            .collect(Collectors.toMap(Tuple2::v1, Tuple2::v2));
    fields.put(Message.FIELD_ID, new UUID().toString());
    messages.add(new Message(fields));
    return true;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:21,代码来源:PipelinePerformanceBenchmarks.java

示例3: testGetIdentityToken

import org.jooq.lambda.tuple.Tuple2; //导入依赖的package包/类
@Test
public void testGetIdentityToken() throws Exception {
    EndpointDescription endpoint = new EndpointDescription(
        null, null, null, null, null,
        new UserTokenPolicy[]{
            new UserTokenPolicy(
                "anonymous",
                UserTokenType.Anonymous,
                null, null, null)
        },
        null, null
    );

    AnonymousProvider p = new AnonymousProvider();

    Tuple2<UserIdentityToken, SignatureData> t2 =
        p.getIdentityToken(endpoint, ByteString.NULL_VALUE);

    assertEquals(t2.v1().getPolicyId(), "anonymous");
    assertTrue(t2.v1() instanceof AnonymousIdentityToken);
}
 
开发者ID:eclipse,项目名称:milo,代码行数:22,代码来源:AnonymousProviderTest.java

示例4: testGetIdentityToken_EmptyPolicyId

import org.jooq.lambda.tuple.Tuple2; //导入依赖的package包/类
@Test
public void testGetIdentityToken_EmptyPolicyId() throws Exception {
    EndpointDescription endpoint = new EndpointDescription(
        null, null, null, null, null,
        new UserTokenPolicy[]{
            new UserTokenPolicy(
                "",
                UserTokenType.Anonymous,
                null, null, null)
        },
        null, null
    );

    AnonymousProvider p = new AnonymousProvider();

    Tuple2<UserIdentityToken, SignatureData> t2 =
        p.getIdentityToken(endpoint, ByteString.NULL_VALUE);

    assertEquals(t2.v1().getPolicyId(), "");
    assertTrue(t2.v1() instanceof AnonymousIdentityToken);
}
 
开发者ID:eclipse,项目名称:milo,代码行数:22,代码来源:AnonymousProviderTest.java

示例5: testGetIdentityToken_NullPolicyId

import org.jooq.lambda.tuple.Tuple2; //导入依赖的package包/类
@Test
public void testGetIdentityToken_NullPolicyId() throws Exception {
    EndpointDescription endpoint = new EndpointDescription(
        null, null, null, null, null,
        new UserTokenPolicy[]{
            new UserTokenPolicy(
                null,
                UserTokenType.Anonymous,
                null, null, null)
        },
        null, null
    );

    AnonymousProvider p = new AnonymousProvider();

    Tuple2<UserIdentityToken, SignatureData> t2 =
        p.getIdentityToken(endpoint, ByteString.NULL_VALUE);

    assertNull(t2.v1().getPolicyId());
    assertTrue(t2.v1() instanceof AnonymousIdentityToken);
}
 
开发者ID:eclipse,项目名称:milo,代码行数:22,代码来源:AnonymousProviderTest.java

示例6: invoke

import org.jooq.lambda.tuple.Tuple2; //导入依赖的package包/类
/**
 * GetMonitoredItems is used to get information about monitored items of a subscription.
 *
 * @param subscriptionId identifier of the subscription.
 * @return a {@link Tuple2} containing the output arguments.
 * <p>
 * serverHandles (UInt32[]) - array of serverHandles for all MonitoredItems of the subscription identified by
 * subscriptionId.
 * <p>
 * clientHandles (UInt32[]) - array of clientHandles for all MonitoredItems of the subscription identified by
 * subscriptionId.
 */
public CompletableFuture<Tuple2<UInteger[], UInteger[]>> invoke(UInteger subscriptionId) {
    Variant[] inputArguments = new Variant[]{
        new Variant(subscriptionId)
    };

    return invoke(inputArguments).thenCompose(outputArguments -> {
        try {
            UInteger[] v0 = (UInteger[]) outputArguments[0].getValue();
            UInteger[] v1 = (UInteger[]) outputArguments[1].getValue();

            return CompletableFuture.completedFuture(new Tuple2<>(v0, v1));
        } catch (Throwable t) {
            CompletableFuture<Tuple2<UInteger[], UInteger[]>> f = new CompletableFuture<>();
            f.completeExceptionally(new UaException(t));
            return f;
        }
    });
}
 
开发者ID:eclipse,项目名称:milo,代码行数:31,代码来源:GetMonitoredItems.java

示例7: getIdentityToken

import org.jooq.lambda.tuple.Tuple2; //导入依赖的package包/类
@Override
public Tuple2<UserIdentityToken, SignatureData> getIdentityToken(
    EndpointDescription endpoint,
    ByteString serverNonce) throws Exception {

    List<UserTokenPolicy> userIdentityTokens = l(endpoint.getUserIdentityTokens());

    return userIdentityTokens.stream()
        .filter(t -> t.getTokenType() == UserTokenType.Anonymous)
        .findFirst()
        .map(policy -> {
            UserIdentityToken token = new AnonymousIdentityToken(policy.getPolicyId());

            return new Tuple2<>(token, new SignatureData());
        })
        .orElseThrow(() -> new Exception("no anonymous token policy found"));
}
 
开发者ID:eclipse,项目名称:milo,代码行数:18,代码来源:AnonymousProvider.java

示例8: getIdentityToken

import org.jooq.lambda.tuple.Tuple2; //导入依赖的package包/类
@Override
public Tuple2<UserIdentityToken, SignatureData> getIdentityToken(EndpointDescription endpoint,
                                                                 ByteString serverNonce) throws Exception {

    Iterator<IdentityProvider> iterator = providers.iterator();

    while (iterator.hasNext()) {
        IdentityProvider provider = iterator.next();

        try {
            return provider.getIdentityToken(endpoint, serverNonce);
        } catch (Exception e) {
            if (!iterator.hasNext()) {
                throw e;
            }

            logger.debug("IdentityProvider={} failed, trying next...", provider.toString());
        }
    }

    throw new Exception("no sufficient UserTokenPolicy found");
}
 
开发者ID:eclipse,项目名称:milo,代码行数:23,代码来源:CompositeProvider.java

示例9: bulkInsert

import org.jooq.lambda.tuple.Tuple2; //导入依赖的package包/类
@Override
public Observable<JsonObject> bulkInsert(String type,
    List<Tuple2<String, JsonObject>> documents) {
  String uri = "/" + index + "/" + type + "/_bulk";
  
  // prepare the whole body now because it's much faster to send
  // it at once instead of using HTTP chunked mode.
  StringBuilder body = new StringBuilder();
  for (Tuple2<String, JsonObject> e : documents) {
    String id = e.v1;
    String source = e.v2.encode();
    JsonObject subject = new JsonObject().put("_id", id);
    body.append("{\"index\":" + subject.encode() + "}\n" + source + "\n");
  }
  
  return performRequestRetry(HttpMethod.POST, uri, body.toString());
}
 
开发者ID:georocket,项目名称:georocket,代码行数:18,代码来源:RemoteElasticsearchClient.java

示例10: bulkInsert

import org.jooq.lambda.tuple.Tuple2; //导入依赖的package包/类
/**
 * Test if the client can insert multiple documents in one request
 * @param context the test context
 */
@Test
public void bulkInsert(TestContext context) {
  String url = "/" + INDEX + "/" + TYPE + "/_bulk";
  
  stubFor(post(urlEqualTo(url))
      .willReturn(aResponse()
          .withStatus(200)
          .withBody("{}")));
  
  List<Tuple2<String, JsonObject>> documents = new ArrayList<>();
  documents.add(Tuple.tuple("A", new JsonObject().put("name", "Elvis")));
  documents.add(Tuple.tuple("B", new JsonObject().put("name", "Max")));
  
  Async async = context.async();
  client.bulkInsert(TYPE, documents).subscribe(res -> {
    verify(postRequestedFor(urlEqualTo(url))
        .withRequestBody(equalToJson("{\"index\":{\"_id\":\"A\"}}\n" + 
            "{\"name\":\"Elvis\"}\n" + 
            "{\"index\":{\"_id\":\"B\"}}\n" + 
            "{\"name\":\"Max\"}\n")));
    context.assertEquals(0, res.size());
    async.complete();
  }, context::fail);
}
 
开发者ID:georocket,项目名称:georocket,代码行数:29,代码来源:RemoteElasticsearchClientTest.java

示例11: split

import org.jooq.lambda.tuple.Tuple2; //导入依赖的package包/类
private List<Tuple2<GeoJsonChunkMeta, JsonObject>> split(String file)
    throws IOException {
  byte[] json = IOUtils.toByteArray(GeoJsonSplitterTest.class.getResource(file));
  List<Tuple2<GeoJsonChunkMeta, JsonObject>> chunks = new ArrayList<>();
  StringWindow window = new StringWindow();
  GeoJsonSplitter splitter = new GeoJsonSplitter(window);
  Observable.just(json)
    .map(Buffer::buffer)
    .doOnNext(window::append)
    .lift(new JsonParserOperator())
    .flatMap(splitter::onEventObservable)
    .toBlocking()
    .forEach(result -> {
      JsonObject o = new JsonObject(result.getChunk());
      chunks.add(Tuple.tuple((GeoJsonChunkMeta)result.getMeta(), o));
    });
  return chunks;
}
 
开发者ID:georocket,项目名称:georocket,代码行数:19,代码来源:GeoJsonSplitterTest.java

示例12: feature

import org.jooq.lambda.tuple.Tuple2; //导入依赖的package包/类
/**
 * Test if a Feature can be split correctly
 * @throws IOException if the test file could not be read
 */
@Test
public void feature() throws IOException {
  String filename = "feature.json";
  long size = getFileSize(filename);
  
  List<Tuple2<GeoJsonChunkMeta, JsonObject>> chunks = split(filename);
  assertEquals(1, chunks.size());
  
  Tuple2<GeoJsonChunkMeta, JsonObject> t1 = chunks.get(0);
  
  GeoJsonChunkMeta m1 = t1.v1;
  assertNull(m1.getParentFieldName());
  assertEquals(0, m1.getStart());
  assertEquals(size, m1.getEnd());
  assertEquals("Feature", m1.getType());
  
  JsonObject o1 = t1.v2;
  assertEquals("Feature", o1.getString("type"));
  assertEquals("Fraunhofer IGD", o1.getJsonObject("properties").getString("name"));
}
 
开发者ID:georocket,项目名称:georocket,代码行数:25,代码来源:GeoJsonSplitterTest.java

示例13: lineString

import org.jooq.lambda.tuple.Tuple2; //导入依赖的package包/类
/**
 * Test if a LineString can be split correctly
 * @throws IOException if the test file could not be read
 */
@Test
public void lineString() throws IOException {
  String filename = "linestring.json";
  long size = getFileSize(filename);
  
  List<Tuple2<GeoJsonChunkMeta, JsonObject>> chunks = split(filename);
  assertEquals(1, chunks.size());
  
  Tuple2<GeoJsonChunkMeta, JsonObject> t1 = chunks.get(0);
  
  GeoJsonChunkMeta m1 = t1.v1;
  assertNull(m1.getParentFieldName());
  assertEquals(0, m1.getStart());
  assertEquals(size, m1.getEnd());
  assertEquals("LineString", m1.getType());
  
  JsonObject o1 = t1.v2;
  assertEquals("LineString", o1.getString("type"));
  assertEquals(13, o1.getJsonArray("coordinates").size());
}
 
开发者ID:georocket,项目名称:georocket,代码行数:25,代码来源:GeoJsonSplitterTest.java

示例14: muliLineString

import org.jooq.lambda.tuple.Tuple2; //导入依赖的package包/类
/**
 * Test if a MultiLineString can be split correctly
 * @throws IOException if the test file could not be read
 */
@Test
public void muliLineString() throws IOException {
  String filename = "multilinestring.json";
  long size = getFileSize(filename);
  
  List<Tuple2<GeoJsonChunkMeta, JsonObject>> chunks = split(filename);
  assertEquals(1, chunks.size());
  
  Tuple2<GeoJsonChunkMeta, JsonObject> t1 = chunks.get(0);
  
  GeoJsonChunkMeta m1 = t1.v1;
  assertNull(m1.getParentFieldName());
  assertEquals(0, m1.getStart());
  assertEquals(size, m1.getEnd());
  assertEquals("MultiLineString", m1.getType());
  
  JsonObject o1 = t1.v2;
  assertEquals("MultiLineString", o1.getString("type"));
  assertEquals(3, o1.getJsonArray("coordinates").size());
}
 
开发者ID:georocket,项目名称:georocket,代码行数:25,代码来源:GeoJsonSplitterTest.java

示例15: multiPoint

import org.jooq.lambda.tuple.Tuple2; //导入依赖的package包/类
/**
 * Test if a MultiPoint can be split correctly
 * @throws IOException if the test file could not be read
 */
@Test
public void multiPoint() throws IOException {
  String filename = "multipoint.json";
  long size = getFileSize(filename);
  
  List<Tuple2<GeoJsonChunkMeta, JsonObject>> chunks = split(filename);
  assertEquals(1, chunks.size());
  
  Tuple2<GeoJsonChunkMeta, JsonObject> t1 = chunks.get(0);
  
  GeoJsonChunkMeta m1 = t1.v1;
  assertNull(m1.getParentFieldName());
  assertEquals(0, m1.getStart());
  assertEquals(size, m1.getEnd());
  assertEquals("MultiPoint", m1.getType());
  
  JsonObject o1 = t1.v2;
  assertEquals("MultiPoint", o1.getString("type"));
  assertEquals(2, o1.getJsonArray("coordinates").size());
}
 
开发者ID:georocket,项目名称:georocket,代码行数:25,代码来源:GeoJsonSplitterTest.java


注:本文中的org.jooq.lambda.tuple.Tuple2类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。