use of org.neo4j.kernel.api.schema.NodePropertyDescriptor in project neo4j by neo4j.
the class ResampleIndexProcedureTest method shouldLookUpTheIndexByLabelIdAndPropertyKeyId.
@Test
public void shouldLookUpTheIndexByLabelIdAndPropertyKeyId() throws ProcedureException, SchemaRuleNotFoundException, IndexNotFoundKernelException {
NewIndexDescriptor index = NewIndexDescriptorFactory.forLabel(0, 0);
when(operations.labelGetForName(anyString())).thenReturn(123);
when(operations.propertyKeyGetForName(anyString())).thenReturn(456);
when(operations.indexGetForLabelAndPropertyKey(anyObject())).thenReturn(index);
procedure.resampleIndex(":Person(name)");
verify(operations).indexGetForLabelAndPropertyKey(new NodePropertyDescriptor(123, 456));
}
use of org.neo4j.kernel.api.schema.NodePropertyDescriptor in project neo4j by neo4j.
the class UniquenessConstraintValidationIT method addingUniqueNodeWithUnrelatedValueShouldNotAffectLookup.
@Test
public void addingUniqueNodeWithUnrelatedValueShouldNotAffectLookup() throws Exception {
// given
createConstraint("Person", "id");
long ourNode;
{
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
ourNode = createLabeledNode(statement, "Person", "id", 1);
commit();
}
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
ReadOperations readOps = statement.readOperations();
int person = readOps.labelGetForName("Person");
int propId = readOps.propertyKeyGetForName("id");
NewIndexDescriptor idx = readOps.uniqueIndexGetForLabelAndPropertyKey(new NodePropertyDescriptor(person, propId));
// when
createLabeledNode(statement, "Person", "id", 2);
// then I should find the original node
assertThat(readOps.nodeGetFromUniqueIndexSeek(idx, exact(propId, 1)), equalTo(ourNode));
}
use of org.neo4j.kernel.api.schema.NodePropertyDescriptor in project neo4j by neo4j.
the class UniquenessConstraintValidationIT method unrelatedNodesWithSamePropertyShouldNotInterfereWithUniquenessCheck.
@Test
public void unrelatedNodesWithSamePropertyShouldNotInterfereWithUniquenessCheck() throws Exception {
// given
createConstraint("Person", "id");
long ourNode;
{
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
ourNode = createLabeledNode(statement, "Person", "id", 1);
createLabeledNode(statement, "Item", "id", 2);
commit();
}
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
ReadOperations readOps = statement.readOperations();
int person = readOps.labelGetForName("Person");
int propId = readOps.propertyKeyGetForName("id");
NewIndexDescriptor idx = readOps.uniqueIndexGetForLabelAndPropertyKey(new NodePropertyDescriptor(person, propId));
// when
createLabeledNode(statement, "Item", "id", 2);
// then I should find the original node
assertThat(readOps.nodeGetFromUniqueIndexSeek(idx, exact(propId, 1)), equalTo(ourNode));
}
use of org.neo4j.kernel.api.schema.NodePropertyDescriptor in project neo4j by neo4j.
the class DbStructureInvocationTracingAcceptanceTest method exerciseVisitor.
private void exerciseVisitor(Function<Object, DbStructureVisitor> visitor) {
visitor.apply(null).visitLabel(0, "Person");
visitor.apply(null).visitLabel(1, "Party");
visitor.apply(null).visitPropertyKey(0, "name");
visitor.apply(null).visitPropertyKey(1, "age");
visitor.apply(null).visitRelationshipType(0, "ACCEPTS");
visitor.apply(null).visitRelationshipType(1, "REJECTS");
visitor.apply(null).visitIndex(NewIndexDescriptorFactory.forLabel(0, 1), ":Person(age)", 0.5d, 1L);
visitor.apply(null).visitUniqueIndex(NewIndexDescriptorFactory.forLabel(0, 0), ":Person(name)", 0.5d, 1L);
visitor.apply(null).visitUniqueConstraint(new UniquenessConstraint(new NodePropertyDescriptor(1, 0)), ":Party(name)");
visitor.apply(null).visitAllNodesCount(55);
visitor.apply(null).visitNodeCount(0, "Person", 50);
visitor.apply(null).visitNodeCount(0, "Party", 5);
visitor.apply(null).visitRelCount(0, 1, -1, "MATCH (:Person)-[:REJECTS]->() RETURN count(*)", 5);
}
Aggregations