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


Java Schema类代码示例

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


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

示例1: setupSchemaIndexes

import org.neo4j.graphdb.schema.Schema; //导入依赖的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

示例2: WikiNerGraphConnector

import org.neo4j.graphdb.schema.Schema; //导入依赖的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

示例3: run

import org.neo4j.graphdb.schema.Schema; //导入依赖的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

示例4: prepareSchema

import org.neo4j.graphdb.schema.Schema; //导入依赖的package包/类
public static void prepareSchema(GraphDatabaseService db) {
    try (Transaction tx = db.beginTx()) {
        Schema schema = db.schema();
        schema.indexFor(NodeLabel.Class).on("name").create();
        schema.indexFor(NodeLabel.Method).on("name").create();
        schema.indexFor(NodeLabel.Annotation).on("name").create();
        tx.success();
    }
}
 
开发者ID:structgraph,项目名称:structgraph,代码行数:10,代码来源:Graph.java

示例5: shouldLoadAndUseLuceneProvider

import org.neo4j.graphdb.schema.Schema; //导入依赖的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

示例6: createIndexes

import org.neo4j.graphdb.schema.Schema; //导入依赖的package包/类
public void createIndexes() {
	try (Transaction tx = graphDb.beginTx()) {
		Schema schema = graphDb.schema();
		schema.indexFor(DynamicLabel.label(LAB_SUBJECT))
				.on(PROP_NAME).create();
		tx.success();
	}
}
 
开发者ID:5agado,项目名称:knowledge-extraction,代码行数:9,代码来源:Neo4JDb.java

示例7: NubDb

import org.neo4j.graphdb.schema.Schema; //导入依赖的package包/类
private NubDb(UsageDao dao, AuthorComparator authorComparator, boolean initialize) {
  this.dao = dao;
  authComp = authorComparator;
  // persistent indices?
  if (initialize) {
    try (Transaction tx = dao.beginTx()) {
      Schema schema = dao.getNeo().schema();
      schema.indexFor(Labels.TAXON).on(NeoProperties.CANONICAL_NAME).create();
      tx.success();
    }
  }
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:13,代码来源:NubDb.java

示例8: testNeoIndices

import org.neo4j.graphdb.schema.Schema; //导入依赖的package包/类
@Test
public void testNeoIndices() throws Exception {
  final UUID datasetKey = datasetKey(1);

  Normalizer norm = Normalizer.create(cfg, datasetKey);
  norm.run();

  openDb(datasetKey);
  compareStats(norm.getStats());

  Set<String> taxonIndices = Sets.newHashSet();
  taxonIndices.add(NeoProperties.TAXON_ID);
  taxonIndices.add(NeoProperties.SCIENTIFIC_NAME);
  taxonIndices.add(NeoProperties.CANONICAL_NAME);
  try (Transaction tx = beginTx()) {
    Schema schema = dao.getNeo().schema();
    for (IndexDefinition idf : schema.getIndexes(Labels.TAXON)) {
      List<String> idxProps = Iterables.asList(idf.getPropertyKeys());
      assertTrue(idxProps.size() == 1);
      assertTrue(taxonIndices.remove(idxProps.get(0)));
    }

    assertNotNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.TAXON_ID, "1001")));
    assertNotNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.SCIENTIFIC_NAME, "Crepis bakeri Greene")));
    assertNotNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.CANONICAL_NAME, "Crepis bakeri")));

    assertNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.TAXON_ID, "x1001")));
    assertNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.SCIENTIFIC_NAME, "xCrepis bakeri Greene")));
    assertNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.CANONICAL_NAME, "xCrepis bakeri")));
  }
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:32,代码来源:NormalizerTest.java

示例9: createIndex

import org.neo4j.graphdb.schema.Schema; //导入依赖的package包/类
public void createIndex(){
    try ( Transaction tx = graphDatabaseService.beginTx() )
    {
        Schema schema = graphDatabaseService.schema();
        if(schema.getIndexes(DynamicLabel.label("Variable")).iterator().hasNext()) {
                 schema.indexFor(DynamicLabel.label("Variable"))
                .on("app_key")
                .create();
         }
        if(schema.getIndexes(DynamicLabel.label("Method")).iterator().hasNext()) {
            schema.indexFor(DynamicLabel.label("Method"))
                    .on("app_key")
                    .create();
            schema.indexFor(DynamicLabel.label("Method"))
                    .on("is_static")
                    .create();
        }
        if(schema.getIndexes(DynamicLabel.label("Argument")).iterator().hasNext()) {
            schema.indexFor(DynamicLabel.label("Argument"))
                    .on("app_key")
                    .create();
            schema.indexFor(DynamicLabel.label("Argument"))
                    .on("app_key")
                    .create();
        }
        if(schema.getIndexes(DynamicLabel.label("ExternalClass")).iterator().hasNext()) {
            schema.indexFor(DynamicLabel.label("ExternalClass"))
                    .on("app_key")
                    .create();
        }
        if(schema.getIndexes(DynamicLabel.label("ExternalMethod")).iterator().hasNext()) {
            schema.indexFor(DynamicLabel.label("ExternalMethod"))
                    .on("app_key")
                    .create();
        }
        tx.success();
    }
    try ( Transaction tx = graphDatabaseService.beginTx() )
    {
        org.neo4j.graphdb.index.IndexManager index = graphDatabaseService.index();
        if(!index.existsForRelationships("calls")) {
            index.forRelationships("calls");
        }
        tx.success();
    }
}
 
开发者ID:GeoffreyHecht,项目名称:paprika,代码行数:47,代码来源:IndexManager.java

示例10: deleteSomeSchemaIndices

import org.neo4j.graphdb.schema.Schema; //导入依赖的package包/类
private void deleteSomeSchemaIndices(final GraphDatabaseService database) throws DMPGraphException {

		MaintainResource.LOG.debug("start delete schema indices TX");

		try (final Transaction itx = database.beginTx()) {

			final Schema schema = database.schema();

			if (schema == null) {

				MaintainResource.LOG.debug("no schema available");

				itx.success();
				itx.close();

				return;
			}

			final Iterable<IndexDefinition> indexDefinitions = schema.getIndexes();

			if (indexDefinitions == null) {

				MaintainResource.LOG.debug("no schema indices available");

				itx.success();
				itx.close();

				return;
			}

			for (final IndexDefinition indexDefinition : indexDefinitions) {

				MaintainResource.LOG.debug("drop '{}' : '{}' schema index", indexDefinition.getLabel().name(),
						indexDefinition.getPropertyKeys().iterator().next());

				indexDefinition.drop();
			}

			itx.success();
			itx.close();
		} catch (final Exception e) {

			final String message = "couldn't finish delete schema indices TX successfully";

			MaintainResource.LOG.error(message, e);

			throw new DMPGraphException(message);
		}

		MaintainResource.LOG.debug("finished delete schema indices TX");
	}
 
开发者ID:dswarm,项目名称:dswarm-graph-neo4j,代码行数:52,代码来源:MaintainResource.java


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