use of org.neo4j.kernel.api.impl.labelscan.writer.PartitionedLuceneLabelScanWriter in project neo4j by neo4j.
the class LuceneLabelScanStoreWriterTest method shouldComplainIfNodesSuppliedOutOfRangeOrder.
@Test
public void shouldComplainIfNodesSuppliedOutOfRangeOrder() throws Exception {
// given
int nodeId1 = 1;
int nodeId2 = 65;
StubIndexPartition partition = newStubIndexPartition();
WritableDatabaseLabelScanIndex index = prepareIndex(singletonList(partition));
long node1Range = format.bitmapFormat().rangeOf(nodeId1);
long node2Range = format.bitmapFormat().rangeOf(nodeId2);
assertNotEquals(node1Range, node2Range);
// when
PartitionedLuceneLabelScanWriter writer = createWriter(index);
writer.write(NodeLabelUpdate.labelChanges(nodeId2, new long[] {}, new long[] {}));
try {
writer.write(NodeLabelUpdate.labelChanges(nodeId1, new long[] {}, new long[] {}));
fail("Should have thrown exception");
} catch (IllegalArgumentException e) {
// expected
}
}
use of org.neo4j.kernel.api.impl.labelscan.writer.PartitionedLuceneLabelScanWriter in project neo4j by neo4j.
the class LuceneLabelScanStoreWriterTest method shouldStoreDocumentWithNodeIdsInTheSameRange.
@Test
public void shouldStoreDocumentWithNodeIdsInTheSameRange() throws Exception {
// given
int nodeId1 = 1;
int nodeId2 = 3;
int label1 = 201;
int label2 = 202;
StubIndexPartition partition = newStubIndexPartition();
long range = format.bitmapFormat().rangeOf(nodeId1);
assertEquals(range, format.bitmapFormat().rangeOf(nodeId2));
WritableDatabaseLabelScanIndex index = buildLabelScanIndex(partition);
// when
PartitionedLuceneLabelScanWriter writer = createWriter(index);
writer.write(NodeLabelUpdate.labelChanges(nodeId1, new long[] {}, new long[] { label1 }));
writer.write(NodeLabelUpdate.labelChanges(nodeId2, new long[] {}, new long[] { label2 }));
writer.close();
// then
Document document = partition.documentFor(new Term(RANGE, valueOf(range)));
assertTrue(format.bitmapFormat().hasLabel(parseLong(document.get(valueOf(label1))), nodeId1));
assertTrue(format.bitmapFormat().hasLabel(parseLong(document.get(valueOf(label2))), nodeId2));
}
use of org.neo4j.kernel.api.impl.labelscan.writer.PartitionedLuceneLabelScanWriter in project neo4j by neo4j.
the class LuceneLabelScanStoreWriterTest method shouldStoreDocumentWithNodeIdsAndLabelsInIt.
@Test
public void shouldStoreDocumentWithNodeIdsAndLabelsInIt() throws Exception {
// given
int nodeId = 1;
int label1 = 201;
int label2 = 202;
StubIndexPartition partition = newStubIndexPartition();
WritableDatabaseLabelScanIndex index = buildLabelScanIndex(partition);
// when
PartitionedLuceneLabelScanWriter writer = createWriter(index);
writer.write(NodeLabelUpdate.labelChanges(nodeId, new long[] {}, new long[] { label1, label2 }));
writer.close();
// then
long range = format.bitmapFormat().rangeOf(nodeId);
Document document = partition.documentFor(new Term(RANGE, valueOf(range)));
assertTrue(format.bitmapFormat().hasLabel(parseLong(document.get(valueOf(label1))), nodeId));
assertTrue(format.bitmapFormat().hasLabel(parseLong(document.get(valueOf(label2))), nodeId));
}
use of org.neo4j.kernel.api.impl.labelscan.writer.PartitionedLuceneLabelScanWriter in project neo4j by neo4j.
the class LuceneLabelScanStoreWriterTest method shouldUpdateExistingDocumentWithNodesInTheSameRange.
@Test
public void shouldUpdateExistingDocumentWithNodesInTheSameRange() throws Exception {
// given
int nodeId1 = 1;
int nodeId2 = 3;
int label1 = 201;
int label2 = 202;
StubIndexPartition partition = newStubIndexPartition();
long range = format.bitmapFormat().rangeOf(nodeId1);
assertEquals(range, format.bitmapFormat().rangeOf(nodeId2));
WritableDatabaseLabelScanIndex index = buildLabelScanIndex(partition);
// node already indexed
PartitionedLuceneLabelScanWriter writer = createWriter(index);
writer.write(NodeLabelUpdate.labelChanges(nodeId1, new long[] {}, new long[] { label1 }));
writer.close();
// when
writer = createWriter(index);
writer.write(NodeLabelUpdate.labelChanges(nodeId2, new long[] {}, new long[] { label2 }));
writer.close();
// then
Document document = partition.documentFor(new Term(RANGE, valueOf(range)));
assertTrue(format.bitmapFormat().hasLabel(parseLong(document.get(valueOf(label1))), nodeId1));
assertTrue(format.bitmapFormat().hasLabel(parseLong(document.get(valueOf(label2))), nodeId2));
}
use of org.neo4j.kernel.api.impl.labelscan.writer.PartitionedLuceneLabelScanWriter in project neo4j by neo4j.
the class LuceneLabelScanStoreWriterTest method automaticPartitionCreation.
@Test
public void automaticPartitionCreation() throws IOException {
int nodeForPartition1 = 1;
int nodeForPartition2 = (format.bitmapFormat().rangeSize() * 2) + 1;
int labelNode1 = 201;
int labelNode2 = 202;
System.setProperty("labelScanStore.maxPartitionSize", "2");
StubIndexPartition partition = newStubIndexPartition();
WritableDatabaseLabelScanIndex index = buildLabelScanIndex(partition);
PartitionedLuceneLabelScanWriter writer = createWriter(index);
writer.write(NodeLabelUpdate.labelChanges(nodeForPartition1, new long[] {}, new long[] { labelNode1 }));
writer.write(NodeLabelUpdate.labelChanges(nodeForPartition2, new long[] {}, new long[] { labelNode2 }));
writer.close();
assertEquals("We should have 2 index partitions", 2, index.getPartitions().size());
}
Aggregations