fix for issue 582 submitted by Vinayak: NonDeterministicChannelReader is now fair with all channels.
diff --git a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/collectors/NonDeterministicChannelReader.java b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/collectors/NonDeterministicChannelReader.java
index 9a84173..7f447c6 100644
--- a/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/collectors/NonDeterministicChannelReader.java
+++ b/hyracks/hyracks-dataflow-std/src/main/java/edu/uci/ics/hyracks/dataflow/std/collectors/NonDeterministicChannelReader.java
@@ -68,7 +68,7 @@
}
public void open() throws HyracksDataException {
- lastReadSender = 0;
+ lastReadSender = -1;
}
public IInputChannel[] getChannels() {
@@ -77,14 +77,9 @@
public synchronized int findNextSender() throws HyracksDataException {
while (true) {
- switch (lastReadSender) {
- default:
- lastReadSender = frameAvailability.nextSetBit(lastReadSender + 1);
- if (lastReadSender >= 0) {
- break;
- }
- case 0:
- lastReadSender = frameAvailability.nextSetBit(0);
+ lastReadSender = frameAvailability.nextSetBit(lastReadSender + 1);
+ if (lastReadSender < 0) {
+ lastReadSender = frameAvailability.nextSetBit(0);
}
if (lastReadSender >= 0) {
assert availableFrameCounts[lastReadSender] > 0;