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

Java RelationshipIndex类代码示例

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

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



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


示例16: forRelationships

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
public RelationshipIndex forRelationships( String indexName,
        Map<String, String> customConfiguration )
{
    RelationshipIndex toReturn = getOrCreateRelationshipIndex( indexName,
            customConfiguration );
    if ( RelationshipAutoIndexerImpl.RELATIONSHIP_AUTO_INDEX.equals( indexName ) )
    {
        toReturn = new RelationshipAutoIndexerImpl.RelationshipReadOnlyIndexToIndexAdapter(
                toReturn );
    }
    return toReturn;
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:13,代码来源:IndexManagerImpl.java


示例17: updateRelationshipInIndex

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
@Override
public void updateRelationshipInIndex(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

            // See http://docs.neo4j.org/chunked/stable/indexing-update.html
            index.remove(rel, key, value.get());
            index.add(rel, key, value.get());
        } finally {
            suspendCurrentTrx("updateRelationshipInIndex");
        }
    } catch (Exception e) {
        Log.e(TAG, "Failed to update relationship in index '" + name + "'", e);
        err.setError(Errors.TRANSACTION, e.getMessage());
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:28,代码来源:DbWrapper.java


示例18: findEdgeById

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
@Override
public Optional<Edge> findEdgeById(UUID edgeId) {
  RelationshipIndex edgeIdIndex = getEdgeIdIndex();
  IndexHits<Relationship> hits = edgeIdIndex.query(TIM_ID, edgeId.toString());

  return hits.hasNext() ? traversal().E(hits.next().getId()).tryNext() : Optional.empty();
}
 
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:8,代码来源:Neo4jIndexHandler.java


示例19: CutIndexDB

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
public CutIndexDB(RelationshipIndex indexCut) {
	this.indexCut = indexCut;
}
 
开发者ID:rrocharoberto,项目名称:GraphPartitionFramework,代码行数:4,代码来源:CutIndexDB.java


示例20: setUpDb

import org.neo4j.graphdb.index.RelationshipIndex; //导入依赖的package包/类
@BeforeClass
public static void setUpDb()
{
    graphDb = new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().newGraphDatabase();
    try ( Transaction tx = graphDb.beginTx() )
    {
        // START SNIPPET: createIndexes
        IndexManager index = graphDb.index();
        Index<Node> actors = index.forNodes( "actors" );
        Index<Node> movies = index.forNodes( "movies" );
        RelationshipIndex roles = index.forRelationships( "roles" );
        // END SNIPPET: createIndexes

        // START SNIPPET: createNodes
        // Actors
        Node reeves = graphDb.createNode();
        reeves.setProperty( "name", "Keanu Reeves" );
        actors.add( reeves, "name", reeves.getProperty( "name" ) );
        Node bellucci = graphDb.createNode();
        bellucci.setProperty( "name", "Monica Bellucci" );
        actors.add( bellucci, "name", bellucci.getProperty( "name" ) );
        // multiple values for a field, in this case for search only
        // and not stored as a property.
        actors.add( bellucci, "name", "La Bellucci" );
        // Movies
        Node theMatrix = graphDb.createNode();
        theMatrix.setProperty( "title", "The Matrix" );
        theMatrix.setProperty( "year", 1999 );
        movies.add( theMatrix, "title", theMatrix.getProperty( "title" ) );
        movies.add( theMatrix, "year", theMatrix.getProperty( "year" ) );
        Node theMatrixReloaded = graphDb.createNode();
        theMatrixReloaded.setProperty( "title", "The Matrix Reloaded" );
        theMatrixReloaded.setProperty( "year", 2003 );
        movies.add( theMatrixReloaded, "title", theMatrixReloaded.getProperty( "title" ) );
        movies.add( theMatrixReloaded, "year", 2003 );
        Node malena = graphDb.createNode();
        malena.setProperty( "title", "Malèna" );
        malena.setProperty( "year", 2000 );
        movies.add( malena, "title", malena.getProperty( "title" ) );
        movies.add( malena, "year", malena.getProperty( "year" ) );
        // END SNIPPET: createNodes

        // START SNIPPET: createRelationships
        // we need a relationship type
        DynamicRelationshipType ACTS_IN = DynamicRelationshipType.withName( "ACTS_IN" );
        // create relationships
        Relationship role1 = reeves.createRelationshipTo( theMatrix, ACTS_IN );
        role1.setProperty( "name", "Neo" );
        roles.add( role1, "name", role1.getProperty( "name" ) );
        Relationship role2 = reeves.createRelationshipTo( theMatrixReloaded, ACTS_IN );
        role2.setProperty( "name", "Neo" );
        roles.add( role2, "name", role2.getProperty( "name" ) );
        Relationship role3 = bellucci.createRelationshipTo( theMatrixReloaded, ACTS_IN );
        role3.setProperty( "name", "Persephone" );
        roles.add( role3, "name", role3.getProperty( "name" ) );
        Relationship role4 = bellucci.createRelationshipTo( malena, ACTS_IN );
        role4.setProperty( "name", "Malèna Scordia" );
        roles.add( role4, "name", role4.getProperty( "name" ) );
        // END SNIPPET: createRelationships

        tx.success();
    }

    try ( Transaction tx = graphDb.beginTx() )
    {
        String title = "Movie and Actor Graph";
        try ( PrintWriter pw = AsciiDocGenerator.getPrintWriter( "target/docs/dev", title ) )
        {
            pw.println( AsciidocHelper.createGraphVizDeletingReferenceNode( title, graphDb, "initial" ) );
            pw.flush();
        }
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:74,代码来源:ImdbDocTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java PMD类代码示例发布时间:2022-05-22
下一篇:
Java PlatformAddress类代码示例发布时间: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