Search in sources :

Example 11 with PropertyRecord

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

the class MetaDataStoreCheckTest method shouldReportPropertyNotFirstInChain.

@Test
public void shouldReportPropertyNotFirstInChain() throws Exception {
    // given
    NeoStoreRecord record = new NeoStoreRecord();
    PropertyRecord property = add(inUse(new PropertyRecord(7)));
    property.setPrevProp(6);
    record.setNextProp(property.getId());
    // when
    ConsistencyReport.NeoStoreConsistencyReport report = check(record);
    // then
    verify(report).propertyNotFirstInChain(property);
    verifyNoMoreInteractions(report);
}
Also used : NeoStoreRecord(org.neo4j.kernel.impl.store.record.NeoStoreRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 12 with PropertyRecord

use of org.neo4j.kernel.impl.store.record.PropertyRecord 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 13 with PropertyRecord

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

the class DirectRecordAccess method rawPropertyChain.

@Override
public Iterator<PropertyRecord> rawPropertyChain(final long firstId) {
    return new PrefetchingIterator<PropertyRecord>() {

        private long next = firstId;

        @Override
        protected PropertyRecord fetchNextOrNull() {
            if (Record.NO_NEXT_PROPERTY.is(next)) {
                return null;
            }
            PropertyRecord record = referenceTo(access.getPropertyStore(), next).record();
            next = record.getNextProp();
            return record;
        }
    };
}
Also used : PrefetchingIterator(org.neo4j.helpers.collection.PrefetchingIterator) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord)

Example 14 with PropertyRecord

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

the class InconsistencyReportReaderTest method shouldReadBasicEntities.

@Test
public void shouldReadBasicEntities() throws Exception {
    // GIVEN
    ByteArrayOutputStream out = new ByteArrayOutputStream(1_000);
    FormattedLog log = FormattedLog.toOutputStream(out);
    InconsistencyMessageLogger logger = new InconsistencyMessageLogger(log);
    long nodeId = 5;
    long relationshipGroupId = 10;
    long relationshipId = 15;
    long propertyId = 20;
    logger.error(RecordType.NODE, new NodeRecord(nodeId), "Some error", "something");
    logger.error(RecordType.RELATIONSHIP, new RelationshipRecord(relationshipId), "Some error", "something");
    logger.error(RecordType.RELATIONSHIP_GROUP, new RelationshipGroupRecord(relationshipGroupId), "Some error", "something");
    logger.error(RecordType.PROPERTY, new PropertyRecord(propertyId), "Some error", "something");
    String text = out.toString();
    PrimitiveLongSet nodes = Primitive.longSet();
    PrimitiveLongSet relationships = Primitive.longSet();
    PrimitiveLongSet relationshipGroups = Primitive.longSet();
    PrimitiveLongSet properties = Primitive.longSet();
    // WHEN
    InconsistencyReportReader reader = new InconsistencyReportReader(new Inconsistencies() {

        @Override
        public void relationshipGroup(long id) {
            relationshipGroups.add(id);
        }

        @Override
        public void relationship(long id) {
            relationships.add(id);
        }

        @Override
        public void property(long id) {
            properties.add(id);
        }

        @Override
        public void node(long id) {
            nodes.add(id);
        }
    });
    reader.read(new StringReader(text));
    // THEN
    assertEquals(asSet(iterator(nodeId)), nodes);
    assertEquals(asSet(iterator(relationshipId)), relationships);
    assertEquals(asSet(iterator(relationshipGroupId)), relationshipGroups);
    assertEquals(asSet(iterator(propertyId)), properties);
}
Also used : FormattedLog(org.neo4j.logging.FormattedLog) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) Inconsistencies(org.neo4j.tools.dump.InconsistencyReportReader.Inconsistencies) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) ByteArrayOutputStream(java.io.ByteArrayOutputStream) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PrimitiveLongSet(org.neo4j.collection.primitive.PrimitiveLongSet) StringReader(java.io.StringReader) InconsistencyMessageLogger(org.neo4j.consistency.report.InconsistencyMessageLogger) Test(org.junit.Test)

Example 15 with PropertyRecord

use of org.neo4j.kernel.impl.store.record.PropertyRecord 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)

Aggregations

PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)230 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)86 Test (org.junit.Test)75 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)37 Test (org.junit.jupiter.api.Test)36 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)35 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)28 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)19 ArrayList (java.util.ArrayList)17 Value (org.neo4j.values.storable.Value)17 PrimitiveRecord (org.neo4j.kernel.impl.store.record.PrimitiveRecord)14 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)14 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 PropertyStore (org.neo4j.kernel.impl.store.PropertyStore)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 NodeStore (org.neo4j.kernel.impl.store.NodeStore)8