You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by paul-rogers <gi...@git.apache.org> on 2017/03/19 02:53:15 UTC

[GitHub] drill pull request #787: DRILL-5319: Refactor "contexts" for unit testing

GitHub user paul-rogers opened a pull request:

    https://github.com/apache/drill/pull/787

    DRILL-5319: Refactor "contexts" for unit testing

    This PR is purely a refactoring: no functionality is added or changed.
    The refactoring splits various context and related classes into a set
    of new interfaces with needed for operator-level unit tests. The other,
    Drillbit-related methods are left in the original interfaces. Most code
    need not change.
    
    The changes here allow operator-level unit tests to mock up the
    exec-time methods so we can use them without firing up a Drillbit (or
    using mocking libraries).
    
    A later PR will provide the sub-operator test framework that uses this
    refactoring.
    
    Changes include:
    
    * The OptionManager is split, with read-only methods moving to a new
    OptionSet interface.
    * The FragmentContext is split, with an exec-only FragmentExecContext
    proving low-level methods.
    * OperatorStats is split, with a new OperatorStatReceiver class
    providing write-only support to operators.
    * Several places that accepted an OperatorContext or FragmentContext,
    but needed only an allocator, are changed to accept the allocator
    directly.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/paul-rogers/drill DRILL-5319

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/drill/pull/787.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #787
    
----
commit e4d3b383ee905921ac505f4278220a3270caa68e
Author: Paul Rogers <pr...@maprtech.com>
Date:   2017-03-19T02:52:52Z

    DRILL-5319: Refactor "contexts" for unit testing
    
    This PR is purely a refactoring: no functionality is added or changed.
    The refactoring splits various context and related classes into a set
    of new interfaces with needed for operator-level unit tests. The other,
    Drillbit-related methods are left in the original interfaces. Most code
    need not change.
    
    The changes here allow operator-level unit tests to mock up the
    exec-time methods so we can use them without firing up a Drillbit (or
    using mocking libraries).
    
    A later PR will provide the sub-operator test framework that uses this
    refactoring.
    
    Changes include:
    
    * The OptionManager is split, with read-only methods moving to a new
    OptionSet interface.
    * The FragmentContext is split, with an exec-only FragmentExecContext
    proving low-level methods.
    * OperatorStats is split, with a new OperatorStatReceiver class
    providing write-only support to operators.
    * Several places that accepted an OperatorContext or FragmentContext,
    but needed only an allocator, are changed to accept the allocator
    directly.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] drill pull request #787: DRILL-5319: Refactor "contexts" for unit testing

