/**
* {@inheritDoc}
*/
@Override
public long run(GraphDatabaseService database, final Map<String, Object> params) {
final BatchTransactionExecutor executor = new NoInputBatchTransactionExecutor(database, (int) params.get(BATCH_SIZE), NO_RELATIONSHIPS, new UnitOfWork<NullItem>() {
@Override
public void execute(GraphDatabaseService database, NullItem input, int batchNumber, int stepNumber) {
final Node node1 = randomNode(database, NO_NODES);
final Node node2 = randomNode(database, NO_NODES);
int randomInt = RANDOM.nextInt(5);
switch ((RelationshipQualifier) params.get(TYPE_OR_PROPERTY)) {
case PROPERTY:
Relationship relationship = node1.createRelationshipTo(node2, RATED);
relationship.setProperty("rating", randomInt);
break;
case RELATIONSHIP_TYPE:
node1.createRelationshipTo(node2, TYPES[randomInt]);
break;
}
}
});
return TestUtils.time(new TestUtils.Timed() {
@Override
public void time() {
executor.execute();
}
});
}