Search in sources :

Example 81 with NodeRecord

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

the class DynamicIndexStoreViewTest method setUp.

@Before
public void setUp() {
    NodeRecord nodeRecord = getNodeRecord();
    when(labelScanStore.allNodeLabelRanges()).thenReturn(nodeLabelRanges);
    when(neoStores.getCounts()).thenReturn(countStore);
    when(neoStores.getNodeStore()).thenReturn(nodeStore);
    when(nodeStore.newRecord()).thenReturn(nodeRecord);
    when(nodeStore.getRecord(anyLong(), any(NodeRecord.class), any(RecordLoad.class))).thenReturn(nodeRecord);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) RecordLoad(org.neo4j.kernel.impl.store.record.RecordLoad) Before(org.junit.Before)

Example 82 with NodeRecord

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

the class NodeCommandTest method shouldSerializeAndDeserializeUnusedRecords.

@Test
public void shouldSerializeAndDeserializeUnusedRecords() throws Exception {
    // Given
    NodeRecord before = new NodeRecord(12, false, 1, 2);
    NodeRecord after = new NodeRecord(12, false, 2, 1);
    // When
    assertSerializationWorksFor(new Command.NodeCommand(before, after));
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Command(org.neo4j.kernel.impl.transaction.command.Command) Test(org.junit.Test)

Example 83 with NodeRecord

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

the class NodeCommandTest method shouldSerializeDynamicRecordLabels.

@Test
public void shouldSerializeDynamicRecordLabels() throws Exception {
    // Given
    NodeRecord before = new NodeRecord(12, false, 1, 2);
    before.setInUse(true);
    NodeRecord after = new NodeRecord(12, false, 2, 1);
    after.setInUse(true);
    NodeLabels nodeLabels = parseLabelsField(after);
    for (int i = 10; i < 100; i++) {
        nodeLabels.add(i, nodeStore, nodeStore.getDynamicLabelStore());
    }
    // When
    assertSerializationWorksFor(new Command.NodeCommand(before, after));
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Command(org.neo4j.kernel.impl.transaction.command.Command) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels) Test(org.junit.Test)

Example 84 with NodeRecord

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

the class NodeCommandTest method shouldSerializeCreatedRecord.

@Test
public void shouldSerializeCreatedRecord() throws Exception {
    // Given
    NodeRecord before = new NodeRecord(12, false, 1, 2);
    NodeRecord after = new NodeRecord(12, false, 2, 1);
    after.setCreated();
    after.setInUse(true);
    // When
    assertSerializationWorksFor(new Command.NodeCommand(before, after));
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Command(org.neo4j.kernel.impl.transaction.command.Command) Test(org.junit.Test)

Example 85 with NodeRecord

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

the class RelationshipGroupGetterTest method shouldAbortLoadingGroupChainIfComeTooFar.

@Test
public void shouldAbortLoadingGroupChainIfComeTooFar() throws Exception {
    // GIVEN a node with relationship group chain 2-->4-->10-->23
    File dir = new File("dir");
    fs.get().mkdirs(dir);
    LogProvider logProvider = NullLogProvider.getInstance();
    StoreFactory storeFactory = new StoreFactory(dir, pageCache.getPageCache(fs.get()), fs.get(), logProvider);
    try (NeoStores stores = storeFactory.openNeoStores(true, StoreType.RELATIONSHIP_GROUP)) {
        RecordStore<RelationshipGroupRecord> store = spy(stores.getRelationshipGroupStore());
        RelationshipGroupRecord group_2 = group(0, 2);
        RelationshipGroupRecord group_4 = group(1, 4);
        RelationshipGroupRecord group_10 = group(2, 10);
        RelationshipGroupRecord group_23 = group(3, 23);
        link(group_2, group_4, group_10, group_23);
        store.updateRecord(group_2);
        store.updateRecord(group_4);
        store.updateRecord(group_10);
        store.updateRecord(group_23);
        RelationshipGroupGetter groupGetter = new RelationshipGroupGetter(store);
        NodeRecord node = new NodeRecord(0, true, group_2.getId(), -1);
        // WHEN trying to find relationship group 7
        RecordAccess<Long, RelationshipGroupRecord, Integer> access = new DirectRecordAccess<>(store, Loaders.relationshipGroupLoader(store));
        RelationshipGroupPosition result = groupGetter.getRelationshipGroup(node, 7, access);
        // THEN only groups 2, 4 and 10 should have been loaded
        InOrder verification = inOrder(store);
        verification.verify(store).getRecord(eq(group_2.getId()), any(RelationshipGroupRecord.class), any(RecordLoad.class));
        verification.verify(store).getRecord(eq(group_4.getId()), any(RelationshipGroupRecord.class), any(RecordLoad.class));
        verification.verify(store).getRecord(eq(group_10.getId()), any(RelationshipGroupRecord.class), any(RecordLoad.class));
        verification.verify(store, times(0)).getRecord(eq(group_23.getId()), any(RelationshipGroupRecord.class), any(RecordLoad.class));
        // it should also be reported as not found
        assertNull(result.group());
        // with group 4 as closes previous one
        assertEquals(group_4, result.closestPrevious().forReadingData());
    }
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) InOrder(org.mockito.InOrder) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) RecordLoad(org.neo4j.kernel.impl.store.record.RecordLoad) LogProvider(org.neo4j.logging.LogProvider) NullLogProvider(org.neo4j.logging.NullLogProvider) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) DirectRecordAccess(org.neo4j.unsafe.batchinsert.DirectRecordAccess) NeoStores(org.neo4j.kernel.impl.store.NeoStores) File(java.io.File) RelationshipGroupPosition(org.neo4j.kernel.impl.transaction.state.RelationshipGroupGetter.RelationshipGroupPosition) Test(org.junit.Test)

Aggregations

NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)391 Test (org.junit.Test)154 Test (org.junit.jupiter.api.Test)108 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)73 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)63 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)58 NodeLabels (org.neo4j.kernel.impl.store.NodeLabels)46 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)42 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)40 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)40 DynamicNodeLabels (org.neo4j.kernel.impl.store.DynamicNodeLabels)38 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)32 ArrayList (java.util.ArrayList)30 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)30 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)30 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)30 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)30 NodeStore (org.neo4j.kernel.impl.store.NodeStore)28 Command (org.neo4j.kernel.impl.transaction.command.Command)27 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)17