use of org.neo4j.kernel.api.properties.Property in project neo4j by neo4j.
the class StateOperationsAutoIndexingTest method shouldSignalNodePropertyChangedToAutoIndex.
@Test
public void shouldSignalNodePropertyChangedToAutoIndex() throws Exception {
// Given
DefinedProperty property = property(1, "Hello!");
PropertyItem existingProperty = mock(PropertyItem.class);
when(existingProperty.propertyKeyId()).thenReturn(property.propertyKeyId());
when(existingProperty.value()).thenReturn("Goodbye!");
NodeItem node = mock(NodeItem.class);
when(node.labels()).thenReturn(PrimitiveIntCollections.emptySet());
when(storeStmt.acquireSingleNodeCursor(1337)).thenReturn(cursor(node));
when(storeLayer.nodeGetProperty(eq(storeStmt), any(NodeItem.class), eq(property.propertyKeyId()))).thenReturn(cursor(existingProperty));
// When
context.nodeSetProperty(stmt, 1337, property);
// Then
verify(nodeOps).propertyChanged(eq(writeOps), eq(1337L), any(Property.class), eq(property));
}
use of org.neo4j.kernel.api.properties.Property in project neo4j by neo4j.
the class StateHandlingStatementOperations method graphSetProperty.
@Override
public Property graphSetProperty(KernelStatement state, DefinedProperty property) {
Object existingPropertyValue = graphGetProperty(state, property.propertyKeyId());
Property existingProperty = existingPropertyValue == null ? Property.noGraphProperty(property.propertyKeyId()) : Property.property(property.propertyKeyId(), existingPropertyValue);
state.txState().graphDoReplaceProperty(existingProperty, property);
return existingProperty;
}
use of org.neo4j.kernel.api.properties.Property in project neo4j by neo4j.
the class StateHandlingStatementOperations method relationshipRemoveProperty.
@Override
public Property relationshipRemoveProperty(KernelStatement state, long relationshipId, int propertyKeyId) throws EntityNotFoundException, InvalidTransactionTypeKernelException, AutoIndexingKernelException {
DataWriteOperations ops = state.dataWriteOperations();
try (Cursor<RelationshipItem> cursor = relationshipCursorById(state, relationshipId)) {
RelationshipItem relationship = cursor.get();
Property existingProperty;
try (Cursor<PropertyItem> properties = relationshipGetPropertyCursor(state, relationship, propertyKeyId)) {
if (!properties.next()) {
existingProperty = Property.noProperty(propertyKeyId, EntityType.RELATIONSHIP, relationship.id());
} else {
existingProperty = Property.property(properties.get().propertyKeyId(), properties.get().value());
autoIndexing.relationships().propertyRemoved(ops, relationshipId, propertyKeyId);
state.txState().relationshipDoRemoveProperty(relationship.id(), (DefinedProperty) existingProperty);
}
}
return existingProperty;
}
}
use of org.neo4j.kernel.api.properties.Property in project neo4j by neo4j.
the class StateHandlingStatementOperations method relationshipSetProperty.
@Override
public Property relationshipSetProperty(KernelStatement state, long relationshipId, DefinedProperty property) throws EntityNotFoundException, InvalidTransactionTypeKernelException, AutoIndexingKernelException {
DataWriteOperations ops = state.dataWriteOperations();
try (Cursor<RelationshipItem> cursor = relationshipCursorById(state, relationshipId)) {
RelationshipItem relationship = cursor.get();
Property existingProperty;
try (Cursor<PropertyItem> properties = relationshipGetPropertyCursor(state, relationship, property.propertyKeyId())) {
if (!properties.next()) {
autoIndexing.relationships().propertyAdded(ops, relationshipId, property);
existingProperty = Property.noProperty(property.propertyKeyId(), EntityType.RELATIONSHIP, relationship.id());
} else {
existingProperty = Property.property(properties.get().propertyKeyId(), properties.get().value());
autoIndexing.relationships().propertyChanged(ops, relationshipId, existingProperty, property);
}
}
state.txState().relationshipDoReplaceProperty(relationship.id(), existingProperty, property);
return existingProperty;
}
}
use of org.neo4j.kernel.api.properties.Property in project neo4j by neo4j.
the class LuceneSchemaIndexUniquenessVerificationIT method verifyUniqueness.
private void verifyUniqueness(Collection<PropertyValue> data) throws IOException, IndexEntryConflictException {
Object[] propertyValues = data.stream().map(property -> property.value).toArray();
PropertyAccessor propertyAccessor = new TestPropertyAccessor(propertyValues);
index.verifyUniqueness(propertyAccessor, new int[] { PROPERTY_KEY_ID });
}
Aggregations