drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paul-rogers <...@git.apache.org>
Subject [GitHub] drill pull request #978: DRILL-5842: Refactor and simplify the fragment, ope...
Date Mon, 30 Oct 2017 21:40:03 GMT
Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/978#discussion_r147842797
  
    --- Diff: exec/java-exec/src/test/java/org/apache/drill/exec/physical/unit/MiniPlanUnitTestBase.java
---
    @@ -360,7 +366,7 @@ public T columnsToRead(String ... columnsToRead) {
        */
       public class JsonScanBuilder extends ScanPopBuider<JsonScanBuilder> {
         List<String> jsonBatches = null;
    -    List<String> inputPaths = Collections.EMPTY_LIST;
    +    List<String> inputPaths = Collections.emptyList();
    --- End diff --
    
    This is a subtle point. Using the constant creates the expression:
    
    ```
    public static final List EMPTY_LIST = new EmptyList<>(); // Definition
    List<String> inputPaths = EMPTY_LIST; // Original code
    ```
    
    The above is not type-friendly: we are setting a typed list (`inputPaths`) to an untyped
constant (`EMPTY_LIST`).
    
    The revised code uses Java's parameterized methods to work around the type ambiguity:
    
    ```
    public static final <T> List<T> emptyList() ... // Definition
    List<String> inputPaths = Collections.emptyList(); // Type-safe assignment
    ```
    
    Functionally, the two expressions are identical. But, the original was type-unsafe and
generated a compiler warning. The new one is type-safe and resolves the warning.


---

Mime
View raw message