use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class NodeLabelsFieldTest method shouldReallocateAllOfPreviousDynamicRecordsAndThenSome.
@Test
public void shouldReallocateAllOfPreviousDynamicRecordsAndThenSome() throws Exception {
// 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()));
// THEN
assertTrue("initial:" + initialRecords + ", reallocated:" + reallocatedRecords, initialRecords.containsAll(used(reallocatedRecords)));
assertTrue(used(reallocatedRecords).size() < initialRecords.size());
}
use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class NodeLabelsFieldTest method removingNonExistentLabelInDynamicRecordsShouldFail.
@Test
public void removingNonExistentLabelInDynamicRecordsShouldFail() throws Exception {
// GIVEN
long[] labels = oneByteLongs(20);
NodeRecord node = nodeRecordWithDynamicLabels(nodeStore, labels);
NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
// WHEN
try {
nodeLabels.remove(123456, nodeStore);
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 shouldInlineFourSmallLabels.
@Test
public void shouldInlineFourSmallLabels() throws Exception {
// GIVEN
long labelId1 = 10, labelId2 = 30, labelId3 = 45, labelId4 = 60;
NodeRecord node = nodeRecordWithInlinedLabels(labelId1, labelId2, labelId3);
NodeLabels nodeLabels = NodeLabelsField.parseLabelsField(node);
// WHEN
nodeLabels.add(labelId4, null, null);
// THEN
assertEquals(inlinedLabelsLongRepresentation(labelId1, labelId2, labelId3, labelId4), node.getLabelField());
}
use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class BatchInsertTest method shouldSortLabelIdsWhenGetOrCreate.
@Test
public void shouldSortLabelIdsWhenGetOrCreate() throws Exception {
// GIVEN
BatchInserter inserter = globalInserter;
// WHEN
long nodeId = inserter.createNode(map("Item", 123456789123L), label("AA"), label("BB"), label("CC"), label("DD"));
inserter.setNodeLabels(nodeId, label("CC"), label("AA"), label("DD"), label("EE"), label("FF"));
// THEN
NodeStore nodeStore = getFlushedNeoStores(inserter).getNodeStore();
NodeRecord node = nodeStore.getRecord(nodeId, nodeStore.newRecord(), RecordLoad.NORMAL);
NodeLabels labels = NodeLabelsField.parseLabelsField(node);
long[] labelIds = labels.get(nodeStore);
long[] sortedLabelIds = labelIds.clone();
Arrays.sort(sortedLabelIds);
assertArrayEquals(sortedLabelIds, labelIds);
}
use of org.neo4j.kernel.impl.store.NodeLabels in project neo4j by neo4j.
the class BatchInsertTest method shouldNotCreateSameLabelTwiceOnSameNode.
@Test
public void shouldNotCreateSameLabelTwiceOnSameNode() throws Exception {
// GIVEN
BatchInserter inserter = globalInserter;
// WHEN
long nodeId = inserter.createNode(map("itemId", 1000L), label("Item"), label("Item"));
// THEN
NodeStore nodeStore = getFlushedNeoStores(inserter).getNodeStore();
NodeRecord node = nodeStore.getRecord(nodeId, nodeStore.newRecord(), NORMAL);
NodeLabels labels = NodeLabelsField.parseLabelsField(node);
long[] labelIds = labels.get(nodeStore);
assertEquals(1, labelIds.length);
}
Aggregations