drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sudheeshkatkam <...@git.apache.org>
Subject [GitHub] drill pull request: Drill 4372 review
Date Wed, 16 Mar 2016 23:04:26 GMT
Github user sudheeshkatkam commented on a diff in the pull request:

    https://github.com/apache/drill/pull/397#discussion_r56431206
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFunctionRegistry.java
---
    @@ -92,23 +118,106 @@ public DrillFunctionRegistry(ScanResult classpathScan) {
       }
     
       public int size(){
    -    return methods.size();
    +    return registeredFunctions.size();
       }
     
       /** Returns functions with given name. Function name is case insensitive. */
       public List<DrillFuncHolder> getMethods(String name) {
    -    return this.methods.get(name.toLowerCase());
    +    return this.registeredFunctions.get(name.toLowerCase());
       }
     
       public void register(DrillOperatorTable operatorTable) {
    +    registerForInference(operatorTable);
    +    registerForDefault(operatorTable);
    +  }
    +
    +  public void registerForInference(DrillOperatorTable operatorTable) {
    +    final Map<String, DrillSqlOperator.DrillSqlOperatorBuilder> map = Maps.newHashMap();
    +    final Map<String, DrillSqlAggOperator.DrillSqlAggOperatorBuilder> mapAgg =
Maps.newHashMap();
    +    for (Entry<String, Collection<DrillFuncHolder>> function : registeredFunctions.asMap().entrySet())
{
    +      final ArrayListMultimap<Pair<Integer, Integer>, DrillFuncHolder> functions
= ArrayListMultimap.create();
    +      final ArrayListMultimap<Integer, DrillFuncHolder> aggregateFunctions = ArrayListMultimap.create();
    +      final String name = function.getKey().toUpperCase();
    +      boolean isDeterministic = true;
    +      for (DrillFuncHolder func : function.getValue()) {
    +        final int paramCount = func.getParamCount();
    +        if(func.isAggregating()) {
    +          aggregateFunctions.put(paramCount, func);
    +        } else {
    +          final Pair<Integer, Integer> argNumberRange;
    +          if(drillFuncToRange.containsKey(name)) {
    +            argNumberRange = drillFuncToRange.get(name);
    +          } else {
    +            argNumberRange = Pair.of(func.getParamCount(), func.getParamCount());
    +          }
    +          functions.put(argNumberRange, func);
    +        }
    +
    +        if(!func.isDeterministic()) {
    +          isDeterministic = false;
    +        }
    +      }
    +      for (Entry<Pair<Integer, Integer>, Collection<DrillFuncHolder>>
entry : functions.asMap().entrySet()) {
    +        final Pair<Integer, Integer> range = entry.getKey();
    +        final int max = range.getRight();
    +        final int min = range.getLeft();
    +        if(map.containsKey(name)) {
    --- End diff --
    
    Nit: simplify if..else
    ```java
    if (!map.containsKey(name) ) {
      map.put(name, new DrillSqlOperator.DrillSqlOperatorBuilder().setName(name));
    }
    map.get(name)...;
    ```


---
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.
---

Mime
View raw message