use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class FileSystemClosingBatchInserterTest method closeFileSystemOnShutdown.
@Test
public void closeFileSystemOnShutdown() throws Exception {
BatchInserter batchInserter = mock(BatchInserter.class);
IndexConfigStoreProvider configStoreProvider = mock(IndexConfigStoreProvider.class);
FileSystemAbstraction fileSystem = mock(FileSystemAbstraction.class);
FileSystemClosingBatchInserter inserter = new FileSystemClosingBatchInserter(batchInserter, configStoreProvider, fileSystem);
inserter.shutdown();
InOrder verificationOrder = inOrder(batchInserter, fileSystem);
verificationOrder.verify(batchInserter).shutdown();
verificationOrder.verify(fileSystem).close();
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertionIT method shouldBeAbleToMakeRepeatedCallsToSetNodeProperty.
@Test
public void shouldBeAbleToMakeRepeatedCallsToSetNodeProperty() throws Exception {
File file = new File(dbRule.getStoreDirAbsolutePath());
BatchInserter inserter = BatchInserters.inserter(file, fileSystemRule.get());
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.getGraphDatabaseAPI();
try (Transaction ignored = db.beginTx()) {
assertThat(db.getNodeById(nodeId).getProperty("a"), equalTo(finalValue));
} finally {
db.shutdown();
}
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertionIT method shouldNotIndexNodesWithWrongLabel.
@Test
public void shouldNotIndexNodesWithWrongLabel() throws Exception {
// Given
File file = new File(dbRule.getStoreDirAbsolutePath());
BatchInserter inserter = BatchInserters.inserter(file, fileSystemRule.get());
inserter.createNode(map("name", "Bob"), label("User"), label("Admin"));
inserter.createDeferredSchemaIndex(label("Banana")).on("name").create();
// When
inserter.shutdown();
// Then
GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
try (Transaction tx = db.beginTx()) {
assertThat(count(db.findNodes(label("Banana"), "name", "Bob")), equalTo(0L));
} finally {
db.shutdown();
}
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertionIT method shouldBeAbleToMakeRepeatedCallsToSetNodePropertyWithMultiplePropertiesPerBlock.
@Test
public void shouldBeAbleToMakeRepeatedCallsToSetNodePropertyWithMultiplePropertiesPerBlock() throws Exception {
File file = new File(dbRule.getStoreDirAbsolutePath());
BatchInserter inserter = BatchInserters.inserter(file, fileSystemRule.get());
long nodeId = inserter.createNode(Collections.<String, Object>emptyMap());
final Object finalValue1 = 87;
final Object finalValue2 = 3.14;
inserter.setNodeProperty(nodeId, "a", "some property value");
inserter.setNodeProperty(nodeId, "a", 42);
inserter.setNodeProperty(nodeId, "b", finalValue2);
inserter.setNodeProperty(nodeId, "a", finalValue2);
inserter.setNodeProperty(nodeId, "a", true);
inserter.setNodeProperty(nodeId, "a", finalValue1);
inserter.shutdown();
GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
try (Transaction ignored = db.beginTx()) {
assertThat(db.getNodeById(nodeId).getProperty("a"), equalTo(finalValue1));
assertThat(db.getNodeById(nodeId).getProperty("b"), equalTo(finalValue2));
} finally {
db.shutdown();
}
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertionIT method makeSureCantCreateNodeWithMagicNumber.
@Test(expected = ReservedIdException.class)
public void makeSureCantCreateNodeWithMagicNumber() throws IOException {
// given
File path = new File(dbRule.getStoreDirAbsolutePath());
BatchInserter inserter = BatchInserters.inserter(path, fileSystemRule.get());
try {
// when
long id = IdGeneratorImpl.INTEGER_MINUS_ONE;
inserter.createNode(id, null);
// then throws
} finally {
inserter.shutdown();
}
}
Aggregations