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());
}
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());
}
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();
}
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));
}
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());
}
Aggregations