Posted by gparai <gi...@git.apache.org>.
Github user gparai commented on a diff in the pull request:

    https://github.com/apache/drill/pull/787#discussion_r109982950
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionSet.java ---
    @@ -0,0 +1,72 @@
    +/*
    + * 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.exec.server.options;
    +
    +/**
    + * Immutable set of options accessible by name or validator.
    + */
    +
    +public interface OptionSet {
    --- End diff --
    
    Maybe rename to OptionReader instead of OptionSet. An OptionManager would extend an OptionReader and OptionModifier interfaces.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] drill pull request #787: DRILL-5319: Refactor "contexts" for unit testing

Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/787#discussion_r110235334
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/server/options/TypeValidators.java ---
    @@ -90,19 +90,19 @@ public void validate(final OptionValue v, final OptionManager manager) {
       }
     
       public static class MinRangeDoubleValidator extends RangeDoubleValidator {
    -    private final double min;
    -    private final double max;
    +//    private final double min;
    --- End diff --
    
    Fixed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] drill issue #787: DRILL-5319: Refactor "contexts" for unit testing

Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on the issue:

    https://github.com/apache/drill/pull/787
  
    Done.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] drill pull request #787: DRILL-5319: Refactor "contexts" for unit testing

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/drill/pull/787


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] drill pull request #787: DRILL-5319: Refactor "contexts" for unit testing

Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/787#discussion_r110232430
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentExecContext.java ---
    @@ -0,0 +1,49 @@
    +/*
    + * 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.exec.ops;
    +
    +import java.io.IOException;
    +import java.util.List;
    +
    +import org.apache.drill.common.config.DrillConfig;
    +import org.apache.drill.exec.exception.ClassTransformationException;
    +import org.apache.drill.exec.expr.ClassGenerator;
    +import org.apache.drill.exec.expr.CodeGenerator;
    +import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry;
    +import org.apache.drill.exec.server.options.OptionSet;
    +import org.apache.drill.exec.testing.ExecutionControls;
    +
    +public interface FragmentExecContext {
    +  FunctionImplementationRegistry getFunctionRegistry();
    +  OptionSet getOptionSet();
    +
    +  <T> T getImplementationClass(final ClassGenerator<T> cg)
    --- End diff --
    
    Was preserving the terseness of the original code, but sure, added comments.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] drill issue #787: DRILL-5319: Refactor "contexts" for unit testing

Posted by arina-ielchiieva <gi...@git.apache.org>.
Github user arina-ielchiieva commented on the issue:

    https://github.com/apache/drill/pull/787
  
    Please squash commits and resolve conflict.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] drill issue #787: DRILL-5319: Refactor "contexts" for unit testing

Posted by gparai <gi...@git.apache.org>.
Github user gparai commented on the issue:

    https://github.com/apache/drill/pull/787
  
    Thanks for the detailed and clear comments.
    +1 LGTM


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] drill pull request #787: DRILL-5319: Refactor "contexts" for unit testing

Posted by paul-rogers <gi...@git.apache.org>.
Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/787#discussion_r110235058
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/server/options/OptionSet.java ---
    @@ -0,0 +1,72 @@
    +/*
    + * 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.exec.server.options;
    +
    +/**
    + * Immutable set of options accessible by name or validator.
    + */
    +
    +public interface OptionSet {
    --- End diff --
    
    Good idea. If I may, I'd like to defer the actual renaming as doing so would impact a number of in-flight PRs. The suggestion of two interfaces is good. I'll do a follow-on PR to rename this one and split out the writer one.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] drill pull request #787: DRILL-5319: Refactor "contexts" for unit testing

Posted by gparai <gi...@git.apache.org>.
Github user gparai commented on a diff in the pull request:

    https://github.com/apache/drill/pull/787#discussion_r110018766
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentExecContext.java ---
    @@ -0,0 +1,49 @@
    +/*
    + * 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.exec.ops;
    +
    +import java.io.IOException;
    +import java.util.List;
    +
    +import org.apache.drill.common.config.DrillConfig;
    +import org.apache.drill.exec.exception.ClassTransformationException;
    +import org.apache.drill.exec.expr.ClassGenerator;
    +import org.apache.drill.exec.expr.CodeGenerator;
    +import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry;
    +import org.apache.drill.exec.server.options.OptionSet;
    +import org.apache.drill.exec.testing.ExecutionControls;
    +
    +public interface FragmentExecContext {
    +  FunctionImplementationRegistry getFunctionRegistry();
    +  OptionSet getOptionSet();
    +
    +  <T> T getImplementationClass(final ClassGenerator<T> cg)
    --- End diff --
    
    Good to have comments describing the interface methods


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] drill pull request #787: DRILL-5319: Refactor "contexts" for unit testing

Posted by gparai <gi...@git.apache.org>.
Github user gparai commented on a diff in the pull request:

    https://github.com/apache/drill/pull/787#discussion_r109986447
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/server/options/TypeValidators.java ---
    @@ -90,19 +90,19 @@ public void validate(final OptionValue v, final OptionManager manager) {
       }
     
       public static class MinRangeDoubleValidator extends RangeDoubleValidator {
    -    private final double min;
    -    private final double max;
    +//    private final double min;
    --- End diff --
    
    Please remove the comments here and below


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---