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


Java ResultSet.all方法代码示例

本文整理汇总了Java中org.apache.tinkerpop.gremlin.driver.ResultSet.all方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.all方法的具体用法?Java ResultSet.all怎么用?Java ResultSet.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.tinkerpop.gremlin.driver.ResultSet的用法示例。


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

示例1: shouldProcessRequestsOutOfOrder

import org.apache.tinkerpop.gremlin.driver.ResultSet; //导入方法依赖的package包/类
@Test
public void shouldProcessRequestsOutOfOrder() throws Exception {
    final Cluster cluster = Cluster.open();
    final Client client = cluster.connect();

    final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
    final ResultSet rsZero = client.submit("'zero'");

    final CompletableFuture<List<Result>> futureFive = rsFive.all();
    final CompletableFuture<List<Result>> futureZero = rsZero.all();

    final long start = System.nanoTime();
    assertFalse(futureFive.isDone());
    assertEquals("zero", futureZero.get().get(0).getString());

    logger.info("Eval of 'zero' complete: " + TimeUtil.millisSince(start));

    assertFalse(futureFive.isDone());
    assertEquals("five", futureFive.get(10, TimeUnit.SECONDS).get(0).getString());

    logger.info("Eval of 'five' complete: " + TimeUtil.millisSince(start));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:23,代码来源:GremlinDriverIntegrateTest.java

示例2: shouldProcessSessionRequestsInOrder

import org.apache.tinkerpop.gremlin.driver.ResultSet; //导入方法依赖的package包/类
@Test
public void shouldProcessSessionRequestsInOrder() throws Exception {
    final Cluster cluster = Cluster.open();
    final Client client = cluster.connect(name.getMethodName());

    final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
    final ResultSet rsZero = client.submit("'zero'");

    final CompletableFuture<List<Result>> futureFive = rsFive.all();
    final CompletableFuture<List<Result>> futureZero = rsZero.all();

    final AtomicBoolean hit = new AtomicBoolean(false);
    while (!futureFive.isDone()) {
        // futureZero can't finish before futureFive - racy business here?
        assertThat(futureZero.isDone(), is(false));
        hit.set(true);
    }

    // should have entered the loop at least once and thus proven that futureZero didn't return ahead of
    // futureFive
    assertThat(hit.get(), is(true));

    assertEquals("zero", futureZero.get().get(0).getString());
    assertEquals("five", futureFive.get(10, TimeUnit.SECONDS).get(0).getString());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:26,代码来源:GremlinDriverIntegrateTest.java

示例3: shouldProcessRequestsOutOfOrder

import org.apache.tinkerpop.gremlin.driver.ResultSet; //导入方法依赖的package包/类
@Test
public void shouldProcessRequestsOutOfOrder() throws Exception {
    final Cluster cluster = TestClientFactory.open();
    final Client client = cluster.connect();

    final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
    final ResultSet rsZero = client.submit("'zero'");

    final CompletableFuture<List<Result>> futureFive = rsFive.all();
    final CompletableFuture<List<Result>> futureZero = rsZero.all();

    final long start = System.nanoTime();
    assertFalse(futureFive.isDone());
    assertEquals("zero", futureZero.get().get(0).getString());

    logger.info("Eval of 'zero' complete: " + TimeUtil.millisSince(start));

    assertFalse(futureFive.isDone());
    assertEquals("five", futureFive.get(10, TimeUnit.SECONDS).get(0).getString());

    logger.info("Eval of 'five' complete: " + TimeUtil.millisSince(start));
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:23,代码来源:GremlinDriverIntegrateTest.java

示例4: shouldProcessSessionRequestsInOrder

import org.apache.tinkerpop.gremlin.driver.ResultSet; //导入方法依赖的package包/类
@Test
public void shouldProcessSessionRequestsInOrder() throws Exception {
    final Cluster cluster = TestClientFactory.open();
    final Client client = cluster.connect(name.getMethodName());

    final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
    final ResultSet rsZero = client.submit("'zero'");

    final CompletableFuture<List<Result>> futureFive = rsFive.all();
    final CompletableFuture<List<Result>> futureZero = rsZero.all();

    final CountDownLatch latch = new CountDownLatch(2);
    final List<String> order = new ArrayList<>();
    final ExecutorService executor = Executors.newSingleThreadExecutor();

    futureFive.thenAcceptAsync(r -> {
        order.add(r.get(0).getString());
        latch.countDown();
    }, executor);

    futureZero.thenAcceptAsync(r -> {
        order.add(r.get(0).getString());
        latch.countDown();
    }, executor);

    // wait for both results
    latch.await(30000, TimeUnit.MILLISECONDS);

    // should be two results
    assertEquals(2, order.size());

    // ensure that "five" is first then "zero"
    assertThat(order, contains("five", "zero"));
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:35,代码来源:GremlinDriverIntegrateTest.java


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