try ( InputIterator nodes = nodes( nodeRandomSeed, nodeCount, config.batchSize(), inputIdGenerator, groups ).iterator(); InputIterator relationships = relationships( relationshipRandomSeed, relationshipCount, config.batchSize(), inputIdGenerator, groups ).iterator(); ResourceIterator<Node> dbNodes = db.getAllNodes().iterator() ) String iid = uniqueId( input.idGroup, input.objectId ); Node node = nodeByInputId.get( iid ); assertNodeEquals( input, node ); verifiedNodes++; assertDegrees( node ); allNodesScanLabelCount += Iterables.count( node.getLabels() ); String name = (String) propertyOf( input, "id" ); Relationship relationship = relationshipByName.get( name ); assertNotNull( "Expected there to be a relationship with name '" + name + "'", relationship ); assertEquals( nodeByInputId.get( uniqueId( input.startIdGroup, input.objectStartId ) ), relationship.getStartNode() ); assertEquals( nodeByInputId.get( uniqueId( input.endIdGroup, input.objectEndId ) ), relationship.getEndNode() ); assertRelationshipEquals( input, relationship );
private void assertRelationshipEquals( InputEntity input, Relationship relationship ) { // properties assertPropertiesEquals( input, relationship ); // type assertEquals( input.stringType, relationship.getType().name() ); }
private void assertPropertiesEquals( InputEntity input, PropertyContainer entity ) { Object[] properties = input.properties(); for ( int i = 0; i < properties.length; i++ ) { String key = (String) properties[i++]; Object value = properties[i]; assertPropertyValueEquals( input, entity, key, value, entity.getProperty( key ) ); } }
private InputIterable nodes( final long randomSeed, final long count, int batchSize, final InputIdGenerator inputIdGenerator, final IdGroupDistribution groups ) { return () -> new GeneratingInputIterator<>( count, batchSize, new RandomsStates( randomSeed ), ( randoms, visitor, id ) -> { Object nodeId = inputIdGenerator.nextNodeId( randoms, id ); Group group = groups.groupOf( id ); visitor.id( nodeId, group ); randomProperties( randoms, uniqueId( group, nodeId ), visitor ); visitor.labels( randoms.selection( TOKENS, 0, TOKENS.length, true ) ); }, 0 ); }
final BatchImporter inserter = new ParallelBatchImporter( databaseLayout, fileSystemRule.get(), null, config, NullLogService.getInstance(), processorAssigner, EMPTY, Config.defaults(), getFormat(), NO_MONITOR, jobScheduler ); try nodes( nodeRandomSeed, NODE_COUNT, config.batchSize(), inputIdGenerator, groupDistribution ), relationships( relationshipRandomSeed, RELATIONSHIP_COUNT, config.batchSize(), inputIdGenerator, groupDistribution ), idMapper.apply( groups ), verifyData( NODE_COUNT, RELATIONSHIP_COUNT, db, groupDistribution, nodeRandomSeed, relationshipRandomSeed ); tx.success(); assertConsistent( databaseLayout ); successful = true;
private String uniqueId( Group group, PropertyContainer entity ) { return uniqueId( group, entity.getProperty( "id" ) ); }
nodes( nodeRandomSeed, NODE_COUNT, inputIdGenerator, groups ), relationships( relationshipRandomSeed, RELATIONSHIP_COUNT, inputIdGenerator, groups ), idMapper, idGenerator, false, verifyData( NODE_COUNT, RELATIONSHIP_COUNT, db, groups, nodeRandomSeed, relationshipRandomSeed ); tx.success(); assertConsistent( directory.graphDbDir() ); successful = true; out.println( inputIdGenerator ); inputIdGenerator.reset(); for ( InputNode node : nodes( nodeRandomSeed, NODE_COUNT, inputIdGenerator, groups ) ) for ( InputRelationship relationship : relationships( relationshipRandomSeed, RELATIONSHIP_COUNT, inputIdGenerator, groups ) )
private String uniqueId( Group group, PropertyContainer entity ) { return uniqueId( group, entity.getProperty( "id" ) ); }
try ( InputIterator<InputNode> nodes = nodes( nodeRandomSeed, nodeCount, inputIdGenerator, groups ).iterator(); InputIterator<InputRelationship> relationships = relationships( relationshipRandomSeed, relationshipCount, inputIdGenerator, groups ).iterator() ) assertNodeEquals( input, node ); String inputId = uniqueId( input.group(), node ); assertNull( nodeByInputId.put( inputId, node ) ); verifiedNodes++; String name = (String) propertyOf( input, "id" ); Relationship relationship = relationshipByName.get( name ); assertEquals( nodeByInputId.get( uniqueId( input.startNodeGroup(), input.startNode() ) ), relationship.getStartNode() ); assertEquals( nodeByInputId.get( uniqueId( input.endNodeGroup(), input.endNode() ) ), relationship.getEndNode() ); assertRelationshipEquals( input, relationship );
private void assertPropertyValueEquals( InputEntity input, PropertyContainer entity, String key, Object expected, Object array ) { if ( expected.getClass().isArray() ) { int length = Array.getLength( expected ); assertEquals( input + ", " + entity, length, Array.getLength( array ) ); for ( int i = 0; i < length; i++ ) { assertPropertyValueEquals( input, entity, key, Array.get( expected, i ), Array.get( array, i ) ); } } else { assertEquals( input + ", " + entity + " for key:" + key, Values.of( expected ), Values.of( array ) ); } }
private void assertNodeEquals( InputEntity input, Node node ) { // properties assertPropertiesEquals( input, node ); // labels Set<String> expectedLabels = asSet( input.labels() ); for ( Label label : node.getLabels() ) { assertTrue( expectedLabels.remove( label.name() ) ); } assertTrue( expectedLabels.isEmpty() ); }
private void assertPropertyValueEquals( InputEntity input, PropertyContainer entity, String key, Object expected, Object array ) { if ( expected.getClass().isArray() ) { int length = Array.getLength( expected ); assertEquals( input + ", " + entity, length, Array.getLength( array ) ); for ( int i = 0; i < length; i++ ) { assertPropertyValueEquals( input, entity, key, Array.get( expected, i ), Array.get( array, i ) ); } } else { assertEquals( input + ", " + entity + " for key:" + key, expected, array ); } }
private void assertNodeEquals( InputNode input, Node node ) { // properties assertPropertiesEquals( input, node ); // labels Set<String> expectedLabels = asSet( input.labels() ); for ( Label label : node.getLabels() ) { assertTrue( expectedLabels.remove( label.name() ) ); } assertTrue( expectedLabels.isEmpty() ); }
private void assertPropertiesEquals( InputEntity input, PropertyContainer entity ) { Object[] properties = input.properties(); for ( int i = 0; i < properties.length; i++ ) { String key = (String) properties[i++]; Object value = properties[i]; assertPropertyValueEquals( input, entity, key, value, entity.getProperty( key ) ); } }
private void assertRelationshipEquals( InputRelationship input, Relationship relationship ) { // properties assertPropertiesEquals( input, relationship ); // type assertEquals( input.type(), relationship.getType().name() ); }