Skip to content

Commit

Permalink
fix NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobin Baker committed Jan 6, 2017
1 parent a4ee407 commit 654be57
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@
import edu.washington.escience.myria.operator.network.distribute.DistributeFunction;
import edu.washington.escience.myria.parallel.ExchangePairID;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** JSON wrapper for GenericShuffleProducer encoding. */
public class GenericShuffleProducerEncoding
extends AbstractProducerEncoding<GenericShuffleProducer> {

private static final Logger LOGGER = LoggerFactory.getLogger(GenericShuffleProducerEncoding.class);

/** The distribute function. */
@Required public DistributeFunction distributeFunction;

Expand All @@ -28,9 +23,7 @@ public class GenericShuffleProducerEncoding
@Override
public GenericShuffleProducer construct(final ConstructArgs args) {
Set<Integer> workerIds = getRealWorkerIds();
LOGGER.info("worker IDs: " + workerIds.toString());
List<ExchangePairID> operatorIds = getRealOperatorIds();
LOGGER.info("operator IDs: " + operatorIds.toString());
distributeFunction.setDestinations(workerIds.size(), operatorIds.size());
GenericShuffleProducer producer =
new GenericShuffleProducer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,23 @@

import edu.washington.escience.myria.storage.TupleBatch;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* A partition function that simply sends one tuple to each output in turn.
*/
public final class RoundRobinPartitionFunction extends PartitionFunction {

private static final Logger LOGGER = LoggerFactory.getLogger(RoundRobinPartitionFunction.class);
/** Required for Java serialization. */
private static final long serialVersionUID = 1L;
/** The current partition to use. */
private int curPartition = 0;

@Override
public TupleBatch[] partition(@Nonnull final TupleBatch tb) {
LOGGER.info("Number of partitions: " + numPartitions());
BitSet[] partitions = new BitSet[numPartitions()];
for (int i = 0; i < partitions.length; ++i) {
partitions[i] = new BitSet();
}
for (int i = 0; i < tb.numTuples(); i++) {
LOGGER.info("Current partition: " + curPartition);
partitions[curPartition].set(i);
curPartition = (curPartition + 1) % numPartitions();
}
Expand Down

0 comments on commit 654be57

Please sign in to comment.