use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class NodeLabelsFieldTest method addingAnAlreadyAddedLabelWhenLabelsAreInlinedShouldFail.
@Test
void addingAnAlreadyAddedLabelWhenLabelsAreInlinedShouldFail() {
// GIVEN
int labelId = 1;
NodeRecord node = nodeRecordWithInlinedLabels(labelId);
NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
// WHEN
try {
nodeLabels.add(labelId, nodeStore, nodeStore.getDynamicLabelStore(), NULL, INSTANCE);
fail("Should have thrown exception");
} catch (IllegalStateException e) {
// THEN
}
}
use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class NodeLabelsFieldTest method shouldReallocateSomeOfPreviousDynamicRecords.
@Test
void shouldReallocateSomeOfPreviousDynamicRecords() {
// 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(), NULL, INSTANCE));
// THEN
assertTrue(reallocatedRecords.containsAll(initialRecords));
assertTrue(reallocatedRecords.size() > initialRecords.size());
}
use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class NodeLabelsFieldTest method oneDynamicRecordShouldShrinkIntoInlinedWhenRemoving.
@Test
void oneDynamicRecordShouldShrinkIntoInlinedWhenRemoving() {
// GIVEN
NodeRecord node = nodeRecordWithDynamicLabels(nodeStore, oneByteLongs(5));
Collection<DynamicRecord> initialRecords = node.getDynamicLabelRecords();
NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
// WHEN
Collection<DynamicRecord> changedDynamicRecords = Iterables.asCollection(nodeLabels.remove(255, nodeStore, NULL, INSTANCE));
// THEN
assertEquals(initialRecords, changedDynamicRecords);
Assertions.assertFalse(Iterables.single(changedDynamicRecords).inUse());
assertEquals(inlinedLabelsLongRepresentation(251, 252, 253, 254), node.getLabelField());
}
use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class NodeLabelsFieldTest method shouldInlineOneLabelWithHighId.
@Test
void shouldInlineOneLabelWithHighId() {
// GIVEN
long labelId = 10000;
NodeRecord node = nodeRecordWithInlinedLabels();
NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
// WHEN
nodeLabels.add(labelId, null, null, NULL, INSTANCE);
// THEN
assertEquals(inlinedLabelsLongRepresentation(labelId), node.getLabelField());
}
use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class NodeLabelsFieldTest method shouldReallocateAllOfPreviousDynamicRecordsAndThenSome.
@Test
void shouldReallocateAllOfPreviousDynamicRecordsAndThenSome() {
// GIVEN
NodeRecord node = nodeRecordWithDynamicLabels(nodeStore, fourByteLongs(100));
Set<DynamicRecord> initialRecords = Iterables.asSet(cloned(node.getDynamicLabelRecords(), DynamicRecord.class));
NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
// WHEN
Set<DynamicRecord> reallocatedRecords = Iterables.asUniqueSet(nodeLabels.put(fourByteLongs(5), nodeStore, nodeStore.getDynamicLabelStore(), NULL, INSTANCE));
// THEN
assertTrue(idsOf(initialRecords).containsAll(idsOf(used(reallocatedRecords))), "initial:" + initialRecords + ", reallocated:" + reallocatedRecords);
assertTrue(used(reallocatedRecords).size() < initialRecords.size());
}
Aggregations