You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by ja...@apache.org on 2015/05/14 06:42:06 UTC

[1/8] drill git commit: DRILL-3079: Move execution fragment json parsing from RPC message to fragment start.

Repository: drill
Updated Branches:
  refs/heads/master 814f553f2 -> 583ca4a95


http://git-wip-us.apache.org/repos/asf/drill/blob/4ad42611/protocol/src/main/java/org/apache/drill/exec/proto/beans/PlanFragment.java
----------------------------------------------------------------------
diff --git a/protocol/src/main/java/org/apache/drill/exec/proto/beans/PlanFragment.java b/protocol/src/main/java/org/apache/drill/exec/proto/beans/PlanFragment.java
index 08c2073..3a3aea2 100644
--- a/protocol/src/main/java/org/apache/drill/exec/proto/beans/PlanFragment.java
+++ b/protocol/src/main/java/org/apache/drill/exec/proto/beans/PlanFragment.java
@@ -24,6 +24,8 @@ import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
 
 import com.dyuproject.protostuff.GraphIOUtil;
 import com.dyuproject.protostuff.Input;
@@ -63,6 +65,7 @@ public final class PlanFragment implements Externalizable, Message<PlanFragment>
     private UserCredentials credentials;
     private String optionsJson;
     private QueryContextInformation context;
+    private List<Collector> collector;
 
     public PlanFragment()
     {
@@ -253,6 +256,19 @@ public final class PlanFragment implements Externalizable, Message<PlanFragment>
         return this;
     }
 
+    // collector
+
+    public List<Collector> getCollectorList()
+    {
+        return collector;
+    }
+
+    public PlanFragment setCollectorList(List<Collector> collector)
+    {
+        this.collector = collector;
+        return this;
+    }
+
     // java serialization
 
     public void readExternal(ObjectInput in) throws IOException
@@ -354,6 +370,12 @@ public final class PlanFragment implements Externalizable, Message<PlanFragment>
                     message.context = input.mergeObject(message.context, QueryContextInformation.getSchema());
                     break;
 
+                case 17:
+                    if(message.collector == null)
+                        message.collector = new ArrayList<Collector>();
+                    message.collector.add(input.mergeObject(null, Collector.getSchema()));
+                    break;
+
                 default:
                     input.handleUnknownField(number, this);
             }   
@@ -409,6 +431,16 @@ public final class PlanFragment implements Externalizable, Message<PlanFragment>
         if(message.context != null)
              output.writeObject(16, message.context, QueryContextInformation.getSchema(), false);
 
+
+        if(message.collector != null)
+        {
+            for(Collector collector : message.collector)
+            {
+                if(collector != null)
+                    output.writeObject(17, collector, Collector.getSchema(), true);
+            }
+        }
+
     }
 
     public String getFieldName(int number)
@@ -429,6 +461,7 @@ public final class PlanFragment implements Externalizable, Message<PlanFragment>
             case 14: return "credentials";
             case 15: return "optionsJson";
             case 16: return "context";
+            case 17: return "collector";
             default: return null;
         }
     }
@@ -456,6 +489,7 @@ public final class PlanFragment implements Externalizable, Message<PlanFragment>
         __fieldMap.put("credentials", 14);
         __fieldMap.put("optionsJson", 15);
         __fieldMap.put("context", 16);
