@Override @SuppressWarnings("unchecked") public int compare(BatchJoinKey<K> o1, BatchJoinKey<K> o2) { final int keyResult; if (delegate == null) { // we know that key is comparable keyResult = ((Comparable<K>) o1.getKey()).compareTo(o2.getKey()); } else { keyResult = delegate.compare(o1.getKey(), o2.getKey()); } if (keyResult == 0) { return compareSide(o1.getSide(), o2.getSide()); } return keyResult; }
private Tuple2<BatchJoinKey<String>, Either<String, String>> entry( String key, BatchJoinKey.Side side, Either<String, String> value) { return new Tuple2<>(new BatchJoinKey<>(key, side), value); }
final Object key = operator.getLeftKeyExtractor().apply(se.getElement()); return new Tuple2<>( new BatchJoinKey<>(key, BatchJoinKey.Side.LEFT), Either.<SparkElement, SparkElement>left(se)); }) final Object key = operator.getRightKeyExtractor().apply(se.getElement()); return new Tuple2<>( new BatchJoinKey<>(key, BatchJoinKey.Side.RIGHT), Either.right(se)); });
private void emitLeft() { leftQueue.forEach( left -> outQueue.add( new Tuple2<>( left._1.getKey(), new Tuple2<>(Optional.of(left._2.left()), Optional.empty())))); leftQueue.clear(); }
private void emitCartesianProduct(Tuple2<BatchJoinKey<K>, Either<L, R>> right) { leftQueue.forEach( left -> outQueue.add( new Tuple2<>( left._1.getKey(), new Tuple2<>(Optional.of(left._2.left()), Optional.of(right._2.right()))))); }
private void addElementToStats(Tuple2<BatchJoinKey<K>, Either<L, R>> element) { K key = element._1.getKey(); if (currentKeyStats == null) { currentKeyStats = new StatsItem<>(key); numberOfKeys++; } if (!key.equals(currentKeyStats.key)) { // key has changed, commit statistics keepOrScrapKeyStats(currentKeyStats); currentKeyStats = new StatsItem<>(key); numberOfKeys++; } Either<L, R> eitherSide = element._2; if (eitherSide.isLeft()) { currentKeyStats.leftSideElements++; } else { currentKeyStats.rightSideElements++; } numOfEncounteredElements++; }