use of org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor in project neo4j by neo4j.
the class IndexEntryConflictExceptionTest method shouldMakeEntryConflicts.
@Test
public void shouldMakeEntryConflicts() {
LabelSchemaDescriptor schema = SchemaDescriptorFactory.forLabel(labelId, 2);
IndexEntryConflictException e = new IndexEntryConflictException(0L, 1L, "hi");
assertThat(e.evidenceMessage(SchemaUtil.idTokenNameLookup, schema), equalTo("Both Node(0) and Node(1) have the label `label[1]` and property `property[2]` = 'hi'"));
}
use of org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor in project neo4j by neo4j.
the class IndexEntryConflictExceptionTest method shouldMakeCompositeEntryConflicts.
@Test
public void shouldMakeCompositeEntryConflicts() {
LabelSchemaDescriptor schema = SchemaDescriptorFactory.forLabel(labelId, 2, 3, 4);
OrderedPropertyValues values = OrderedPropertyValues.ofUndefined(true, "hi", new long[] { 6L, 4L });
IndexEntryConflictException e = new IndexEntryConflictException(0L, 1L, values);
assertThat(e.evidenceMessage(SchemaUtil.idTokenNameLookup, schema), equalTo("Both Node(0) and Node(1) have the label `label[1]` " + "and properties `property[2]` = true, `property[3]` = 'hi', `property[4]` = [6, 4]"));
}
use of org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor in project neo4j by neo4j.
the class LockingStatementOperationsTest method shouldAcquireSchemaWriteLockBeforeAddingIndexRule.
@Test
public void shouldAcquireSchemaWriteLockBeforeAddingIndexRule() throws Exception {
// given
LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(123, 456);
NewIndexDescriptor index = NewIndexDescriptorFactory.forLabel(123, 456);
when(schemaWriteOps.indexCreate(state, descriptor)).thenReturn(index);
// when
NewIndexDescriptor result = lockingOps.indexCreate(state, descriptor);
// then
assertSame(index, result);
order.verify(locks).acquireExclusive(LockTracer.NONE, ResourceTypes.SCHEMA, schemaResource());
order.verify(schemaWriteOps).indexCreate(state, descriptor);
}
use of org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor in project neo4j by neo4j.
the class IndexPopulationJobTest method shouldPopulateIndexWithOneNode.
@Test
public void shouldPopulateIndexWithOneNode() throws Exception {
// GIVEN
String value = "Taylor";
long nodeId = createNode(map(name, value), FIRST);
IndexPopulator populator = spy(inMemoryPopulator(false));
IndexPopulationJob job = newIndexPopulationJob(populator, new FlippableIndexProxy(), false);
LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(0, 0);
// WHEN
job.run();
// THEN
IndexEntryUpdate update = IndexEntryUpdate.add(nodeId, descriptor, value);
verify(populator).create();
verify(populator).configureSampling(true);
verify(populator).includeSample(update);
verify(populator).add(anyListOf(IndexEntryUpdate.class));
verify(populator).sampleResult();
verify(populator).close(true);
verifyNoMoreInteractions(populator);
}
use of org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor in project neo4j by neo4j.
the class IndexCRUDIT method addingANodeWithPropertyShouldGetIndexed.
@Test
public void addingANodeWithPropertyShouldGetIndexed() throws Exception {
// Given
String indexProperty = "indexProperty";
GatheringIndexWriter writer = newWriter();
createIndex(db, myLabel, indexProperty);
// When
int value1 = 12;
String otherProperty = "otherProperty";
int otherValue = 17;
Node node = createNode(map(indexProperty, value1, otherProperty, otherValue), myLabel);
// Then, for now, this should trigger two NodePropertyUpdates
try (Transaction tx = db.beginTx()) {
ReadOperations readOperations = ctxSupplier.get().readOperations();
int propertyKey1 = readOperations.propertyKeyGetForName(indexProperty);
int label = readOperations.labelGetForName(myLabel.name());
LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(label, propertyKey1);
assertThat(writer.updatesCommitted, equalTo(asSet(IndexEntryUpdate.add(node.getId(), descriptor, value1))));
tx.success();
}
// We get two updates because we both add a label and a property to be indexed
// in the same transaction, in the future, we should optimize this down to
// one NodePropertyUpdate.
}
Aggregations