+        __fieldMap.put("collector", 17);
     }
     
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/4ad42611/protocol/src/main/protobuf/BitControl.proto
----------------------------------------------------------------------
diff --git a/protocol/src/main/protobuf/BitControl.proto b/protocol/src/main/protobuf/BitControl.proto
index c9295f0..6d1b529 100644
--- a/protocol/src/main/protobuf/BitControl.proto
+++ b/protocol/src/main/protobuf/BitControl.proto
@@ -67,6 +67,14 @@ message PlanFragment {
   optional exec.shared.UserCredentials credentials = 14;
   optional string options_json = 15;
   optional QueryContextInformation context = 16;
+  repeated Collector collector = 17;
+}
+
+message Collector {
+  optional int32 opposite_major_fragment_id = 1;
+  repeated int32 incoming_minor_fragment = 2 [packed=true];
+  optional bool supports_out_of_order = 3;
+  optional bool is_spooling = 4;
 }
 
 message QueryContextInformation {


[5/8] drill git commit: DRILL-3062: Rtrim the fixed char strings in the IN list for comparison with varchar columns.

Posted by ja...@apache.org.
DRILL-3062:  Rtrim the fixed char strings in the IN list for comparison with varchar columns.


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/49940b88
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/49940b88
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/49940b88

Branch: refs/heads/master
Commit: 49940b887aa8c31c7f5a435ce365294b7a082870
Parents: 97a6316
Author: Aman Sinha <as...@maprtech.com>
Authored: Wed May 13 18:31:33 2015 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Wed May 13 19:34:01 2015 -0700

----------------------------------------------------------------------
 .../drill/exec/planner/logical/DrillValuesRel.java  |  7 ++++++-
 .../physical/impl/filter/TestLargeInClause.java     | 16 ++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/49940b88/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillValuesRel.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillValuesRel.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillValuesRel.java
index cd259d7..a6c4661 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillValuesRel.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillValuesRel.java
@@ -183,7 +183,12 @@ public class DrillValuesRel extends AbstractRelNode implements DrillRel {
       if (isLiteralNull(literal)) {
         out.writeVarcharNull();
       }else{
-        out.writeVarChar(((NlsString)literal.getValue()).getValue());
+        // Since Calcite treats string literals as fixed char and adds trailing spaces to the strings to make them the
+        // same length, here we do an rtrim() to get the string without the trailing spaces. If we don't rtrim, the comparison
+        // with Drill's varchar column values would not return a match.
+        // TODO: However, note that if the user had explicitly added spaces in the string literals then even those would get
+        // trimmed, so this exposes another issue that needs to be resolved.
+        out.writeVarChar(((NlsString)literal.getValue()).rtrim().getValue());
       }
       return ;
 

http://git-wip-us.apache.org/repos/asf/drill/blob/49940b88/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/filter/TestLargeInClause.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/filter/TestLargeInClause.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/filter/TestLargeInClause.java
index 1e29214..281a946 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/filter/TestLargeInClause.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/filter/TestLargeInClause.java
@@ -59,4 +59,20 @@ public class TestLargeInClause extends BaseTestQuery {
     test("select * from cp.`employee.json` where cast(birth_date as date) in (" + getInDateList(500) + ")");
   }
 
+  @Test // DRILL-3062
+  public void testStringLiterals() throws Exception {
+    String query = "select count(*) as cnt from (select n_name from cp.`tpch/nation.parquet` "
+        + " where n_name in ('ALGERIA', 'ARGENTINA', 'BRAZIL', 'CANADA', 'EGYPT', 'ETHIOPIA', 'FRANCE', "
+        + "'GERMANY', 'INDIA', 'INDONESIA', 'IRAN', 'IRAQ', 'JAPAN', 'JORDAN', 'KENYA', 'MOROCCO', 'MOZAMBIQUE', "
+        + "'PERU', 'CHINA', 'ROMANIA', 'SAUDI ARABIA', 'VIETNAM'))";
+
+    testBuilder()
+      .sqlQuery(query)
+      .unOrdered()
+      .baselineColumns("cnt")
+      .baselineValues(22l)
+      .go();
+
+  }
+
 }


[2/8] drill git commit: DRILL-3079: Move execution fragment json parsing from RPC message to fragment start.

Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/drill/blob/4ad42611/protocol/src/main/java/org/apache/drill/exec/proto/BitControl.java
----------------------------------------------------------------------
diff --git a/protocol/src/main/java/org/apache/drill/exec/proto/BitControl.java b/protocol/src/main/java/org/apache/drill/exec/proto/BitControl.java
index b428337..493036b 100644
--- a/protocol/src/main/java/org/apache/drill/exec/proto/BitControl.java
+++ b/protocol/src/main/java/org/apache/drill/exec/proto/BitControl.java
@@ -3189,6 +3189,31 @@ public final class BitControl {
      * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
      */
     org.apache.drill.exec.proto.BitControl.QueryContextInformationOrBuilder getContextOrBuilder();
+
+    // repeated .exec.bit.control.Collector collector = 17;
+    /**
+     * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+     */
+    java.util.List<org.apache.drill.exec.proto.BitControl.Collector> 
+        getCollectorList();
+    /**
+     * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+     */
+    org.apache.drill.exec.proto.BitControl.Collector getCollector(int index);
+    /**
+     * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+     */
+    int getCollectorCount();
+    /**
+     * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+     */
+    java.util.List<? extends org.apache.drill.exec.proto.BitControl.CollectorOrBuilder> 
+        getCollectorOrBuilderList();
+    /**
+     * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+     */
+    org.apache.drill.exec.proto.BitControl.CollectorOrBuilder getCollectorOrBuilder(
+        int index);
   }
   /**
    * Protobuf type {@code exec.bit.control.PlanFragment}
@@ -3351,6 +3376,14 @@ public final class BitControl {
               bitField0_ |= 0x00002000;
               break;
             }
+            case 138: {
+              if (!((mutable_bitField0_ & 0x00004000) == 0x00004000)) {
+                collector_ = new java.util.ArrayList<org.apache.drill.exec.proto.BitControl.Collector>();
+                mutable_bitField0_ |= 0x00004000;
+              }
+              collector_.add(input.readMessage(org.apache.drill.exec.proto.BitControl.Collector.PARSER, extensionRegistry));
+              break;
+            }
           }
         }
       } catch (com.google.protobuf.InvalidProtocolBufferException e) {
@@ -3359,6 +3392,9 @@ public final class BitControl {
         throw new com.google.protobuf.InvalidProtocolBufferException(
             e.getMessage()).setUnfinishedMessage(this);
       } finally {
+        if (((mutable_bitField0_ & 0x00004000) == 0x00004000)) {
+          collector_ = java.util.Collections.unmodifiableList(collector_);
+        }
         this.unknownFields = unknownFields.build();
         makeExtensionsImmutable();
       }
@@ -3715,6 +3751,42 @@ public final class BitControl {
       return context_;
     }
 
+    // repeated .exec.bit.control.Collector collector = 17;
+    public static final int COLLECTOR_FIELD_NUMBER = 17;
+    private java.util.List<org.apache.drill.exec.proto.BitControl.Collector> collector_;
+    /**
+     * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+     */
+    public java.util.List<org.apache.drill.exec.proto.BitControl.Collector> getCollectorList() {
+      return collector_;
+    }
+    /**
+     * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+     */
+    public java.util.List<? extends org.apache.drill.exec.proto.BitControl.CollectorOrBuilder> 
+        getCollectorOrBuilderList() {
+      return collector_;
+    }
+    /**
+     * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+     */
+    public int getCollectorCount() {
+      return collector_.size();
+    }
+    /**
+     * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+     */
+    public org.apache.drill.exec.proto.BitControl.Collector getCollector(int index) {
+      return collector_.get(index);
+    }
+    /**
+     * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+     */
+    public org.apache.drill.exec.proto.BitControl.CollectorOrBuilder getCollectorOrBuilder(
+        int index) {
+      return collector_.get(index);
+    }
+
     private void initFields() {
       handle_ = org.apache.drill.exec.proto.ExecProtos.FragmentHandle.getDefaultInstance();
       networkCost_ = 0F;
@@ -3730,6 +3802,7 @@ public final class BitControl {
       credentials_ = org.apache.drill.exec.proto.UserBitShared.UserCredentials.getDefaultInstance();
       optionsJson_ = "";
       context_ = org.apache.drill.exec.proto.BitControl.QueryContextInformation.getDefaultInstance();
+      collector_ = java.util.Collections.emptyList();
     }
     private byte memoizedIsInitialized = -1;
     public final boolean isInitialized() {
@@ -3785,6 +3858,9 @@ public final class BitControl {
       if (((bitField0_ & 0x00002000) == 0x00002000)) {
         output.writeMessage(16, context_);
       }
+      for (int i = 0; i < collector_.size(); i++) {
+        output.writeMessage(17, collector_.get(i));
+      }
       getUnknownFields().writeTo(output);
     }
 
@@ -3850,6 +3926,10 @@ public final class BitControl {
         size += com.google.protobuf.CodedOutputStream
           .computeMessageSize(16, context_);
       }
+      for (int i = 0; i < collector_.size(); i++) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeMessageSize(17, collector_.get(i));
+      }
       size += getUnknownFields().getSerializedSize();
       memoizedSerializedSize = size;
       return size;
@@ -3963,6 +4043,7 @@ public final class BitControl {
           getForemanFieldBuilder();
           getCredentialsFieldBuilder();
           getContextFieldBuilder();
+          getCollectorFieldBuilder();
         }
       }
       private static Builder create() {
@@ -4019,6 +4100,12 @@ public final class BitControl {
           contextBuilder_.clear();
         }
         bitField0_ = (bitField0_ & ~0x00002000);
+        if (collectorBuilder_ == null) {
+          collector_ = java.util.Collections.emptyList();
+          bitField0_ = (bitField0_ & ~0x00004000);
+        } else {
+          collectorBuilder_.clear();
+        }
         return this;
       }
 
@@ -4123,6 +4210,15 @@ public final class BitControl {
         } else {
           result.context_ = contextBuilder_.build();
         }
+        if (collectorBuilder_ == null) {
+          if (((bitField0_ & 0x00004000) == 0x00004000)) {
+            collector_ = java.util.Collections.unmodifiableList(collector_);
+            bitField0_ = (bitField0_ & ~0x00004000);
+          }
+          result.collector_ = collector_;
+        } else {
+          result.collector_ = collectorBuilder_.build();
+        }
         result.bitField0_ = to_bitField0_;
         onBuilt();
         return result;
@@ -4185,6 +4281,32 @@ public final class BitControl {
         if (other.hasContext()) {
           mergeContext(other.getContext());
         }
+        if (collectorBuilder_ == null) {
+          if (!other.collector_.isEmpty()) {
+            if (collector_.isEmpty()) {
+              collector_ = other.collector_;
+              bitField0_ = (bitField0_ & ~0x00004000);
+            } else {
+              ensureCollectorIsMutable();
+              collector_.addAll(other.collector_);
+            }
+            onChanged();
+          }
+        } else {
+          if (!other.collector_.isEmpty()) {
+            if (collectorBuilder_.isEmpty()) {
+              collectorBuilder_.dispose();
+              collectorBuilder_ = null;
+              collector_ = other.collector_;
+              bitField0_ = (bitField0_ & ~0x00004000);
+              collectorBuilder_ = 
+                com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
+                   getCollectorFieldBuilder() : null;
+            } else {
+              collectorBuilder_.addAllMessages(other.collector_);
+            }
+          }
+        }
         this.mergeUnknownFields(other.getUnknownFields());
         return this;
       }
@@ -4945,278 +5067,1243 @@ public final class BitControl {
           credentials_ = builderForValue.build();
           onChanged();
         } else {
-          credentialsBuilder_.setMessage(builderForValue.build());
+          credentialsBuilder_.setMessage(builderForValue.build());
+        }
+        bitField0_ |= 0x00000800;
+        return this;
+      }
+      /**
+       * <code>optional .exec.shared.UserCredentials credentials = 14;</code>
+       */
+      public Builder mergeCredentials(org.apache.drill.exec.proto.UserBitShared.UserCredentials value) {
+        if (credentialsBuilder_ == null) {
+          if (((bitField0_ & 0x00000800) == 0x00000800) &&
+              credentials_ != org.apache.drill.exec.proto.UserBitShared.UserCredentials.getDefaultInstance()) {
+            credentials_ =
+              org.apache.drill.exec.proto.UserBitShared.UserCredentials.newBuilder(credentials_).mergeFrom(value).buildPartial();
+          } else {
+            credentials_ = value;
+          }
+          onChanged();
+        } else {
+          credentialsBuilder_.mergeFrom(value);
+        }
+        bitField0_ |= 0x00000800;
+        return this;
+      }
+      /**
+       * <code>optional .exec.shared.UserCredentials credentials = 14;</code>
+       */
+      public Builder clearCredentials() {
+        if (credentialsBuilder_ == null) {
+          credentials_ = org.apache.drill.exec.proto.UserBitShared.UserCredentials.getDefaultInstance();
+          onChanged();
+        } else {
+          credentialsBuilder_.clear();
+        }
+        bitField0_ = (bitField0_ & ~0x00000800);
+        return this;
+      }
+      /**
+       * <code>optional .exec.shared.UserCredentials credentials = 14;</code>
+       */
+      public org.apache.drill.exec.proto.UserBitShared.UserCredentials.Builder getCredentialsBuilder() {
+        bitField0_ |= 0x00000800;
+        onChanged();
+        return getCredentialsFieldBuilder().getBuilder();
+      }
+      /**
+       * <code>optional .exec.shared.UserCredentials credentials = 14;</code>
+       */
+      public org.apache.drill.exec.proto.UserBitShared.UserCredentialsOrBuilder getCredentialsOrBuilder() {
+        if (credentialsBuilder_ != null) {
+          return credentialsBuilder_.getMessageOrBuilder();
+        } else {
+          return credentials_;
+        }
+      }
+      /**
+       * <code>optional .exec.shared.UserCredentials credentials = 14;</code>
+       */
+      private com.google.protobuf.SingleFieldBuilder<
+          org.apache.drill.exec.proto.UserBitShared.UserCredentials, org.apache.drill.exec.proto.UserBitShared.UserCredentials.Builder, org.apache.drill.exec.proto.UserBitShared.UserCredentialsOrBuilder> 
+          getCredentialsFieldBuilder() {
+        if (credentialsBuilder_ == null) {
+          credentialsBuilder_ = new com.google.protobuf.SingleFieldBuilder<
+              org.apache.drill.exec.proto.UserBitShared.UserCredentials, org.apache.drill.exec.proto.UserBitShared.UserCredentials.Builder, org.apache.drill.exec.proto.UserBitShared.UserCredentialsOrBuilder>(
+                  credentials_,
+                  getParentForChildren(),
+                  isClean());
+          credentials_ = null;
+        }
+        return credentialsBuilder_;
+      }
+
+      // optional string options_json = 15;
+      private java.lang.Object optionsJson_ = "";
+      /**
+       * <code>optional string options_json = 15;</code>
+       */
+      public boolean hasOptionsJson() {
+        return ((bitField0_ & 0x00001000) == 0x00001000);
+      }
+      /**
+       * <code>optional string options_json = 15;</code>
+       */
+      public java.lang.String getOptionsJson() {
+        java.lang.Object ref = optionsJson_;
+        if (!(ref instanceof java.lang.String)) {
+          java.lang.String s = ((com.google.protobuf.ByteString) ref)
+              .toStringUtf8();
+          optionsJson_ = s;
+          return s;
+        } else {
+          return (java.lang.String) ref;
+        }
+      }
+      /**
+       * <code>optional string options_json = 15;</code>
+       */
+      public com.google.protobuf.ByteString
+          getOptionsJsonBytes() {
+        java.lang.Object ref = optionsJson_;
+        if (ref instanceof String) {
+          com.google.protobuf.ByteString b = 
+              com.google.protobuf.ByteString.copyFromUtf8(
+                  (java.lang.String) ref);
+          optionsJson_ = b;
+          return b;
+        } else {
+          return (com.google.protobuf.ByteString) ref;
+        }
+      }
+      /**
+       * <code>optional string options_json = 15;</code>
+       */
+      public Builder setOptionsJson(
+          java.lang.String value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  bitField0_ |= 0x00001000;
+        optionsJson_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>optional string options_json = 15;</code>
+       */
+      public Builder clearOptionsJson() {
+        bitField0_ = (bitField0_ & ~0x00001000);
+        optionsJson_ = getDefaultInstance().getOptionsJson();
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>optional string options_json = 15;</code>
+       */
+      public Builder setOptionsJsonBytes(
+          com.google.protobuf.ByteString value) {
+        if (value == null) {
+    throw new NullPointerException();
+  }
+  bitField0_ |= 0x00001000;
+        optionsJson_ = value;
+        onChanged();
+        return this;
+      }
+
+      // optional .exec.bit.control.QueryContextInformation context = 16;
+      private org.apache.drill.exec.proto.BitControl.QueryContextInformation context_ = org.apache.drill.exec.proto.BitControl.QueryContextInformation.getDefaultInstance();
+      private com.google.protobuf.SingleFieldBuilder<
+          org.apache.drill.exec.proto.BitControl.QueryContextInformation, org.apache.drill.exec.proto.BitControl.QueryContextInformation.Builder, org.apache.drill.exec.proto.BitControl.QueryContextInformationOrBuilder> contextBuilder_;
+      /**
+       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       */
+      public boolean hasContext() {
+        return ((bitField0_ & 0x00002000) == 0x00002000);
+      }
+      /**
+       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       */
+      public org.apache.drill.exec.proto.BitControl.QueryContextInformation getContext() {
+        if (contextBuilder_ == null) {
+          return context_;
+        } else {
+          return contextBuilder_.getMessage();
+        }
+      }
+      /**
+       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       */
+      public Builder setContext(org.apache.drill.exec.proto.BitControl.QueryContextInformation value) {
+        if (contextBuilder_ == null) {
+          if (value == null) {
+            throw new NullPointerException();
+          }
+          context_ = value;
+          onChanged();
+        } else {
+          contextBuilder_.setMessage(value);
+        }
+        bitField0_ |= 0x00002000;
+        return this;
+      }
+      /**
+       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       */
+      public Builder setContext(
+          org.apache.drill.exec.proto.BitControl.QueryContextInformation.Builder builderForValue) {
+        if (contextBuilder_ == null) {
+          context_ = builderForValue.build();
+          onChanged();
+        } else {
+          contextBuilder_.setMessage(builderForValue.build());
+        }
+        bitField0_ |= 0x00002000;
+        return this;
+      }
+      /**
+       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       */
+      public Builder mergeContext(org.apache.drill.exec.proto.BitControl.QueryContextInformation value) {
+        if (contextBuilder_ == null) {
+          if (((bitField0_ & 0x00002000) == 0x00002000) &&
+              context_ != org.apache.drill.exec.proto.BitControl.QueryContextInformation.getDefaultInstance()) {
+            context_ =
+              org.apache.drill.exec.proto.BitControl.QueryContextInformation.newBuilder(context_).mergeFrom(value).buildPartial();
+          } else {
+            context_ = value;
+          }
+          onChanged();
+        } else {
+          contextBuilder_.mergeFrom(value);
+        }
+        bitField0_ |= 0x00002000;
+        return this;
+      }
+      /**
+       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       */
+      public Builder clearContext() {
+        if (contextBuilder_ == null) {
+          context_ = org.apache.drill.exec.proto.BitControl.QueryContextInformation.getDefaultInstance();
+          onChanged();
+        } else {
+          contextBuilder_.clear();
+        }
+        bitField0_ = (bitField0_ & ~0x00002000);
+        return this;
+      }
+      /**
+       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       */
+      public org.apache.drill.exec.proto.BitControl.QueryContextInformation.Builder getContextBuilder() {
+        bitField0_ |= 0x00002000;
+        onChanged();
+        return getContextFieldBuilder().getBuilder();
+      }
+      /**
+       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       */
+      public org.apache.drill.exec.proto.BitControl.QueryContextInformationOrBuilder getContextOrBuilder() {
+        if (contextBuilder_ != null) {
+          return contextBuilder_.getMessageOrBuilder();
+        } else {
+          return context_;
+        }
+      }
+      /**
+       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       */
+      private com.google.protobuf.SingleFieldBuilder<
+          org.apache.drill.exec.proto.BitControl.QueryContextInformation, org.apache.drill.exec.proto.BitControl.QueryContextInformation.Builder, org.apache.drill.exec.proto.BitControl.QueryContextInformationOrBuilder> 
+          getContextFieldBuilder() {
+        if (contextBuilder_ == null) {
+          contextBuilder_ = new com.google.protobuf.SingleFieldBuilder<
+              org.apache.drill.exec.proto.BitControl.QueryContextInformation, org.apache.drill.exec.proto.BitControl.QueryContextInformation.Builder, org.apache.drill.exec.proto.BitControl.QueryContextInformationOrBuilder>(
+                  context_,
+                  getParentForChildren(),
+                  isClean());
+          context_ = null;
+        }
+        return contextBuilder_;
+      }
+
+      // repeated .exec.bit.control.Collector collector = 17;
+      private java.util.List<org.apache.drill.exec.proto.BitControl.Collector> collector_ =
+        java.util.Collections.emptyList();
+      private void ensureCollectorIsMutable() {
+        if (!((bitField0_ & 0x00004000) == 0x00004000)) {
+          collector_ = new java.util.ArrayList<org.apache.drill.exec.proto.BitControl.Collector>(collector_);
+          bitField0_ |= 0x00004000;
+         }
+      }
+
+      private com.google.protobuf.RepeatedFieldBuilder<
+          org.apache.drill.exec.proto.BitControl.Collector, org.apache.drill.exec.proto.BitControl.Collector.Builder, org.apache.drill.exec.proto.BitControl.CollectorOrBuilder> collectorBuilder_;
+
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public java.util.List<org.apache.drill.exec.proto.BitControl.Collector> getCollectorList() {
+        if (collectorBuilder_ == null) {
+          return java.util.Collections.unmodifiableList(collector_);
+        } else {
+          return collectorBuilder_.getMessageList();
+        }
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public int getCollectorCount() {
+        if (collectorBuilder_ == null) {
+          return collector_.size();
+        } else {
+          return collectorBuilder_.getCount();
+        }
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public org.apache.drill.exec.proto.BitControl.Collector getCollector(int index) {
+        if (collectorBuilder_ == null) {
+          return collector_.get(index);
+        } else {
+          return collectorBuilder_.getMessage(index);
+        }
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public Builder setCollector(
+          int index, org.apache.drill.exec.proto.BitControl.Collector value) {
+        if (collectorBuilder_ == null) {
+          if (value == null) {
+            throw new NullPointerException();
+          }
+          ensureCollectorIsMutable();
+          collector_.set(index, value);
+          onChanged();
+        } else {
+          collectorBuilder_.setMessage(index, value);
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public Builder setCollector(
+          int index, org.apache.drill.exec.proto.BitControl.Collector.Builder builderForValue) {
+        if (collectorBuilder_ == null) {
+          ensureCollectorIsMutable();
+          collector_.set(index, builderForValue.build());
+          onChanged();
+        } else {
+          collectorBuilder_.setMessage(index, builderForValue.build());
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public Builder addCollector(org.apache.drill.exec.proto.BitControl.Collector value) {
+        if (collectorBuilder_ == null) {
+          if (value == null) {
+            throw new NullPointerException();
+          }
+          ensureCollectorIsMutable();
+          collector_.add(value);
+          onChanged();
+        } else {
+          collectorBuilder_.addMessage(value);
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public Builder addCollector(
+          int index, org.apache.drill.exec.proto.BitControl.Collector value) {
+        if (collectorBuilder_ == null) {
+          if (value == null) {
+            throw new NullPointerException();
+          }
+          ensureCollectorIsMutable();
+          collector_.add(index, value);
+          onChanged();
+        } else {
+          collectorBuilder_.addMessage(index, value);
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public Builder addCollector(
+          org.apache.drill.exec.proto.BitControl.Collector.Builder builderForValue) {
+        if (collectorBuilder_ == null) {
+          ensureCollectorIsMutable();
+          collector_.add(builderForValue.build());
+          onChanged();
+        } else {
+          collectorBuilder_.addMessage(builderForValue.build());
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public Builder addCollector(
+          int index, org.apache.drill.exec.proto.BitControl.Collector.Builder builderForValue) {
+        if (collectorBuilder_ == null) {
+          ensureCollectorIsMutable();
+          collector_.add(index, builderForValue.build());
+          onChanged();
+        } else {
+          collectorBuilder_.addMessage(index, builderForValue.build());
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public Builder addAllCollector(
+          java.lang.Iterable<? extends org.apache.drill.exec.proto.BitControl.Collector> values) {
+        if (collectorBuilder_ == null) {
+          ensureCollectorIsMutable();
+          super.addAll(values, collector_);
+          onChanged();
+        } else {
+          collectorBuilder_.addAllMessages(values);
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public Builder clearCollector() {
+        if (collectorBuilder_ == null) {
+          collector_ = java.util.Collections.emptyList();
+          bitField0_ = (bitField0_ & ~0x00004000);
+          onChanged();
+        } else {
+          collectorBuilder_.clear();
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public Builder removeCollector(int index) {
+        if (collectorBuilder_ == null) {
+          ensureCollectorIsMutable();
+          collector_.remove(index);
+          onChanged();
+        } else {
+          collectorBuilder_.remove(index);
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public org.apache.drill.exec.proto.BitControl.Collector.Builder getCollectorBuilder(
+          int index) {
+        return getCollectorFieldBuilder().getBuilder(index);
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public org.apache.drill.exec.proto.BitControl.CollectorOrBuilder getCollectorOrBuilder(
+          int index) {
+        if (collectorBuilder_ == null) {
+          return collector_.get(index);  } else {
+          return collectorBuilder_.getMessageOrBuilder(index);
+        }
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public java.util.List<? extends org.apache.drill.exec.proto.BitControl.CollectorOrBuilder> 
+           getCollectorOrBuilderList() {
+        if (collectorBuilder_ != null) {
+          return collectorBuilder_.getMessageOrBuilderList();
+        } else {
+          return java.util.Collections.unmodifiableList(collector_);
+        }
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public org.apache.drill.exec.proto.BitControl.Collector.Builder addCollectorBuilder() {
+        return getCollectorFieldBuilder().addBuilder(
+            org.apache.drill.exec.proto.BitControl.Collector.getDefaultInstance());
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public org.apache.drill.exec.proto.BitControl.Collector.Builder addCollectorBuilder(
+          int index) {
+        return getCollectorFieldBuilder().addBuilder(
+            index, org.apache.drill.exec.proto.BitControl.Collector.getDefaultInstance());
+      }
+      /**
+       * <code>repeated .exec.bit.control.Collector collector = 17;</code>
+       */
+      public java.util.List<org.apache.drill.exec.proto.BitControl.Collector.Builder> 
+           getCollectorBuilderList() {
+        return getCollectorFieldBuilder().getBuilderList();
+      }
+      private com.google.protobuf.RepeatedFieldBuilder<
+          org.apache.drill.exec.proto.BitControl.Collector, org.apache.drill.exec.proto.BitControl.Collector.Builder, org.apache.drill.exec.proto.BitControl.CollectorOrBuilder> 
+          getCollectorFieldBuilder() {
+        if (collectorBuilder_ == null) {
+          collectorBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
+              org.apache.drill.exec.proto.BitControl.Collector, org.apache.drill.exec.proto.BitControl.Collector.Builder, org.apache.drill.exec.proto.BitControl.CollectorOrBuilder>(
+                  collector_,
+                  ((bitField0_ & 0x00004000) == 0x00004000),
+                  getParentForChildren(),
+                  isClean());
+          collector_ = null;
+        }
+        return collectorBuilder_;
+      }
+
+      // @@protoc_insertion_point(builder_scope:exec.bit.control.PlanFragment)
+    }
+
+    static {
+      defaultInstance = new PlanFragment(true);
+      defaultInstance.initFields();
+    }
+
+    // @@protoc_insertion_point(class_scope:exec.bit.control.PlanFragment)
+  }
+
+  public interface CollectorOrBuilder
+      extends com.google.protobuf.MessageOrBuilder {
+
+    // optional int32 opposite_major_fragment_id = 1;
+    /**
+     * <code>optional int32 opposite_major_fragment_id = 1;</code>
+     */
+    boolean hasOppositeMajorFragmentId();
+    /**
+     * <code>optional int32 opposite_major_fragment_id = 1;</code>
+     */
+    int getOppositeMajorFragmentId();
+
+    // repeated int32 incoming_minor_fragment = 2 [packed = true];
+    /**
+     * <code>repeated int32 incoming_minor_fragment = 2 [packed = true];</code>
+     */
+    java.util.List<java.lang.Integer> getIncomingMinorFragmentList();
+    /**
+     * <code>repeated int32 incoming_minor_fragment = 2 [packed = true];</code>
+     */
+    int getIncomingMinorFragmentCount();
+    /**
+     * <code>repeated int32 incoming_minor_fragment = 2 [packed = true];</code>
+     */
+    int getIncomingMinorFragment(int index);
+
+    // optional bool supports_out_of_order = 3;
+    /**
+     * <code>optional bool supports_out_of_order = 3;</code>
+     */
+    boolean hasSupportsOutOfOrder();
+    /**
+     * <code>optional bool supports_out_of_order = 3;</code>
+     */
+    boolean getSupportsOutOfOrder();
+
+    // optional bool is_spooling = 4;
+    /**
+     * <code>optional bool is_spooling = 4;</code>
+     */
+    boolean hasIsSpooling();
+    /**
+     * <code>optional bool is_spooling = 4;</code>
+     */
+    boolean getIsSpooling();
+  }
+  /**
+   * Protobuf type {@code exec.bit.control.Collector}
+   */
+  public static final class Collector extends
+      com.google.protobuf.GeneratedMessage
+      implements CollectorOrBuilder {
+    // Use Collector.newBuilder() to construct.
+    private Collector(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
+      super(builder);
+      this.unknownFields = builder.getUnknownFields();
+    }
+    private Collector(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
+
+    private static final Collector defaultInstance;
+    public static Collector getDefaultInstance() {
+      return defaultInstance;
+    }
+
+    public Collector getDefaultInstanceForType() {
+      return defaultInstance;
+    }
+
+    private final com.google.protobuf.UnknownFieldSet unknownFields;
+    @java.lang.Override
+    public final com.google.protobuf.UnknownFieldSet
+        getUnknownFields() {
+      return this.unknownFields;
+    }
+    private Collector(
+        com.google.protobuf.CodedInputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      initFields();
+      int mutable_bitField0_ = 0;
+      com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+          com.google.protobuf.UnknownFieldSet.newBuilder();
+      try {
+        boolean done = false;
+        while (!done) {
+          int tag = input.readTag();
+          switch (tag) {
+            case 0:
+              done = true;
+              break;
+            default: {
+              if (!parseUnknownField(input, unknownFields,
+                                     extensionRegistry, tag)) {
+                done = true;
+              }
+              break;
+            }
+            case 8: {
+              bitField0_ |= 0x00000001;
+              oppositeMajorFragmentId_ = input.readInt32();
+              break;
+            }
+            case 16: {
+              if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
+                incomingMinorFragment_ = new java.util.ArrayList<java.lang.Integer>();
+                mutable_bitField0_ |= 0x00000002;
+              }
+              incomingMinorFragment_.add(input.readInt32());
+              break;
+            }
+            case 18: {
+              int length = input.readRawVarint32();
+              int limit = input.pushLimit(length);
+              if (!((mutable_bitField0_ & 0x00000002) == 0x00000002) && input.getBytesUntilLimit() > 0) {
+                incomingMinorFragment_ = new java.util.ArrayList<java.lang.Integer>();
+                mutable_bitField0_ |= 0x00000002;
+              }
+              while (input.getBytesUntilLimit() > 0) {
+                incomingMinorFragment_.add(input.readInt32());
+              }
+              input.popLimit(limit);
+              break;
+            }
+            case 24: {
+              bitField0_ |= 0x00000002;
+              supportsOutOfOrder_ = input.readBool();
+              break;
+            }
+            case 32: {
+              bitField0_ |= 0x00000004;
+              isSpooling_ = input.readBool();
+              break;
+            }
+          }
+        }
+      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+        throw e.setUnfinishedMessage(this);
+      } catch (java.io.IOException e) {
+        throw new com.google.protobuf.InvalidProtocolBufferException(
+            e.getMessage()).setUnfinishedMessage(this);
+      } finally {
+        if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) {
+          incomingMinorFragment_ = java.util.Collections.unmodifiableList(incomingMinorFragment_);
+        }
+        this.unknownFields = unknownFields.build();
+        makeExtensionsImmutable();
+      }
+    }
+    public static final com.google.protobuf.Descriptors.Descriptor
+        getDescriptor() {
+      return org.apache.drill.exec.proto.BitControl.internal_static_exec_bit_control_Collector_descriptor;
+    }
+
+    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+        internalGetFieldAccessorTable() {
+      return org.apache.drill.exec.proto.BitControl.internal_static_exec_bit_control_Collector_fieldAccessorTable
+          .ensureFieldAccessorsInitialized(
+              org.apache.drill.exec.proto.BitControl.Collector.class, org.apache.drill.exec.proto.BitControl.Collector.Builder.class);
+    }
+
+    public static com.google.protobuf.Parser<Collector> PARSER =
+        new com.google.protobuf.AbstractParser<Collector>() {
+      public Collector parsePartialFrom(
+          com.google.protobuf.CodedInputStream input,
+          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+          throws com.google.protobuf.InvalidProtocolBufferException {
+        return new Collector(input, extensionRegistry);
+      }
+    };
+
+    @java.lang.Override
+    public com.google.protobuf.Parser<Collector> getParserForType() {
+      return PARSER;
+    }
+
+    private int bitField0_;
+    // optional int32 opposite_major_fragment_id = 1;
+    public static final int OPPOSITE_MAJOR_FRAGMENT_ID_FIELD_NUMBER = 1;
+    private int oppositeMajorFragmentId_;
+    /**
+     * <code>optional int32 opposite_major_fragment_id = 1;</code>
+     */
+    public boolean hasOppositeMajorFragmentId() {
+      return ((bitField0_ & 0x00000001) == 0x00000001);
+    }
+    /**
+     * <code>optional int32 opposite_major_fragment_id = 1;</code>
+     */
+    public int getOppositeMajorFragmentId() {
+      return oppositeMajorFragmentId_;
+    }
+
+    // repeated int32 incoming_minor_fragment = 2 [packed = true];
+    public static final int INCOMING_MINOR_FRAGMENT_FIELD_NUMBER = 2;
+    private java.util.List<java.lang.Integer> incomingMinorFragment_;
+    /**
+     * <code>repeated int32 incoming_minor_fragment = 2 [packed = true];</code>
+     */
+    public java.util.List<java.lang.Integer>
+        getIncomingMinorFragmentList() {
+      return incomingMinorFragment_;
+    }
+    /**
+     * <code>repeated int32 incoming_minor_fragment = 2 [packed = true];</code>
+     */
+    public int getIncomingMinorFragmentCount() {
+      return incomingMinorFragment_.size();
+    }
+    /**
+     * <code>repeated int32 incoming_minor_fragment = 2 [packed = true];</code>
+     */
+    public int getIncomingMinorFragment(int index) {
+      return incomingMinorFragment_.get(index);
+    }
+    private int incomingMinorFragmentMemoizedSerializedSize = -1;
+
+    // optional bool supports_out_of_order = 3;
+    public static final int SUPPORTS_OUT_OF_ORDER_FIELD_NUMBER = 3;
+    private boolean supportsOutOfOrder_;
+    /**
+     * <code>optional bool supports_out_of_order = 3;</code>
+     */
+    public boolean hasSupportsOutOfOrder() {
+      return ((bitField0_ & 0x00000002) == 0x00000002);
+    }
+    /**
+     * <code>optional bool supports_out_of_order = 3;</code>
+     */
+    public boolean getSupportsOutOfOrder() {
+      return supportsOutOfOrder_;
+    }
+
+    // optional bool is_spooling = 4;
+    public static final int IS_SPOOLING_FIELD_NUMBER = 4;
+    private boolean isSpooling_;
+    /**
+     * <code>optional bool is_spooling = 4;</code>
+     */
+    public boolean hasIsSpooling() {
+      return ((bitField0_ & 0x00000004) == 0x00000004);
+    }
+    /**
+     * <code>optional bool is_spooling = 4;</code>
+     */
+    public boolean getIsSpooling() {
+      return isSpooling_;
+    }
+
+    private void initFields() {
+      oppositeMajorFragmentId_ = 0;
+      incomingMinorFragment_ = java.util.Collections.emptyList();
+      supportsOutOfOrder_ = false;
+      isSpooling_ = false;
+    }
+    private byte memoizedIsInitialized = -1;
+    public final boolean isInitialized() {
+      byte isInitialized = memoizedIsInitialized;
+      if (isInitialized != -1) return isInitialized == 1;
+
+      memoizedIsInitialized = 1;
+      return true;
+    }
+
+    public void writeTo(com.google.protobuf.CodedOutputStream output)
+                        throws java.io.IOException {
+      getSerializedSize();
+      if (((bitField0_ & 0x00000001) == 0x00000001)) {
+        output.writeInt32(1, oppositeMajorFragmentId_);
+      }
+      if (getIncomingMinorFragmentList().size() > 0) {
+        output.writeRawVarint32(18);
+        output.writeRawVarint32(incomingMinorFragmentMemoizedSerializedSize);
+      }
+      for (int i = 0; i < incomingMinorFragment_.size(); i++) {
+        output.writeInt32NoTag(incomingMinorFragment_.get(i));
+      }
+      if (((bitField0_ & 0x00000002) == 0x00000002)) {
+        output.writeBool(3, supportsOutOfOrder_);
+      }
+      if (((bitField0_ & 0x00000004) == 0x00000004)) {
+        output.writeBool(4, isSpooling_);
+      }
+      getUnknownFields().writeTo(output);
+    }
+
+    private int memoizedSerializedSize = -1;
+    public int getSerializedSize() {
+      int size = memoizedSerializedSize;
+      if (size != -1) return size;
+
+      size = 0;
+      if (((bitField0_ & 0x00000001) == 0x00000001)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeInt32Size(1, oppositeMajorFragmentId_);
+      }
+      {
+        int dataSize = 0;
+        for (int i = 0; i < incomingMinorFragment_.size(); i++) {
+          dataSize += com.google.protobuf.CodedOutputStream
+            .computeInt32SizeNoTag(incomingMinorFragment_.get(i));
+        }
+        size += dataSize;
+        if (!getIncomingMinorFragmentList().isEmpty()) {
+          size += 1;
+          size += com.google.protobuf.CodedOutputStream
+              .computeInt32SizeNoTag(dataSize);
+        }
+        incomingMinorFragmentMemoizedSerializedSize = dataSize;
+      }
+      if (((bitField0_ & 0x00000002) == 0x00000002)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeBoolSize(3, supportsOutOfOrder_);
+      }
+      if (((bitField0_ & 0x00000004) == 0x00000004)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeBoolSize(4, isSpooling_);
+      }
+      size += getUnknownFields().getSerializedSize();
+      memoizedSerializedSize = size;
+      return size;
+    }
+
+    private static final long serialVersionUID = 0L;
+    @java.lang.Override
+    protected java.lang.Object writeReplace()
+        throws java.io.ObjectStreamException {
+      return super.writeReplace();
+    }
+
+    public static org.apache.drill.exec.proto.BitControl.Collector parseFrom(
+        com.google.protobuf.ByteString data)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data);
+    }
+    public static org.apache.drill.exec.proto.BitControl.Collector parseFrom(
+        com.google.protobuf.ByteString data,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data, extensionRegistry);
+    }
+    public static org.apache.drill.exec.proto.BitControl.Collector parseFrom(byte[] data)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data);
+    }
+    public static org.apache.drill.exec.proto.BitControl.Collector parseFrom(
+        byte[] data,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data, extensionRegistry);
+    }
+    public static org.apache.drill.exec.proto.BitControl.Collector parseFrom(java.io.InputStream input)
+        throws java.io.IOException {
+      return PARSER.parseFrom(input);
+    }
+    public static org.apache.drill.exec.proto.BitControl.Collector parseFrom(
+        java.io.InputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return PARSER.parseFrom(input, extensionRegistry);
+    }
+    public static org.apache.drill.exec.proto.BitControl.Collector parseDelimitedFrom(java.io.InputStream input)
+        throws java.io.IOException {
+      return PARSER.parseDelimitedFrom(input);
+    }
+    public static org.apache.drill.exec.proto.BitControl.Collector parseDelimitedFrom(
+        java.io.InputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return PARSER.parseDelimitedFrom(input, extensionRegistry);
+    }
+    public static org.apache.drill.exec.proto.BitControl.Collector parseFrom(
+        com.google.protobuf.CodedInputStream input)
+        throws java.io.IOException {
+      return PARSER.parseFrom(input);
+    }
+    public static org.apache.drill.exec.proto.BitControl.Collector parseFrom(
+        com.google.protobuf.CodedInputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return PARSER.parseFrom(input, extensionRegistry);
+    }
+
+    public static Builder newBuilder() { return Builder.create(); }
+    public Builder newBuilderForType() { return newBuilder(); }
+    public static Builder newBuilder(org.apache.drill.exec.proto.BitControl.Collector prototype) {
+      return newBuilder().mergeFrom(prototype);
+    }
+    public Builder toBuilder() { return newBuilder(this); }
+
+    @java.lang.Override
+    protected Builder newBuilderForType(
+        com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+      Builder builder = new Builder(parent);
+      return builder;
+    }
+    /**
+     * Protobuf type {@code exec.bit.control.Collector}
+     */
+    public static final class Builder extends
+        com.google.protobuf.GeneratedMessage.Builder<Builder>
+       implements org.apache.drill.exec.proto.BitControl.CollectorOrBuilder {
+      public static final com.google.protobuf.Descriptors.Descriptor
+          getDescriptor() {
+        return org.apache.drill.exec.proto.BitControl.internal_static_exec_bit_control_Collector_descriptor;
+      }
+
+      protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+          internalGetFieldAccessorTable() {
+        return org.apache.drill.exec.proto.BitControl.internal_static_exec_bit_control_Collector_fieldAccessorTable
+            .ensureFieldAccessorsInitialized(
+                org.apache.drill.exec.proto.BitControl.Collector.class, org.apache.drill.exec.proto.BitControl.Collector.Builder.class);
+      }
+
+      // Construct using org.apache.drill.exec.proto.BitControl.Collector.newBuilder()
+      private Builder() {
+        maybeForceBuilderInitialization();
+      }
+
+      private Builder(
+          com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+        super(parent);
+        maybeForceBuilderInitialization();
+      }
+      private void maybeForceBuilderInitialization() {
+        if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+        }
+      }
+      private static Builder create() {
+        return new Builder();
+      }
+
+      public Builder clear() {
+        super.clear();
+        oppositeMajorFragmentId_ = 0;
+        bitField0_ = (bitField0_ & ~0x00000001);
+        incomingMinorFragment_ = java.util.Collections.emptyList();
+        bitField0_ = (bitField0_ & ~0x00000002);
+        supportsOutOfOrder_ = false;
+        bitField0_ = (bitField0_ & ~0x00000004);
+        isSpooling_ = false;
+        bitField0_ = (bitField0_ & ~0x00000008);
+        return this;
+      }
+
+      public Builder clone() {
+        return create().mergeFrom(buildPartial());
+      }
+
+      public com.google.protobuf.Descriptors.Descriptor
+          getDescriptorForType() {
+        return org.apache.drill.exec.proto.BitControl.internal_static_exec_bit_control_Collector_descriptor;
+      }
+
+      public org.apache.drill.exec.proto.BitControl.Collector getDefaultInstanceForType() {
+        return org.apache.drill.exec.proto.BitControl.Collector.getDefaultInstance();
+      }
+
+      public org.apache.drill.exec.proto.BitControl.Collector build() {
+        org.apache.drill.exec.proto.BitControl.Collector result = buildPartial();
+        if (!result.isInitialized()) {
+          throw newUninitializedMessageException(result);
+        }
+        return result;
+      }
+
+      public org.apache.drill.exec.proto.BitControl.Collector buildPartial() {
+        org.apache.drill.exec.proto.BitControl.Collector result = new org.apache.drill.exec.proto.BitControl.Collector(this);
+        int from_bitField0_ = bitField0_;
+        int to_bitField0_ = 0;
+        if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+          to_bitField0_ |= 0x00000001;
+        }
+        result.oppositeMajorFragmentId_ = oppositeMajorFragmentId_;
+        if (((bitField0_ & 0x00000002) == 0x00000002)) {
+          incomingMinorFragment_ = java.util.Collections.unmodifiableList(incomingMinorFragment_);
+          bitField0_ = (bitField0_ & ~0x00000002);
+        }
+        result.incomingMinorFragment_ = incomingMinorFragment_;
+        if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
+          to_bitField0_ |= 0x00000002;
+        }
+        result.supportsOutOfOrder_ = supportsOutOfOrder_;
+        if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
+          to_bitField0_ |= 0x00000004;
+        }
+        result.isSpooling_ = isSpooling_;
+        result.bitField0_ = to_bitField0_;
+        onBuilt();
+        return result;
+      }
+
+      public Builder mergeFrom(com.google.protobuf.Message other) {
+        if (other instanceof org.apache.drill.exec.proto.BitControl.Collector) {
+          return mergeFrom((org.apache.drill.exec.proto.BitControl.Collector)other);
+        } else {
+          super.mergeFrom(other);
+          return this;
         }
-        bitField0_ |= 0x00000800;
-        return this;
       }
-      /**
-       * <code>optional .exec.shared.UserCredentials credentials = 14;</code>
-       */
-      public Builder mergeCredentials(org.apache.drill.exec.proto.UserBitShared.UserCredentials value) {
-        if (credentialsBuilder_ == null) {
-          if (((bitField0_ & 0x00000800) == 0x00000800) &&
-              credentials_ != org.apache.drill.exec.proto.UserBitShared.UserCredentials.getDefaultInstance()) {
-            credentials_ =
-              org.apache.drill.exec.proto.UserBitShared.UserCredentials.newBuilder(credentials_).mergeFrom(value).buildPartial();
+
+      public Builder mergeFrom(org.apache.drill.exec.proto.BitControl.Collector other) {
+        if (other == org.apache.drill.exec.proto.BitControl.Collector.getDefaultInstance()) return this;
+        if (other.hasOppositeMajorFragmentId()) {
+          setOppositeMajorFragmentId(other.getOppositeMajorFragmentId());
+        }
+        if (!other.incomingMinorFragment_.isEmpty()) {
+          if (incomingMinorFragment_.isEmpty()) {
+            incomingMinorFragment_ = other.incomingMinorFragment_;
+            bitField0_ = (bitField0_ & ~0x00000002);
           } else {
-            credentials_ = value;
+            ensureIncomingMinorFragmentIsMutable();
+            incomingMinorFragment_.addAll(other.incomingMinorFragment_);
           }
           onChanged();
-        } else {
-          credentialsBuilder_.mergeFrom(value);
         }
-        bitField0_ |= 0x00000800;
+        if (other.hasSupportsOutOfOrder()) {
+          setSupportsOutOfOrder(other.getSupportsOutOfOrder());
+        }
+        if (other.hasIsSpooling()) {
+          setIsSpooling(other.getIsSpooling());
+        }
+        this.mergeUnknownFields(other.getUnknownFields());
         return this;
       }
-      /**
-       * <code>optional .exec.shared.UserCredentials credentials = 14;</code>
-       */
-      public Builder clearCredentials() {
-        if (credentialsBuilder_ == null) {
-          credentials_ = org.apache.drill.exec.proto.UserBitShared.UserCredentials.getDefaultInstance();
-          onChanged();
-        } else {
-          credentialsBuilder_.clear();
+
+      public final boolean isInitialized() {
+        return true;
+      }
+
+      public Builder mergeFrom(
+          com.google.protobuf.CodedInputStream input,
+          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+          throws java.io.IOException {
+        org.apache.drill.exec.proto.BitControl.Collector parsedMessage = null;
+        try {
+          parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+        } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+          parsedMessage = (org.apache.drill.exec.proto.BitControl.Collector) e.getUnfinishedMessage();
+          throw e;
+        } finally {
+          if (parsedMessage != null) {
+            mergeFrom(parsedMessage);
+          }
         }
-        bitField0_ = (bitField0_ & ~0x00000800);
         return this;
       }
+      private int bitField0_;
+
+      // optional int32 opposite_major_fragment_id = 1;
+      private int oppositeMajorFragmentId_ ;
       /**
-       * <code>optional .exec.shared.UserCredentials credentials = 14;</code>
+       * <code>optional int32 opposite_major_fragment_id = 1;</code>
        */
-      public org.apache.drill.exec.proto.UserBitShared.UserCredentials.Builder getCredentialsBuilder() {
-        bitField0_ |= 0x00000800;
-        onChanged();
-        return getCredentialsFieldBuilder().getBuilder();
+      public boolean hasOppositeMajorFragmentId() {
+        return ((bitField0_ & 0x00000001) == 0x00000001);
       }
       /**
-       * <code>optional .exec.shared.UserCredentials credentials = 14;</code>
+       * <code>optional int32 opposite_major_fragment_id = 1;</code>
        */
-      public org.apache.drill.exec.proto.UserBitShared.UserCredentialsOrBuilder getCredentialsOrBuilder() {
-        if (credentialsBuilder_ != null) {
-          return credentialsBuilder_.getMessageOrBuilder();
-        } else {
-          return credentials_;
-        }
+      public int getOppositeMajorFragmentId() {
+        return oppositeMajorFragmentId_;
       }
       /**
-       * <code>optional .exec.shared.UserCredentials credentials = 14;</code>
+       * <code>optional int32 opposite_major_fragment_id = 1;</code>
        */
-      private com.google.protobuf.SingleFieldBuilder<
-          org.apache.drill.exec.proto.UserBitShared.UserCredentials, org.apache.drill.exec.proto.UserBitShared.UserCredentials.Builder, org.apache.drill.exec.proto.UserBitShared.UserCredentialsOrBuilder> 
-          getCredentialsFieldBuilder() {
-        if (credentialsBuilder_ == null) {
-          credentialsBuilder_ = new com.google.protobuf.SingleFieldBuilder<
-              org.apache.drill.exec.proto.UserBitShared.UserCredentials, org.apache.drill.exec.proto.UserBitShared.UserCredentials.Builder, org.apache.drill.exec.proto.UserBitShared.UserCredentialsOrBuilder>(
-                  credentials_,
-                  getParentForChildren(),
-                  isClean());
-          credentials_ = null;
-        }
-        return credentialsBuilder_;
+      public Builder setOppositeMajorFragmentId(int value) {
+        bitField0_ |= 0x00000001;
+        oppositeMajorFragmentId_ = value;
+        onChanged();
+        return this;
+      }
+      /**
+       * <code>optional int32 opposite_major_fragment_id = 1;</code>
+       */
+      public Builder clearOppositeMajorFragmentId() {
+        bitField0_ = (bitField0_ & ~0x00000001);
+        oppositeMajorFragmentId_ = 0;
+        onChanged();
+        return this;
       }
 
-      // optional string options_json = 15;
-      private java.lang.Object optionsJson_ = "";
+      // repeated int32 incoming_minor_fragment = 2 [packed = true];
+      private java.util.List<java.lang.Integer> incomingMinorFragment_ = java.util.Collections.emptyList();
+      private void ensureIncomingMinorFragmentIsMutable() {
+        if (!((bitField0_ & 0x00000002) == 0x00000002)) {
+          incomingMinorFragment_ = new java.util.ArrayList<java.lang.Integer>(incomingMinorFragment_);
+          bitField0_ |= 0x00000002;
+         }
+      }
       /**
-       * <code>optional string options_json = 15;</code>
+       * <code>repeated int32 incoming_minor_fragment = 2 [packed = true];</code>
        */
-      public boolean hasOptionsJson() {
-        return ((bitField0_ & 0x00001000) == 0x00001000);
+      public java.util.List<java.lang.Integer>
+          getIncomingMinorFragmentList() {
+        return java.util.Collections.unmodifiableList(incomingMinorFragment_);
       }
       /**
-       * <code>optional string options_json = 15;</code>
+       * <code>repeated int32 incoming_minor_fragment = 2 [packed = true];</code>
        */
-      public java.lang.String getOptionsJson() {
-        java.lang.Object ref = optionsJson_;
-        if (!(ref instanceof java.lang.String)) {
-          java.lang.String s = ((com.google.protobuf.ByteString) ref)
-              .toStringUtf8();
-          optionsJson_ = s;
-          return s;
-        } else {
-          return (java.lang.String) ref;
-        }
+      public int getIncomingMinorFragmentCount() {
+        return incomingMinorFragment_.size();
       }
       /**
-       * <code>optional string options_json = 15;</code>
+       * <code>repeated int32 incoming_minor_fragment = 2 [packed = true];</code>
        */
-      public com.google.protobuf.ByteString
-          getOptionsJsonBytes() {
-        java.lang.Object ref = optionsJson_;
-        if (ref instanceof String) {
-          com.google.protobuf.ByteString b = 
-              com.google.protobuf.ByteString.copyFromUtf8(
-                  (java.lang.String) ref);
-          optionsJson_ = b;
-          return b;
-        } else {
-          return (com.google.protobuf.ByteString) ref;
-        }
+      public int getIncomingMinorFragment(int index) {
+        return incomingMinorFragment_.get(index);
       }
       /**
-       * <code>optional string options_json = 15;</code>
+       * <code>repeated int32 incoming_minor_fragment = 2 [packed = true];</code>
        */
-      public Builder setOptionsJson(
-          java.lang.String value) {
-        if (value == null) {
-    throw new NullPointerException();
-  }
-  bitField0_ |= 0x00001000;
-        optionsJson_ = value;
+      public Builder setIncomingMinorFragment(
+          int index, int value) {
+        ensureIncomingMinorFragmentIsMutable();
+        incomingMinorFragment_.set(index, value);
         onChanged();
         return this;
       }
       /**
-       * <code>optional string options_json = 15;</code>
+       * <code>repeated int32 incoming_minor_fragment = 2 [packed = true];</code>
        */
-      public Builder clearOptionsJson() {
-        bitField0_ = (bitField0_ & ~0x00001000);
-        optionsJson_ = getDefaultInstance().getOptionsJson();
+      public Builder addIncomingMinorFragment(int value) {
+        ensureIncomingMinorFragmentIsMutable();
+        incomingMinorFragment_.add(value);
         onChanged();
         return this;
       }
       /**
-       * <code>optional string options_json = 15;</code>
+       * <code>repeated int32 incoming_minor_fragment = 2 [packed = true];</code>
        */
-      public Builder setOptionsJsonBytes(
-          com.google.protobuf.ByteString value) {
-        if (value == null) {
-    throw new NullPointerException();
-  }
-  bitField0_ |= 0x00001000;
-        optionsJson_ = value;
+      public Builder addAllIncomingMinorFragment(
+          java.lang.Iterable<? extends java.lang.Integer> values) {
+        ensureIncomingMinorFragmentIsMutable();
+        super.addAll(values, incomingMinorFragment_);
         onChanged();
         return this;
       }
-
-      // optional .exec.bit.control.QueryContextInformation context = 16;
-      private org.apache.drill.exec.proto.BitControl.QueryContextInformation context_ = org.apache.drill.exec.proto.BitControl.QueryContextInformation.getDefaultInstance();
-      private com.google.protobuf.SingleFieldBuilder<
-          org.apache.drill.exec.proto.BitControl.QueryContextInformation, org.apache.drill.exec.proto.BitControl.QueryContextInformation.Builder, org.apache.drill.exec.proto.BitControl.QueryContextInformationOrBuilder> contextBuilder_;
       /**
-       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       * <code>repeated int32 incoming_minor_fragment = 2 [packed = true];</code>
        */
-      public boolean hasContext() {
-        return ((bitField0_ & 0x00002000) == 0x00002000);
+      public Builder clearIncomingMinorFragment() {
+        incomingMinorFragment_ = java.util.Collections.emptyList();
+        bitField0_ = (bitField0_ & ~0x00000002);
+        onChanged();
+        return this;
       }
+
+      // optional bool supports_out_of_order = 3;
+      private boolean supportsOutOfOrder_ ;
       /**
-       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       * <code>optional bool supports_out_of_order = 3;</code>
        */
-      public org.apache.drill.exec.proto.BitControl.QueryContextInformation getContext() {
-        if (contextBuilder_ == null) {
-          return context_;
-        } else {
-          return contextBuilder_.getMessage();
-        }
+      public boolean hasSupportsOutOfOrder() {
+        return ((bitField0_ & 0x00000004) == 0x00000004);
       }
       /**
-       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       * <code>optional bool supports_out_of_order = 3;</code>
        */
-      public Builder setContext(org.apache.drill.exec.proto.BitControl.QueryContextInformation value) {
-        if (contextBuilder_ == null) {
-          if (value == null) {
-            throw new NullPointerException();
-          }
-          context_ = value;
-          onChanged();
-        } else {
-          contextBuilder_.setMessage(value);
-        }
-        bitField0_ |= 0x00002000;
-        return this;
+      public boolean getSupportsOutOfOrder() {
+        return supportsOutOfOrder_;
       }
       /**
-       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       * <code>optional bool supports_out_of_order = 3;</code>
        */
-      public Builder setContext(
-          org.apache.drill.exec.proto.BitControl.QueryContextInformation.Builder builderForValue) {
-        if (contextBuilder_ == null) {
-          context_ = builderForValue.build();
-          onChanged();
-        } else {
-          contextBuilder_.setMessage(builderForValue.build());
-        }
-        bitField0_ |= 0x00002000;
+      public Builder setSupportsOutOfOrder(boolean value) {
+        bitField0_ |= 0x00000004;
+        supportsOutOfOrder_ = value;
+        onChanged();
         return this;
       }
       /**
-       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       * <code>optional bool supports_out_of_order = 3;</code>
        */
-      public Builder mergeContext(org.apache.drill.exec.proto.BitControl.QueryContextInformation value) {
-        if (contextBuilder_ == null) {
-          if (((bitField0_ & 0x00002000) == 0x00002000) &&
-              context_ != org.apache.drill.exec.proto.BitControl.QueryContextInformation.getDefaultInstance()) {
-            context_ =
-              org.apache.drill.exec.proto.BitControl.QueryContextInformation.newBuilder(context_).mergeFrom(value).buildPartial();
-          } else {
-            context_ = value;
-          }
-          onChanged();
-        } else {
-          contextBuilder_.mergeFrom(value);
-        }
-        bitField0_ |= 0x00002000;
+      public Builder clearSupportsOutOfOrder() {
+        bitField0_ = (bitField0_ & ~0x00000004);
+        supportsOutOfOrder_ = false;
+        onChanged();
         return this;
       }
+
+      // optional bool is_spooling = 4;
+      private boolean isSpooling_ ;
       /**
-       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       * <code>optional bool is_spooling = 4;</code>
        */
-      public Builder clearContext() {
-        if (contextBuilder_ == null) {
-          context_ = org.apache.drill.exec.proto.BitControl.QueryContextInformation.getDefaultInstance();
-          onChanged();
-        } else {
-          contextBuilder_.clear();
-        }
-        bitField0_ = (bitField0_ & ~0x00002000);
-        return this;
+      public boolean hasIsSpooling() {
+        return ((bitField0_ & 0x00000008) == 0x00000008);
       }
       /**
-       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       * <code>optional bool is_spooling = 4;</code>
        */
-      public org.apache.drill.exec.proto.BitControl.QueryContextInformation.Builder getContextBuilder() {
-        bitField0_ |= 0x00002000;
-        onChanged();
-        return getContextFieldBuilder().getBuilder();
+      public boolean getIsSpooling() {
+        return isSpooling_;
       }
       /**
-       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       * <code>optional bool is_spooling = 4;</code>
        */
-      public org.apache.drill.exec.proto.BitControl.QueryContextInformationOrBuilder getContextOrBuilder() {
-        if (contextBuilder_ != null) {
-          return contextBuilder_.getMessageOrBuilder();
-        } else {
-          return context_;
-        }
+      public Builder setIsSpooling(boolean value) {
+        bitField0_ |= 0x00000008;
+        isSpooling_ = value;
+        onChanged();
+        return this;
       }
       /**
-       * <code>optional .exec.bit.control.QueryContextInformation context = 16;</code>
+       * <code>optional bool is_spooling = 4;</code>
        */
-      private com.google.protobuf.SingleFieldBuilder<
-          org.apache.drill.exec.proto.BitControl.QueryContextInformation, org.apache.drill.exec.proto.BitControl.QueryContextInformation.Builder, org.apache.drill.exec.proto.BitControl.QueryContextInformationOrBuilder> 
-          getContextFieldBuilder() {
-        if (contextBuilder_ == null) {
-          contextBuilder_ = new com.google.protobuf.SingleFieldBuilder<
-              org.apache.drill.exec.proto.BitControl.QueryContextInformation, org.apache.drill.exec.proto.BitControl.QueryContextInformation.Builder, org.apache.drill.exec.proto.BitControl.QueryContextInformationOrBuilder>(
-                  context_,
-                  getParentForChildren(),
-                  isClean());
-          context_ = null;
-        }
-        return contextBuilder_;
+      public Builder clearIsSpooling() {
+        bitField0_ = (bitField0_ & ~0x00000008);
+        isSpooling_ = false;
+        onChanged();
+        return this;
       }
 
-      // @@protoc_insertion_point(builder_scope:exec.bit.control.PlanFragment)
+      // @@protoc_insertion_point(builder_scope:exec.bit.control.Collector)
     }
 
     static {
-      defaultInstance = new PlanFragment(true);
+      defaultInstance = new Collector(true);
       defaultInstance.initFields();
     }
 
-    // @@protoc_insertion_point(class_scope:exec.bit.control.PlanFragment)
+    // @@protoc_insertion_point(class_scope:exec.bit.control.Collector)
   }
 
   public interface QueryContextInformationOrBuilder
@@ -7358,6 +8445,11 @@ public final class BitControl {
     com.google.protobuf.GeneratedMessage.FieldAccessorTable
       internal_static_exec_bit_control_PlanFragment_fieldAccessorTable;
   private static com.google.protobuf.Descriptors.Descriptor
+    internal_static_exec_bit_control_Collector_descriptor;
+  private static
+    com.google.protobuf.GeneratedMessage.FieldAccessorTable
+      internal_static_exec_bit_control_Collector_fieldAccessorTable;
+  private static com.google.protobuf.Descriptors.Descriptor
     internal_static_exec_bit_control_QueryContextInformation_descriptor;
   private static
     com.google.protobuf.GeneratedMessage.FieldAccessorTable
@@ -7393,7 +8485,7 @@ public final class BitControl {
       "red.MinorFragmentProfile\022(\n\006handle\030\002 \001(\013",
       "2\030.exec.bit.FragmentHandle\"G\n\023Initialize" +
       "Fragments\0220\n\010fragment\030\001 \003(\0132\036.exec.bit.c" +
-      "ontrol.PlanFragment\"\314\003\n\014PlanFragment\022(\n\006" +
+      "ontrol.PlanFragment\"\374\003\n\014PlanFragment\022(\n\006" +
       "handle\030\001 \001(\0132\030.exec.bit.FragmentHandle\022\024" +
       "\n\014network_cost\030\004 \001(\002\022\020\n\010cpu_cost\030\005 \001(\002\022\021" +
       "\n\tdisk_cost\030\006 \001(\002\022\023\n\013memory_cost\030\007 \001(\002\022\025" +
@@ -7405,24 +8497,29 @@ public final class BitControl {
       "ials\030\016 \001(\0132\034.exec.shared.UserCredentials" +
       "\022\024\n\014options_json\030\017 \001(\t\022:\n\007context\030\020 \001(\0132" +
       ").exec.bit.control.QueryContextInformati" +
-      "on\"c\n\027QueryContextInformation\022\030\n\020query_s" +
-      "tart_time\030\001 \001(\003\022\021\n\ttime_zone\030\002 \001(\005\022\033\n\023de" +
-      "fault_schema_name\030\003 \001(\t\"f\n\017WorkQueueStat" +
-      "us\022(\n\010endpoint\030\001 \001(\0132\026.exec.DrillbitEndp" +
-      "oint\022\024\n\014queue_length\030\002 \001(\005\022\023\n\013report_tim" +
-      "e\030\003 \001(\003\"h\n\020FinishedReceiver\022*\n\010receiver\030",
-      "\001 \001(\0132\030.exec.bit.FragmentHandle\022(\n\006sende" +
-      "r\030\002 \001(\0132\030.exec.bit.FragmentHandle*\323\002\n\007Rp" +
-      "cType\022\r\n\tHANDSHAKE\020\000\022\007\n\003ACK\020\001\022\013\n\007GOODBYE" +
-      "\020\002\022\034\n\030REQ_INITIALIZE_FRAGMENTS\020\003\022\027\n\023REQ_" +
-      "CANCEL_FRAGMENT\020\006\022\031\n\025REQ_RECEIVER_FINISH" +
-      "ED\020\007\022\027\n\023REQ_FRAGMENT_STATUS\020\010\022\022\n\016REQ_BIT" +
-      "_STATUS\020\t\022\024\n\020REQ_QUERY_STATUS\020\n\022\024\n\020REQ_Q" +
-      "UERY_CANCEL\020\017\022\030\n\024REQ_UNPAUSE_FRAGMENT\020\020\022" +
-      "\030\n\024RESP_FRAGMENT_HANDLE\020\013\022\030\n\024RESP_FRAGME" +
-      "NT_STATUS\020\014\022\023\n\017RESP_BIT_STATUS\020\r\022\025\n\021RESP",
-      "_QUERY_STATUS\020\016B+\n\033org.apache.drill.exec" +
-      ".protoB\nBitControlH\001"
+      "on\022.\n\tcollector\030\021 \003(\0132\033.exec.bit.control" +
+      ".Collector\"\210\001\n\tCollector\022\"\n\032opposite_maj" +
+      "or_fragment_id\030\001 \001(\005\022#\n\027incoming_minor_f" +
+      "ragment\030\002 \003(\005B\002\020\001\022\035\n\025supports_out_of_ord" +
+      "er\030\003 \001(\010\022\023\n\013is_spooling\030\004 \001(\010\"c\n\027QueryCo" +
+      "ntextInformation\022\030\n\020query_start_time\030\001 \001",
+      "(\003\022\021\n\ttime_zone\030\002 \001(\005\022\033\n\023default_schema_" +
+      "name\030\003 \001(\t\"f\n\017WorkQueueStatus\022(\n\010endpoin" +
+      "t\030\001 \001(\0132\026.exec.DrillbitEndpoint\022\024\n\014queue" +
+      "_length\030\002 \001(\005\022\023\n\013report_time\030\003 \001(\003\"h\n\020Fi" +
+      "nishedReceiver\022*\n\010receiver\030\001 \001(\0132\030.exec." +
+      "bit.FragmentHandle\022(\n\006sender\030\002 \001(\0132\030.exe" +
+      "c.bit.FragmentHandle*\323\002\n\007RpcType\022\r\n\tHAND" +
+      "SHAKE\020\000\022\007\n\003ACK\020\001\022\013\n\007GOODBYE\020\002\022\034\n\030REQ_INI" +
+      "TIALIZE_FRAGMENTS\020\003\022\027\n\023REQ_CANCEL_FRAGME" +
+      "NT\020\006\022\031\n\025REQ_RECEIVER_FINISHED\020\007\022\027\n\023REQ_F",
+      "RAGMENT_STATUS\020\010\022\022\n\016REQ_BIT_STATUS\020\t\022\024\n\020" +
+      "REQ_QUERY_STATUS\020\n\022\024\n\020REQ_QUERY_CANCEL\020\017" +
+      "\022\030\n\024REQ_UNPAUSE_FRAGMENT\020\020\022\030\n\024RESP_FRAGM" +
+      "ENT_HANDLE\020\013\022\030\n\024RESP_FRAGMENT_STATUS\020\014\022\023" +
+      "\n\017RESP_BIT_STATUS\020\r\022\025\n\021RESP_QUERY_STATUS" +
+      "\020\016B+\n\033org.apache.drill.exec.protoB\nBitCo" +
+      "ntrolH\001"
     };
     com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
       new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -7458,21 +8555,27 @@ public final class BitControl {
           internal_static_exec_bit_control_PlanFragment_fieldAccessorTable = new
             com.google.protobuf.GeneratedMessage.FieldAccessorTable(
               internal_static_exec_bit_control_PlanFragment_descriptor,
-              new java.lang.String[] { "Handle", "NetworkCost", "CpuCost", "DiskCost", "MemoryCost", "FragmentJson", "LeafFragment", "Assignment", "Foreman", "MemInitial", "MemMax", "Credentials", "OptionsJson", "Context", });
-          internal_static_exec_bit_control_QueryContextInformation_descriptor =
+              new java.lang.String[] { "Handle", "NetworkCost", "CpuCost", "DiskCost", "MemoryCost", "FragmentJson", "LeafFragment", "Assignment", "Foreman", "MemInitial", "MemMax", "Credentials", "OptionsJson", "Context", "Collector", });
+          internal_static_exec_bit_control_Collector_descriptor =
             getDescriptor().getMessageTypes().get(5);
+          internal_static_exec_bit_control_Collector_fieldAccessorTable = new
+            com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+              internal_static_exec_bit_control_Collector_descriptor,
+              new java.lang.String[] { "OppositeMajorFragmentId", "IncomingMinorFragment", "SupportsOutOfOrder", "IsSpooling", });
+          internal_static_exec_bit_control_QueryContextInformation_descriptor =
+            getDescriptor().getMessageTypes().get(6);
           internal_static_exec_bit_control_QueryContextInformation_fieldAccessorTable = new
             com.google.protobuf.GeneratedMessage.FieldAccessorTable(
               internal_static_exec_bit_control_QueryContextInformation_descriptor,
               new java.lang.String[] { "QueryStartTime", "TimeZone", "DefaultSchemaName", });
           internal_static_exec_bit_control_WorkQueueStatus_descriptor =
-            getDescriptor().getMessageTypes().get(6);
+            getDescriptor().getMessageTypes().get(7);
           internal_static_exec_bit_control_WorkQueueStatus_fieldAccessorTable = new
             com.google.protobuf.GeneratedMessage.FieldAccessorTable(
               internal_static_exec_bit_control_WorkQueueStatus_descriptor,
               new java.lang.String[] { "Endpoint", "QueueLength", "ReportTime", });
           internal_static_exec_bit_control_FinishedReceiver_descriptor =
-            getDescriptor().getMessageTypes().get(7);
+            getDescriptor().getMessageTypes().get(8);
           internal_static_exec_bit_control_FinishedReceiver_fieldAccessorTable = new
             com.google.protobuf.GeneratedMessage.FieldAccessorTable(
               internal_static_exec_bit_control_FinishedReceiver_descriptor,

http://git-wip-us.apache.org/repos/asf/drill/blob/4ad42611/protocol/src/main/java/org/apache/drill/exec/proto/SchemaBitControl.java
----------------------------------------------------------------------
diff --git a/protocol/src/main/java/org/apache/drill/exec/proto/SchemaBitControl.java b/protocol/src/main/java/org/apache/drill/exec/proto/SchemaBitControl.java
index bbf7860..a4088c9 100644
--- a/protocol/src/main/java/org/apache/drill/exec/proto/SchemaBitControl.java
+++ b/protocol/src/main/java/org/apache/drill/exec/proto/SchemaBitControl.java
@@ -543,6 +543,9 @@ public final class SchemaBitControl
                 if(message.hasContext())
                     output.writeObject(16, message.getContext(), org.apache.drill.exec.proto.SchemaBitControl.QueryContextInformation.WRITE, false);
 
+                for(org.apache.drill.exec.proto.BitControl.Collector collector : message.getCollectorList())
+                    output.writeObject(17, collector, org.apache.drill.exec.proto.SchemaBitControl.Collector.WRITE, true);
+
             }
             public boolean isInitialized(org.apache.drill.exec.proto.BitControl.PlanFragment message)
             {
@@ -629,6 +632,10 @@ public final class SchemaBitControl
                             builder.setContext(input.mergeObject(org.apache.drill.exec.proto.BitControl.QueryContextInformation.newBuilder(), org.apache.drill.exec.proto.SchemaBitControl.QueryContextInformation.MERGE));
 
                             break;
+                        case 17:
+                            builder.addCollector(input.mergeObject(org.apache.drill.exec.proto.BitControl.Collector.newBuilder(), org.apache.drill.exec.proto.SchemaBitControl.Collector.MERGE));
+
+                            break;
                         default:
                             input.handleUnknownField(number, this);
                     }
@@ -683,6 +690,7 @@ public final class SchemaBitControl
                 case 14: return "credentials";
                 case 15: return "optionsJson";
                 case 16: return "context";
+                case 17: return "collector";
                 default: return null;
             }
         }
@@ -708,6 +716,139 @@ public final class SchemaBitControl
             fieldMap.put("credentials", 14);
             fieldMap.put("optionsJson", 15);
             fieldMap.put("context", 16);
+            fieldMap.put("collector", 17);
+        }
+    }
+
+    public static final class Collector
+    {
+        public static final org.apache.drill.exec.proto.SchemaBitControl.Collector.MessageSchema WRITE =
+            new org.apache.drill.exec.proto.SchemaBitControl.Collector.MessageSchema();
+        public static final org.apache.drill.exec.proto.SchemaBitControl.Collector.BuilderSchema MERGE =
+            new org.apache.drill.exec.proto.SchemaBitControl.Collector.BuilderSchema();
+        
+        public static class MessageSchema implements com.dyuproject.protostuff.Schema<org.apache.drill.exec.proto.BitControl.Collector>
+        {
+            public void writeTo(com.dyuproject.protostuff.Output output, org.apache.drill.exec.proto.BitControl.Collector message) throws java.io.IOException
+            {
+                if(message.hasOppositeMajorFragmentId())
+                    output.writeInt32(1, message.getOppositeMajorFragmentId(), false);
+                for(int incomingMinorFragment : message.getIncomingMinorFragmentList())
+                    output.writeInt32(2, incomingMinorFragment, true);
+                if(message.hasSupportsOutOfOrder())
+                    output.writeBool(3, message.getSupportsOutOfOrder(), false);
+                if(message.hasIsSpooling())
+                    output.writeBool(4, message.getIsSpooling(), false);
+            }
+            public boolean isInitialized(org.apache.drill.exec.proto.BitControl.Collector message)
+            {
+                return message.isInitialized();
+            }
+            public java.lang.String getFieldName(int number)
+            {
+                return org.apache.drill.exec.proto.SchemaBitControl.Collector.getFieldName(number);
+            }
+            public int getFieldNumber(java.lang.String name)
+            {
+                return org.apache.drill.exec.proto.SchemaBitControl.Collector.getFieldNumber(name);
+            }
+            public java.lang.Class<org.apache.drill.exec.proto.BitControl.Collector> typeClass()
+            {
+                return org.apache.drill.exec.proto.BitControl.Collector.class;
+            }
+            public java.lang.String messageName()
+            {
+                return org.apache.drill.exec.proto.BitControl.Collector.class.getSimpleName();
+            }
+            public java.lang.String messageFullName()
+            {
+                return org.apache.drill.exec.proto.BitControl.Collector.class.getName();
+            }
+            //unused
+            public void mergeFrom(com.dyuproject.protostuff.Input input, org.apache.drill.exec.proto.BitControl.Collector message) throws java.io.IOException {}
+            public org.apache.drill.exec.proto.BitControl.Collector newMessage() { return null; }
+        }
+        public static class BuilderSchema implements com.dyuproject.protostuff.Schema<org.apache.drill.exec.proto.BitControl.Collector.Builder>
+        {
+            public void mergeFrom(com.dyuproject.protostuff.Input input, org.apache.drill.exec.proto.BitControl.Collector.Builder builder) throws java.io.IOException
+            {
+                for(int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
+                {
+                    switch(number)
+                    {
+                        case 0:
+                            return;
+                        case 1:
+                            builder.setOppositeMajorFragmentId(input.readInt32());
+                            break;
+                        case 2:
+                            builder.addIncomingMinorFragment(input.readInt32());
+                            break;
+                        case 3:
+                            builder.setSupportsOutOfOrder(input.readBool());
+                            break;
+                        case 4:
+                            builder.setIsSpooling(input.readBool());
+                            break;
+                        default:
+                            input.handleUnknownField(number, this);
+                    }
+                }
+            }
+            public boolean isInitialized(org.apache.drill.exec.proto.BitControl.Collector.Builder builder)
+            {
+                return builder.isInitialized();
+            }
+            public org.apache.drill.exec.proto.BitControl.Collector.Builder newMessage()
+            {
+                return org.apache.drill.exec.proto.BitControl.Collector.newBuilder();
+            }
+            public java.lang.String getFieldName(int number)
+            {
+                return org.apache.drill.exec.proto.SchemaBitControl.Collector.getFieldName(number);
+            }
+            public int getFieldNumber(java.lang.String name)
+            {
+                return org.apache.drill.exec.proto.SchemaBitControl.Collector.getFieldNumber(name);
+            }
+            public java.lang.Class<org.apache.drill.exec.proto.BitControl.Collector.Builder> typeClass()
+            {
+                return org.apache.drill.exec.proto.BitControl.Collector.Builder.class;
+            }
+            public java.lang.String messageName()
+            {
+                return org.apache.drill.exec.proto.BitControl.Collector.class.getSimpleName();
+            }
+            public java.lang.String messageFullName()
+            {
+                return org.apache.drill.exec.proto.BitControl.Collector.class.getName();
+            }
+            //unused
+            public void writeTo(com.dyuproject.protostuff.Output output, org.apache.drill.exec.proto.BitControl.Collector.Builder builder) throws java.io.IOException {}
+        }
+        public static java.lang.String getFieldName(int number)
+        {
+            switch(number)
+            {
+                case 1: return "oppositeMajorFragmentId";
+                case 2: return "incomingMinorFragment";
+                case 3: return "supportsOutOfOrder";
+                case 4: return "isSpooling";
+                default: return null;
+            }
+        }
+        public static int getFieldNumber(java.lang.String name)
+        {
+            java.lang.Integer number = fieldMap.get(name);
+            return number == null ? 0 : number.intValue();
+        }
+        private static final java.util.HashMap<java.lang.String,java.lang.Integer> fieldMap = new java.util.HashMap<java.lang.String,java.lang.Integer>();
+        static
+        {
+            fieldMap.put("oppositeMajorFragmentId", 1);
+            fieldMap.put("incomingMinorFragment", 2);
+            fieldMap.put("supportsOutOfOrder", 3);
+            fieldMap.put("isSpooling", 4);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/4ad42611/protocol/src/main/java/org/apache/drill/exec/proto/beans/Collector.java
----------------------------------------------------------------------
diff --git a/protocol/src/main/java/org/apache/drill/exec/proto/beans/Collector.java b/protocol/src/main/java/org/apache/drill/exec/proto/beans/Collector.java
new file mode 100644
index 0000000..ab9bec5
--- /dev/null
+++ b/protocol/src/main/java/org/apache/drill/exec/proto/beans/Collector.java
@@ -0,0 +1,239 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Generated by http://code.google.com/p/protostuff/ ... DO NOT EDIT!
+// Generated from protobuf
+
+package org.apache.drill.exec.proto.beans;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.dyuproject.protostuff.GraphIOUtil;
+import com.dyuproject.protostuff.Input;
+import com.dyuproject.protostuff.Message;
+import com.dyuproject.protostuff.Output;
+import com.dyuproject.protostuff.Schema;
+
+public final class Collector implements Externalizable, Message<Collector>, Schema<Collector>
+{
+
+    public static Schema<Collector> getSchema()
+    {
+        return DEFAULT_INSTANCE;
+    }
+
+    public static Collector getDefaultInstance()
+    {
+        return DEFAULT_INSTANCE;
+    }
+
+    static final Collector DEFAULT_INSTANCE = new Collector();
+
+    
+    private int oppositeMajorFragmentId;
+    private List<Integer> incomingMinorFragment;
+    private Boolean supportsOutOfOrder;
+    private Boolean isSpooling;
+
+    public Collector()
+    {
+        
+    }
+
+    // getters and setters
+
+    // oppositeMajorFragmentId
+
+    public int getOppositeMajorFragmentId()
+    {
+        return oppositeMajorFragmentId;
+    }
+
+    public Collector setOppositeMajorFragmentId(int oppositeMajorFragmentId)
+    {
+        this.oppositeMajorFragmentId = oppositeMajorFragmentId;
+        return this;
+    }
+
+    // incomingMinorFragment
+
+    public List<Integer> getIncomingMinorFragmentList()
+    {
+        return incomingMinorFragment;
+    }
+
+    public Collector setIncomingMinorFragmentList(List<Integer> incomingMinorFragment)
+    {
+        this.incomingMinorFragment = incomingMinorFragment;
+        return this;
+    }
+
+    // supportsOutOfOrder
+
+    public Boolean getSupportsOutOfOrder()
+    {
+        return supportsOutOfOrder;
+    }
+
+    public Collector setSupportsOutOfOrder(Boolean supportsOutOfOrder)
+    {
+        this.supportsOutOfOrder = supportsOutOfOrder;
+        return this;
+    }
+
+    // isSpooling
+
+    public Boolean getIsSpooling()
+    {
+        return isSpooling;
+    }
+
+    public Collector setIsSpooling(Boolean isSpooling)
+    {
+        this.isSpooling = isSpooling;
+        return this;
+    }
+
+    // java serialization
+
+    public void readExternal(ObjectInput in) throws IOException
+    {
+        GraphIOUtil.mergeDelimitedFrom(in, this, this);
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException
+    {
+        GraphIOUtil.writeDelimitedTo(out, this, this);
+    }
+
+    // message method
+
+    public Schema<Collector> cachedSchema()
+    {
+        return DEFAULT_INSTANCE;
+    }
+
+    // schema methods
+
+    public Collector newMessage()
+    {
+        return new Collector();
+    }
+
+    public Class<Collector> typeClass()
+    {
+        return Collector.class;
+    }
+
+    public String messageName()
+    {
+        return Collector.class.getSimpleName();
+    }
+
+    public String messageFullName()
+    {
+        return Collector.class.getName();
+    }
+
+    public boolean isInitialized(Collector message)
+    {
+        return true;
+    }
+
+    public void mergeFrom(Input input, Collector message) throws IOException
+    {
+        for(int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
+        {
+            switch(number)
+            {
+                case 0:
+                    return;
+                case 1:
+                    message.oppositeMajorFragmentId = input.readInt32();
+                    break;
+                case 2:
+                    if(message.incomingMinorFragment == null)
+                        message.incomingMinorFragment = new ArrayList<Integer>();
+                    message.incomingMinorFragment.add(input.readInt32());
+                    break;
+                case 3:
+                    message.supportsOutOfOrder = input.readBool();
+                    break;
+                case 4:
+                    message.isSpooling = input.readBool();
+                    break;
+                default:
+                    input.handleUnknownField(number, this);
+            }   
+        }
+    }
+
+
+    public void writeTo(Output output, Collector message) throws IOException
+    {
+        if(message.oppositeMajorFragmentId != 0)
+            output.writeInt32(1, message.oppositeMajorFragmentId, false);
+
+        if(message.incomingMinorFragment != null)
+        {
+            for(Integer incomingMinorFragment : message.incomingMinorFragment)
+            {
+                if(incomingMinorFragment != null)
+                    output.writeInt32(2, incomingMinorFragment, true);
+            }
+        }
+
+        if(message.supportsOutOfOrder != null)
+            output.writeBool(3, message.supportsOutOfOrder, false);
+
+        if(message.isSpooling != null)
+            output.writeBool(4, message.isSpooling, false);
+    }
+
+    public String getFieldName(int number)
+    {
+        switch(number)
+        {
+            case 1: return "oppositeMajorFragmentId";
+            case 2: return "incomingMinorFragment";
+            case 3: return "supportsOutOfOrder";
+            case 4: return "isSpooling";
+            default: return null;
+        }
+    }
+
+    public int getFieldNumber(String name)
+    {
+        final Integer number = __fieldMap.get(name);
+        return number == null ? 0 : number.intValue();
+    }
+
+    private static final java.util.HashMap<String,Integer> __fieldMap = new java.util.HashMap<String,Integer>();
+    static
+    {
+        __fieldMap.put("oppositeMajorFragmentId", 1);
+        __fieldMap.put("incomingMinorFragment", 2);
+        __fieldMap.put("supportsOutOfOrder", 3);
+        __fieldMap.put("isSpooling", 4);
+    }
+    
+}


[7/8] drill git commit: DRILL-3080: Fix queue failure messages.

Posted by ja...@apache.org.
DRILL-3080: Fix queue failure messages.


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/f63dac9d
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/f63dac9d
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/f63dac9d

Branch: refs/heads/master
Commit: f63dac9dc9d65624712932fe0527726626d304cc
Parents: 49940b8
Author: Jacques Nadeau <ja...@apache.org>
Authored: Wed May 13 19:30:33 2015 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Wed May 13 19:34:01 2015 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/drill/exec/work/foreman/Foreman.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/f63dac9d/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java
index fe267ba..6840cf3 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java
@@ -493,7 +493,7 @@ public class Foreman implements Runnable {
             .resourceError()
             .message(
                 "Unable to acquire queue resources for query within timeout.  Timeout for %s queue was set at %d seconds.",
-                queueTimeout / 1000, queueName)
+                queueName, queueTimeout / 1000)
             .build();
       }
 


[8/8] drill git commit: DRILL-3053: add unchecked exception injection site in ChildAllocator

Posted by ja...@apache.org.
DRILL-3053: add unchecked exception injection site in ChildAllocator


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/583ca4a9
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/583ca4a9
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/583ca4a9

Branch: refs/heads/master
Commit: 583ca4a95df2c45b5ba20b517cb1aeed48c7548e
Parents: f63dac9
Author: adeneche <ad...@gmail.com>
Authored: Wed May 13 09:45:23 2015 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Wed May 13 19:36:30 2015 -0700

----------------------------------------------------------------------
 .../exceptions/DrillRuntimeException.java       |  2 +-
 .../drill/common/exceptions/UserException.java  |  1 +
 .../drill/exec/memory/TopLevelAllocator.java    | 25 ++++--
 .../exec/testing/ExecutionControlsInjector.java | 18 +++++
 .../apache/drill/TestAllocationException.java   | 82 ++++++++++++++++++++
 5 files changed, 122 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/583ca4a9/common/src/main/java/org/apache/drill/common/exceptions/DrillRuntimeException.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/exceptions/DrillRuntimeException.java b/common/src/main/java/org/apache/drill/common/exceptions/DrillRuntimeException.java
index abc7065..8786994 100644
--- a/common/src/main/java/org/apache/drill/common/exceptions/DrillRuntimeException.java
+++ b/common/src/main/java/org/apache/drill/common/exceptions/DrillRuntimeException.java
@@ -18,7 +18,7 @@
 package org.apache.drill.common.exceptions;
 
 public class DrillRuntimeException extends RuntimeException {
-  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillRuntimeException.class);
+  private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillRuntimeException.class);
   private static final long serialVersionUID = -3796081521525479249L;
 
   public DrillRuntimeException() {

http://git-wip-us.apache.org/repos/asf/drill/blob/583ca4a9/common/src/main/java/org/apache/drill/common/exceptions/UserException.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/drill/common/exceptions/UserException.java b/common/src/main/java/org/apache/drill/common/exceptions/UserException.java
index a67cb3f..6f28a2b 100644
--- a/common/src/main/java/org/apache/drill/common/exceptions/UserException.java
+++ b/common/src/main/java/org/apache/drill/common/exceptions/UserException.java
@@ -37,6 +37,7 @@ import org.apache.drill.exec.proto.UserBitShared.DrillPBError;
  * @see org.apache.drill.exec.proto.UserBitShared.DrillPBError.ErrorType
  */
 public class UserException extends DrillRuntimeException {
+  private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(UserException.class);
 
   public static final String MEMORY_ERROR_MSG = "One or more nodes ran out of memory while executing the query.";
 

http://git-wip-us.apache.org/repos/asf/drill/blob/583ca4a9/exec/java-exec/src/main/java/org/apache/drill/exec/memory/TopLevelAllocator.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/memory/TopLevelAllocator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/memory/TopLevelAllocator.java
index 9670c7e..f6a37e7 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/memory/TopLevelAllocator.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/memory/TopLevelAllocator.java
@@ -31,11 +31,15 @@ import org.apache.drill.common.config.DrillConfig;
 import org.apache.drill.exec.ExecConstants;
 import org.apache.drill.exec.ops.FragmentContext;
 import org.apache.drill.exec.proto.ExecProtos.FragmentHandle;
+import org.apache.drill.exec.testing.ExecutionControlsInjector;
 import org.apache.drill.exec.util.AssertionUtil;
 import org.apache.drill.exec.util.Pointer;
 
 public class TopLevelAllocator implements BufferAllocator {
-  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TopLevelAllocator.class);
+  private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TopLevelAllocator.class);
+
+  private static final ExecutionControlsInjector injector = ExecutionControlsInjector.getInjector(TopLevelAllocator.class);
+  public static final String CHILD_BUFFER_INJECTION_SITE = "child.buffer";
 
   public static long MAXIMUM_DIRECT_MEMORY;
 
@@ -127,7 +131,7 @@ public class TopLevelAllocator implements BufferAllocator {
               .format(
                   "You attempted to create a new child allocator with initial reservation %d but only %d bytes of memory were available.",
                   initialReservation, acct.getCapacity() - acct.getAllocation()));
-    };
+    }
     logger.debug("New child allocator with initial reservation {}", initialReservation);
     ChildAllocator allocator = new ChildAllocator(context, acct, maximumReservation, initialReservation, childrenMap, applyFragmentLimit);
     if(ENABLE_ACCOUNTING){
@@ -180,7 +184,7 @@ public class TopLevelAllocator implements BufferAllocator {
 
 
 
-  private class ChildAllocator implements BufferAllocator{
+  private class ChildAllocator implements BufferAllocator {
     private final DrillBuf empty;
     private Accountor childAcct;
     private Map<ChildAllocator, StackTraceElement[]> children = new HashMap<>();
@@ -221,13 +225,24 @@ public class TopLevelAllocator implements BufferAllocator {
 
     @Override
     public DrillBuf buffer(int size, int max) {
+      if (ENABLE_ACCOUNTING) {
+        try {
+          injector.injectUnchecked(fragmentContext, CHILD_BUFFER_INJECTION_SITE);
+        } catch (NullPointerException e) {
+          // This is an unusual way to use exception injection. If we inject a NullPointerException into this site
+          // it will actually cause this method to return null, simulating a "normal" failure to allocate memory
+          // this can be useful to check if the caller will properly handle nulls
+          return null;
+        }
+      }
+
       if (size == 0) {
         return empty;
       }
       if(!childAcct.reserve(size)) {
         logger.warn("Unable to allocate buffer of size {} due to memory limit. Current allocation: {}", size, getAllocatedMemory(), new Exception());
         return null;
-      };
+      }
 
       UnsafeDirectLittleEndian buffer = innerAllocator.directBuffer(size, max);
       DrillBuf wrapped = new DrillBuf(this, childAcct, buffer);
@@ -253,7 +268,7 @@ public class TopLevelAllocator implements BufferAllocator {
                 .format(
                     "You attempted to create a new child allocator with initial reservation %d but only %d bytes of memory were available.",
                     initialReservation, childAcct.getAvailable()));
-      };
+      }
       logger.debug("New child allocator with initial reservation {}", initialReservation);
       ChildAllocator newChildAllocator = new ChildAllocator(context, childAcct, maximumReservation, initialReservation, null, applyFragmentLimit);
       this.children.put(newChildAllocator, Thread.currentThread().getStackTrace());

http://git-wip-us.apache.org/repos/asf/drill/blob/583ca4a9/exec/java-exec/src/main/java/org/apache/drill/exec/testing/ExecutionControlsInjector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/testing/ExecutionControlsInjector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/testing/ExecutionControlsInjector.java
index 387d300..e3a4ba6 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/testing/ExecutionControlsInjector.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/testing/ExecutionControlsInjector.java
@@ -17,6 +17,7 @@
  */
 package org.apache.drill.exec.testing;
 
+import org.apache.drill.exec.ops.FragmentContext;
 import org.apache.drill.exec.util.AssertionUtil;
 import org.slf4j.Logger;
 
@@ -83,6 +84,23 @@ public class ExecutionControlsInjector {
   }
 
   /**
+   * Inject (throw) an unchecked exception at this point, if the fragmentContext is not null,
+   * an injection is specified, and it is time for it to be thrown.
+   * <p/>
+   * <p>Implementors use this in their code at a site where they want to simulate an exception
+   * during testing.
+   *
+   * @param fragmentContext   fragmentContext used to retrieve the controls, can be null
+   * @param desc              the site description
+   *                          throws the exception specified by the injection, if it is time
+   */
+  public void injectUnchecked(final FragmentContext fragmentContext, final String desc) {
+    if (fragmentContext != null) {
+      injectUnchecked(fragmentContext.getExecutionControls(), desc);
+    }
+  }
+
+  /**
    * Inject (throw) a checked exception at this point, if an injection is specified, and it is time
    * for it to be thrown.
    * <p/>

http://git-wip-us.apache.org/repos/asf/drill/blob/583ca4a9/exec/java-exec/src/test/java/org/apache/drill/TestAllocationException.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestAllocationException.java b/exec/java-exec/src/test/java/org/apache/drill/TestAllocationException.java
new file mode 100644
index 0000000..051ad4e
--- /dev/null
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestAllocationException.java
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill;
+
+import org.apache.drill.common.exceptions.UserException;
+import org.apache.drill.exec.memory.OutOfMemoryRuntimeException;
+import org.apache.drill.exec.memory.TopLevelAllocator;
+import org.apache.drill.exec.proto.CoordinationProtos;
+import org.apache.drill.exec.proto.UserBitShared.DrillPBError;
+import org.apache.drill.exec.testing.ControlsInjectionUtil;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import org.junit.Test;
+
+/**
+ * Run several tpch queries and inject an OutOfMemoryException in ScanBatch that will cause an OUT_OF_MEMORY outcome to
+ * be propagated downstream. Make sure the proper "memory error" message is sent to the client.
+ */
+public class TestAllocationException extends BaseTestQuery {
+
+  private static final String SINGLE_MODE = "ALTER SESSION SET `planner.disable_exchanges` = true";
+
+  private void testWithException(final String fileName) throws Exception {
+    testWithException(fileName, OutOfMemoryRuntimeException.class);
+  }
+
+  private void testWithException(final String fileName, Class<? extends Throwable> exceptionClass) throws Exception{
+    test(SINGLE_MODE);
+
+    CoordinationProtos.DrillbitEndpoint endpoint = bits[0].getContext().getEndpoint();
+
+    String controlsString = "{\"injections\":[{"
+      + "\"address\":\"" + endpoint.getAddress() + "\","
+      + "\"port\":\"" + endpoint.getUserPort() + "\","
+      + "\"type\":\"exception\","
+      + "\"siteClass\":\"" + TopLevelAllocator.class.getName() + "\","
+      + "\"desc\":\"" + TopLevelAllocator.CHILD_BUFFER_INJECTION_SITE + "\","
+      + "\"nSkip\":200,"
+      + "\"nFire\":1,"
+      + "\"exceptionClass\":\"" + exceptionClass.getName() + "\""
+      + "}]}";
+    ControlsInjectionUtil.setControls(client, controlsString);
+
+    String query = getFile(fileName);
+
+    try {
+      test(query);
+      fail("The query should have failed!");
+    } catch(UserException uex) {
+      DrillPBError error = uex.getOrCreatePBError(false);
+      assertEquals(DrillPBError.ErrorType.RESOURCE, error.getErrorType());
+      assertTrue("Error message isn't related to memory error",
+        uex.getMessage().contains(UserException.MEMORY_ERROR_MSG));
+    }
+  }
+
+  @Test
+  public void testWithNull() throws Exception{
+    testWithException("queries/tpch/01.sql");
+  }
+
+  @Test
+  public void testWithOOM() throws Exception{
+    testWithException("queries/tpch/03.sql", NullPointerException.class);
+  }
+}


[3/8] drill git commit: DRILL-3079: Move execution fragment json parsing from RPC message to fragment start.

Posted by ja...@apache.org.
DRILL-3079: Move execution fragment json parsing from RPC message to fragment start.


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/4ad42611
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/4ad42611
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/4ad42611

Branch: refs/heads/master
Commit: 4ad426117512b1a6ec65ab15274ebc33db33b5a8
Parents: 814f553
Author: Jacques Nadeau <ja...@apache.org>
Authored: Wed May 13 12:55:01 2015 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Wed May 13 19:33:55 2015 -0700

----------------------------------------------------------------------
 .../planner/fragment/SimpleParallelizer.java    |   55 +-
 .../exec/work/batch/AbstractDataCollector.java  |   38 +-
 .../exec/work/batch/ControlMessageHandler.java  |    5 +-
 .../drill/exec/work/batch/IncomingBuffers.java  |   52 +-
 .../drill/exec/work/batch/MergingCollector.java |    6 +-
 .../exec/work/batch/PartitionedCollector.java   |    6 +-
 .../apache/drill/exec/work/foreman/Foreman.java |    9 +-
 .../exec/work/fragment/FragmentExecutor.java    |   36 +-
 .../work/fragment/NonRootFragmentManager.java   |   15 +-
 .../org/apache/drill/exec/proto/BitControl.java | 1531 +++++++++++++++---
 .../drill/exec/proto/SchemaBitControl.java      |  141 ++
 .../drill/exec/proto/beans/Collector.java       |  239 +++
 .../drill/exec/proto/beans/PlanFragment.java    |   34 +
 protocol/src/main/protobuf/BitControl.proto     |    8 +
 14 files changed, 1870 insertions(+), 305 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/4ad42611/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/SimpleParallelizer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/SimpleParallelizer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/SimpleParallelizer.java
index d36ad42..e04a8a2 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/SimpleParallelizer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/SimpleParallelizer.java
@@ -17,6 +17,7 @@
  */
 package org.apache.drill.exec.planner.fragment;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
@@ -26,22 +27,22 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ThreadLocalRandom;
 
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Sets;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.Ordering;
 import org.apache.drill.common.exceptions.ExecutionSetupException;
 import org.apache.drill.common.util.DrillStringUtils;
 import org.apache.drill.exec.ExecConstants;
 import org.apache.drill.exec.ops.QueryContext;
 import org.apache.drill.exec.physical.EndpointAffinity;
+import org.apache.drill.exec.physical.MinorFragmentEndpoint;
 import org.apache.drill.exec.physical.PhysicalOperatorSetupException;
+import org.apache.drill.exec.physical.base.AbstractPhysicalVisitor;
 import org.apache.drill.exec.physical.base.Exchange.ParallelizationDependency;
 import org.apache.drill.exec.physical.base.FragmentRoot;
 import org.apache.drill.exec.physical.base.PhysicalOperator;
+import org.apache.drill.exec.physical.base.Receiver;
 import org.apache.drill.exec.planner.PhysicalPlanReader;
 import org.apache.drill.exec.planner.fragment.Fragment.ExchangeFragmentPair;
 import org.apache.drill.exec.planner.fragment.Materializer.IndexedFragmentNode;
+import org.apache.drill.exec.proto.BitControl.Collector;
 import org.apache.drill.exec.proto.BitControl.PlanFragment;
 import org.apache.drill.exec.proto.BitControl.QueryContextInformation;
 import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
@@ -54,8 +55,12 @@ import org.apache.drill.exec.work.QueryWorkUnit;
 import org.apache.drill.exec.work.foreman.ForemanSetupException;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterators;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Ordering;
+import com.google.common.collect.Sets;
 
 /**
  * The simple parallelizer determines the level of parallelization of a plan based on the cost of the underlying
@@ -367,6 +372,7 @@ public class SimpleParallelizer {
             .setMinorFragmentId(minorFragmentId) //
             .setQueryId(queryId) //
             .build();
+
         PlanFragment fragment = PlanFragment.newBuilder() //
             .setForeman(foremanNode) //
             .setFragmentJson(plan) //
@@ -378,6 +384,7 @@ public class SimpleParallelizer {
             .setMemMax(wrapper.getMaxAllocation())
             .setOptionsJson(optionsData)
             .setCredentials(session.getCredentials())
+            .addAllCollector(CountRequiredFragments.getCollectors(root))
             .build();
 
         if (isRootNode) {
@@ -393,4 +400,44 @@ public class SimpleParallelizer {
 
     return new QueryWorkUnit(rootOperator, rootFragment, fragments);
   }
+
+  /**
+   * Designed to setup initial values for arriving fragment accounting.
+   */
+  private static class CountRequiredFragments extends AbstractPhysicalVisitor<Void, List<Collector>, RuntimeException> {
+    private static final CountRequiredFragments INSTANCE = new CountRequiredFragments();
+
+    public static List<Collector> getCollectors(PhysicalOperator root) {
+      List<Collector> collectors = Lists.newArrayList();
+      root.accept(INSTANCE, collectors);
+      return collectors;
+    }
+
+    @Override
+    public Void visitReceiver(Receiver receiver, List<Collector> collectors) throws RuntimeException {
+      List<MinorFragmentEndpoint> endpoints = receiver.getProvidingEndpoints();
+      List<Integer> list = new ArrayList<>(endpoints.size());
+      for (MinorFragmentEndpoint ep : endpoints) {
+        list.add(ep.getId());
+      }
+
+
+      collectors.add(Collector.newBuilder()
+        .setIsSpooling(receiver.isSpooling())
+        .setOppositeMajorFragmentId(receiver.getOppositeMajorFragmentId())
+        .setSupportsOutOfOrder(receiver.supportsOutOfOrderExchange())
+          .addAllIncomingMinorFragment(list)
+          .build());
+      return null;
+    }
+
+    @Override
+    public Void visitOp(PhysicalOperator op, List<Collector> collectors) throws RuntimeException {
+      for (PhysicalOperator o : op) {
+        o.accept(this, collectors);
+      }
+      return null;
+    }
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/4ad42611/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/AbstractDataCollector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/AbstractDataCollector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/AbstractDataCollector.java
index 6f16976..407c547 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/AbstractDataCollector.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/AbstractDataCollector.java
@@ -18,30 +18,25 @@
 package org.apache.drill.exec.work.batch;
 
 import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicIntegerArray;
 
-import org.apache.drill.exec.ExecConstants;
 import org.apache.drill.exec.memory.OutOfMemoryException;
 import org.apache.drill.exec.ops.FragmentContext;
-import org.apache.drill.exec.physical.MinorFragmentEndpoint;
-import org.apache.drill.exec.physical.base.Receiver;
+import org.apache.drill.exec.proto.BitControl.Collector;
 import org.apache.drill.exec.record.RawFragmentBatch;
+import org.apache.drill.exec.util.ArrayWrappedIntIntMap;
 
 import com.google.common.base.Preconditions;
-import org.apache.drill.exec.util.ArrayWrappedIntIntMap;
 
 public abstract class AbstractDataCollector implements DataCollector{
 
-  private final List<MinorFragmentEndpoint> incoming;
+  // private final List<MinorFragmentEndpoint> incoming;
   private final int oppositeMajorFragmentId;
   private final AtomicIntegerArray remainders;
   private final AtomicInteger remainingRequired;
   private final AtomicInteger parentAccounter;
-
+  private final int incomingStreams;
   protected final RawBatchBuffer[] buffers;
   protected final ArrayWrappedIntIntMap fragmentMap;
 
@@ -52,37 +47,36 @@ public abstract class AbstractDataCollector implements DataCollector{
    * @param bufferCapacity Capacity of each RawBatchBuffer.
    * @param context
    */
-  public AbstractDataCollector(AtomicInteger parentAccounter, Receiver receiver,
-      final int numBuffers, final int bufferCapacity, FragmentContext context) {
-    Preconditions.checkNotNull(receiver);
+  public AbstractDataCollector(AtomicInteger parentAccounter,
+      final int numBuffers, Collector collector, final int bufferCapacity, FragmentContext context) {
+    Preconditions.checkNotNull(collector);
     Preconditions.checkNotNull(parentAccounter);
 
+    this.incomingStreams = collector.getIncomingMinorFragmentCount();
     this.parentAccounter = parentAccounter;
-    this.incoming = receiver.getProvidingEndpoints();
-    this.remainders = new AtomicIntegerArray(incoming.size());
-    this.oppositeMajorFragmentId = receiver.getOppositeMajorFragmentId();
-
+    this.remainders = new AtomicIntegerArray(incomingStreams);
+    this.oppositeMajorFragmentId = collector.getOppositeMajorFragmentId();
     // Create fragmentId to index that is within the range [0, incoming.size()-1]
     // We use this mapping to find objects belonging to the fragment in buffers and remainders arrays.
     fragmentMap = new ArrayWrappedIntIntMap();
     int index = 0;
-    for(MinorFragmentEndpoint endpoint : incoming) {
-      fragmentMap.put(endpoint.getId(), index);
+    for (Integer endpoint : collector.getIncomingMinorFragmentList()) {
+      fragmentMap.put(endpoint, index);
       index++;
     }
 
     buffers = new RawBatchBuffer[numBuffers];
     remainingRequired = new AtomicInteger(numBuffers);
 
-    final boolean spooling = receiver.isSpooling();
+    final boolean spooling = collector.getIsSpooling();
 
     try {
 
       for (int i = 0; i < numBuffers; i++) {
         if (spooling) {
-          buffers[i] = new SpoolingRawBatchBuffer(context, bufferCapacity, receiver.getOppositeMajorFragmentId(), i);
+          buffers[i] = new SpoolingRawBatchBuffer(context, bufferCapacity, collector.getOppositeMajorFragmentId(), i);
         } else {
-          buffers[i] = new UnlimitedRawBatchBuffer(context, bufferCapacity, receiver.getOppositeMajorFragmentId());
+          buffers[i] = new UnlimitedRawBatchBuffer(context, bufferCapacity, collector.getOppositeMajorFragmentId());
         }
       }
     } catch (IOException | OutOfMemoryException e) {
@@ -129,7 +123,7 @@ public abstract class AbstractDataCollector implements DataCollector{
 
   @Override
   public int getTotalIncomingFragments() {
-    return incoming.size();
+    return incomingStreams;
   }
 
   protected abstract RawBatchBuffer getBuffer(int minorFragmentId);

http://git-wip-us.apache.org/repos/asf/drill/blob/4ad42611/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/ControlMessageHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/ControlMessageHandler.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/ControlMessageHandler.java
index 421ad7f..8ee7d38 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/ControlMessageHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/ControlMessageHandler.java
@@ -21,7 +21,6 @@ import static org.apache.drill.exec.rpc.RpcBus.get;
 import io.netty.buffer.ByteBuf;
 
 import org.apache.drill.exec.ops.FragmentContext;
-import org.apache.drill.exec.physical.base.FragmentRoot;
 import org.apache.drill.exec.proto.BitControl.FinishedReceiver;
 import org.apache.drill.exec.proto.BitControl.FragmentStatus;
 import org.apache.drill.exec.proto.BitControl.InitializeFragments;
@@ -132,9 +131,7 @@ public class ControlMessageHandler {
             drillbitContext.getFunctionImplementationRegistry());
         final ControlTunnel tunnel = drillbitContext.getController().getTunnel(fragment.getForeman());
         final NonRootStatusReporter listener = new NonRootStatusReporter(context, tunnel);
-        final FragmentRoot rootOperator = drillbitContext.getPlanReader().readFragmentOperator(
-            fragment.getFragmentJson());
-        final FragmentExecutor fr = new FragmentExecutor(context, rootOperator, listener);
+        final FragmentExecutor fr = new FragmentExecutor(context, fragment, listener);
         bee.addFragmentRunner(fr);
       } else {
         // isIntermediate, store for incoming data.

http://git-wip-us.apache.org/repos/asf/drill/blob/4ad42611/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/IncomingBuffers.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/IncomingBuffers.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/IncomingBuffers.java
index b0206f7..1c8b066 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/IncomingBuffers.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/IncomingBuffers.java
@@ -24,9 +24,8 @@ import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.drill.exec.exception.FragmentSetupException;
 import org.apache.drill.exec.ops.FragmentContext;
-import org.apache.drill.exec.physical.base.AbstractPhysicalVisitor;
-import org.apache.drill.exec.physical.base.PhysicalOperator;
-import org.apache.drill.exec.physical.base.Receiver;
+import org.apache.drill.exec.proto.BitControl.Collector;
+import org.apache.drill.exec.proto.BitControl.PlanFragment;
 import org.apache.drill.exec.record.RawFragmentBatch;
 
 import com.google.common.collect.ImmutableMap;
@@ -39,18 +38,24 @@ public class IncomingBuffers implements AutoCloseable {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(IncomingBuffers.class);
 
   private final AtomicInteger streamsRemaining = new AtomicInteger(0);
-  private final AtomicInteger remainingRequired = new AtomicInteger(0);
+  private final AtomicInteger remainingRequired;
   private final Map<Integer, DataCollector> fragCounts;
   private final FragmentContext context;
 
-  public IncomingBuffers(PhysicalOperator root, FragmentContext context) {
+  public IncomingBuffers(PlanFragment fragment, FragmentContext context) {
     this.context = context;
-    Map<Integer, DataCollector> counts = Maps.newHashMap();
-    CountRequiredFragments reqFrags = new CountRequiredFragments();
-    root.accept(reqFrags, counts);
+    Map<Integer, DataCollector> collectors = Maps.newHashMap();
+    remainingRequired = new AtomicInteger(fragment.getCollectorCount());
+    for(int i =0; i < fragment.getCollectorCount(); i++){
+      Collector collector = fragment.getCollector(i);
+      DataCollector newCollector = collector.getSupportsOutOfOrder() ?
+          new MergingCollector(remainingRequired, collector, context) :
+          new PartitionedCollector(remainingRequired, collector, context);
+      collectors.put(collector.getOppositeMajorFragmentId(), newCollector);
+    }
 
-    logger.debug("Came up with a list of {} required fragments.  Fragments {}", remainingRequired.get(), counts);
-    fragCounts = ImmutableMap.copyOf(counts);
+    logger.debug("Came up with a list of {} required fragments.  Fragments {}", remainingRequired.get(), collectors);
+    fragCounts = ImmutableMap.copyOf(collectors);
 
     // Determine the total number of incoming streams that will need to be completed before we are finished.
     int totalStreams = 0;
@@ -98,34 +103,7 @@ public class IncomingBuffers implements AutoCloseable {
   }
 
 
-  /**
-   * Designed to setup initial values for arriving fragment accounting.
-   */
-  public class CountRequiredFragments extends AbstractPhysicalVisitor<Void, Map<Integer, DataCollector>, RuntimeException> {
-
-    @Override
-    public Void visitReceiver(Receiver receiver, Map<Integer, DataCollector> counts) throws RuntimeException {
-      DataCollector set;
-      if (receiver.supportsOutOfOrderExchange()) {
-        set = new MergingCollector(remainingRequired, receiver, context);
-      } else {
-        set = new PartitionedCollector(remainingRequired, receiver, context);
-      }
-
-      counts.put(set.getOppositeMajorFragmentId(), set);
-      remainingRequired.incrementAndGet();
-      return null;
-    }
 
-    @Override
-    public Void visitOp(PhysicalOperator op, Map<Integer, DataCollector> value) throws RuntimeException {
-      for (PhysicalOperator o : op) {
-        o.accept(this, value);
-      }
-      return null;
-    }
-
-  }
 
   public boolean isDone() {
     return streamsRemaining.get() < 1;

http://git-wip-us.apache.org/repos/asf/drill/blob/4ad42611/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/MergingCollector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/MergingCollector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/MergingCollector.java
index 8c09f80..5d13a34 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/MergingCollector.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/MergingCollector.java
@@ -20,12 +20,12 @@ package org.apache.drill.exec.work.batch;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.drill.exec.ops.FragmentContext;
-import org.apache.drill.exec.physical.base.Receiver;
+import org.apache.drill.exec.proto.BitControl.Collector;
 
 public class MergingCollector extends AbstractDataCollector{
 
-  public MergingCollector(AtomicInteger parentAccounter, Receiver receiver, FragmentContext context) {
-    super(parentAccounter, receiver, 1, receiver.getProvidingEndpoints().size(), context);
+  public MergingCollector(AtomicInteger parentAccounter, Collector collector, FragmentContext context) {
+    super(parentAccounter, 1, collector, collector.getIncomingMinorFragmentCount(), context);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/drill/blob/4ad42611/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/PartitionedCollector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/PartitionedCollector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/PartitionedCollector.java
index 7ce9074..a334d30 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/PartitionedCollector.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/PartitionedCollector.java
@@ -20,12 +20,12 @@ package org.apache.drill.exec.work.batch;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.drill.exec.ops.FragmentContext;
-import org.apache.drill.exec.physical.base.Receiver;
+import org.apache.drill.exec.proto.BitControl.Collector;
 
 public class PartitionedCollector extends AbstractDataCollector{
 
-  public PartitionedCollector(AtomicInteger parentAccounter, Receiver receiver, FragmentContext context) {
-    super(parentAccounter, receiver, receiver.getProvidingEndpoints().size(), 1, context);
+  public PartitionedCollector(AtomicInteger parentAccounter, Collector collector, FragmentContext context) {
+    super(parentAccounter, collector.getIncomingMinorFragmentCount(), collector, 1, context);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/drill/blob/4ad42611/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java
index cdf1276..fe267ba 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/Foreman.java
@@ -929,15 +929,14 @@ public class Foreman implements Runnable {
     final FragmentContext rootContext = new FragmentContext(drillbitContext, rootFragment, queryContext,
         initiatingClient, drillbitContext.getFunctionImplementationRegistry());
     @SuppressWarnings("resource")
-    final IncomingBuffers buffers = new IncomingBuffers(rootOperator, rootContext);
+    final IncomingBuffers buffers = new IncomingBuffers(rootFragment, rootContext);
     rootContext.setBuffers(buffers);
 
     queryManager.addFragmentStatusTracker(rootFragment, true);
 
-    rootRunner = new FragmentExecutor(rootContext, rootOperator,
-        queryManager.newRootStatusHandler(rootContext));
-    final RootFragmentManager fragmentManager =
-        new RootFragmentManager(rootFragment.getHandle(), buffers, rootRunner);
+    rootRunner = new FragmentExecutor(rootContext, rootFragment, queryManager.newRootStatusHandler(rootContext),
+        rootOperator);
+    final RootFragmentManager fragmentManager = new RootFragmentManager(rootFragment.getHandle(), buffers, rootRunner);
 
     if (buffers.isDone()) {
       // if we don't have to wait for any incoming data, start the fragment runner.

http://git-wip-us.apache.org/repos/asf/drill/blob/4ad42611/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/FragmentExecutor.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/FragmentExecutor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/FragmentExecutor.java
index 6b44ae3..8c49d68 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/FragmentExecutor.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/FragmentExecutor.java
@@ -33,6 +33,7 @@ import org.apache.drill.exec.physical.base.FragmentRoot;
 import org.apache.drill.exec.physical.impl.ImplCreator;
 import org.apache.drill.exec.physical.impl.RootExec;
 import org.apache.drill.exec.proto.BitControl.FragmentStatus;
+import org.apache.drill.exec.proto.BitControl.PlanFragment;
 import org.apache.drill.exec.proto.CoordinationProtos;
 import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
 import org.apache.drill.exec.proto.ExecProtos.FragmentHandle;
@@ -53,10 +54,11 @@ public class FragmentExecutor implements Runnable {
   private final static ExecutionControlsInjector injector = ExecutionControlsInjector.getInjector(FragmentExecutor.class);
 
   private final String fragmentName;
-  private final FragmentRoot rootOperator;
   private final FragmentContext fragmentContext;
   private final StatusReporter listener;
   private final DeferredException deferredException = new DeferredException();
+  private final PlanFragment fragment;
+  private final FragmentRoot rootOperator;
 
   private volatile RootExec root;
   private final AtomicReference<FragmentState> fragmentState = new AtomicReference<>(FragmentState.AWAITING_ALLOCATION);
@@ -65,11 +67,33 @@ public class FragmentExecutor implements Runnable {
   // Thread that is currently executing the Fragment. Value is null if the fragment hasn't started running or finished
   private final AtomicReference<Thread> myThreadRef = new AtomicReference<>(null);
 
-  public FragmentExecutor(final FragmentContext context, final FragmentRoot rootOperator,
-                          final StatusReporter listener) {
+  /**
+   * Create a FragmentExecutor where we need to parse and materialize the root operator.
+   *
+   * @param context
+   * @param fragment
+   * @param listener
+   * @param rootOperator
+   */
+  public FragmentExecutor(final FragmentContext context, final PlanFragment fragment,
+      final StatusReporter listener) {
+    this(context, fragment, listener, null);
+  }
+
+  /**
+   * Create a FragmentExecutor where we already have a root operator in memory.
+   *
+   * @param context
+   * @param fragment
+   * @param listener
+   * @param rootOperator
+   */
+  public FragmentExecutor(final FragmentContext context, final PlanFragment fragment,
+      final StatusReporter listener, final FragmentRoot rootOperator) {
     this.fragmentContext = context;
-    this.rootOperator = rootOperator;
     this.listener = listener;
+    this.fragment = fragment;
+    this.rootOperator = rootOperator;
     this.fragmentName = QueryIdHelper.getQueryIdentifier(context.getHandle());
 
     context.setExecutorState(new ExecutorStateImpl());
@@ -197,6 +221,10 @@ public class FragmentExecutor implements Runnable {
          * fragmentState might have changed even before this method is called e.g. cancel()
          */
         if (shouldContinue()) {
+          // if we didn't get the root operator when the executor was created, create it now.
+          final FragmentRoot rootOperator = this.rootOperator != null ? this.rootOperator :
+              drillbitContext.getPlanReader().readFragmentOperator(fragment.getFragmentJson());
+
           root = ImplCreator.getExec(fragmentContext, rootOperator);
 
           clusterCoordinator.addDrillbitStatusListener(drillbitStatusListener);

http://git-wip-us.apache.org/repos/asf/drill/blob/4ad42611/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/NonRootFragmentManager.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/NonRootFragmentManager.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/NonRootFragmentManager.java
index ca5d5b8..77440c5 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/NonRootFragmentManager.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/fragment/NonRootFragmentManager.java
@@ -24,7 +24,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import org.apache.drill.common.exceptions.ExecutionSetupException;
 import org.apache.drill.exec.exception.FragmentSetupException;
 import org.apache.drill.exec.ops.FragmentContext;
-import org.apache.drill.exec.physical.base.FragmentRoot;
 import org.apache.drill.exec.proto.BitControl.PlanFragment;
 import org.apache.drill.exec.proto.ExecProtos.FragmentHandle;
 import org.apache.drill.exec.record.RawFragmentBatch;
@@ -42,10 +41,9 @@ import com.google.common.base.Preconditions;
 public class NonRootFragmentManager implements FragmentManager {
   private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(NonRootFragmentManager.class);
 
-  private final PlanFragment fragment;
-  private FragmentRoot root;
   private final IncomingBuffers buffers;
   private final FragmentExecutor runner;
+  private final FragmentHandle handle;
   private volatile boolean cancel = false;
   private final FragmentContext context;
   private final List<RemoteConnection> connections = new CopyOnWriteArrayList<>();
@@ -54,16 +52,15 @@ public class NonRootFragmentManager implements FragmentManager {
   public NonRootFragmentManager(final PlanFragment fragment, final DrillbitContext context)
       throws ExecutionSetupException {
     try {
-      this.fragment = fragment;
-      this.root = context.getPlanReader().readFragmentOperator(fragment.getFragmentJson());
+      this.handle = fragment.getHandle();
       this.context = new FragmentContext(context, fragment, context.getFunctionImplementationRegistry());
-      this.buffers = new IncomingBuffers(root, this.context);
+      this.buffers = new IncomingBuffers(fragment, this.context);
       final StatusReporter reporter = new NonRootStatusReporter(this.context, context.getController().getTunnel(
           fragment.getForeman()));
-      this.runner = new FragmentExecutor(this.context, root, reporter);
+      this.runner = new FragmentExecutor(this.context, fragment, reporter);
       this.context.setBuffers(buffers);
 
-    } catch (ForemanException | IOException e) {
+    } catch (ForemanException e) {
       throw new FragmentSetupException("Failure while decoding fragment.", e);
     }
   }
@@ -118,7 +115,7 @@ public class NonRootFragmentManager implements FragmentManager {
 
   @Override
   public FragmentHandle getHandle() {
-    return fragment.getHandle();
+    return handle;
   }
 
   @Override


[6/8] drill git commit: DRILL-3069: Fix StreamingAggBatch to appropriately set current index when it receives empty batches

Posted by ja...@apache.org.
DRILL-3069: Fix StreamingAggBatch to appropriately set current index when it receives empty batches


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/97a63168
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/97a63168
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/97a63168

Branch: refs/heads/master
Commit: 97a63168e93a70c7ed88d2e801dd2ea2e5f1dd74
Parents: b1b75f6
Author: Mehant Baid <me...@gmail.com>
Authored: Wed May 13 17:17:35 2015 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Wed May 13 19:34:01 2015 -0700

----------------------------------------------------------------------
 .../impl/aggregate/StreamingAggTemplate.java    |  1 +
 .../exec/fn/impl/TestAggregateFunctions.java    | 34 ++++++++++++++++++++
 .../test/resources/agg/bugs/drill3069/1.json    |  2 ++
 .../test/resources/agg/bugs/drill3069/2.json    |  2 ++
 .../test/resources/agg/bugs/drill3069/3.json    |  2 ++
 5 files changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/97a63168/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/StreamingAggTemplate.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/StreamingAggTemplate.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/StreamingAggTemplate.java
index 0bbfd18..4932b0f 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/StreamingAggTemplate.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/StreamingAggTemplate.java
@@ -95,6 +95,7 @@ public abstract class StreamingAggTemplate implements StreamingAggregator {
               if (incoming.getRecordCount() == 0) {
                 continue;
               } else {
+                currentIndex = this.getVectorIndex(underlyingIndex);
                 break outer;
               }
             case OUT_OF_MEMORY:

http://git-wip-us.apache.org/repos/asf/drill/blob/97a63168/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
index 69a7cbf..78ebe0f 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
@@ -19,11 +19,14 @@ package org.apache.drill.exec.fn.impl;
 
 import org.apache.drill.BaseTestQuery;
 import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.util.TestTools;
 import org.junit.Ignore;
 import org.junit.Test;
 
 public class TestAggregateFunctions extends BaseTestQuery {
 
+  private static final String TEST_RES_PATH =   TestTools.getWorkingPath() + "/src/test/resources";
+
   /*
    * Test checks the count of a nullable column within a map
    * and verifies count is equal only to the number of times the
@@ -289,4 +292,35 @@ public class TestAggregateFunctions extends BaseTestQuery {
         .go();
 
   }
+
+  /*
+   * Streaming agg on top of a filter produces wrong results if the first two batches are filtered out.
+   * In the below test we have three files in the input directory and since the ordering of reading
+   * of these files may not be deterministic, we have three tests to make sure we test the case where
+   * streaming agg gets two empty batches.
+   */
+  @Test
+  public void drill3069() throws Exception {
+    final String query = "select max(foo) col1 from dfs_test.`%s/agg/bugs/drill3069` where foo = %d";
+    testBuilder()
+        .sqlQuery(String.format(query, TEST_RES_PATH, 2))
+        .unOrdered()
+        .baselineColumns("col1")
+        .baselineValues(2l)
+        .go();
+
+    testBuilder()
+        .sqlQuery(String.format(query, TEST_RES_PATH, 4))
+        .unOrdered()
+        .baselineColumns("col1")
+        .baselineValues(4l)
+        .go();
+
+    testBuilder()
+        .sqlQuery(String.format(query, TEST_RES_PATH, 6))
+        .unOrdered()
+        .baselineColumns("col1")
+        .baselineValues(6l)
+        .go();
+  }
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/97a63168/exec/java-exec/src/test/resources/agg/bugs/drill3069/1.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/agg/bugs/drill3069/1.json b/exec/java-exec/src/test/resources/agg/bugs/drill3069/1.json
new file mode 100644
index 0000000..9bf33e6
--- /dev/null
+++ b/exec/java-exec/src/test/resources/agg/bugs/drill3069/1.json
@@ -0,0 +1,2 @@
+{"foo": 1}
+{"foo": 2}

http://git-wip-us.apache.org/repos/asf/drill/blob/97a63168/exec/java-exec/src/test/resources/agg/bugs/drill3069/2.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/agg/bugs/drill3069/2.json b/exec/java-exec/src/test/resources/agg/bugs/drill3069/2.json
new file mode 100644
index 0000000..b5e059c
--- /dev/null
+++ b/exec/java-exec/src/test/resources/agg/bugs/drill3069/2.json
@@ -0,0 +1,2 @@
+{"foo": 3}
+{"foo": 4}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/drill/blob/97a63168/exec/java-exec/src/test/resources/agg/bugs/drill3069/3.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/agg/bugs/drill3069/3.json b/exec/java-exec/src/test/resources/agg/bugs/drill3069/3.json
new file mode 100644
index 0000000..ac7915d
--- /dev/null
+++ b/exec/java-exec/src/test/resources/agg/bugs/drill3069/3.json
@@ -0,0 +1,2 @@
+{"foo": 5}
+{"foo": 6}
\ No newline at end of file


[4/8] drill git commit: DRILL-3074: Fix infinite loop issue in ReconnectingConnection

Posted by ja...@apache.org.
DRILL-3074: Fix infinite loop issue in ReconnectingConnection

Also use the remaining timeout incase of interruption


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/b1b75f6a
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/b1b75f6a
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/b1b75f6a

Branch: refs/heads/master
Commit: b1b75f6abc56ed1ba097e20bdce81e7992396180
Parents: 4ad4261
Author: vkorukanti <ve...@gmail.com>
Authored: Wed May 13 17:56:14 2015 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Wed May 13 19:34:00 2015 -0700

----------------------------------------------------------------------
 .../org/apache/drill/exec/rpc/BasicClient.java     | 17 +++++++++--------
 .../drill/exec/rpc/ReconnectingConnection.java     | 17 ++++++++++-------
 2 files changed, 19 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/b1b75f6a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicClient.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicClient.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicClient.java
index 34758ef..a33b370 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicClient.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BasicClient.java
@@ -196,16 +196,15 @@ public abstract class BasicClient<T extends EnumLite, R extends RemoteConnection
       public void operationComplete(ChannelFuture future) throws Exception {
         boolean isInterrupted = false;
 
-        final long timeoutMills = 30000;
-
-        // We want to wait for at least 30 secs when interrupts occur. Establishing a connection fails/succeeds quickly,
+        // We want to wait for at least 120 secs when interrupts occur. Establishing a connection fails/succeeds quickly,
         // So there is no point propagating the interruption as failure immediately.
-        final long targetMillis = System.currentTimeMillis() + timeoutMills;
+        long remainingWaitTimeMills = 120000;
+        long startTime = System.currentTimeMillis();
 
         // logger.debug("Connection operation finished.  Success: {}", future.isSuccess());
         while(true) {
           try {
-            future.get(timeoutMills, TimeUnit.MILLISECONDS);
+            future.get(remainingWaitTimeMills, TimeUnit.MILLISECONDS);
             if (future.isSuccess()) {
               // send a handshake on the current thread. This is the only time we will send from within the event thread.
               // We can do this because the connection will not be backed up.
@@ -216,14 +215,16 @@ public abstract class BasicClient<T extends EnumLite, R extends RemoteConnection
             // logger.debug("Handshake queued for send.");
             break;
           } catch (final InterruptedException interruptEx) {
-            // Ignore the interrupt and continue to wait until targetMillis has elapsed.
+            remainingWaitTimeMills -= (System.currentTimeMillis() - startTime);
+            startTime = System.currentTimeMillis();
             isInterrupted = true;
-            final long wait = targetMillis - System.currentTimeMillis();
-            if (wait < 1) {
+            if (remainingWaitTimeMills < 1) {
               l.connectionFailed(FailureType.CONNECTION, interruptEx);
               break;
             }
+            // Ignore the interrupt and continue to wait until we elapse remainingWaitTimeMills.
           } catch (final Exception ex) {
+            logger.error("Failed to establish connection", ex);
             l.connectionFailed(FailureType.CONNECTION, ex);
             break;
           }

http://git-wip-us.apache.org/repos/asf/drill/blob/b1b75f6a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/ReconnectingConnection.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/ReconnectingConnection.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/ReconnectingConnection.java
index 12e0063..d62b6f2 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/ReconnectingConnection.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/ReconnectingConnection.java
@@ -104,15 +104,15 @@ public abstract class ReconnectingConnection<CONNECTION_TYPE extends RemoteConne
     public void waitAndRun() {
       boolean isInterrupted = false;
 
-      final long timeoutMills = 30000;
-      // We want to wait for at least 30 secs when interrupts occur. Establishing a connection fails/succeeds quickly,
+      // We want to wait for at least 120 secs when interrupts occur. Establishing a connection fails/succeeds quickly,
       // So there is no point propagating the interruption as failure immediately.
-      final long targetMillis = System.currentTimeMillis() + timeoutMills;
+      long remainingWaitTimeMills = 120000;
+      long startTime = System.currentTimeMillis();
 
       while(true) {
         try {
           //        logger.debug("Waiting for connection.");
-          CONNECTION_TYPE connection = this.get(timeoutMills, TimeUnit.MILLISECONDS);
+          CONNECTION_TYPE connection = this.get(remainingWaitTimeMills, TimeUnit.MILLISECONDS);
 
           if (connection == null) {
             //          logger.debug("Connection failed.");
@@ -123,15 +123,18 @@ public abstract class ReconnectingConnection<CONNECTION_TYPE extends RemoteConne
           }
           break;
         } catch (final InterruptedException interruptEx) {
-          // Ignore the interrupt and continue to wait until targetMillis has elapsed.
+          remainingWaitTimeMills -= (System.currentTimeMillis() - startTime);
+          startTime = System.currentTimeMillis();
           isInterrupted = true;
-          final long wait = targetMillis - System.currentTimeMillis();
-          if (wait < 1) {
+          if (remainingWaitTimeMills < 1) {
             cmd.connectionFailed(FailureType.CONNECTION, interruptEx);
             break;
           }
+          // Ignore the interrupt and continue to wait until we elapse remainingWaitTimeMills.
         } catch (final ExecutionException | TimeoutException ex) {
+          logger.error("Failed to establish connection", ex);
           cmd.connectionFailed(FailureType.CONNECTION, ex);
+          break;
         }
       }