Search in sources :

Example 6 with ProgressListener

use of org.neo4j.helpers.progress.ProgressListener in project neo4j by neo4j.

the class EncodingIdMapperTest method shouldReportyProgressForSortAndDetect.

@Test
public void shouldReportyProgressForSortAndDetect() throws Exception {
    // GIVEN
    IdMapper idMapper = mapper(new StringEncoder(), Radix.STRING, NO_MONITOR);
    ProgressListener progress = mock(ProgressListener.class);
    idMapper.prepare(null, mock(Collector.class), progress);
    // WHEN
    long id = idMapper.get("123", GLOBAL);
    // THEN
    assertEquals(ID_NOT_FOUND, id);
    verify(progress, times(3)).started(anyString());
    verify(progress, times(3)).done();
}
Also used : ProgressListener(org.neo4j.helpers.progress.ProgressListener) Collector(org.neo4j.unsafe.impl.batchimport.input.Collector) Collectors.badCollector(org.neo4j.unsafe.impl.batchimport.input.Collectors.badCollector) IdMapper(org.neo4j.unsafe.impl.batchimport.cache.idmapping.IdMapper) Test(org.junit.Test)

Example 7 with ProgressListener

use of org.neo4j.helpers.progress.ProgressListener in project neo4j by neo4j.

the class EncodingIdMapperTest method shouldCopeWithCollisionsBasedOnDifferentInputIds.

@Test
public void shouldCopeWithCollisionsBasedOnDifferentInputIds() throws Exception {
    // GIVEN
    Monitor monitor = mock(Monitor.class);
    Encoder encoder = mock(Encoder.class);
    when(encoder.encode(any())).thenReturn(12345L);
    IdMapper mapper = mapper(encoder, Radix.STRING, monitor);
    InputIterable<Object> ids = wrap("source", Arrays.<Object>asList("10", "9"));
    try (ResourceIterator<Object> iterator = ids.iterator()) {
        for (int i = 0; iterator.hasNext(); i++) {
            mapper.put(iterator.next(), i, GLOBAL);
        }
    }
    // WHEN
    ProgressListener progress = mock(ProgressListener.class);
    Collector collector = mock(Collector.class);
    mapper.prepare(ids, collector, progress);
    // THEN
    verifyNoMoreInteractions(collector);
    verify(monitor).numberOfCollisions(2);
    assertEquals(0L, mapper.get("10", GLOBAL));
    assertEquals(1L, mapper.get("9", GLOBAL));
    // 7 times since SPLIT+SORT+DETECT+RESOLVE+SPLIT+SORT,DEDUPLICATE
    verify(progress, times(7)).started(anyString());
    verify(progress, times(7)).done();
}
Also used : Monitor(org.neo4j.unsafe.impl.batchimport.cache.idmapping.string.EncodingIdMapper.Monitor) ProgressListener(org.neo4j.helpers.progress.ProgressListener) Collector(org.neo4j.unsafe.impl.batchimport.input.Collector) Collectors.badCollector(org.neo4j.unsafe.impl.batchimport.input.Collectors.badCollector) IdMapper(org.neo4j.unsafe.impl.batchimport.cache.idmapping.IdMapper) Test(org.junit.Test)

Aggregations

ProgressListener (org.neo4j.helpers.progress.ProgressListener)7 Test (org.junit.Test)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 ProgressMonitorFactory (org.neo4j.helpers.progress.ProgressMonitorFactory)2 IdMapper (org.neo4j.unsafe.impl.batchimport.cache.idmapping.IdMapper)2 Collector (org.neo4j.unsafe.impl.batchimport.input.Collector)2 Collectors.badCollector (org.neo4j.unsafe.impl.batchimport.input.Collectors.badCollector)2 Iterator (java.util.Iterator)1 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1 BlockingQueue (java.util.concurrent.BlockingQueue)1 QueueDistributor (org.neo4j.consistency.checking.full.QueueDistribution.QueueDistributor)1 CountsEntry (org.neo4j.consistency.store.synthetic.CountsEntry)1 DependencyResolver (org.neo4j.graphdb.DependencyResolver)1 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)1 PageCache (org.neo4j.io.pagecache.PageCache)1 CountsVisitor (org.neo4j.kernel.impl.api.CountsVisitor)1 TransactionRepresentationCommitProcess (org.neo4j.kernel.impl.api.TransactionRepresentationCommitProcess)1 TransactionToApply (org.neo4j.kernel.impl.api.TransactionToApply)1 CommittedTransactionRepresentation (org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation)1 TransactionRepresentation (org.neo4j.kernel.impl.transaction.TransactionRepresentation)1