Search in sources :

Example 1 with PropertyBlock

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

the class IndexConsultedPropertyBlockSweeperTest method shouldFixThePropertyChainAfterAllTheBlocksInRecordAreRemoved.

@Test
public void shouldFixThePropertyChainAfterAllTheBlocksInRecordAreRemoved() throws IOException {
    int propertyKeyId = propertyKeys.get(indexedPropKey);
    PropertyRecord propertyRecord = getRecord(propertyStore, propertyId);
    for (PropertyBlock propertyBlock : propertyRecord) {
        long[] valueBlocks = propertyBlock.getValueBlocks();
        // Change the value to something non-indexed!
        valueBlocks[1] += 2;
        propertyBlock.setKeyIndexId(propertyKeyId);
    }
    propertyStore.updateRecord(propertyRecord);
    sweeper = new IndexConsultedPropertyBlockSweeper(propertyKeyId, indexMock, nodeRecord, propertyStore, propertyRemoverMock);
    assertFalse(sweeper.visited(propertyId));
    // The property record was emptied of property blocks, so the chain must be fixed
    verify(propertyRemoverMock).fixUpPropertyLinksAroundUnusedRecord(nodeRecord, propertyRecord);
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) Test(org.junit.Test)

Example 2 with PropertyBlock

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

the class NonIndexedConflictResolverTest method collectPropertyKeyIds.

private Set<Integer> collectPropertyKeyIds(long propertyId) {
    Set<Integer> result = new HashSet<>();
    PropertyRecord record = propertyStore.newRecord();
    while (propertyId != Record.NO_NEXT_PROPERTY.intValue()) {
        propertyStore.getRecord(propertyId, record, FORCE);
        for (PropertyBlock propertyBlock : record) {
            int propertyKeyId = propertyBlock.getKeyIndexId();
            assertTrue(result.add(propertyKeyId));
        }
        propertyId = record.getNextProp();
    }
    return result;
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) HashSet(java.util.HashSet)

Example 3 with PropertyBlock

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

the class DuplicatePropertyTest method shouldReportDuplicatePropertyIndexesInPropertyRecordForNode.

@Test
public void shouldReportDuplicatePropertyIndexesInPropertyRecordForNode() throws Exception {
    // given
    ChainCheck check = new ChainCheck();
    RecordAccessStub records = new RecordAccessStub();
    NodeRecord master = records.add(inUse(new NodeRecord(1, false, -1, 1)));
    PropertyRecord propertyRecord = inUse(new PropertyRecord(1));
    PropertyBlock firstBlock = new PropertyBlock();
    firstBlock.setSingleBlock(1);
    firstBlock.setKeyIndexId(1);
    PropertyBlock secondBlock = new PropertyBlock();
    secondBlock.setSingleBlock(1);
    secondBlock.setKeyIndexId(2);
    PropertyBlock thirdBlock = new PropertyBlock();
    thirdBlock.setSingleBlock(1);
    thirdBlock.setKeyIndexId(1);
    propertyRecord.addPropertyBlock(firstBlock);
    propertyRecord.addPropertyBlock(secondBlock);
    propertyRecord.addPropertyBlock(thirdBlock);
    records.add(propertyRecord);
    // when
    ConsistencyReport.NodeConsistencyReport report = mock(ConsistencyReport.NodeConsistencyReport.class);
    CheckerEngine<NodeRecord, ConsistencyReport.NodeConsistencyReport> checkEngine = records.engine(master, report);
    check.checkReference(master, propertyRecord, checkEngine, records);
    // then
    verify(report).propertyKeyNotUniqueInChain();
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) ChainCheck(org.neo4j.consistency.checking.ChainCheck) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 4 with PropertyBlock

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

the class CheckTxLogsTest method propertyRecord.

private static PropertyRecord propertyRecord(long id, boolean inUse, long prevProp, long nextProp, long... blocks) {
    PropertyRecord record = new PropertyRecord(id);
    record.setInUse(inUse);
    record.setPrevProp(prevProp);
    record.setNextProp(nextProp);
    for (int i = 0; i < blocks.length; i++) {
        long blockValue = blocks[i];
        PropertyBlock block = new PropertyBlock();
        long value = PropertyStore.singleBlockLongValue(i, PropertyType.INT, blockValue);
        block.setSingleBlock(value);
        record.addPropertyBlock(block);
    }
    return record;
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 5 with PropertyBlock

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

the class PropertyRecordCheckTest method shouldReportPropertyKeyNotInUse.

@Test
public void shouldReportPropertyKeyNotInUse() throws Exception {
    // given
    PropertyRecord property = inUse(new PropertyRecord(42));
    PropertyKeyTokenRecord key = add(notInUse(new PropertyKeyTokenRecord(0)));
    PropertyBlock block = propertyBlock(key, PropertyType.INT, 0);
    property.addPropertyBlock(block);
    // when
    ConsistencyReport.PropertyConsistencyReport report = check(property);
    // then
    verify(report).keyNotInUse(block, key);
    verifyNoMoreInteractions(report);
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Aggregations

PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)139 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)86 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)25 Test (org.junit.jupiter.api.Test)16 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)14 Value (org.neo4j.values.storable.Value)13 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)10 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 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)7 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)7 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)7 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)7 PrimitiveRecord (org.neo4j.kernel.impl.store.record.PrimitiveRecord)7