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


Java IndexDefinition类代码示例

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


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

示例1: convertIndexToConstraint

import org.neo4j.graphdb.schema.IndexDefinition; //导入依赖的package包/类
@Test
public void convertIndexToConstraint()
{
    try( Transaction tx = graphDb.beginTx() )
    {
        graphDb.schema().indexFor( LABEL ).on( PROPERTY_KEY ).create();
        tx.success();
    }

    try( Transaction tx = graphDb.beginTx() )
    {
        IndexDefinition index = first( graphDb.schema().getIndexes( LABEL ) );
        index.drop();

        graphDb.schema().constraintFor( LABEL ).assertPropertyIsUnique( PROPERTY_KEY ).create();
        tx.success();
    }
    // assert no exception is thrown
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:20,代码来源:IndexConstraintsTest.java

示例2: getIndex

import org.neo4j.graphdb.schema.IndexDefinition; //导入依赖的package包/类
private IndexDefinition getIndex( Label label, String propertyKey )
{
    try ( Transaction tx = graphDb.beginTx() )
    {
        IndexDefinition found = null;
        for ( IndexDefinition index : graphDb.schema().getIndexes( label ) )
        {
            if ( propertyKey.equals( single( index.getPropertyKeys() ) ) )
            {
                assertNull( "Found multiple indexes.", found );
                found = index;
            }
        }
        tx.success();
        return found;
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:18,代码来源:IndexConstraintsTest.java

示例3: changeShouldBeIdempotentWhenDoingRecovery

import org.neo4j.graphdb.schema.IndexDefinition; //导入依赖的package包/类
@Test
public void changeShouldBeIdempotentWhenDoingRecovery() throws Exception
{
    // Given
    startDb( createLuceneIndexFactory() );

    IndexDefinition indexDefinition = createIndex( myLabel );
    waitForIndex( indexDefinition );

    long node = createNode( myLabel, 12 );
    rotateLogsAndCheckPoint();

    updateNode( node, 13 );

    // And Given
    killDb();

    // When
    startDb( createLuceneIndexFactory() );

    // Then
    assertEquals( 0, doIndexLookup( myLabel, 12 ).size() );
    assertEquals( 1, doIndexLookup( myLabel, 13 ).size() );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:25,代码来源:LuceneIndexRecoveryIT.java

示例4: removeShouldBeIdempotentWhenDoingRecovery

import org.neo4j.graphdb.schema.IndexDefinition; //导入依赖的package包/类
@Test
public void removeShouldBeIdempotentWhenDoingRecovery() throws Exception
{
    // Given
    startDb( createLuceneIndexFactory() );

    IndexDefinition indexDefinition = createIndex( myLabel );
    waitForIndex( indexDefinition );

    long node = createNode( myLabel, 12 );
    rotateLogsAndCheckPoint();

    deleteNode( node );

    // And Given
    killDb();

    // When
    startDb( createLuceneIndexFactory() );

    // Then
    assertEquals( 0, doIndexLookup( myLabel, 12 ).size() );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:24,代码来源:LuceneIndexRecoveryIT.java

示例5: shouldNotUpdateTwiceDuringRecovery

import org.neo4j.graphdb.schema.IndexDefinition; //导入依赖的package包/类
@Test
public void shouldNotUpdateTwiceDuringRecovery() throws Exception
{
    // Given
    startDb( createLuceneIndexFactory() );

    IndexDefinition indexDefinition = createIndex( myLabel );
    waitForIndex( indexDefinition );

    long nodeId = createNode( myLabel, 12 );
    updateNode( nodeId, 14 );

    // And Given
    killDb();

    // When
    startDb( createLuceneIndexFactory() );

    // Then
    assertEquals( 0, doIndexLookup( myLabel, 12 ).size() );
    assertEquals( 1, doIndexLookup( myLabel, 14 ).size() );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:23,代码来源:LuceneIndexRecoveryIT.java

示例6: recoveryAfterCreateAndDropIndex

import org.neo4j.graphdb.schema.IndexDefinition; //导入依赖的package包/类
@Test
public void recoveryAfterCreateAndDropIndex() throws Exception
{
    // GIVEN
    IndexDefinition indexDefinition = createIndex( db, label, propertyKey );
    createSomeData( label, propertyKey );
    doStuff( db, label, propertyKey );
    dropIndex( indexDefinition );
    doStuff( db, label, propertyKey );

    // WHEN
    crashAndRestart();

    // THEN
    assertThat( getIndexes( db, label ), isEmpty() );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:17,代码来源:SchemaIndexAcceptanceTest.java

示例7: setupSchemaIndexes

import org.neo4j.graphdb.schema.IndexDefinition; //导入依赖的package包/类
public static void setupSchemaIndexes(GraphDatabaseService graphDb, Neo4jConfiguration config) {
  Map<String, Set<String>> schemaIndexes = config.getSchemaIndexes();
  for (Map.Entry<String, Set<String>> entry : schemaIndexes.entrySet()) {
    Label label = Label.label(entry.getKey());
    for (String property : entry.getValue()) {
      try (Transaction tx = graphDb.beginTx()) {
        Schema schema = graphDb.schema();
        IndexDefinition indexDefinition = schema.indexFor(label).on(property).create();
        tx.success();
        tx.close();

        Transaction tx2 = graphDb.beginTx();
        schema.awaitIndexOnline(indexDefinition, 2, TimeUnit.MINUTES);
        tx2.success();
        tx2.close();
      }
    }
  }
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:20,代码来源:Neo4jModule.java

示例8: WikiNerGraphConnector

import org.neo4j.graphdb.schema.IndexDefinition; //导入依赖的package包/类
private WikiNerGraphConnector(String dbDir) {
	graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbDir);
	IndexDefinition indexDefinition;
	Schema schema;
	Transaction tx = graphDb.beginTx();	
	
	schema = graphDb.schema();
	IndexManager index = graphDb.index();
	entities = index.forNodes(entityLabel.name());
	cities = index.forNodes(cityLabel.name());
	try{
		 indexDefinition = schema.indexFor( entityLabel ).on( "nameType" ).create();
	}catch(Exception e){
		
	}
	
	tx.success();
	tx.close();
}
 
开发者ID:drossner,项目名称:WikiN-G-ER,代码行数:20,代码来源:WikiNerGraphConnector.java

示例9: run

import org.neo4j.graphdb.schema.IndexDefinition; //导入依赖的package包/类
public NeoProfile run(NeoProfiler parent) {
	SchemaProfile p = new SchemaProfile();
	
	try(Transaction tx = parent.getDB().beginTx()) {
		Schema schema = parent.getDB().schema();
	
		Iterator<ConstraintDefinition> constraints = schema.getConstraints().iterator();
					
		while(constraints.hasNext()) {			
			ConstraintDefinition c = constraints.next();				
			p.addConstraint(new NeoConstraint(true, false, c.getPropertyKeys(), c.getLabel(), c.getConstraintType()));				
		}
					
		Iterator<IndexDefinition> idxs = schema.getIndexes().iterator();
		while(idxs.hasNext()) {
			IndexDefinition idx = idxs.next();
			p.addConstraint(new NeoConstraint(idx.isConstraintIndex(), true, idx.getPropertyKeys(), idx.getLabel(), null));				
		}
	}
	return p;
}
 
开发者ID:moxious,项目名称:neoprofiler,代码行数:22,代码来源:SchemaProfiler.java

示例10: doesIndexExist

import org.neo4j.graphdb.schema.IndexDefinition; //导入依赖的package包/类
private boolean doesIndexExist(Iterable<IndexDefinition> indexes, String name, String on) {
	for (IndexDefinition index : indexes) {
		if (index.getLabel().equals(Label.label(name))
				&& StreamSupport.stream(index.getPropertyKeys().spliterator(), false).anyMatch(on::equals)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:phenopolis,项目名称:pheno4j,代码行数:10,代码来源:DatabaseIndexCreator.java

示例11: shouldLoadAndUseLuceneProvider

import org.neo4j.graphdb.schema.IndexDefinition; //导入依赖的package包/类
@Test
public void shouldLoadAndUseLuceneProvider() throws Exception
{
    // GIVEN
    File storeDir = testDirectory.graphDbDir();
    BatchInserter inserter = BatchInserters.inserter( storeDir );
    inserter.createDeferredSchemaIndex( LABEL ).on( "name" ).create();

    // WHEN
    inserter.createNode( map( "name", "Mattias" ), LABEL );
    inserter.shutdown();

    // THEN
    GraphDatabaseFactory graphDatabaseFactory = new TestGraphDatabaseFactory();
    GraphDatabaseAPI db = (GraphDatabaseAPI) graphDatabaseFactory.newEmbeddedDatabase( storeDir );
    DependencyResolver dependencyResolver = db.getDependencyResolver();
    SchemaIndexProvider schemaIndexProvider = dependencyResolver.resolveDependency(
            SchemaIndexProvider.class,
            SchemaIndexProvider.HIGHEST_PRIORITIZED_OR_NONE );

    // assert the indexProvider is a Lucene one
    try ( Transaction ignore = db.beginTx() )
    {
        IndexDefinition indexDefinition = single( db.schema().getIndexes( LABEL ) );
        assertThat( db.schema().getIndexState( indexDefinition ), is( Schema.IndexState.ONLINE ) );
        assertThat( schemaIndexProvider, instanceOf( LuceneSchemaIndexProvider.class ) );
    }

    // CLEANUP
    db.shutdown();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:32,代码来源:TestLuceneSchemaBatchInsertIT.java

示例12: convertIndexToConstraintWithExistingData

import org.neo4j.graphdb.schema.IndexDefinition; //导入依赖的package包/类
@Test
public void convertIndexToConstraintWithExistingData()
{
    try( Transaction tx = graphDb.beginTx() )
    {
        for ( int i = 0; i < 2000; i++)
        {
            Node node = graphDb.createNode( LABEL );
            node.setProperty( PROPERTY_KEY, i );
        }
        tx.success();
    }

    try( Transaction tx = graphDb.beginTx() )
    {
        graphDb.schema().indexFor( LABEL ).on( PROPERTY_KEY ).create();
        tx.success();
    }

    try( Transaction tx = graphDb.beginTx() )
    {
        IndexDefinition index = first( graphDb.schema().getIndexes( LABEL ) );
        index.drop();

        graphDb.schema().constraintFor( LABEL ).assertPropertyIsUnique( PROPERTY_KEY ).create();
        tx.success();
    }
    // assert no exception is thrown
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:30,代码来源:IndexConstraintsTest.java

示例13: recreate

import org.neo4j.graphdb.schema.IndexDefinition; //导入依赖的package包/类
private IndexDefinition recreate( IndexDefinition index, int times )
{
    for ( int i = 0; i < times; i++ )
    {
        index.drop();
        index = graphDb.schema()
                .indexFor( index.getLabel() )
                .on( single( index.getPropertyKeys() ) )
                .create();
    }
    return index;
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:13,代码来源:IndexConstraintsTest.java

示例14: addShouldBeIdempotentWhenDoingRecovery

import org.neo4j.graphdb.schema.IndexDefinition; //导入依赖的package包/类
@Test
public void addShouldBeIdempotentWhenDoingRecovery() throws Exception
{
    // Given
    startDb( createLuceneIndexFactory() );

    IndexDefinition index = createIndex( myLabel );
    waitForIndex( index );

    long nodeId = createNode( myLabel, 12 );
    try(Transaction tx = db.beginTx())
    {
        assertNotNull( db.getNodeById( nodeId ) );
    }
    assertEquals( 1, doIndexLookup( myLabel, 12 ).size() );

    // And Given
    killDb();

    // When
    startDb( createLuceneIndexFactory() );

    // Then
    try(Transaction tx = db.beginTx())
    {
        assertNotNull( db.getNodeById( nodeId ) );
    }
    assertEquals( 1, doIndexLookup( myLabel, 12 ).size() );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:30,代码来源:LuceneIndexRecoveryIT.java

示例15: shouldNotAddTwiceDuringRecoveryIfCrashedDuringPopulation

import org.neo4j.graphdb.schema.IndexDefinition; //导入依赖的package包/类
@Test
public void shouldNotAddTwiceDuringRecoveryIfCrashedDuringPopulation() throws Exception
{
    // Given
    startDb( createAlwaysInitiallyPopulatingLuceneIndexFactory() );

    IndexDefinition indexDefinition = createIndex( myLabel );
    waitForIndex( indexDefinition );

    long nodeId = createNode( myLabel, 12 );
    assertEquals( 1, doIndexLookup( myLabel, 12 ).size() );

    // And Given
    killDb();

    // When
    startDb( createAlwaysInitiallyPopulatingLuceneIndexFactory() );

    try ( Transaction tx = db.beginTx() )
    {
        IndexDefinition index = db.schema().getIndexes().iterator().next();
        waitForIndex( index );

        // Then
        assertEquals( 12, db.getNodeById( nodeId ).getProperty( NUM_BANANAS_KEY ) );
        assertEquals( 1, doIndexLookup( myLabel, 12 ).size() );
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:29,代码来源:LuceneIndexRecoveryIT.java


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