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


Java StatementResult.consume方法代码示例

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


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

示例1: reconnect

import org.neo4j.driver.v1.StatementResult; //导入方法依赖的package包/类
private void reconnect() {
    String bookmark = null;
    if (session != null) {
        bookmark = session.lastBookmark();
        session.close();
    }
    session = driver.session(AccessMode.WRITE, bookmark);
    StatementResult run = session.run("RETURN 1");
    this.version = run.summary().server().version();
    run.consume();
}
 
开发者ID:neo4j,项目名称:cypher-shell,代码行数:12,代码来源:BoltStateHandler.java

示例2: getRelationships

import org.neo4j.driver.v1.StatementResult; //导入方法依赖的package包/类
private StateTracker<RemoteRelationship, Set<RemoteRelationship>> getRelationships(RemoteNode source, RemoteRelationshipType type,
        RemoteDirection remoteDirection) {
    StateTracker<RemoteRelationship, Set<RemoteRelationship>> trackedRelationships = source.getState().getRelationships(remoteDirection, type);
    if (trackedRelationships == null) {
        String sourceIdentifier;
        switch (remoteDirection) {
        case OUTGOING:
            sourceIdentifier = "start";
            break;
        case INCOMING:
            sourceIdentifier = "end";
            break;
        default:
            throw new XOException("Direction not supported: " + remoteDirection);
        }
        String statement = String.format("MATCH (start)-[r:%s]->(end) WHERE id(%s)={id} RETURN start,r,end", type.getName(), sourceIdentifier);
        StatementResult statementResult = statementExecutor.execute(statement, parameters("id", source.getId()));
        Set<RemoteRelationship> loaded = new LinkedHashSet<>();
        try {
            while (statementResult.hasNext()) {
                Record record = statementResult.next();
                Node start = record.get("start").asNode();
                Relationship relationship = record.get("r").asRelationship();
                Node end = record.get("end").asNode();
                RemoteRelationship remoteRelationship = datastoreSessionCache.getRelationship(start, relationship, end);
                loaded.add(remoteRelationship);
            }
        } finally {
            statementResult.consume();
        }
        trackedRelationships = new StateTracker<>(loaded);
        source.getState().setRelationships(remoteDirection, type, trackedRelationships);
    }
    return trackedRelationships;
}
 
开发者ID:buschmais,项目名称:extended-objects,代码行数:36,代码来源:RemoteDatastoreRelationManager.java

示例3: getSingleResult

import org.neo4j.driver.v1.StatementResult; //导入方法依赖的package包/类
private Record getSingleResult(StatementResult result) {
    try {
        return result.single();
    } catch (NoSuchRecordException e) {
        throw new XOException("Query returned no result.");
    } finally {
        result.consume();
    }
}
 
开发者ID:buschmais,项目名称:extended-objects,代码行数:10,代码来源:StatementExecutor.java

示例4: findEntity

import org.neo4j.driver.v1.StatementResult; //导入方法依赖的package包/类
@Override
public ResultIterator<RemoteNode> findEntity(EntityTypeMetadata<NodeMetadata<RemoteLabel>> type, RemoteLabel remoteLabel,
        Map<PrimitivePropertyMethodMetadata<PropertyMetadata>, Object> values) {
    if (values.size() > 1) {
        throw new XOException("Only one property value is supported for find operation");
    }
    Map.Entry<PrimitivePropertyMethodMetadata<PropertyMetadata>, Object> entry = values.entrySet().iterator().next();
    PropertyMetadata propertyMetadata = getIndexedPropertyMetadata(type, entry.getKey());
    Object value = entry.getValue();
    String statement = String.format("MATCH (n:%s) WHERE n.%s={v} RETURN n", remoteLabel.getName(), propertyMetadata.getName());
    StatementResult result = statementExecutor.execute(statement, parameters("v", value));
    return new ResultIterator<RemoteNode>() {
        @Override
        public boolean hasNext() {
            return result.hasNext();
        }

        @Override
        public RemoteNode next() {
            Record record = result.next();
            Node node = record.get("n").asNode();
            return datastoreSessionCache.getNode(node);
        }

        @Override
        public void close() {
            result.consume();
        }
    };
}
 
开发者ID:buschmais,项目名称:extended-objects,代码行数:31,代码来源:RemoteDatastoreEntityManager.java


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