• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ResultSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: interpret

import org.apache.tinkerpop.gremlin.driver.ResultSet; //导入依赖的package包/类
@Override
public InterpreterResult interpret(String gremlin, InterpreterContext interpreterContext) {
    logger.info("execute gremlin traversal {}", gremlin);
    try {
        ResultSet results = client.submit(gremlin);
        JsonArray array = results.stream()
                                 .map(result -> new JsonPrimitive(results.toString()))
                                 .collect(JsonArray::new, JsonArray::add, JsonArray::addAll);

        //TODO extract ResultSet
        //Case MessageSerializer

        return new InterpreterResult(InterpreterResult.Code.SUCCESS, array.toString());
    } catch (RuntimeException e) {
        return new InterpreterResult(InterpreterResult.Code.ERROR, e.getMessage());
    }
}
 
开发者ID:shikeio,项目名称:gremzeppelin,代码行数:18,代码来源:GremlinInterpreter.java


示例2: shouldFailWithBadClientSideSerialization

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

    final ResultSet results = client.submit("java.awt.Color.RED");

    try {
        results.all().join();
        fail("Should have thrown exception over bad serialization");
    } catch (Exception ex) {
        final Throwable inner = ExceptionUtils.getRootCause(ex);
        assertTrue(inner instanceof RuntimeException);
        assertThat(inner.getMessage(), startsWith("Encountered unregistered class ID:"));
    }

    // should not die completely just because we had a bad serialization error.  that kind of stuff happens
    // from time to time, especially in the console if you're just exploring.
    assertEquals(2, client.submit("1+1").all().get().get(0).getInt());

    cluster.close();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:23,代码来源:GremlinDriverIntegrateTest.java


示例3: shouldFailWithScriptExecutionException

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

    final ResultSet results = client.submit("1/0");

    try {
        results.all().join();
        fail("Should have thrown exception over bad serialization");
    } catch (Exception ex) {
        final Throwable inner = ExceptionUtils.getRootCause(ex);
        assertTrue(inner instanceof ResponseException);
        assertThat(inner.getMessage(), endsWith("Division by zero"));
    }

    // should not die completely just because we had a bad serialization error.  that kind of stuff happens
    // from time to time, especially in the console if you're just exploring.
    assertEquals(2, client.submit("1+1").all().get().get(0).getInt());

    cluster.close();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:23,代码来源:GremlinDriverIntegrateTest.java


示例4: 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


示例5: 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


示例6: shouldWaitForAllResultsToArrive

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

    final AtomicInteger checked = new AtomicInteger(0);
    final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
    while (!results.allItemsAvailable()) {
        assertTrue(results.getAvailableItemCount() < 10);
        checked.incrementAndGet();
        Thread.sleep(100);
    }

    assertTrue(checked.get() > 0);
    assertEquals(9, results.getAvailableItemCount());
    cluster.close();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:GremlinDriverIntegrateTest.java


示例7: shouldWorkOverNioTransport

