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


Java RelationshipIndex类代码示例

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


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

示例1: question5346011

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
@Test
public void question5346011()
{
    GraphDatabaseService service = new TestGraphDatabaseFactory().newImpermanentDatabase();
    try ( Transaction tx = service.beginTx() )
    {
        RelationshipIndex index = service.index().forRelationships( "exact" );
        // ...creation of the nodes and relationship
        Node node1 = service.createNode();
        Node node2 = service.createNode();
        String a_uuid = "xyz";
        Relationship relationship = node1.createRelationshipTo( node2, DynamicRelationshipType.withName( "related" ) );
        index.add( relationship, "uuid", a_uuid );
        // query
        IndexHits<Relationship> hits = index.get( "uuid", a_uuid, node1, node2 );
        assertEquals( 1, hits.size() );
        tx.success();
    }
    service.shutdown();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:21,代码来源:RelatedNodesQuestionTest.java

示例2: makeSureYouCanRemoveFromRelationshipIndex

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
@Test
public void makeSureYouCanRemoveFromRelationshipIndex()
{
    Node n1 = graphDb.createNode();
    Node n2 = graphDb.createNode();
    Relationship r = n1.createRelationshipTo( n2, DynamicRelationshipType.withName( "foo" ) );
    RelationshipIndex index = graphDb.index().forRelationships( "rel-index" );
    String key = "bar";
    index.remove( r, key, "value" );
    index.add( r, key, "otherValue" );
    for ( int i = 0; i < 2; i++ )
    {
        assertThat( index.get( key, "value" ), isEmpty() );
        assertThat( index.get( key, "otherValue" ), contains( r ) );
        restartTx();
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:18,代码来源:TestLuceneIndex.java

示例3: shouldNotSeeDeletedRelationshipWhenQueryingWithStartAndEndNode

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
@Test
public void shouldNotSeeDeletedRelationshipWhenQueryingWithStartAndEndNode()
{
    // GIVEN
    RelationshipIndex index = relationshipIndex( EXACT_CONFIG );
    Node start = graphDb.createNode();
    Node end = graphDb.createNode();
    RelationshipType type = withName( "REL" );
    Relationship rel = start.createRelationshipTo( end, type );
    index.add( rel, "Type", type.name() );
    finishTx( true );
    beginTx();

    // WHEN
    IndexHits<Relationship> hits = index.get( "Type", type.name(), start, end );
    assertEquals( 1, count( (Iterator<Relationship>)hits ) );
    assertEquals( 1, hits.size() );
    index.remove( rel );

    // THEN
    hits = index.get( "Type", type.name(), start, end );
    assertEquals( 0, count( (Iterator<Relationship>)hits ) );
    assertEquals( 0, hits.size() );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:25,代码来源:TestLuceneIndex.java

示例4: relationshipIndex

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
@Override
public RelationshipIndex relationshipIndex( String indexName, Map<String, String> config )
{
    IndexIdentifier identifier = new IndexIdentifier( LuceneCommand.RELATIONSHIP,
            dataSource.relationshipEntityType, indexName );
    synchronized ( dataSource.indexes )
    {
        LuceneIndex index = dataSource.indexes.get( identifier );
        if ( index == null )
        {
            index = new LuceneIndex.RelationshipIndex( this, identifier );
            dataSource.indexes.put( identifier, index );
        }
        return (RelationshipIndex) index;
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:17,代码来源:LuceneIndexImplementation.java

示例5: deleteRelationshipIndex

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
@Override
public void deleteRelationshipIndex(String name, ParcelableError err) throws RemoteException {

    try {
        checkCallerHasWritePermission();
        resumeTrx();

        try {
            RelationshipIndex index = mDb.index().forRelationships(name); // this
                                                                          // will
                                                                          // create
                                                                          // the
                                                                          // index
            index.delete();
        } finally {
            suspendCurrentTrx("deleteRelationshipIndex");
        }
    } catch (Exception e) {
        Log.e(TAG, "Failed to delete relationship index '" + name + "'", e);
        err.setError(Errors.TRANSACTION, e.getMessage());
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:23,代码来源:DbWrapper.java

示例6: addRelationshipToIndex

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
@Override
public void addRelationshipToIndex(String name, long relationshipId, String key, ParcelableIndexValue value, ParcelableError err)
        throws RemoteException {

    try {
        checkCallerHasWritePermission();
        resumeTrx();

        try {
            Relationship rel = mDb.getRelationshipById(relationshipId);
            RelationshipIndex index = mDb.index().forRelationships(name); // this
                                                                          // will
                                                                          // create
                                                                          // the
                                                                          // index
            index.add(rel, key, value.get());
        } finally {
            suspendCurrentTrx("addRelationshipToIndex");
        }
    } catch (Exception e) {
        Log.e(TAG, "Failed to add relationship to index '" + name + "'", e);
        err.setError(Errors.TRANSACTION, e.getMessage());
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:25,代码来源:DbWrapper.java

示例7: removeRelationshipFromIndex

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
@Override
public void removeRelationshipFromIndex(String name, long relationshipId, ParcelableError err) throws RemoteException {

    try {
        checkCallerHasWritePermission();
        resumeTrx();

        try {
            Relationship rel = mDb.getRelationshipById(relationshipId);
            RelationshipIndex index = mDb.index().forRelationships(name); // this
                                                                          // will
                                                                          // create
                                                                          // the
                                                                          // index
            index.remove(rel);
        } finally {
            suspendCurrentTrx("removeRelationshipFromIndex");
        }
    } catch (Exception e) {
        Log.e(TAG, "Failed to add relationship to index '" + name + "'", e);
        err.setError(Errors.TRANSACTION, e.getMessage());
    }

}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:25,代码来源:DbWrapper.java

示例8: removeRelationshipKeyFromIndex

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
@Override
public void removeRelationshipKeyFromIndex(String name, long relationshipId, String key, ParcelableError err)
        throws RemoteException {

    try {
        checkCallerHasWritePermission();
        resumeTrx();

        try {
            Relationship rel = mDb.getRelationshipById(relationshipId);
            RelationshipIndex index = mDb.index().forRelationships(name); // this
                                                                          // will
                                                                          // create
                                                                          // the
                                                                          // index
            index.remove(rel, key);
        } finally {
            suspendCurrentTrx("removeRelationshipKeyFromIndex");
        }
    } catch (Exception e) {
        Log.e(TAG, "Failed to add relationship to index '" + name + "'", e);
        err.setError(Errors.TRANSACTION, e.getMessage());
    }

}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:26,代码来源:DbWrapper.java

示例9: removeRelationshipKeyValueFromIndex

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
@Override
public void removeRelationshipKeyValueFromIndex(String name, long relationshipId, String key, ParcelableIndexValue value,
        ParcelableError err) throws RemoteException {

    try {
        checkCallerHasWritePermission();
        resumeTrx();

        try {
            Relationship rel = mDb.getRelationshipById(relationshipId);
            RelationshipIndex index = mDb.index().forRelationships(name); // this
                                                                          // will
                                                                          // create
                                                                          // the
                                                                          // index
            index.remove(rel, key, value.get());
        } finally {
            suspendCurrentTrx("removeRelationshipKeyValueFromIndex");
        }
    } catch (Exception e) {
        Log.e(TAG, "Failed to add relationship to index '" + name + "'", e);
        err.setError(Errors.TRANSACTION, e.getMessage());
    }

}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:26,代码来源:DbWrapper.java

示例10: getRelationshipsFromIndex

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
@Override
public IRelationshipIterator getRelationshipsFromIndex(String name, String key, ParcelableIndexValue value, ParcelableError err)
        throws RemoteException {

    try {
        resumeTrxIfExists();

        try {
            RelationshipIndex index = mDb.index().forRelationships(name); // this
                                                                          // will
                                                                          // create
                                                                          // the
                                                                          // index
            IndexHits<Relationship> hits = index.get(key, value.get());
            return new RelationshipIteratorWrapper(hits);
        } finally {
            suspendCurrentTrx("getRelationshipsFromIndex");
        }
    } catch (Exception e) {
        Log.e(TAG, "Failed to add relationship to index '" + name + "'", e);
        err.setError(Errors.TRANSACTION, e.getMessage());
        return null;
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:25,代码来源:DbWrapper.java

示例11: fillUpAncestorIds

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
private static void fillUpAncestorIds(GoTermNode node,
        HashSet<String> ancestorsIds,
        IsAGoRel goParentRel,
        RelationshipIndex goParentRelIndex,
        int call) {

    ancestorsIds.add(node.getId());

    //logger.log(Level.INFO, ("fillUpAncestorIds (v2) --> " + node.getId() + " call: " + call));


    Iterator<Relationship> relIterator = goParentRelIndex.get(IsAGoRel.IS_A_REL_INDEX, String.valueOf(node.getNode().getId())).iterator();
    if (relIterator.hasNext()) {
        node = new GoTermNode(relIterator.next().getEndNode());

        fillUpAncestorIds(node, ancestorsIds, goParentRel, goParentRelIndex, call);
        while (relIterator.hasNext()) {
            node = new GoTermNode(relIterator.next().getEndNode());
            //logger.log(Level.INFO, ("double parent --> " + node.getId() + " call: " + call));
            fillUpAncestorIds(node, ancestorsIds, goParentRel, goParentRelIndex, call + 400000);
        }
    }


}
 
开发者ID:bio4j,项目名称:bio4j-neo4j,代码行数:26,代码来源:GoUtil.java

示例12: doGetForRelationships

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
@Test
public void doGetForRelationships()
{
    RelationshipIndex roles = graphDb.index().forRelationships( "roles" );

    // START SNIPPET: getSingleRelationship
    Relationship persephone = roles.get( "name", "Persephone" ).getSingle();
    Node actor = persephone.getStartNode();
    Node movie = persephone.getEndNode();
    // END SNIPPET: getSingleRelationship

    assertEquals( "Monica Bellucci", actor.getProperty( "name" ) );
    assertEquals( "The Matrix Reloaded", movie.getProperty( "title" ) );

    @SuppressWarnings("serial") List<String> expectedActors = new ArrayList<String>()
    {
        {
            add( "Keanu Reeves" );
            add( "Keanu Reeves" );
        }
    };
    List<String> foundActors = new ArrayList<>();

    // START SNIPPET: getRelationships
    for ( Relationship role : roles.get( "name", "Neo" ) )
    {
        // this will give us Reeves twice
        Node reeves = role.getStartNode();
        // END SNIPPET: getRelationships
        foundActors.add( (String) reeves.getProperty( "name" ) );
        // START SNIPPET: getRelationships
    }
    // END SNIPPET: getRelationships

    assertEquals( expectedActors, foundActors );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:37,代码来源:ImdbDocTest.java

示例13: testNodeLocalRelationshipIndex

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
@Test
public void testNodeLocalRelationshipIndex()
{
    RelationshipIndex index = relationshipIndex(
            LuceneIndexImplementation.EXACT_CONFIG );

    RelationshipType type = DynamicRelationshipType.withName( "YO" );
    Node startNode = graphDb.createNode();
    Node endNode1 = graphDb.createNode();
    Node endNode2 = graphDb.createNode();
    Relationship rel1 = startNode.createRelationshipTo( endNode1, type );
    Relationship rel2 = startNode.createRelationshipTo( endNode2, type );
    index.add( rel1, "name", "something" );
    index.add( rel2, "name", "something" );

    for ( int i = 0; i < 2; i++ )
    {
        assertThat( index.query( "name:something" ), contains( rel1, rel2 ) );
        assertThat( index.query( "name:something", null, endNode1 ), contains( rel1 ) );
        assertThat( index.query( "name:something", startNode, endNode2 ), contains( rel2 ) );
        assertThat( index.query( null, startNode, endNode1 ), contains( rel1 ) );
        assertThat( index.get( "name", "something", null, endNode1 ), contains( rel1 ) );
        assertThat( index.get( "name", "something", startNode, endNode2 ), contains( rel2 ) );
        assertThat( index.get( null, null, startNode, endNode1 ), contains( rel1 ) );

        restartTx();
    }

    rel2.delete();
    rel1.delete();
    startNode.delete();
    endNode1.delete();
    endNode2.delete();
    index.delete();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:36,代码来源:TestLuceneIndex.java

示例14: relationshipTimeline

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
private TimelineIndex<PropertyContainer> relationshipTimeline()
{
    try( Transaction tx = db.beginTx() )
    {
        RelationshipIndex relationshipIndex = db.index().forRelationships( "timeline" );
        tx.success();
        return new LuceneTimeline( db, relationshipIndex );
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:10,代码来源:TestTimeline.java

示例15: getOrCreateRelationshipIndex

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
RelationshipIndex getOrCreateRelationshipIndex( String indexName,
        Map<String, String> customConfiguration )
{
    Map<String, String> config = getOrCreateIndexConfig(
            Relationship.class, indexName, customConfiguration );
    return getIndexProvider( config.get( PROVIDER ) ).relationshipIndex(
            indexName, config );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:9,代码来源:IndexManagerImpl.java


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