Search in sources :

Example 76 with PropertyBlock

use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.

the class StorePropertyCursorTest method createTwoPropertyValues.

private static PropertyRecord createTwoPropertyValues(PropertyStore store, int keyId1, Object value1, int keyId2, Object value2) {
    DynamicRecordAllocator stringAllocator = store.getStringStore();
    DynamicRecordAllocator arrayAllocator = store.getArrayStore();
    PropertyBlock block1 = new PropertyBlock();
    PropertyStore.encodeValue(block1, keyId1, value1, stringAllocator, arrayAllocator);
    PropertyBlock block2 = new PropertyBlock();
    PropertyStore.encodeValue(block2, keyId2, value2, stringAllocator, arrayAllocator);
    PropertyRecord record = new PropertyRecord(store.nextId());
    record.addPropertyBlock(block1);
    if (block1.getSize() + block2.getSize() <= PropertyRecordFormat.DEFAULT_PAYLOAD_SIZE) {
        record.addPropertyBlock(block2);
    } else {
        PropertyRecord nextRecord = new PropertyRecord(store.nextId());
        record.setNextProp(nextRecord.getId());
        nextRecord.addPropertyBlock(block2);
        nextRecord.setPrevProp(record.getId());
        nextRecord.setInUse(true);
        updateRecord(store, nextRecord);
    }
    record.setInUse(true);
    updateRecord(store, record);
    return record;
}
Also used : DynamicRecordAllocator(org.neo4j.kernel.impl.store.DynamicRecordAllocator) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 77 with PropertyBlock

use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.

the class StorePropertyPayloadCursorTest method asBlocks.

private static long[] asBlocks(Object... values) {
    DynamicRecordAllocator stringAllocator = new StandaloneDynamicRecordAllocator();
    DynamicRecordAllocator arrayAllocator = new StandaloneDynamicRecordAllocator();
    long[] blocks = new long[PropertyType.getPayloadSizeLongs()];
    int cursor = 0;
    for (int i = 0; i < values.length; i++) {
        Object value = values[i];
        PropertyBlock block = new PropertyBlock();
        PropertyStore.encodeValue(block, i, value, stringAllocator, arrayAllocator);
        long[] valueBlocks = block.getValueBlocks();
        System.arraycopy(valueBlocks, 0, blocks, cursor, valueBlocks.length);
        cursor += valueBlocks.length;
    }
    return blocks;
}
Also used : DynamicRecordAllocator(org.neo4j.kernel.impl.store.DynamicRecordAllocator) StandaloneDynamicRecordAllocator(org.neo4j.kernel.impl.store.StandaloneDynamicRecordAllocator) StandaloneDynamicRecordAllocator(org.neo4j.kernel.impl.store.StandaloneDynamicRecordAllocator) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 78 with PropertyBlock

use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.

the class NeoStoresTest method validateNodeRel1.

private void validateNodeRel1(final long node, DefinedProperty prop1, DefinedProperty prop2, DefinedProperty prop3, long rel1, long rel2, final int relType1, final int relType2) throws IOException {
    assertTrue(nodeExists(node));
    ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>();
    PropertyReceiver<DefinedProperty> receiver = newPropertyReceiver(props);
    propertyLoader.nodeLoadProperties(node, receiver);
    int count = 0;
    for (int keyId : props.keySet()) {
        long id = props.get(keyId).other();
        PropertyRecord record = getRecord(pStore, id);
        PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId());
        DefinedProperty data = block.newPropertyData(pStore);
        if (data.propertyKeyId() == prop1.propertyKeyId()) {
            assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name());
            assertEquals("string1", data.value());
            nodeAddProperty(node, prop1.propertyKeyId(), "-string1");
        } else if (data.propertyKeyId() == prop2.propertyKeyId()) {
            assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name());
            assertEquals(1, data.value());
            nodeAddProperty(node, prop2.propertyKeyId(), -1);
        } else if (data.propertyKeyId() == prop3.propertyKeyId()) {
            assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name());
            assertEquals(true, data.value());
            nodeAddProperty(node, prop3.propertyKeyId(), false);
        } else {
            throw new IOException();
        }
        count++;
    }
    assertEquals(3, count);
    count = validateAndCountRelationships(node, rel1, rel2, relType1, relType2);
    assertEquals(2, count);
}
Also used : DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) ArrayMap(org.neo4j.kernel.impl.util.ArrayMap) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) Pair(org.neo4j.helpers.collection.Pair)