import org.apache.tinkerpop.gremlin.driver.ResultSet; //导入依赖的package包/类
@Test
public void shouldWorkOverNioTransport() throws Exception {
    final Cluster cluster = Cluster.build().channelizer(Channelizer.NioChannelizer.class.getName()).create();
    final Client client = cluster.connect();

    final AtomicInteger checked = new AtomicInteger(0);
    final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
    while (!results.allItemsAvailable()) {
        assertTrue(results.getAvailableItemCount() < 10);
        checked.incrementAndGet();
        Thread.sleep(100);
    }

    assertTrue(checked.get() > 0);
    assertEquals(9, results.getAvailableItemCount());
    cluster.close();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:GremlinDriverIntegrateTest.java


示例8: shouldStream

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

    final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
    final AtomicInteger counter = new AtomicInteger(0);
    results.stream().map(i -> i.get(Integer.class) * 2).forEach(i -> assertEquals(counter.incrementAndGet() * 2, Integer.parseInt(i.toString())));
    assertEquals(9, counter.get());
    assertThat(results.allItemsAvailable(), is(true));

    // cant stream it again
    assertThat(results.stream().iterator().hasNext(), is(false));

    cluster.close();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:GremlinDriverIntegrateTest.java


示例9: shouldIterate

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

    final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
    final Iterator<Result> itty = results.iterator();
    final AtomicInteger counter = new AtomicInteger(0);
    while (itty.hasNext()) {
        counter.incrementAndGet();
        assertEquals(counter.get(), itty.next().getInt());
    }

    assertEquals(9, counter.get());
    assertThat(results.allItemsAvailable(), is(true));

    // can't stream it again
    assertThat(results.iterator().hasNext(), is(false));

    cluster.close();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:22,代码来源:GremlinDriverIntegrateTest.java


示例10: shouldFailWithBadServerSideSerialization

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

    final ResultSet results = client.submit("TinkerGraph.open().variables()");

    try {
        results.all().join();
        fail();
    } catch (Exception ex) {
        final Throwable inner = ExceptionUtils.getRootCause(ex);
        assertTrue(inner instanceof ResponseException);
        assertEquals(ResponseStatusCode.SERVER_ERROR_SERIALIZATION, ((ResponseException) inner).getResponseStatusCode());
    }

    // should not die completely just because we had a bad serialization error.  that kind of stuff happens
    // from time to time, especially in the console if you're just exploring.
    assertEquals(2, client.submit("1+1").all().get().get(0).getInt());

    cluster.close();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:23,代码来源:GremlinDriverIntegrateTest.java


示例11: shouldSerializeToStringWhenRequested

import org.apache.tinkerpop.gremlin.driver.ResultSet; //导入依赖的package包/类
@Test
public void shouldSerializeToStringWhenRequested() throws Exception {
    final Map<String, Object> m = new HashMap<>();
    m.put("serializeResultToString", true);
    final GryoMessageSerializerV1d0 serializer = new GryoMessageSerializerV1d0();
    serializer.configure(m, null);

    final Cluster cluster = Cluster.build().serializer(serializer).create();
    final Client client = cluster.connect();

    final ResultSet resultSet = client.submit("TinkerFactory.createClassic()");
    final List<Result> results = resultSet.all().join();
    assertEquals(1, results.size());
    assertEquals("tinkergraph[vertices:6 edges:6]", results.get(0).getString());

    cluster.close();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:GremlinDriverIntegrateTest.java


示例12: shouldHandleRequestSentThatNeverReturns

import org.apache.tinkerpop.gremlin.driver.ResultSet; //导入依赖的package包/类
@Test
@org.junit.Ignore("Can't seem to make this test pass consistently")
public void shouldHandleRequestSentThatNeverReturns() throws Exception {
    final Cluster cluster = Cluster.open();
    final Client client = cluster.connect();

    final ResultSet results = client.submit("Thread.sleep(10000); 'should-not-ever-get-back-coz-we-killed-the-server'");

    stopServer();

    // give the server a chance to kill everything
    Thread.sleep(1000);

    try {
        results.all().get(10000, TimeUnit.MILLISECONDS);
        fail("Server was stopped before the request could execute");
    } catch (TimeoutException toe) {
        fail("Should not have tossed a TimeOutException getting the result");
    } catch (Exception ex) {
        final Throwable cause = ExceptionUtils.getCause(ex);
        assertThat(cause.getMessage(), containsString("rejected from java.util.concurrent.ThreadPoolExecutor"));
    }

    cluster.close();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:26,代码来源:GremlinDriverIntegrateTest.java


示例13: shouldExecuteScriptInSession

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

    final ResultSet results1 = client.submit("x = [1,2,3,4,5,6,7,8,9]");
    assertEquals(9, results1.all().get().size());

    final ResultSet results2 = client.submit("x[0]+1");
    assertEquals(2, results2.all().get().get(0).getInt());

    final ResultSet results3 = client.submit("x[1]+2");
    assertEquals(4, results3.all().get().get(0).getInt());

    cluster.close();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:GremlinDriverIntegrateTest.java


示例14: shouldCloseSession

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

    final ResultSet results1 = client.submit("x = [1,2,3,4,5,6,7,8,9]");
    assertEquals(9, results1.all().get().size());
    final ResultSet results2 = client.submit("x[0]+1");
    assertEquals(2, results2.all().get().get(0).getInt());

    client.close();

    try {
        client.submit("x[0]+1");
        fail("Should have thrown an exception because the connection is closed");
    } catch (Exception ex) {
        final Throwable root = ExceptionUtils.getRootCause(ex);
        assertThat(root, instanceOf(ConnectionException.class));
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:GremlinDriverIntegrateTest.java


示例15: shouldExecuteScriptsInMultipleSession

import org.apache.tinkerpop.gremlin.driver.ResultSet; //导入依赖的package包/类
@Test
public void shouldExecuteScriptsInMultipleSession() throws Exception {
    final Cluster cluster = Cluster.build().create();
    final Client client1 = cluster.connect(name.getMethodName() + "1");
    final Client client2 = cluster.connect(name.getMethodName() + "2");
    final Client client3 = cluster.connect(name.getMethodName() + "3");

    final ResultSet results11 = client1.submit("x = 1");
    final ResultSet results21 = client2.submit("x = 2");
    final ResultSet results31 = client3.submit("x = 3");
    assertEquals(1, results11.all().get().get(0).getInt());
    assertEquals(2, results21.all().get().get(0).getInt());
    assertEquals(3, results31.all().get().get(0).getInt());

    final ResultSet results12 = client1.submit("x + 100");
    final ResultSet results22 = client2.submit("x * 2");
    final ResultSet results32 = client3.submit("x * 10");
    assertEquals(101, results12.all().get().get(0).getInt());
    assertEquals(4, results22.all().get().get(0).getInt());
    assertEquals(30, results32.all().get().get(0).getInt());

    cluster.close();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:24,代码来源:GremlinDriverIntegrateTest.java


示例16: tryWebSocketGremlin

import org.apache.tinkerpop.gremlin.driver.ResultSet; //导入依赖的package包/类
private void tryWebSocketGremlin() throws Exception {
    final Map<String, Object> params = new HashMap<>();
    params.put("x", 16384l);

    final CompletableFuture<ResultSet> future1 = client.get().submitAsync("g.V(x).out().out().next(512)", params);
    final CompletableFuture<ResultSet> future2 = client.get().submitAsync("g.V(x).out().next(7)", params);
    final CompletableFuture<ResultSet> future3 = client.get().submitAsync("g.V(16384l).out().out().next(10)");
    final CompletableFuture<ResultSet> future4 = client.get().submitAsync("g.V(16432l).out().out().next(10)");
    final CompletableFuture<ResultSet> future5 = client.get().submitAsync("g.V(14l).out().next(1)");

    assertEquals(512, future1.get().stream().count());
    assertEquals(7, future2.get().stream().count());
    assertEquals(10, future3.get().stream().count());
    assertEquals(10, future4.get().stream().count());
    assertEquals(1, future5.get().stream().count());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:GremlinTraversalPerformanceTest.java


示例17: shouldHandleVertexResult

import org.apache.tinkerpop.gremlin.driver.ResultSet; //导入依赖的package包/类
@Test
public void shouldHandleVertexResult() throws Exception {
    final ResultSet results = client.submit("g.V(1).next()");
    final Vertex v = results.all().get().get(0).getVertex();
    assertThat(v, instanceOf(DetachedVertex.class));

    assertEquals("marko", v.properties("name").next().value());
    v.properties().forEachRemaining(p -> {
        if (p.key().equals("name"))
            assertEquals("marko", p.value());
        else if (p.key().equals("age"))
            assertEquals(29, p.value());
        else
            fail("Should not have any other keys besides 'name' and 'age'");
    });
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:GremlinResultSetIntegrateTest.java


示例18: DriverRemoteTraversal

import org.apache.tinkerpop.gremlin.driver.ResultSet; //导入依赖的package包/类
public DriverRemoteTraversal(final ResultSet rs, final Client client, final boolean attach, final Optional<Configuration> conf) {
    // attaching is really just for testing purposes. it doesn't make sense in any real-world scenario as it would
    // require that the client have access to the Graph instance that produced the result. tests need that
    // attachment process to properly execute in full hence this little hack.
    if (attach) {
        if (!conf.isPresent()) throw new IllegalStateException("Traverser can't be reattached for testing");
        final Graph graph = ((Supplier<Graph>) conf.get().getProperty("hidden.for.testing.only")).get();
        this.traversers = new AttachingTraverserIterator<>(rs.iterator(), graph);
    } else {
        this.traversers = new TraverserIterator<>(rs.iterator());
    }

    this.rs = rs;
    this.sideEffects = new DriverRemoteTraversalSideEffects(client,
            rs.getOriginalRequestMessage().getRequestId(),
            rs.getHost(), rs.allItemsAvailableAsync());
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:18,代码来源:DriverRemoteTraversal.java


示例19: shouldFailWithBadClientSideSerialization

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

    final ResultSet results = client.submit("java.awt.Color.RED");

    try {
        results.all().join();
        fail("Should have thrown exception over bad serialization");
    } catch (Exception ex) {
        final Throwable inner = ExceptionUtils.getRootCause(ex);
        assertThat(inner, instanceOf(ResponseException.class));
        assertEquals(ResponseStatusCode.SERVER_ERROR_SERIALIZATION, ((ResponseException) inner).getResponseStatusCode());
    }

    // should not die completely just because we had a bad serialization error.  that kind of stuff happens
    // from time to time, especially in the console if you're just exploring.
    assertEquals(2, client.submit("1+1").all().get().get(0).getInt());

    cluster.close();
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:23,代码来源:GremlinDriverIntegrateTest.java


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GeoPackageException类代码示例发布时间:2022-05-22
下一篇:
Java Read类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap