use of uk.gov.gchq.gaffer.operation.impl.join.match.MatchKey in project Gaffer by gchq.
the class JoinHandler method doOperation.
@Override
public Iterable<? extends MapTuple> doOperation(final Join<I> operation, final Context context, final Store store) throws OperationException {
final int limit = operation.getCollectionLimit() != null ? operation.getCollectionLimit() : 100000;
if (null == operation.getJoinType()) {
throw new OperationException("A join type must be specified");
}
if (null == operation.getMatchMethod()) {
throw new OperationException("A match method must be supplied");
}
if (null == operation.getInput()) {
operation.setInput(new ArrayList<>());
}
MatchKey matchKey = operation.getMatchKey();
if (null == matchKey) {
if (!operation.getJoinType().equals(JoinType.INNER)) {
throw new OperationException("You must specify an Iterable side to match on");
}
// setting match key to avoid swapping inputs
matchKey = MatchKey.LEFT;
}
JoinFunction joinFunction = operation.getJoinType().createInstance();
updateOperationInput(operation.getOperation(), null);
Iterable<I> rightIterable = (Iterable<I>) getResultsOrNull(operation.getOperation(), context, store);
final Iterable limitedLeftIterable;
final Iterable limitedRightIterable;
try {
limitedLeftIterable = new LimitedCloseableIterable(operation.getInput(), 0, limit, false);
limitedRightIterable = new LimitedCloseableIterable(rightIterable, 0, limit, false);
return joinFunction.join(limitedLeftIterable, limitedRightIterable, operation.getMatchMethod(), matchKey, operation.isFlatten());
} catch (final LimitExceededException e) {
throw new OperationException("Join exceeded the collectionLimit, a solution is to increasing collectionLimit value in the join operation.", e);
}
}
Aggregations