Search in sources :

Example 6 with PropertyAccessor

use of org.neo4j.kernel.api.index.PropertyAccessor in project neo4j by neo4j.

the class SimpleUniquenessVerifierTest method numericIndexVerificationNoDuplicates.

@Test
public void numericIndexVerificationNoDuplicates() throws Exception {
    List<Object> data = asList(Integer.MAX_VALUE - 2, Integer.MAX_VALUE - 1, Integer.MAX_VALUE);
    PropertyAccessor propertyAccessor = newPropertyAccessor(data);
    insert(data);
    IndexSearcher indexSearcher = spy(searcherManager.acquire());
    runUniquenessVerification(propertyAccessor, indexSearcher);
    verify(indexSearcher, never()).search(any(Query.class), any(Collector.class));
}
Also used : IndexSearcher(org.apache.lucene.search.IndexSearcher) TestPropertyAccessor(org.neo4j.kernel.api.impl.index.TestPropertyAccessor) PropertyAccessor(org.neo4j.kernel.api.index.PropertyAccessor) Query(org.apache.lucene.search.Query) Collector(org.apache.lucene.search.Collector) Test(org.junit.Test)

Example 7 with PropertyAccessor

use of org.neo4j.kernel.api.index.PropertyAccessor in project neo4j by neo4j.

the class ConstraintIndexCreatorTest method shouldReleaseSchemaLockWhileAwaitingIndexPopulation.

@Test
public void shouldReleaseSchemaLockWhileAwaitingIndexPopulation() throws Exception {
    // given
    StubKernel kernel = new StubKernel();
    IndexingService indexingService = mock(IndexingService.class);
    StatementOperationParts constraintCreationContext = mockedParts();
    PropertyAccessor propertyAccessor = mock(PropertyAccessor.class);
    KernelStatement state = mockedState();
    when(constraintCreationContext.schemaReadOperations().indexGetCommittedId(state, index)).thenReturn(2468L);
    IndexProxy indexProxy = mock(IndexProxy.class);
    when(indexingService.getIndexProxy(anyLong())).thenReturn(indexProxy);
    ConstraintIndexCreator creator = new ConstraintIndexCreator(() -> kernel, indexingService, propertyAccessor, true);
    // when
    creator.createUniquenessConstraintIndex(state, constraintCreationContext.schemaReadOperations(), index.schema());
    // then
    verify(state.locks().pessimistic()).releaseExclusive(ResourceTypes.SCHEMA, ResourceTypes.schemaResource());
    verify(state.locks().pessimistic()).acquireExclusive(state.lockTracer(), ResourceTypes.SCHEMA, ResourceTypes.schemaResource());
}
Also used : ConstraintIndexCreator(org.neo4j.kernel.impl.api.state.ConstraintIndexCreator) PropertyAccessor(org.neo4j.kernel.api.index.PropertyAccessor) StatementOperationParts(org.neo4j.kernel.impl.api.StatementOperationParts) KernelStatement(org.neo4j.kernel.impl.api.KernelStatement) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) IndexProxy(org.neo4j.kernel.impl.api.index.IndexProxy) Test(org.junit.Test)

Aggregations

PropertyAccessor (org.neo4j.kernel.api.index.PropertyAccessor)7 Test (org.junit.Test)6 Collector (org.apache.lucene.search.Collector)3 IndexSearcher (org.apache.lucene.search.IndexSearcher)3 Query (org.apache.lucene.search.Query)3 TestPropertyAccessor (org.neo4j.kernel.api.impl.index.TestPropertyAccessor)3 IOException (java.io.IOException)2 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)2 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 List (java.util.List)1 Objects (java.util.Objects)1 Set (java.util.Set)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 IntStream (java.util.stream.IntStream)1 RandomStringUtils (org.apache.commons.lang3.RandomStringUtils)1 Document (org.apache.lucene.document.Document)1