Example 79 with PropertyBlock

use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.

the class NeoStoresTest method validateRel1.

private void validateRel1(long rel, DefinedProperty prop1, DefinedProperty prop2, DefinedProperty prop3, long firstNode, long secondNode, int relType) throws IOException {
    ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>();
    propertyLoader.relLoadProperties(rel, newPropertyReceiver(props));
    int count = 0;
    for (int keyId : props.keySet()) {
        long id = props.get(keyId).other();
        PropertyRecord record = getRecord(pStore, id);
        PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId());
        DefinedProperty data = block.newPropertyData(pStore);
        if (data.propertyKeyId() == prop1.propertyKeyId()) {
            assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name());
            assertEquals("string1", data.value());
            relAddProperty(rel, prop1.propertyKeyId(), "-string1");
        } else if (data.propertyKeyId() == prop2.propertyKeyId()) {
            assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name());
            assertEquals(1, data.value());
            relAddProperty(rel, prop2.propertyKeyId(), -1);
        } else if (data.propertyKeyId() == prop3.propertyKeyId()) {
            assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name());
            assertEquals(true, data.value());
            relAddProperty(rel, prop3.propertyKeyId(), false);
        } else {
            throw new IOException();
        }
        count++;
    }
    assertEquals(3, count);
    assertRelationshipData(rel, firstNode, secondNode, relType);
}
Also used : DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) ArrayMap(org.neo4j.kernel.impl.util.ArrayMap) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) Pair(org.neo4j.helpers.collection.Pair)

Example 80 with PropertyBlock

use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.

the class NeoStoresTest method deleteNode1.

private void deleteNode1(long node, DefinedProperty prop1, DefinedProperty prop2, DefinedProperty prop3) throws IOException {
    ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>();
    propertyLoader.nodeLoadProperties(node, newPropertyReceiver(props));
    int count = 0;
    for (int keyId : props.keySet()) {
        long id = props.get(keyId).other();
        PropertyRecord record = pStore.getRecord(id, pStore.newRecord(), NORMAL);
        PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId());
        DefinedProperty data = block.newPropertyData(pStore);
        if (data.propertyKeyId() == prop1.propertyKeyId()) {
            assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name());
            assertEquals("-string1", data.value());
        } else if (data.propertyKeyId() == prop2.propertyKeyId()) {
            assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name());
            assertEquals(-1, data.value());
        } else if (data.propertyKeyId() == prop3.propertyKeyId()) {
            assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name());
            assertEquals(false, data.value());
            transaction.nodeDoRemoveProperty(node, prop3);
        } else {
            throw new IOException();
        }
        count++;
    }
    assertEquals(3, count);
    CountingPropertyReceiver propertyCounter = new CountingPropertyReceiver();
    propertyLoader.nodeLoadProperties(node, propertyCounter);
    assertEquals(3, propertyCounter.count);
    assertHasRelationships(node);
    transaction.nodeDoDelete(node);
}
Also used : DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) ArrayMap(org.neo4j.kernel.impl.util.ArrayMap) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) Pair(org.neo4j.helpers.collection.Pair)

Aggregations

PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)90 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)57 Test (org.junit.Test)21 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)16 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)9 IOException (java.io.IOException)8 InterruptedIOException (java.io.InterruptedIOException)8 Pair (org.neo4j.helpers.collection.Pair)8 DefinedProperty (org.neo4j.kernel.api.properties.DefinedProperty)8 ArrayMap (org.neo4j.kernel.impl.util.ArrayMap)8 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)6 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)6 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)5 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)5 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)5 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)5 PrimitiveRecord (org.neo4j.kernel.impl.store.record.PrimitiveRecord)4 ChainCheck (org.neo4j.consistency.checking.ChainCheck)3 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)3 DynamicRecordAllocator (org.neo4j.kernel.impl.store.DynamicRecordAllocator)3