本文整理匯總了Java中org.neo4j.graphdb.GraphDatabaseService.shutdown方法的典型用法代碼示例。如果您正苦於以下問題:Java GraphDatabaseService.shutdown方法的具體用法?Java GraphDatabaseService.shutdown怎麽用?Java GraphDatabaseService.shutdown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.neo4j.graphdb.GraphDatabaseService
的用法示例。
在下文中一共展示了GraphDatabaseService.shutdown方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: shouldNotIndexNodesWithWrongLabel
import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void shouldNotIndexNodesWithWrongLabel() throws Exception
{
// Given
BatchInserter inserter = BatchInserters.inserter( dbRule.getStoreDirAbsolutePath() );
inserter.createNode( map("name", "Bob"), label( "User" ), label("Admin"));
inserter.createDeferredSchemaIndex( label( "Banana" ) ).on( "name" ).create();
// When
inserter.shutdown();
// Then
GraphDatabaseService db = dbRule.getGraphDatabaseService();
try(Transaction tx = db.beginTx())
{
assertThat( count( db.findNodes( label( "Banana" ), "name", "Bob" ) ), equalTo(0) );
}
finally
{
db.shutdown();
}
}
示例2: shouldBeAbleToMakeRepeatedCallsToSetNodeProperty
import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void shouldBeAbleToMakeRepeatedCallsToSetNodeProperty() throws Exception
{
BatchInserter inserter = BatchInserters.inserter( dbRule.getStoreDirAbsolutePath() );
long nodeId = inserter.createNode( Collections.<String, Object>emptyMap() );
final Object finalValue = 87;
inserter.setNodeProperty( nodeId, "a", "some property value" );
inserter.setNodeProperty( nodeId, "a", 42 );
inserter.setNodeProperty( nodeId, "a", 3.14 );
inserter.setNodeProperty( nodeId, "a", true );
inserter.setNodeProperty( nodeId, "a", finalValue );
inserter.shutdown();
GraphDatabaseService db = dbRule.getGraphDatabaseService();
try(Transaction ignored = db.beginTx())
{
assertThat( db.getNodeById( nodeId ).getProperty( "a" ), equalTo( finalValue ) );
}
finally
{
db.shutdown();
}
}
示例3: insert_node_should_succeed_with_populated_index
import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void insert_node_should_succeed_with_populated_index() throws Exception {
Neo4jBatchInserterNode nodeInserter = getNeo4jBatchInserterNode(false);
// populate the db
List<String> columns = DummyTalendPojo.getColumnList();
for (int i = 0; i < 100; i++) {
DummyTalendPojo pojo = DummyTalendPojo.getDummyTalendPojo();
nodeInserter.create(pojo, columns);
}
nodeInserter.finish();
// check if index size
Assert.assertEquals(100, batchDb.batchInserterIndexes.get(INDEX_NAME).query("*:*").size());
// check the database data
batchDb.shutdown();
// Testing it with real graphdb
GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
try (Transaction tx = graphDb.beginTx()) {
String result = graphDb.execute("MATCH (n:" + LABEL_NAME + ") RETURN count(n) AS count").resultAsString();
Assert.assertEquals("+-------+\n| count |\n+-------+\n| 100 |\n+-------+\n1 row\n", result);
}
graphDb.shutdown();
}
示例4: update_node_should_succeed
import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void update_node_should_succeed() throws Exception {
// populate the db
Neo4jBatchInserterNode nodeInserter = getNeo4jBatchInserterNode(false);
List<String> columns = DummyTalendPojo.getColumnList();
DummyTalendPojo pojo = DummyTalendPojo.getDummyTalendPojo();
nodeInserter.create(pojo, columns);
nodeInserter.finish();
// By indexing the import id, I update the last node
pojo.propString = "A new String";
nodeInserter = getNeo4jBatchInserterNode(true);
nodeInserter.create(pojo, columns);
nodeInserter.finish();
// check the result into the database
batchDb.shutdown();
GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
try (Transaction tx = graphDb.beginTx()) {
String result = graphDb.execute("MATCH (n:" + LABEL_NAME + ") WHERE exists(n.id) RETURN n.propString AS string").resultAsString();
Assert.assertEquals("+----------------+\n| string |\n+----------------+\n| \"A new String\" |\n+----------------+\n1 row\n", result);
}
graphDb.shutdown();
}
示例5: create_node_uniqueness_constraint_should_work
import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void create_node_uniqueness_constraint_should_work() {
// Test const.
String label = "Test";
String property = "myProp";
// crete the schema
batchDb.createSchema("NODE_PROPERTY_UNIQUE", label, property);
batchDb.shutdown();
// Testing it with real graphdb
GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
try (Transaction tx = graphDb.beginTx()) {
Assert.assertTrue(graphDb.schema().getConstraints(DynamicLabel.label(label)).iterator().hasNext());
}
graphDb.shutdown();
}
示例6: create_node_index_should_work
import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void create_node_index_should_work() {
// Test const.
String label = "Test";
String property = "myProp";
// crete the schema
batchDb.createSchema("NODE_PROPERTY_INDEX", label, property);
batchDb.shutdown();
// Testing it with real graphdb
GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
try (Transaction tx = graphDb.beginTx()) {
Assert.assertTrue(graphDb.schema().getIndexes(DynamicLabel.label(label)).iterator().hasNext());
}
graphDb.shutdown();
}
示例7: testRelReader
import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void testRelReader() throws IOException{
RelReader reader = new RelReader(neo4jLocation);
reader.batchBuildGraph(new File("my_test_umls/"), "CtakesAllTuis.txt", "SNOMEDCT_US");
GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase(new File(neo4jLocation));
try ( Transaction tx = db.beginTx() ){
TraversalDescription td = db.traversalDescription()
.breadthFirst()
.relationships(RelReader.RelTypes.ISA, Direction.INCOMING)
.evaluator(Evaluators.excludeStartPosition());
Node cuiNode = db.findNode(RelReader.DictLabels.Concept, RelReader.CUI_PROPERTY, "C0007102");
Assert.assertNotNull(cuiNode);
Traverser traverser = td.traverse(cuiNode);
for(Path path : traverser){
System.out.println("At depth " + path.length() + " => " + path.endNode().getProperty("cui"));
}
}
db.shutdown();
}
示例8: executeBreadthFirstSearch
import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
private BreadthFirstSearchOutput executeBreadthFirstSearch(GraphStructure graph,
BreadthFirstSearchParameters parameters, boolean directed) {
GraphDatabaseService database = ValidationGraphLoader.loadValidationGraphToDatabase(graph);
new BreadthFirstSearchComputation(database, parameters.getSourceVertex(), directed).run();
Map<Long, Long> output = new HashMap<>();
try (Transaction ignored = database.beginTx()) {
for (Node node : GlobalGraphOperations.at(database).getAllNodes()) {
if (node.hasProperty(DISTANCE)) {
output.put((long)node.getProperty(ID_PROPERTY), (long)node.getProperty(DISTANCE));
} else {
output.put((long)node.getProperty(ID_PROPERTY), Long.MAX_VALUE);
}
}
}
database.shutdown();
return new BreadthFirstSearchOutput(output);
}
開發者ID:atlarge-research,項目名稱:graphalytics-platforms-neo4j,代碼行數:19,代碼來源:BreadthFirstSearchComputationTest.java
示例9: deleteIndex
import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void deleteIndex()
{
GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
try ( Transaction tx = graphDb.beginTx() )
{
// START SNIPPET: delete
IndexManager index = graphDb.index();
Index<Node> actors = index.forNodes( "actors" );
actors.delete();
// END SNIPPET: delete
tx.success();
}
assertFalse( indexExists( graphDb ) );
graphDb.shutdown();
}
示例10: dbWithConstraint
import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
private void dbWithConstraint()
{
GraphDatabaseService db = startDatabase();
try
{
try ( Transaction tx = db.beginTx() )
{
db.schema().constraintFor( label( "Label1" ) ).assertPropertyIsUnique( "key1" ).create();
tx.success();
}
}
finally
{
db.shutdown();
}
}
示例11: canReadAndUpgradeOldIndexStoreFormat
import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void canReadAndUpgradeOldIndexStoreFormat() throws Exception
{
File path = new File( "target/var/old-index-store" );
Neo4jTestCase.deleteFileOrDirectory( path );
startDatabase( path ).shutdown();
InputStream stream = getClass().getClassLoader().getResourceAsStream( "old-index.db" );
writeFile( stream, new File( path, "index.db" ) );
GraphDatabaseService db = startDatabase( path );
try ( Transaction ignore = db.beginTx() )
{
assertTrue( db.index().existsForNodes( "indexOne" ) );
Index<Node> indexOne = db.index().forNodes( "indexOne" );
verifyConfiguration( db, indexOne, LuceneIndexImplementation.EXACT_CONFIG );
assertTrue( db.index().existsForNodes( "indexTwo" ) );
Index<Node> indexTwo = db.index().forNodes( "indexTwo" );
verifyConfiguration( db, indexTwo, LuceneIndexImplementation.FULLTEXT_CONFIG );
assertTrue( db.index().existsForRelationships( "indexThree" ) );
Index<Relationship> indexThree = db.index().forRelationships( "indexThree" );
verifyConfiguration( db, indexThree, LuceneIndexImplementation.EXACT_CONFIG );
}
db.shutdown();
}
示例12: main
import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
public static void main( String[] args )
{
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( args[0] );
Index<Node> index;
Index<Node> index2;
try ( Transaction tx = db.beginTx() )
{
index = db.index().forNodes( "index" );
index2 = db.index().forNodes( "index2" );
Node node = db.createNode();
index.add( node, "key", "value" );
tx.success();
}
try ( Transaction tx = db.beginTx() )
{
index.delete();
index2.add( db.createNode(), "key", "value" );
tx.success();
}
db.shutdown();
System.exit( 0 );
}
示例13: concurrentIndexPopulationAndInsertsShouldNotProduceDuplicates
import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void concurrentIndexPopulationAndInsertsShouldNotProduceDuplicates() throws IOException
{
// Given
GraphDatabaseService db = newEmbeddedGraphDatabaseWithSlowJobScheduler();
// When
try ( Transaction tx = db.beginTx() )
{
db.schema().indexFor( label( "SomeLabel" ) ).on( "key" ).create();
tx.success();
}
Node node;
try ( Transaction tx = db.beginTx() )
{
node = db.createNode( label( "SomeLabel" ) );
node.setProperty( "key", "value" );
tx.success();
}
db.shutdown();
// Then
assertThat( nodeIdsInIndex( 1, "value" ), equalTo( singletonList( node.getId() ) ) );
}
示例14: execute_import_should_succeed
import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void execute_import_should_succeed() throws IOException {
this.importTool.execute();
// Testing it with real graphdb
GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
try (Transaction tx = graphDb.beginTx()) {
String result = graphDb.execute("MATCH ()-[r]->() RETURN count(r) AS count").resultAsString();
Assert.assertEquals("+-------+\n| count |\n+-------+\n| 9 |\n+-------+\n1 row\n", result);
}
graphDb.shutdown();
}
示例15: insert_edge_should_succeed
import org.neo4j.graphdb.GraphDatabaseService; //導入方法依賴的package包/類
@Test
public void insert_edge_should_succeed() throws Exception {
Neo4jBatchInserterNode nodeInserter = getNeo4jBatchInserterNode(false);
// populate the db with nodes
List<String> columns = DummyTalendPojo.getColumnList();
for (int i = 0; i < 100; i++) {
DummyTalendPojo pojo = DummyTalendPojo.getDummyTalendPojo(i);
nodeInserter.create(pojo, columns);
}
nodeInserter.finish();
// create relationship
Neo4jBatchInserterRelationship batchInserterRelationship = getNeo4jBatchInserterRelationship(true);
for (int i = 0; i < 100; i++) {
batchInserterRelationship.create(DummyTalendPojo.getDummyTalendPojo(i), DummyTalendPojo.getColumnList());
}
batchInserterRelationship.finish();
// check the database data
batchDb.shutdown();
// Testing it with real graphdb
GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
try (Transaction tx = graphDb.beginTx()) {
String result = graphDb.execute("MATCH ()-[r:" + REL_TYPE + "]->() RETURN count(r) AS count").resultAsString();
Assert.assertEquals("+-------+\n| count |\n+-------+\n| 100 |\n+-------+\n1 row\n", result);
}
graphDb.shutdown();
}