Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 遍历急切地收集节点的所有关系,如下所示: public class SpecificRelsPathExpander implements PathExpander, Predicate<Relationship> { private final String requiredProperty; public SpecificRelsPathExpander( String requiredProperty ) { this.requiredProperty = requiredProperty; } @Override public Iterable<Relationship> expand( Path path, BranchState state ) { Iterable<Relationship> rels = path.endNode().getRelationships( RelTypes.FOO, Direction.BOTH ); return Iterables.filter( this, rels ); } @Override public boolean accept( Relationship relationship ) { return requiredProperty.equals( relationship.getProperty( "propertyName", null ) ); } // not used @Override public PathExpander<Object> reverse() { return null; } } public类specificRelsPathPander实现PathExpander,谓词 { 私有最终字符串requiredProperty; 公共SpecificRelsPathExpander(字符串requiredProperty) { this.requiredProperty=requiredProperty; } @凌驾 公共Iterable扩展(路径、分支状态) { Iterable rels=path.endNode().getRelationships(RelTypes.FOO,Direction.BOTH); 返回Iterables.filter(this,rels); } @凌驾 公共布尔接受(关系) { 返回requiredProperty.equals(relationship.getProperty(“propertyName”,null)); } //不用 @凌驾 公共路径扩展器反向() { 返回null; } }_Java_Neo4j_Traversal - Fatal编程技术网

Java 遍历急切地收集节点的所有关系,如下所示: public class SpecificRelsPathExpander implements PathExpander, Predicate<Relationship> { private final String requiredProperty; public SpecificRelsPathExpander( String requiredProperty ) { this.requiredProperty = requiredProperty; } @Override public Iterable<Relationship> expand( Path path, BranchState state ) { Iterable<Relationship> rels = path.endNode().getRelationships( RelTypes.FOO, Direction.BOTH ); return Iterables.filter( this, rels ); } @Override public boolean accept( Relationship relationship ) { return requiredProperty.equals( relationship.getProperty( "propertyName", null ) ); } // not used @Override public PathExpander<Object> reverse() { return null; } } public类specificRelsPathPander实现PathExpander,谓词 { 私有最终字符串requiredProperty; 公共SpecificRelsPathExpander(字符串requiredProperty) { this.requiredProperty=requiredProperty; } @凌驾 公共Iterable扩展(路径、分支状态) { Iterable rels=path.endNode().getRelationships(RelTypes.FOO,Direction.BOTH); 返回Iterables.filter(this,rels); } @凌驾 公共布尔接受(关系) { 返回requiredProperty.equals(relationship.getProperty(“propertyName”,null)); } //不用 @凌驾 公共路径扩展器反向() { 返回null; } }

Java 遍历急切地收集节点的所有关系,如下所示: public class SpecificRelsPathExpander implements PathExpander, Predicate<Relationship> { private final String requiredProperty; public SpecificRelsPathExpander( String requiredProperty ) { this.requiredProperty = requiredProperty; } @Override public Iterable<Relationship> expand( Path path, BranchState state ) { Iterable<Relationship> rels = path.endNode().getRelationships( RelTypes.FOO, Direction.BOTH ); return Iterables.filter( this, rels ); } @Override public boolean accept( Relationship relationship ) { return requiredProperty.equals( relationship.getProperty( "propertyName", null ) ); } // not used @Override public PathExpander<Object> reverse() { return null; } } public类specificRelsPathPander实现PathExpander,谓词 { 私有最终字符串requiredProperty; 公共SpecificRelsPathExpander(字符串requiredProperty) { this.requiredProperty=requiredProperty; } @凌驾 公共Iterable扩展(路径、分支状态) { Iterable rels=path.endNode().getRelationships(RelTypes.FOO,Direction.BOTH); 返回Iterables.filter(this,rels); } @凌驾 公共布尔接受(关系) { 返回requiredProperty.equals(relationship.getProperty(“propertyName”,null)); } //不用 @凌驾 公共路径扩展器反向() { 返回null; } },java,neo4j,traversal,Java,Neo4j,Traversal,此外,只要客户端(即从开始遍历调用时接收到的迭代器所在的客户端)拥有next/next,遍历就会继续。将不会单独进行遍历,这一切都发生在hasNext/next中。这是一个很好的改进,肯定有助于实现目标。但问题仍然存在,有可能扩展一个具有数百个关系的节点,这将导致(有几个类似的节点)遍历中排队的路径快速增长。我需要一个更严格的约束,可以立即停止遍历。这是一个很好的改进,肯定有助于实现目标。但问题仍然存在,有可能扩展一个具有数百个关系的节点,这将导致(有几个类似的节点)遍历中排队的路径快速增长。我

此外,只要客户端(即从开始遍历调用时接收到的迭代器所在的客户端)拥有next/next,遍历就会继续。将不会单独进行遍历,这一切都发生在hasNext/next中。

这是一个很好的改进,肯定有助于实现目标。但问题仍然存在,有可能扩展一个具有数百个关系的节点,这将导致(有几个类似的节点)遍历中排队的路径快速增长。我需要一个更严格的约束,可以立即停止遍历。这是一个很好的改进,肯定有助于实现目标。但问题仍然存在,有可能扩展一个具有数百个关系的节点,这将导致(有几个类似的节点)遍历中排队的路径快速增长。我需要一个更严格的约束,可以立即停止遍历。这是一个很好的改进,肯定有助于实现目标。但问题仍然存在,有可能扩展一个具有数百个关系的节点,这将导致(有几个类似的节点)遍历中排队的路径快速增长。我需要一个更严格的约束,可以立即停止遍历。
private class IncludePathWithTargetPropertyEvaluator implements Evaluator {

private String targetProperty;
private int results;
private long startTime, curTime, elapsed;       

public IncludePathWithTargetPropertyEvaluator(String targetProperty) {
    this.targetProperty = targetProperty;
    this.startTime = System.currentTimeMillis();
    this.results = 0;
}

public Evaluation evaluate(Path path) {

    curTime = System.currentTimeMillis();
    elapsed = curTime - startTime;

    if (elapsed >= 200) {
        return Evaluation.EXCLUDE_AND_PRUNE;
    }

    if (results >= 3) {
        return Evaluation.EXCLUDE_AND_PRUNE;
    }

    String property = (String) path.endNode().getProperty("propertyName");

    if (property.equals(targetProperty)) {
        results = results + 1;
        return Evaluation.INCLUDE_AND_PRUNE;
    }

    return Evaluation.EXCLUDE_AND_CONTINUE;
}
private class SpecificRelsPathExpander implements PathExpander {

private String requiredProperty;

public SpecificRelsPathExpander(String requiredProperty) {
    this.requiredProperty = requiredProperty;
}

public Iterable<Relationship> expand(Path path, BranchState<Object> state) {
    Iterable<Relationship> rels = path.endNode().getRelationships(RelTypes.FOO, Direction.BOTH);
    if (!rels.iterator().hasNext())
        return null;
    List<Relationship> validRels = new LinkedList<Relationship>();
    for (Relationship rel : rels) {
        String property = (String) rel.getProperty("propertyName");
        if (property.equals(requiredProperty)) {
            validRels.add(rel);
        }
    }
    return validRels;
}

// not used
public PathExpander<Object> reverse() {
    return null;
}
private class SpecificRelsPathExpander implements PathExpander {

private String requiredProperty;
private long startTime, curTime, elapsed;

public SpecificRelsPathExpander(String requiredProperty) {
    this.requiredProperty = requiredProperty;
    this.startTime = System.currentTimeMillis();
}

public Iterable<Relationship> expand(Path path, BranchState<Object> state) {
    curTime = System.currentTimeMillis();
    elapsed = curTime - startTime;

    if (elapsed >= 200) {
        return null;
    }

    Iterable<Relationship> rels = path.endNode().getRelationships(RelTypes.FOO, Direction.BOTH);
    if (!rels.iterator().hasNext())
        return null;
    List<Relationship> validRels = new LinkedList<Relationship>();
    for (Relationship rel : rels) {
        String property = (String) rel.getProperty("propertyName");
        if (property.equals(requiredProperty)) {
            validRels.add(rel);
        }
    }
    return validRels;
}

// not used
public PathExpander<Object> reverse() {
    return null;
}
public class SpecificRelsPathExpander implements PathExpander, Predicate<Relationship>
{
    private final String requiredProperty;

    public SpecificRelsPathExpander( String requiredProperty )
    {
        this.requiredProperty = requiredProperty;
    }

    @Override
    public Iterable<Relationship> expand( Path path, BranchState state )
    {
        Iterable<Relationship> rels = path.endNode().getRelationships( RelTypes.FOO, Direction.BOTH );
        return Iterables.filter( this, rels );
    }

    @Override
    public boolean accept( Relationship relationship )
    {
        return requiredProperty.equals( relationship.getProperty( "propertyName", null ) );
    }

    // not used
    @Override
    public PathExpander<Object> reverse()
    {
        return null;
    }
}