use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class NodeLabelsFieldTest method shouldInlineFiveSmallLabels.
@Test
void shouldInlineFiveSmallLabels() {
// GIVEN
long labelId1 = 10;
long labelId2 = 30;
long labelId3 = 45;
long labelId4 = 60;
long labelId5 = 61;
NodeRecord node = nodeRecordWithInlinedLabels(labelId1, labelId2, labelId3, labelId4);
NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
// WHEN
nodeLabels.add(labelId5, null, null, NULL, INSTANCE);
// THEN
assertEquals(inlinedLabelsLongRepresentation(labelId1, labelId2, labelId3, labelId4, labelId5), node.getLabelField());
}
use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class NodeLabelsFieldTest method shouldInlineOneLabel.
@Test
void shouldInlineOneLabel() {
// GIVEN
long labelId = 10;
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 shouldInlineThreeSmallLabels.
@Test
void shouldInlineThreeSmallLabels() {
// GIVEN
long labelId1 = 10;
long labelId2 = 30;
long labelId3 = 4095;
NodeRecord node = nodeRecordWithInlinedLabels(labelId1, labelId2);
NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
// WHEN
nodeLabels.add(labelId3, null, null, NULL, INSTANCE);
// THEN
assertEquals(inlinedLabelsLongRepresentation(labelId1, labelId2, labelId3), node.getLabelField());
}
use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class NodeLabelsFieldTest method removingNonExistentInlinedLabelShouldFail.
@Test
void removingNonExistentInlinedLabelShouldFail() {
// GIVEN
int labelId1 = 1;
int labelId2 = 2;
NodeRecord node = nodeRecordWithInlinedLabels(labelId1);
NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
assertThrows(IllegalStateException.class, () -> nodeLabels.remove(labelId2, nodeStore, NULL, INSTANCE));
}
use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class NodeLabelsFieldTest method twoDynamicRecordsShouldShrinkToOneWhenRemovingWithoutChangingItsOwner.
@Test
void twoDynamicRecordsShouldShrinkToOneWhenRemovingWithoutChangingItsOwner() {
// GIVEN
// will occupy 61B of data, i.e. just two dynamic records
Long nodeId = 42L;
NodeRecord node = nodeRecordWithDynamicLabels(nodeId, nodeStore, oneByteLongs(57));
NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
List<DynamicRecord> changedDynamicRecords = addAll(new ArrayList<>(), nodeLabels.remove(255, /*Initial labels go from 255 and down to 255-58*/
nodeStore, NULL, INSTANCE));
// WHEN
Pair<Long, long[]> changedPair = DynamicNodeLabels.getDynamicLabelsArrayAndOwner(changedDynamicRecords, nodeStore.getDynamicLabelStore(), NULL);
// THEN
assertEquals(nodeId, changedPair.first());
}
Aggregations