use of org.neo4j.kernel.api.impl.schema.SchemaIndex in project neo4j by neo4j.
the class UniqueDatabaseIndexPopulatingUpdaterTest method closeVerifiesUniquenessOfAddedAndChangedValues.
@Test
public void closeVerifiesUniquenessOfAddedAndChangedValues() throws Exception {
SchemaIndex index = mock(SchemaIndex.class);
UniqueLuceneIndexPopulatingUpdater updater = newUpdater(index);
updater.process(add(1, descriptor, "added1"));
updater.process(add(2, descriptor, "added2"));
updater.process(change(3, descriptor, "before1", "after1"));
updater.process(change(4, descriptor, "before2", "after2"));
updater.process(remove(5, descriptor, "removed1"));
verifyZeroInteractions(index);
updater.close();
List<Object> toBeVerified = Arrays.asList("added1", "added2", "after1", "after2");
verify(index).verifyUniqueness(any(), eq(descriptor.getPropertyIds()), eq(toBeVerified));
}
use of org.neo4j.kernel.api.impl.schema.SchemaIndex in project neo4j by neo4j.
the class LuceneSchemaIndexPopulationIT method partitionedIndexPopulation.
@Test
public void partitionedIndexPopulation() throws Exception {
try (SchemaIndex uniqueIndex = LuceneSchemaIndexBuilder.create(descriptor).withFileSystem(fileSystemRule.get()).withIndexRootFolder(testDir.directory("partitionIndex" + affectedNodes)).withIndexIdentifier("uniqueIndex" + affectedNodes).build()) {
uniqueIndex.open();
// index is empty and not yet exist
assertEquals(0, uniqueIndex.allDocumentsReader().maxCount());
assertFalse(uniqueIndex.exists());
try (LuceneIndexAccessor indexAccessor = new LuceneIndexAccessor(uniqueIndex, descriptor)) {
generateUpdates(indexAccessor, affectedNodes);
indexAccessor.force();
// now index is online and should contain updates data
assertTrue(uniqueIndex.isOnline());
try (IndexReader indexReader = indexAccessor.newReader()) {
long[] nodes = PrimitiveLongCollections.asArray(indexReader.query(IndexQuery.exists(1)));
assertEquals(affectedNodes, nodes.length);
IndexSampler indexSampler = indexReader.createSampler();
IndexSample sample = indexSampler.sampleIndex();
assertEquals(affectedNodes, sample.indexSize());
assertEquals(affectedNodes, sample.uniqueValues());
assertEquals(affectedNodes, sample.sampleSize());
}
}
}
}
use of org.neo4j.kernel.api.impl.schema.SchemaIndex in project neo4j by neo4j.
the class UniqueDatabaseIndexPopulatingUpdaterTest method closeVerifiesUniquenessOfChangedValues.
@Test
public void closeVerifiesUniquenessOfChangedValues() throws Exception {
SchemaIndex index = mock(SchemaIndex.class);
UniqueLuceneIndexPopulatingUpdater updater = newUpdater(index);
updater.process(change(1, descriptor, "foo1", "foo2"));
updater.process(change(1, descriptor, "bar1", "bar2"));
updater.process(change(1, descriptor, "baz1", "baz2"));
verifyZeroInteractions(index);
updater.close();
verify(index).verifyUniqueness(any(), eq(descriptor.getPropertyIds()), eq(Arrays.asList("foo2", "bar2", "baz2")));
}
use of org.neo4j.kernel.api.impl.schema.SchemaIndex in project neo4j by neo4j.
the class UniqueDatabaseIndexPopulatingUpdaterTest method closeVerifiesUniquenessOfAddedValues.
@Test
public void closeVerifiesUniquenessOfAddedValues() throws Exception {
SchemaIndex index = mock(SchemaIndex.class);
UniqueLuceneIndexPopulatingUpdater updater = newUpdater(index);
updater.process(add(1, descriptor, "foo"));
updater.process(add(1, descriptor, "bar"));
updater.process(add(1, descriptor, "baz"));
verifyZeroInteractions(index);
updater.close();
verify(index).verifyUniqueness(any(), eq(descriptor.getPropertyIds()), eq(Arrays.asList("foo", "bar", "baz")));
}
Aggregations