Search in sources :

Example 6 with Property

use of org.neo4j.kernel.api.properties.Property in project neo4j by neo4j.

the class NeoStoreIndexStoreViewTest method shouldReadProperties.

@Test
public void shouldReadProperties() throws EntityNotFoundException {
    Property property = storeView.getProperty(alistair.getId(), propertyKeyId);
    assertTrue(property.valueEquals("Alistair"));
}
Also used : Property(org.neo4j.kernel.api.properties.Property) Test(org.junit.Test)

Example 7 with Property

use of org.neo4j.kernel.api.properties.Property in project neo4j by neo4j.

the class CompositeDuplicateCheckingCollector method doCollect.

@Override
protected void doCollect(int doc) throws IOException, KernelException, IndexEntryConflictException {
    Document document = reader.document(doc);
    long nodeId = LuceneDocumentStructure.getNodeId(document);
    Property[] properties = new Property[propertyKeyIds.length];
    Object[] values = new Object[propertyKeyIds.length];
    for (int i = 0; i < properties.length; i++) {
        properties[i] = accessor.getProperty(nodeId, propertyKeyIds[i]);
        values[i] = properties[i].value();
    }
    // We either have to find the first conflicting entry set element,
    // or append one for the property we just fetched:
    CompositeEntrySet current = actualValues;
    scan: do {
        for (int i = 0; i < CompositeEntrySet.INCREMENT; i++) {
            Object[] currentValues = current.values[i];
            if (current.nodeId[i] == StatementConstants.NO_SUCH_NODE) {
                current.values[i] = values;
                current.nodeId[i] = nodeId;
                if (i == CompositeEntrySet.INCREMENT - 1) {
                    current.next = new CompositeEntrySet();
                }
                break scan;
            } else if (propertyValuesEqual(properties, currentValues)) {
                throw new IndexEntryConflictException(current.nodeId[i], nodeId, OrderedPropertyValues.ofUndefined(currentValues));
            }
        }
        current = current.next;
    } while (current != null);
}
Also used : Document(org.apache.lucene.document.Document) Property(org.neo4j.kernel.api.properties.Property) IndexEntryConflictException(org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException)

Example 8 with Property

use of org.neo4j.kernel.api.properties.Property in project neo4j by neo4j.

the class DuplicateCheckingCollector method doCollect.

protected void doCollect(int doc) throws IOException, KernelException, IndexEntryConflictException {
    Document document = reader.document(doc);
    long nodeId = LuceneDocumentStructure.getNodeId(document);
    Property property = accessor.getProperty(nodeId, propertyKeyId);
    // We either have to find the first conflicting entry set element,
    // or append one for the property we just fetched:
    EntrySet current = actualValues;
    scan: do {
        for (int i = 0; i < EntrySet.INCREMENT; i++) {
            Object value = current.value[i];
            if (current.nodeId[i] == StatementConstants.NO_SUCH_NODE) {
                current.value[i] = property.value();
                current.nodeId[i] = nodeId;
                if (i == EntrySet.INCREMENT - 1) {
                    current.next = new EntrySet();
                }
                break scan;
            } else if (property.valueEquals(value)) {
                throw new IndexEntryConflictException(current.nodeId[i], nodeId, value);
            }
        }
        current = current.next;
    } while (current != null);
}
Also used : Document(org.apache.lucene.document.Document) Property(org.neo4j.kernel.api.properties.Property) IndexEntryConflictException(org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException)

Example 9 with Property

use of org.neo4j.kernel.api.properties.Property in project neo4j by neo4j.

the class StateOperationsAutoIndexingTest method shouldSignalRelationshipPropertyChangedToAutoIndex.

@Test
public void shouldSignalRelationshipPropertyChangedToAutoIndex() throws Exception {
    // Given
    int propertyKeyId = 1;
    DefinedProperty property = property(propertyKeyId, "Hello!");
    PropertyItem existingProperty = mock(PropertyItem.class);
    when(existingProperty.propertyKeyId()).thenReturn(property.propertyKeyId());
    when(existingProperty.value()).thenReturn("Goodbye!");
    RelationshipItem relationship = mock(RelationshipItem.class);
    when(storeStmt.acquireSingleRelationshipCursor(1337)).thenReturn(cursor(relationship));
    when(storeLayer.relationshipGetProperty(storeStmt, relationship, propertyKeyId)).thenReturn(cursor(existingProperty));
    // When
    context.relationshipSetProperty(stmt, 1337, property);
    // Then
    verify(relOps).propertyChanged(eq(writeOps), eq(1337L), any(Property.class), eq(property));
}
Also used : DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) PropertyItem(org.neo4j.storageengine.api.PropertyItem) Property(org.neo4j.kernel.api.properties.Property) DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) RelationshipItem(org.neo4j.storageengine.api.RelationshipItem) Test(org.junit.Test)

Example 10 with Property

use of org.neo4j.kernel.api.properties.Property in project neo4j by neo4j.

the class NeoStoresTest method relAddProperty.

private DefinedProperty relAddProperty(long relationshipId, int key, Object value) {
    DefinedProperty property = Property.property(key, value);
    Property oldProperty = Property.noRelationshipProperty(relationshipId, key);
    try (StorageStatement statement = storeLayer.newStatement();
        Cursor<RelationshipItem> cursor = statement.acquireSingleRelationshipCursor(relationshipId)) {
        if (cursor.next()) {
            Property fetched = getProperty(key, statement, cursor.get().nextPropertyId());
            if (fetched != null) {
                oldProperty = fetched;
            }
        }
    }
    transaction.relationshipDoReplaceProperty(relationshipId, oldProperty, property);
    return property;
}
Also used : DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) StorageStatement(org.neo4j.storageengine.api.StorageStatement) Property(org.neo4j.kernel.api.properties.Property) DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) RelationshipItem(org.neo4j.storageengine.api.RelationshipItem)

Aggregations

Property (org.neo4j.kernel.api.properties.Property)10 DefinedProperty (org.neo4j.kernel.api.properties.DefinedProperty)6 Test (org.junit.Test)4 PropertyItem (org.neo4j.storageengine.api.PropertyItem)4 RelationshipItem (org.neo4j.storageengine.api.RelationshipItem)4 Document (org.apache.lucene.document.Document)3 IndexEntryConflictException (org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException)3 StorageProperty (org.neo4j.storageengine.api.StorageProperty)3 DataWriteOperations (org.neo4j.kernel.api.DataWriteOperations)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 List (java.util.List)1 Objects (java.util.Objects)1 Set (java.util.Set)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 IntStream (java.util.stream.IntStream)1 RandomStringUtils (org.apache.commons.lang3.RandomStringUtils)1