use of org.neo4j.internal.batchimport.cache.idmapping.IdMapper in project neo4j by neo4j.
the class EncodingIdMapperTest method shouldBeAbleToHaveDuplicateInputIdButInDifferentGroups.
@Test
public void shouldBeAbleToHaveDuplicateInputIdButInDifferentGroups() {
// GIVEN
EncodingIdMapper.Monitor monitor = mock(EncodingIdMapper.Monitor.class);
Group firstGroup = groups.getOrCreate("first");
Group secondGroup = groups.getOrCreate("second");
IdMapper mapper = mapper(new StringEncoder(), Radix.STRING, monitor);
PropertyValueLookup ids = values("10", "9", "10");
int id = 0;
// group 0
mapper.put(ids.lookupProperty(id, NULL), id++, firstGroup);
mapper.put(ids.lookupProperty(id, NULL), id++, firstGroup);
// group 1
mapper.put(ids.lookupProperty(id, NULL), id, secondGroup);
Collector collector = mock(Collector.class);
mapper.prepare(ids, collector, NONE);
// WHEN/THEN
verifyNoMoreInteractions(collector);
verify(monitor).numberOfCollisions(0);
assertEquals(0L, mapper.get("10", firstGroup));
assertEquals(1L, mapper.get("9", firstGroup));
assertEquals(2L, mapper.get("10", secondGroup));
assertFalse(mapper.leftOverDuplicateNodesIds().hasNext());
}
use of org.neo4j.internal.batchimport.cache.idmapping.IdMapper in project neo4j by neo4j.
the class EncodingIdMapperTest method shouldHandleHolesInIdSequence.
@Test
public void shouldHandleHolesInIdSequence() {
// GIVEN
IdMapper mapper = mapper(new LongEncoder(), Radix.LONG, EncodingIdMapper.NO_MONITOR);
List<Object> ids = new ArrayList<>();
for (int i = 0; i < 100; i++) {
if (!random.nextBoolean()) {
Long id = (long) i;
ids.add(id);
mapper.put(id, i, Group.GLOBAL);
}
}
// WHEN
mapper.prepare(values(ids.toArray()), mock(Collector.class), NONE);
// THEN
for (Object id : ids) {
assertEquals(((Long) id).longValue(), mapper.get(id, Group.GLOBAL));
}
}
use of org.neo4j.internal.batchimport.cache.idmapping.IdMapper in project neo4j by neo4j.
the class EncodingIdMapperTest method shouldReportyProgressForSortAndDetect.
@Test
public void shouldReportyProgressForSortAndDetect() {
// GIVEN
IdMapper idMapper = mapper(new StringEncoder(), Radix.STRING, EncodingIdMapper.NO_MONITOR);
ProgressListener progress = mock(ProgressListener.class);
idMapper.prepare(null, mock(Collector.class), progress);
// WHEN
long id = idMapper.get("123", Group.GLOBAL);
// THEN
assertEquals(IdMapper.ID_NOT_FOUND, id);
verify(progress, times(3)).started(anyString());
verify(progress, times(3)).done();
}
use of org.neo4j.internal.batchimport.cache.idmapping.IdMapper in project neo4j by neo4j.
the class EncodingIdMapperTest method shouldReportCollisionsForSameInputId.
@Test
public void shouldReportCollisionsForSameInputId() {
// GIVEN
IdMapper mapper = mapper(new StringEncoder(), Radix.STRING, EncodingIdMapper.NO_MONITOR);
PropertyValueLookup values = values("10", "9", "10");
for (int i = 0; i < 3; i++) {
mapper.put(values.lookupProperty(i, NULL), i, Group.GLOBAL);
}
// WHEN
Collector collector = mock(Collector.class);
mapper.prepare(values, collector, NONE);
// THEN
verify(collector).collectDuplicateNode("10", 2, Group.GLOBAL.name());
verifyNoMoreInteractions(collector);
}
use of org.neo4j.internal.batchimport.cache.idmapping.IdMapper in project neo4j by neo4j.
the class HumanUnderstandableExecutionMonitor method initialize.
@Override
public void initialize(DependencyResolver dependencyResolver) {
this.dependencyResolver = dependencyResolver;
Input.Estimates estimates = dependencyResolver.resolveDependency(Input.Estimates.class);
BatchingNeoStores neoStores = dependencyResolver.resolveDependency(BatchingNeoStores.class);
IdMapper idMapper = dependencyResolver.resolveDependency(IdMapper.class);
pageCacheArrayFactoryMonitor = dependencyResolver.resolveDependency(PageCacheArrayFactoryMonitor.class);
long biggestCacheMemory = estimatedCacheSize(neoStores, NodeRelationshipCache.memoryEstimation(estimates.numberOfNodes()), idMapper.memoryEstimation(estimates.numberOfNodes()));
System.out.println();
printStageHeader("Import starting", ESTIMATED_NUMBER_OF_NODES, count(estimates.numberOfNodes()), ESTIMATED_NUMBER_OF_NODE_PROPERTIES, count(estimates.numberOfNodeProperties()), ESTIMATED_NUMBER_OF_RELATIONSHIPS, count(estimates.numberOfRelationships()), ESTIMATED_NUMBER_OF_RELATIONSHIP_PROPERTIES, count(estimates.numberOfRelationshipProperties()), ESTIMATED_DISK_SPACE_USAGE, bytesToString(nodesDiskUsage(estimates, neoStores) + relationshipsDiskUsage(estimates, neoStores) + estimates.sizeOfNodeProperties() + estimates.sizeOfRelationshipProperties()), ESTIMATED_REQUIRED_MEMORY_USAGE, bytesToString(biggestCacheMemory));
System.out.println();
}
Aggregations