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

Java Result类代码示例

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

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



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

示例1: findPersonsByPrefix

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的package包/类
public List<Person> findPersonsByPrefix(String firstNamePrefix) {

        String query = String.format(
                "g.V().hasLabel('%s').has('%s', Text.textContainsPrefix('%s')).valueMap(true)",
                PERSON.LABEL,
                PERSON.FIRST_NAME,
                firstNamePrefix);

        try {
            List<Result> results = client.submit(query).all().get();

            List<Person> people = new ArrayList<>(results.size());
            for(Result result : results) {
                people.add(toPerson(result.get(Map.class)));
            }

            return people;
        }
        catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
 
开发者ID:experoinc,项目名称:spring-boot-graph-day,代码行数:23,代码来源:PersonRepository.java


示例2: shouldProcessRequestsOutOfOrder

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的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


示例3: shouldProcessSessionRequestsInOrder

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的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


示例4: shouldIterate

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的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


示例5: shouldSerializeToStringWhenRequested

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的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


示例6: shouldProcessRequestsOutOfOrder

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的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


示例7: shouldIterate

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的package包/类
@Test
public void shouldIterate() throws Exception {
    final Cluster cluster = TestClientFactory.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:apache,项目名称:tinkerpop,代码行数:22,代码来源:GremlinDriverIntegrateTest.java


示例8: shouldSerializeToStringWhenRequestedGryoV1

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的package包/类
@Test
public void shouldSerializeToStringWhenRequestedGryoV1() 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 = TestClientFactory.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:apache,项目名称:tinkerpop,代码行数:18,代码来源:GremlinDriverIntegrateTest.java


示例9: shouldSerializeToStringWhenRequestedGryoV3

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

    final Cluster cluster = TestClientFactory.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:apache,项目名称:tinkerpop,代码行数:18,代码来源:GremlinDriverIntegrateTest.java


示例10: shouldWorkWithGraphSONV2Serialization

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的package包/类
@Test
public void shouldWorkWithGraphSONV2Serialization() throws Exception {
    final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHSON_V2D0).create();
    final Client client = cluster.connect();

    final List<Result> r = client.submit("TinkerFactory.createModern().traversal().V(1)").all().join();
    assertEquals(1, r.size());

    final Vertex v = r.get(0).get(DetachedVertex.class);
    assertEquals(1, v.id());
    assertEquals("person", v.label());

    assertEquals(2, IteratorUtils.count(v.properties()));
    assertEquals("marko", v.value("name"));
    assertEquals(29, Integer.parseInt(v.value("age").toString()));

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


示例11: shouldWorkWithGraphSONV3Serialization

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的package包/类
@Test
public void shouldWorkWithGraphSONV3Serialization() throws Exception {
    final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHSON_V3D0).create();
    final Client client = cluster.connect();

    final List<Result> r = client.submit("TinkerFactory.createModern().traversal().V(1)").all().join();
    assertEquals(1, r.size());

    final Vertex v = r.get(0).get(DetachedVertex.class);
    assertEquals(1, v.id());
    assertEquals("person", v.label());

    assertEquals(2, IteratorUtils.count(v.properties()));
    assertEquals("marko", v.value("name"));
    assertEquals(29, Integer.parseInt(v.value("age").toString()));

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


示例12: shouldSubmitScript

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的package包/类
@Test
public void shouldSubmitScript() throws InterruptedException, ExecutionException {
    List<Result> results = client.submit("g.V().valueMap()").all().get();
    assertThat(results, notNullValue());
    assertThat(results, not(empty()));
    results.stream().forEach(System.out::println);
}
 
开发者ID:robertdale,项目名称:tinkerpop-spring-boot,代码行数:8,代码来源:TinkerModernGraphTest.java


示例13: submit

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的package包/类
@Override
public Object submit(final List<String> args) throws RemoteException {
    final String line = RemoteAcceptor.getScript(String.join(" ", args), this.shell);

    try {
        final List<Result> resultSet = send(line);
        this.shell.getInterp().getContext().setProperty(RESULT, resultSet);
        return resultSet.stream().map(result -> result.getObject()).iterator();
    } catch (SaslException sasl) {
        throw new RemoteException("Security error - check username/password and related settings", sasl);
    } catch (Exception ex) {
        final Optional<ResponseException> inner = findResponseException(ex);
        if (inner.isPresent()) {
            final ResponseException responseException = inner.get();
            if (responseException.getResponseStatusCode() == ResponseStatusCode.SERVER_ERROR_SERIALIZATION)
                throw new RemoteException(String.format("Server could not serialize the result requested. Server error - %s. Note that the class must be serializable by the client and server for proper operation.", responseException.getMessage()));
            else
                throw new RemoteException(responseException.getMessage());
        } else if (ex.getCause() != null) {
            final Throwable rootCause = ExceptionUtils.getRootCause(ex);
            if (rootCause instanceof TimeoutException)
                throw new RemoteException("Host did not respond in a timely fashion - check the server status and submit again.");
            else
                throw new RemoteException(rootCause.getMessage());
        } else
            throw new RemoteException(ex.getMessage());
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:29,代码来源:DriverRemoteAcceptor.java


示例14: send

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的package包/类
private List<Result> send(final String gremlin) throws SaslException {
    try {
        final ResultSet rs = this.currentClient.submitAsync(gremlin, aliases, Collections.emptyMap()).get();
        return timeout > NO_TIMEOUT ? rs.all().get(timeout, TimeUnit.MILLISECONDS) : rs.all().get();
    } catch(TimeoutException ignored) {
        throw new IllegalStateException("Request timed out while processing - increase the timeout with the :remote command");
    } catch (Exception e) {
        // handle security error as-is and unwrapped
        final Optional<Throwable> throwable  = Stream.of(ExceptionUtils.getThrowables(e)).filter(t -> t instanceof SaslException).findFirst();
        if (throwable.isPresent())
            throw (SaslException) throwable.get();

        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:16,代码来源:DriverRemoteAcceptor.java


示例15: shouldConnectAndSubmitSession

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的package包/类
@Test
public void shouldConnectAndSubmitSession() throws Exception {
    assertThat(acceptor.connect(Arrays.asList(TestHelper.generateTempFileFromResource(this.getClass(), "remote.yaml", ".tmp").getAbsolutePath(), "session")).toString(), startsWith("Configured "));
    assertEquals("1", ((Iterator) acceptor.submit(Collections.singletonList("x = 1"))).next());
    assertEquals("0", ((Iterator) acceptor.submit(Collections.singletonList("x - 1"))).next());
    assertEquals("0", ((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).iterator().next().getString());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:8,代码来源:DriverRemoteAcceptorIntegrateTest.java


示例16: shouldConnectAndSubmitManagedSession

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的package包/类
@Test
public void shouldConnectAndSubmitManagedSession() throws Exception {
    assertThat(acceptor.connect(Arrays.asList(TestHelper.generateTempFileFromResource(this.getClass(), "remote.yaml", ".tmp").getAbsolutePath(), "session-managed")).toString(), startsWith("Configured "));
    assertEquals("1", ((Iterator) acceptor.submit(Collections.singletonList("x = 1"))).next());
    assertEquals("0", ((Iterator) acceptor.submit(Collections.singletonList("x - 1"))).next());
    assertEquals("0", ((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).iterator().next().getString());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:8,代码来源:DriverRemoteAcceptorIntegrateTest.java


示例17: shouldConnectAndReturnVerticesWithAnAlias

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的package包/类
@Test
public void shouldConnectAndReturnVerticesWithAnAlias() throws Exception {
    assertThat(acceptor.connect(Collections.singletonList(TestHelper.generateTempFileFromResource(this.getClass(), "remote.yaml", ".tmp").getAbsolutePath())).toString(), startsWith("Configured "));
    acceptor.configure(Arrays.asList("alias", "x", "g"));
    assertThat(IteratorUtils.list(((Iterator<String>) acceptor.submit(Collections.singletonList("x.addVertex('name','stephen');x.addVertex('name','marko');x.traversal().V()")))), hasSize(2));
    assertThat(((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).stream().map(Result::getString).collect(Collectors.toList()), hasSize(2));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:8,代码来源:DriverRemoteAcceptorIntegrateTest.java


示例18: shouldConnectAndSubmitInSession

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的package包/类
@Test
public void shouldConnectAndSubmitInSession() throws Exception {
    assertThat(acceptor.connect(Arrays.asList(TestHelper.generateTempFileFromResource(this.getClass(), "remote.yaml", ".tmp").getAbsolutePath(), "session")).toString(), startsWith("Configured "));
    assertEquals("2", ((Iterator) acceptor.submit(Collections.singletonList("x=1+1"))).next());
    assertEquals("2", ((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).iterator().next().getString());
    assertEquals("4", ((Iterator) acceptor.submit(Collections.singletonList("x+2"))).next());
    assertEquals("4", ((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).iterator().next().getString());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:9,代码来源:DriverRemoteAcceptorIntegrateTest.java


示例19: shouldConnectAndSubmitInNamedSession

import org.apache.tinkerpop.gremlin.driver.Result; //导入依赖的package包/类
@Test
public void shouldConnectAndSubmitInNamedSession() throws Exception {
    assertThat(acceptor.connect(Arrays.asList(TestHelper.generateTempFileFromResource(this.getClass(), "remote.yaml", ".tmp").getAbsolutePath(), "session", "AAA")).toString(), startsWith("Configured "));
    assertEquals("2", ((Iterator) acceptor.submit(Collections.singletonList("x=1+1"))).next());
    assertEquals("2", ((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).iterator().next().getString());
    assertEquals("4", ((Iterator) acceptor.submit(Collections.singletonList("x+2"))).next());
    assertEquals("4", ((List<Result>) groovysh.getInterp().getContext().getProperty(DriverRemoteAcceptor.RESULT)).iterator().next().getString());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:9,代码来源:DriverRemoteAcceptorIntegrateTest.java


示例20: shouldEnsureSessionBindingsAreThreadSafe

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

    client.submitAsync("a=100;b=1000;c=10000;null");
    final int requests = 10000;
    final List<CompletableFuture<ResultSet>> futures = new ArrayList<>(requests);
    IntStream.range(0, requests).forEach(i -> {
        try {
            futures.add(client.submitAsync("a+b+c"));
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    });

    assertEquals(requests, futures.size());

    int counter = 0;
    for(CompletableFuture<ResultSet> f : futures) {
        final Result r = f.get().all().get(30000, TimeUnit.MILLISECONDS).get(0);
        assertEquals(11100, r.getInt());
        counter++;
    }

    assertEquals(requests, counter);

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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