Search in sources :

Example 21 with IdMapper

use of org.neo4j.internal.batchimport.cache.idmapping.IdMapper in project neo4j by neo4j.

the class EncodingIdMapperTest method shouldHandleManyGroups.

@Test
public void shouldHandleManyGroups() {
    // GIVEN
    // which results in GLOBAL (0) + 1-256 = 257 groups, i.e. requiring two bytes
    int size = 256;
    for (int i = 0; i < size; i++) {
        groups.getOrCreate("" + i);
    }
    IdMapper mapper = mapper(new LongEncoder(), Radix.LONG, EncodingIdMapper.NO_MONITOR);
    // WHEN
    for (int i = 0; i < size; i++) {
        mapper.put(i, i, groups.get("" + i));
    }
    // null since this test should have been set up to not run into collisions
    mapper.prepare(null, mock(Collector.class), NONE);
    // THEN
    for (int i = 0; i < size; i++) {
        assertEquals(i, mapper.get(i, groups.get("" + i)));
    }
}
Also used : Collector(org.neo4j.internal.batchimport.input.Collector) IdMapper(org.neo4j.internal.batchimport.cache.idmapping.IdMapper) Test(org.junit.Test)

Aggregations

IdMapper (org.neo4j.internal.batchimport.cache.idmapping.IdMapper)21 Test (org.junit.Test)19 Collector (org.neo4j.internal.batchimport.input.Collector)16 PropertyValueLookup (org.neo4j.internal.batchimport.PropertyValueLookup)9 ArrayList (java.util.ArrayList)7 MutableLong (org.apache.commons.lang3.mutable.MutableLong)7 Group (org.neo4j.internal.batchimport.input.Group)7 ProgressListener (org.neo4j.internal.helpers.progress.ProgressListener)7 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 AtomicLong (java.util.concurrent.atomic.AtomicLong)5 ArgumentMatchers.anyLong (org.mockito.ArgumentMatchers.anyLong)5 Math.toIntExact (java.lang.Math.toIntExact)4 Collection (java.util.Collection)4 HashSet (java.util.HashSet)4 List (java.util.List)4 Random (java.util.Random)4 Set (java.util.Set)4 UUID (java.util.UUID)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 LongFunction (java.util.function.LongFunction)4