use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method shouldCreateDeferredUniquenessConstraintInEmptyDatabase.
@Test
public void shouldCreateDeferredUniquenessConstraintInEmptyDatabase() throws Exception {
// GIVEN
BatchInserter inserter = newBatchInserter();
// WHEN
ConstraintDefinition definition = inserter.createDeferredConstraint(label("Hacker")).assertPropertyIsUnique("handle").create();
// THEN
assertEquals("Hacker", definition.getLabel().name());
assertEquals(ConstraintType.UNIQUENESS, definition.getConstraintType());
assertEquals(asSet("handle"), Iterables.asSet(definition.getPropertyKeys()));
inserter.shutdown();
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method shouldRunIndexPopulationJobAtShutdown.
@Test
public void shouldRunIndexPopulationJobAtShutdown() throws Throwable {
// GIVEN
IndexPopulator populator = mock(IndexPopulator.class);
SchemaIndexProvider provider = mock(SchemaIndexProvider.class);
when(provider.getProviderDescriptor()).thenReturn(InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR);
when(provider.getPopulator(anyLong(), any(NewIndexDescriptor.class), any(IndexSamplingConfig.class))).thenReturn(populator);
BatchInserter inserter = newBatchInserterWithSchemaIndexProvider(singleInstanceSchemaIndexProviderFactory(InMemoryIndexProviderFactory.KEY, provider));
inserter.createDeferredSchemaIndex(label("Hacker")).on("handle").create();
long nodeId = inserter.createNode(map("handle", "Jakewins"), label("Hacker"));
// WHEN
inserter.shutdown();
// THEN
verify(provider).init();
verify(provider).start();
verify(provider).getPopulator(anyLong(), any(NewIndexDescriptor.class), any(IndexSamplingConfig.class));
verify(populator).create();
verify(populator).add(singletonList(IndexEntryUpdate.add(nodeId, internalIndex.schema(), "Jakewins")));
verify(populator).verifyDeferredConstraints(any(PropertyAccessor.class));
verify(populator).close(true);
verify(provider).stop();
verify(provider).shutdown();
verifyNoMoreInteractions(populator);
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method messagesLogGetsClosed.
@Test
public void messagesLogGetsClosed() throws Exception {
File storeDir = this.storeDir.graphDbDir();
BatchInserter inserter = BatchInserters.inserter(storeDir, fileSystemRule.get(), stringMap());
inserter.shutdown();
assertTrue(new File(storeDir, StoreLogService.INTERNAL_LOG_NAME).delete());
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method createEntitiesWithDynamicPropertiesMap.
@Test
public void createEntitiesWithDynamicPropertiesMap() throws Exception {
BatchInserter inserter = globalInserter;
setAndGet(inserter, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
setAndGet(inserter, intArray(20));
}
use of org.neo4j.unsafe.batchinsert.BatchInserter in project neo4j by neo4j.
the class BatchInsertTest method createEntitiesWithEmptyPropertiesMap.
@Test
public void createEntitiesWithEmptyPropertiesMap() throws Exception {
BatchInserter inserter = globalInserter;
// Assert for node
long nodeId = inserter.createNode(map());
inserter.getNodeProperties(nodeId);
//cp=N U http://www.w3.org/1999/02/22-rdf-syntax-ns#type, c=N
// Assert for relationship
long anotherNodeId = inserter.createNode(null);
long relId = inserter.createRelationship(nodeId, anotherNodeId, RelTypes.BATCH_TEST, map());
inserter.getRelationshipProperties(relId);
}
Aggregations