Search in sources :

Example 86 with NodeRecord

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

the class NodeLabelsFieldTest method shouldReallocateSomeOfPreviousDynamicRecords.

@Test
public void shouldReallocateSomeOfPreviousDynamicRecords() throws Exception {
    // GIVEN
    NodeRecord node = nodeRecordWithDynamicLabels(nodeStore, oneByteLongs(5));
    Set<DynamicRecord> initialRecords = Iterables.asUniqueSet(node.getDynamicLabelRecords());
    NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
    // WHEN
    Set<DynamicRecord> reallocatedRecords = Iterables.asUniqueSet(nodeLabels.put(fourByteLongs(100), nodeStore, nodeStore.getDynamicLabelStore()));
    // THEN
    assertTrue(reallocatedRecords.containsAll(initialRecords));
    assertTrue(reallocatedRecords.size() > initialRecords.size());
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) Test(org.junit.Test)

Example 87 with NodeRecord

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

the class NodeLabelsFieldTest method shouldInlineTwoSmallLabels.

@Test
public void shouldInlineTwoSmallLabels() throws Exception {
    // GIVEN
    long labelId1 = 10, labelId2 = 30;
    NodeRecord node = nodeRecordWithInlinedLabels(labelId1);
    NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
    // WHEN
    nodeLabels.add(labelId2, null, null);
    // THEN
    assertEquals(inlinedLabelsLongRepresentation(labelId1, labelId2), node.getLabelField());
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) Test(org.junit.Test)

Example 88 with NodeRecord

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

the class NodeStoreScanTest method shouldGiveBackCompletionPercentage.

@Test
public void shouldGiveBackCompletionPercentage() throws Throwable {
    // given
    final int total = 10;
    when(nodeStore.getHighId()).thenReturn((long) total);
    NodeRecord inUseRecord = new NodeRecord(42);
    inUseRecord.setInUse(true);
    when(nodeStore.getRecord(anyLong(), any(NodeRecord.class), any(RecordLoad.class))).thenReturn(inUseRecord, inUseRecord, inUseRecord, inUseRecord, inUseRecord, inUseRecord, inUseRecord, inUseRecord, inUseRecord, inUseRecord);
    final PercentageSupplier percentageSupplier = new PercentageSupplier();
    final NodeStoreScan scan = new NodeStoreScan(nodeStore, locks, total) {

        private int read = 0;

        @Override
        public void acceptUpdate(MultipleIndexPopulator.MultipleIndexUpdater updater, IndexEntryUpdate update, long currentlyIndexedNodeId) {
        // no-op
        }

        @Override
        public void configure(List list) {
        // no-op
        }

        @Override
        public void process(NodeRecord node) {
            // then
            read++;
            float expected = (float) read / total;
            float actual = percentageSupplier.get();
            assertEquals(String.format("%f==%f", expected, actual), expected, actual, 0.0);
        }
    };
    percentageSupplier.setStoreScan(scan);
    // when
    scan.run();
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeStoreScan(org.neo4j.kernel.impl.transaction.state.storeview.NodeStoreScan) IndexEntryUpdate(org.neo4j.kernel.api.index.IndexEntryUpdate) List(java.util.List) RecordLoad(org.neo4j.kernel.impl.store.record.RecordLoad) Test(org.junit.Test)

Example 89 with NodeRecord

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

the class NodeCommandTest method shouldSerializeDenseRecord.

@Test
public void shouldSerializeDenseRecord() throws Exception {
    // Given
    NodeRecord before = new NodeRecord(12, false, 1, 2);
    before.setInUse(true);
    NodeRecord after = new NodeRecord(12, true, 2, 1);
    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 90 with NodeRecord

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

the class NodeLabelsFieldTest method shouldInlineThreeSmallLabels.

@Test
public void shouldInlineThreeSmallLabels() throws Exception {
    // GIVEN
    long labelId1 = 10, labelId2 = 30, labelId3 = 4095;
    NodeRecord node = nodeRecordWithInlinedLabels(labelId1, labelId2);
    NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
    // WHEN
    nodeLabels.add(labelId3, null, null);
    // THEN
    assertEquals(inlinedLabelsLongRepresentation(labelId1, labelId2, labelId3), node.getLabelField());
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) NodeLabels(org.neo4j.kernel.impl.store.NodeLabels) DynamicNodeLabels(org.neo4j.kernel.impl.store.DynamicNodeLabels) 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