Return-Path: X-Original-To: apmail-drill-commits-archive@www.apache.org Delivered-To: apmail-drill-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C93C510E70 for ; Wed, 6 May 2015 00:27:35 +0000 (UTC) Received: (qmail 85388 invoked by uid 500); 6 May 2015 00:27:35 -0000 Delivered-To: apmail-drill-commits-archive@drill.apache.org Received: (qmail 85301 invoked by uid 500); 6 May 2015 00:27:35 -0000 Mailing-List: contact commits-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: commits@drill.apache.org Delivered-To: mailing list commits@drill.apache.org Received: (qmail 85284 invoked by uid 99); 6 May 2015 00:27:35 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 May 2015 00:27:35 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8CD72E00E0; Wed, 6 May 2015 00:27:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: venki@apache.org To: commits@drill.apache.org Date: Wed, 06 May 2015 00:27:36 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/5] drill git commit: DRILL-2902: Add support for context functions: user (synonyms session_user and system_user) and current_schema http://git-wip-us.apache.org/repos/asf/drill/blob/703314ba/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 5e7562e..bbf7860 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 @@ -535,15 +535,14 @@ public final class SchemaBitControl output.writeInt64(12, message.getMemInitial(), false); if(message.hasMemMax()) output.writeInt64(13, message.getMemMax(), false); - if(message.hasQueryStartTime()) - output.writeInt64(14, message.getQueryStartTime(), false); if(message.hasCredentials()) - output.writeObject(15, message.getCredentials(), org.apache.drill.exec.proto.SchemaUserBitShared.UserCredentials.WRITE, false); + output.writeObject(14, message.getCredentials(), org.apache.drill.exec.proto.SchemaUserBitShared.UserCredentials.WRITE, false); - if(message.hasTimeZone()) - output.writeInt32(16, message.getTimeZone(), false); if(message.hasOptionsJson()) - output.writeString(17, message.getOptionsJson(), false); + output.writeString(15, message.getOptionsJson(), false); + if(message.hasContext()) + output.writeObject(16, message.getContext(), org.apache.drill.exec.proto.SchemaBitControl.QueryContextInformation.WRITE, false); + } public boolean isInitialized(org.apache.drill.exec.proto.BitControl.PlanFragment message) { @@ -620,18 +619,16 @@ public final class SchemaBitControl builder.setMemMax(input.readInt64()); break; case 14: - builder.setQueryStartTime(input.readInt64()); - break; - case 15: builder.setCredentials(input.mergeObject(org.apache.drill.exec.proto.UserBitShared.UserCredentials.newBuilder(), org.apache.drill.exec.proto.SchemaUserBitShared.UserCredentials.MERGE)); break; - case 16: - builder.setTimeZone(input.readInt32()); - break; - case 17: + case 15: builder.setOptionsJson(input.readString()); break; + case 16: + builder.setContext(input.mergeObject(org.apache.drill.exec.proto.BitControl.QueryContextInformation.newBuilder(), org.apache.drill.exec.proto.SchemaBitControl.QueryContextInformation.MERGE)); + + break; default: input.handleUnknownField(number, this); } @@ -683,10 +680,9 @@ public final class SchemaBitControl case 11: return "foreman"; case 12: return "memInitial"; case 13: return "memMax"; - case 14: return "queryStartTime"; - case 15: return "credentials"; - case 16: return "timeZone"; - case 17: return "optionsJson"; + case 14: return "credentials"; + case 15: return "optionsJson"; + case 16: return "context"; default: return null; } } @@ -709,10 +705,134 @@ public final class SchemaBitControl fieldMap.put("foreman", 11); fieldMap.put("memInitial", 12); fieldMap.put("memMax", 13); - fieldMap.put("queryStartTime", 14); - fieldMap.put("credentials", 15); - fieldMap.put("timeZone", 16); - fieldMap.put("optionsJson", 17); + fieldMap.put("credentials", 14); + fieldMap.put("optionsJson", 15); + fieldMap.put("context", 16); + } + } + + public static final class QueryContextInformation + { + public static final org.apache.drill.exec.proto.SchemaBitControl.QueryContextInformation.MessageSchema WRITE = + new org.apache.drill.exec.proto.SchemaBitControl.QueryContextInformation.MessageSchema(); + public static final org.apache.drill.exec.proto.SchemaBitControl.QueryContextInformation.BuilderSchema MERGE = + new org.apache.drill.exec.proto.SchemaBitControl.QueryContextInformation.BuilderSchema(); + + public static class MessageSchema implements com.dyuproject.protostuff.Schema + { + public void writeTo(com.dyuproject.protostuff.Output output, org.apache.drill.exec.proto.BitControl.QueryContextInformation message) throws java.io.IOException + { + if(message.hasQueryStartTime()) + output.writeInt64(1, message.getQueryStartTime(), false); + if(message.hasTimeZone()) + output.writeInt32(2, message.getTimeZone(), false); + if(message.hasDefaultSchemaName()) + output.writeString(3, message.getDefaultSchemaName(), false); + } + public boolean isInitialized(org.apache.drill.exec.proto.BitControl.QueryContextInformation message) + { + return message.isInitialized(); + } + public java.lang.String getFieldName(int number) + { + return org.apache.drill.exec.proto.SchemaBitControl.QueryContextInformation.getFieldName(number); + } + public int getFieldNumber(java.lang.String name) + { + return org.apache.drill.exec.proto.SchemaBitControl.QueryContextInformation.getFieldNumber(name); + } + public java.lang.Class typeClass() + { + return org.apache.drill.exec.proto.BitControl.QueryContextInformation.class; + } + public java.lang.String messageName() + { + return org.apache.drill.exec.proto.BitControl.QueryContextInformation.class.getSimpleName(); + } + public java.lang.String messageFullName() + { + return org.apache.drill.exec.proto.BitControl.QueryContextInformation.class.getName(); + } + //unused + public void mergeFrom(com.dyuproject.protostuff.Input input, org.apache.drill.exec.proto.BitControl.QueryContextInformation message) throws java.io.IOException {} + public org.apache.drill.exec.proto.BitControl.QueryContextInformation newMessage() { return null; } + } + public static class BuilderSchema implements com.dyuproject.protostuff.Schema + { + public void mergeFrom(com.dyuproject.protostuff.Input input, org.apache.drill.exec.proto.BitControl.QueryContextInformation.Builder builder) throws java.io.IOException + { + for(int number = input.readFieldNumber(this);; number = input.readFieldNumber(this)) + { + switch(number) + { + case 0: + return; + case 1: + builder.setQueryStartTime(input.readInt64()); + break; + case 2: + builder.setTimeZone(input.readInt32()); + break; + case 3: + builder.setDefaultSchemaName(input.readString()); + break; + default: + input.handleUnknownField(number, this); + } + } + } + public boolean isInitialized(org.apache.drill.exec.proto.BitControl.QueryContextInformation.Builder builder) + { + return builder.isInitialized(); + } + public org.apache.drill.exec.proto.BitControl.QueryContextInformation.Builder newMessage() + { + return org.apache.drill.exec.proto.BitControl.QueryContextInformation.newBuilder(); + } + public java.lang.String getFieldName(int number) + { + return org.apache.drill.exec.proto.SchemaBitControl.QueryContextInformation.getFieldName(number); + } + public int getFieldNumber(java.lang.String name) + { + return org.apache.drill.exec.proto.SchemaBitControl.QueryContextInformation.getFieldNumber(name); + } + public java.lang.Class typeClass() + { + return org.apache.drill.exec.proto.BitControl.QueryContextInformation.Builder.class; + } + public java.lang.String messageName() + { + return org.apache.drill.exec.proto.BitControl.QueryContextInformation.class.getSimpleName(); + } + public java.lang.String messageFullName() + { + return org.apache.drill.exec.proto.BitControl.QueryContextInformation.class.getName(); + } + //unused + public void writeTo(com.dyuproject.protostuff.Output output, org.apache.drill.exec.proto.BitControl.QueryContextInformation.Builder builder) throws java.io.IOException {} + } + public static java.lang.String getFieldName(int number) + { + switch(number) + { + case 1: return "queryStartTime"; + case 2: return "timeZone"; + case 3: return "defaultSchemaName"; + 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 fieldMap = new java.util.HashMap(); + static + { + fieldMap.put("queryStartTime", 1); + fieldMap.put("timeZone", 2); + fieldMap.put("defaultSchemaName", 3); } } http://git-wip-us.apache.org/repos/asf/drill/blob/703314ba/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 f6fbce1..08c2073 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 @@ -60,10 +60,9 @@ public final class PlanFragment implements Externalizable, Message private DrillbitEndpoint foreman; private long memInitial = DEFAULT_MEM_INITIAL; private long memMax = DEFAULT_MEM_MAX; - private long queryStartTime; private UserCredentials credentials; - private int timeZone; private String optionsJson; + private QueryContextInformation context; public PlanFragment() { @@ -215,19 +214,6 @@ public final class PlanFragment implements Externalizable, Message return this; } - // queryStartTime - - public long getQueryStartTime() - { - return queryStartTime; - } - - public PlanFragment setQueryStartTime(long queryStartTime) - { - this.queryStartTime = queryStartTime; - return this; - } - // credentials public UserCredentials getCredentials() @@ -241,29 +227,29 @@ public final class PlanFragment implements Externalizable, Message return this; } - // timeZone + // optionsJson - public int getTimeZone() + public String getOptionsJson() { - return timeZone; + return optionsJson; } - public PlanFragment setTimeZone(int timeZone) + public PlanFragment setOptionsJson(String optionsJson) { - this.timeZone = timeZone; + this.optionsJson = optionsJson; return this; } - // optionsJson + // context - public String getOptionsJson() + public QueryContextInformation getContext() { - return optionsJson; + return context; } - public PlanFragment setOptionsJson(String optionsJson) + public PlanFragment setContext(QueryContextInformation context) { - this.optionsJson = optionsJson; + this.context = context; return this; } @@ -358,18 +344,16 @@ public final class PlanFragment implements Externalizable, Message message.memMax = input.readInt64(); break; case 14: - message.queryStartTime = input.readInt64(); - break; - case 15: message.credentials = input.mergeObject(message.credentials, UserCredentials.getSchema()); break; - case 16: - message.timeZone = input.readInt32(); - break; - case 17: + case 15: message.optionsJson = input.readString(); break; + case 16: + message.context = input.mergeObject(message.context, QueryContextInformation.getSchema()); + break; + default: input.handleUnknownField(number, this); } @@ -415,18 +399,16 @@ public final class PlanFragment implements Externalizable, Message if(message.memMax != DEFAULT_MEM_MAX) output.writeInt64(13, message.memMax, false); - if(message.queryStartTime != 0) - output.writeInt64(14, message.queryStartTime, false); - if(message.credentials != null) - output.writeObject(15, message.credentials, UserCredentials.getSchema(), false); + output.writeObject(14, message.credentials, UserCredentials.getSchema(), false); - if(message.timeZone != 0) - output.writeInt32(16, message.timeZone, false); - if(message.optionsJson != null) - output.writeString(17, message.optionsJson, false); + output.writeString(15, message.optionsJson, false); + + if(message.context != null) + output.writeObject(16, message.context, QueryContextInformation.getSchema(), false); + } public String getFieldName(int number) @@ -444,10 +426,9 @@ public final class PlanFragment implements Externalizable, Message case 11: return "foreman"; case 12: return "memInitial"; case 13: return "memMax"; - case 14: return "queryStartTime"; - case 15: return "credentials"; - case 16: return "timeZone"; - case 17: return "optionsJson"; + case 14: return "credentials"; + case 15: return "optionsJson"; + case 16: return "context"; default: return null; } } @@ -472,10 +453,9 @@ public final class PlanFragment implements Externalizable, Message __fieldMap.put("foreman", 11); __fieldMap.put("memInitial", 12); __fieldMap.put("memMax", 13); - __fieldMap.put("queryStartTime", 14); - __fieldMap.put("credentials", 15); - __fieldMap.put("timeZone", 16); - __fieldMap.put("optionsJson", 17); + __fieldMap.put("credentials", 14); + __fieldMap.put("optionsJson", 15); + __fieldMap.put("context", 16); } } http://git-wip-us.apache.org/repos/asf/drill/blob/703314ba/protocol/src/main/java/org/apache/drill/exec/proto/beans/QueryContextInformation.java ---------------------------------------------------------------------- diff --git a/protocol/src/main/java/org/apache/drill/exec/proto/beans/QueryContextInformation.java b/protocol/src/main/java/org/apache/drill/exec/proto/beans/QueryContextInformation.java new file mode 100644 index 0000000..440968b --- /dev/null +++ b/protocol/src/main/java/org/apache/drill/exec/proto/beans/QueryContextInformation.java @@ -0,0 +1,207 @@ +/** + * 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 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 QueryContextInformation implements Externalizable, Message, Schema +{ + + public static Schema getSchema() + { + return DEFAULT_INSTANCE; + } + + public static QueryContextInformation getDefaultInstance() + { + return DEFAULT_INSTANCE; + } + + static final QueryContextInformation DEFAULT_INSTANCE = new QueryContextInformation(); + + + private long queryStartTime; + private int timeZone; + private String defaultSchemaName; + + public QueryContextInformation() + { + + } + + // getters and setters + + // queryStartTime + + public long getQueryStartTime() + { + return queryStartTime; + } + + public QueryContextInformation setQueryStartTime(long queryStartTime) + { + this.queryStartTime = queryStartTime; + return this; + } + + // timeZone + + public int getTimeZone() + { + return timeZone; + } + + public QueryContextInformation setTimeZone(int timeZone) + { + this.timeZone = timeZone; + return this; + } + + // defaultSchemaName + + public String getDefaultSchemaName() + { + return defaultSchemaName; + } + + public QueryContextInformation setDefaultSchemaName(String defaultSchemaName) + { + this.defaultSchemaName = defaultSchemaName; + 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 cachedSchema() + { + return DEFAULT_INSTANCE; + } + + // schema methods + + public QueryContextInformation newMessage() + { + return new QueryContextInformation(); + } + + public Class typeClass() + { + return QueryContextInformation.class; + } + + public String messageName() + { + return QueryContextInformation.class.getSimpleName(); + } + + public String messageFullName() + { + return QueryContextInformation.class.getName(); + } + + public boolean isInitialized(QueryContextInformation message) + { + return true; + } + + public void mergeFrom(Input input, QueryContextInformation message) throws IOException + { + for(int number = input.readFieldNumber(this);; number = input.readFieldNumber(this)) + { + switch(number) + { + case 0: + return; + case 1: + message.queryStartTime = input.readInt64(); + break; + case 2: + message.timeZone = input.readInt32(); + break; + case 3: + message.defaultSchemaName = input.readString(); + break; + default: + input.handleUnknownField(number, this); + } + } + } + + + public void writeTo(Output output, QueryContextInformation message) throws IOException + { + if(message.queryStartTime != 0) + output.writeInt64(1, message.queryStartTime, false); + + if(message.timeZone != 0) + output.writeInt32(2, message.timeZone, false); + + if(message.defaultSchemaName != null) + output.writeString(3, message.defaultSchemaName, false); + } + + public String getFieldName(int number) + { + switch(number) + { + case 1: return "queryStartTime"; + case 2: return "timeZone"; + case 3: return "defaultSchemaName"; + 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 __fieldMap = new java.util.HashMap(); + static + { + __fieldMap.put("queryStartTime", 1); + __fieldMap.put("timeZone", 2); + __fieldMap.put("defaultSchemaName", 3); + } + +} http://git-wip-us.apache.org/repos/asf/drill/blob/703314ba/protocol/src/main/protobuf/BitControl.proto ---------------------------------------------------------------------- diff --git a/protocol/src/main/protobuf/BitControl.proto b/protocol/src/main/protobuf/BitControl.proto index 0424725..93bc33c 100644 --- a/protocol/src/main/protobuf/BitControl.proto +++ b/protocol/src/main/protobuf/BitControl.proto @@ -59,15 +59,20 @@ message PlanFragment { optional float disk_cost = 6; optional float memory_cost = 7; optional string fragment_json = 8; - optional DrillbitEndpoint assignment = 10; optional bool leaf_fragment = 9; + optional DrillbitEndpoint assignment = 10; optional DrillbitEndpoint foreman = 11; optional int64 mem_initial = 12 [default = 20000000]; // 20 megs optional int64 mem_max = 13 [default = 2000000000]; // 20 gigs - optional int64 query_start_time = 14; // start time of query in milliseconds - optional exec.shared.UserCredentials credentials = 15; - optional int32 time_zone = 16; - optional string options_json = 17; + optional exec.shared.UserCredentials credentials = 14; + optional string options_json = 15; + optional QueryContextInformation context = 16; +} + +message QueryContextInformation { + optional int64 query_start_time = 1; // start time of query in milliseconds + optional int32 time_zone = 2; // timezone of the Drillbit where user is connected + optional string default_schema_name = 3; // default schema in current session when the query is submitted } message WorkQueueStatus{