calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [9/9] incubator-calcite git commit: [CALCITE-335] Remove uses of linq4j Functions.adapt
Date Mon, 23 Mar 2015 17:26:23 GMT
[CALCITE-335] Remove uses of linq4j Functions.adapt


Project: http://git-wip-us.apache.org/repos/asf/incubator-calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/574dc7cc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-calcite/tree/574dc7cc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-calcite/diff/574dc7cc

Branch: refs/heads/master
Commit: 574dc7cc89c6319ed51629f316d3a87eedfb1c0f
Parents: 0fe2637
Author: Julian Hyde <jhyde@apache.org>
Authored: Mon Mar 23 02:51:56 2015 -0700
Committer: Julian Hyde <jhyde@apache.org>
Committed: Mon Mar 23 02:51:56 2015 -0700

----------------------------------------------------------------------
 .../calcite/adapter/clone/ColumnLoader.java     | 33 ++++++++++----------
 .../apache/calcite/adapter/jdbc/JdbcTable.java  | 14 ++++-----
 .../materialize/MaterializationService.java     | 12 +++----
 .../org/apache/calcite/rel/core/Project.java    |  9 +++---
 .../org/apache/calcite/rel/core/Values.java     | 17 +++++-----
 .../calcite/linq4j/function/Functions.java      | 20 +++++++-----
 .../calcite/linq4j/tree/ConstantExpression.java | 13 ++++----
 .../linq4j/tree/ConstructorDeclaration.java     |  8 ++---
 .../calcite/linq4j/tree/MethodDeclaration.java  |  8 ++---
 .../calcite/linq4j/function/FunctionTest.java   | 15 ---------
 10 files changed, 66 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/574dc7cc/core/src/main/java/org/apache/calcite/adapter/clone/ColumnLoader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/clone/ColumnLoader.java b/core/src/main/java/org/apache/calcite/adapter/clone/ColumnLoader.java
index 86bb77f..d33ee61 100644
--- a/core/src/main/java/org/apache/calcite/adapter/clone/ColumnLoader.java
+++ b/core/src/main/java/org/apache/calcite/adapter/clone/ColumnLoader.java
@@ -21,13 +21,14 @@ import org.apache.calcite.avatica.ColumnMetaData;
 import org.apache.calcite.avatica.util.DateTimeUtils;
 import org.apache.calcite.linq4j.Enumerable;
 import org.apache.calcite.linq4j.Ord;
-import org.apache.calcite.linq4j.function.Function1;
-import org.apache.calcite.linq4j.function.Functions;
 import org.apache.calcite.linq4j.tree.Primitive;
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeField;
 import org.apache.calcite.rel.type.RelProtoDataType;
 
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
 import java.lang.reflect.Type;
 import java.sql.Date;
 import java.sql.Time;
@@ -52,15 +53,15 @@ class ColumnLoader<T> {
     0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000, 0xFFFFFFFF00000000L};
   static final int[] LONG_S = {1, 2, 4, 8, 16, 32};
 
-  private static final Function1<Timestamp, Long> TIMESTAMP_TO_LONG =
-      new Function1<Timestamp, Long>() {
+  private static final Function<Timestamp, Long> TIMESTAMP_TO_LONG =
+      new Function<Timestamp, Long>() {
         public Long apply(Timestamp a0) {
           return a0 == null ? null : a0.getTime();
         }
       };
 
-  private static final Function1<Time, Integer> TIME_TO_INT =
-      new Function1<Time, Integer>() {
+  private static final Function<Time, Integer> TIME_TO_INT =
+      new Function<Time, Integer>() {
         public Integer apply(Time a0) {
           return a0 == null
               ? null
@@ -68,8 +69,8 @@ class ColumnLoader<T> {
         }
       };
 
-  private static final Function1<Date, Integer> DATE_TO_INT =
-      new Function1<Date, Integer>() {
+  private static final Function<Date, Integer> DATE_TO_INT =
+      new Function<Date, Integer>() {
         public Integer apply(Date a0) {
           return a0 == null
               ? null
@@ -77,9 +78,8 @@ class ColumnLoader<T> {
         }
       };
 
-  public final List<T> list = new ArrayList<T>();
-  public final List<ArrayTable.Column> representationValues =
-      new ArrayList<ArrayTable.Column>();
+  public final List<T> list = new ArrayList<>();
+  public final List<ArrayTable.Column> representationValues = new ArrayList<>();
   private final JavaTypeFactory typeFactory;
   public final int sortField;
 
@@ -264,21 +264,21 @@ class ColumnLoader<T> {
       switch (rep) {
       case OBJECT:
       case JAVA_SQL_TIMESTAMP:
-        return Functions.adapt(list, TIMESTAMP_TO_LONG);
+        return Lists.transform(list, TIMESTAMP_TO_LONG);
       }
       break;
     case TIME:
       switch (rep) {
       case OBJECT:
       case JAVA_SQL_TIME:
-        return Functions.adapt(list, TIME_TO_INT);
+        return Lists.transform(list, TIME_TO_INT);
       }
       break;
     case DATE:
       switch (rep) {
       case OBJECT:
       case JAVA_SQL_DATE:
-        return Functions.adapt(list, DATE_TO_INT);
+        return Lists.transform(list, DATE_TO_INT);
       }
       break;
     }
@@ -291,9 +291,8 @@ class ColumnLoader<T> {
    */
   static class ValueSet {
     final Class clazz;
-    final Map<Comparable, Comparable> map =
-        new HashMap<Comparable, Comparable>();
-    final List<Comparable> values = new ArrayList<Comparable>();
+    final Map<Comparable, Comparable> map = new HashMap<>();
+    final List<Comparable> values = new ArrayList<>();
     Comparable min;
     Comparable max;
     boolean containsNull;

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/574dc7cc/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcTable.java b/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcTable.java
index 7e68c52..976e311 100644
--- a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcTable.java
+++ b/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcTable.java
@@ -24,8 +24,6 @@ import org.apache.calcite.linq4j.Enumerable;
 import org.apache.calcite.linq4j.Enumerator;
 import org.apache.calcite.linq4j.QueryProvider;
 import org.apache.calcite.linq4j.Queryable;
-import org.apache.calcite.linq4j.function.Function1;
-import org.apache.calcite.linq4j.function.Functions;
 import org.apache.calcite.linq4j.tree.Primitive;
 import org.apache.calcite.plan.RelOptTable;
 import org.apache.calcite.rel.RelNode;
@@ -48,6 +46,9 @@ import org.apache.calcite.sql.util.SqlString;
 import org.apache.calcite.util.Pair;
 import org.apache.calcite.util.Util;
 
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -110,9 +111,8 @@ class JdbcTable extends AbstractQueryableTable
   private List<Pair<Primitive, Integer>> fieldClasses(
       final JavaTypeFactory typeFactory) {
     final RelDataType rowType = protoRowType.apply(typeFactory);
-    return Functions.adapt(
-        rowType.getFieldList(),
-        new Function1<RelDataTypeField, Pair<Primitive, Integer>>() {
+    return Lists.transform(rowType.getFieldList(),
+        new Function<RelDataTypeField, Pair<Primitive, Integer>>() {
           public Pair<Primitive, Integer> apply(RelDataTypeField field) {
             RelDataType type = field.getType();
             Class clazz = (Class) typeFactory.getJavaClass(type);
@@ -137,7 +137,7 @@ class JdbcTable extends AbstractQueryableTable
   }
 
   SqlIdentifier tableName() {
-    final List<String> strings = new ArrayList<String>();
+    final List<String> strings = new ArrayList<>();
     if (jdbcSchema.catalog != null) {
       strings.add(jdbcSchema.catalog);
     }
@@ -156,7 +156,7 @@ class JdbcTable extends AbstractQueryableTable
 
   public <T> Queryable<T> asQueryable(QueryProvider queryProvider,
       SchemaPlus schema, String tableName) {
-    return new JdbcTableQueryable<T>(queryProvider, schema, tableName);
+    return new JdbcTableQueryable<>(queryProvider, schema, tableName);
   }
 
   public Enumerable<Object[]> scan(DataContext root) {

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/574dc7cc/core/src/main/java/org/apache/calcite/materialize/MaterializationService.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/materialize/MaterializationService.java
b/core/src/main/java/org/apache/calcite/materialize/MaterializationService.java
index 2d4c3f2..3d98567 100644
--- a/core/src/main/java/org/apache/calcite/materialize/MaterializationService.java
+++ b/core/src/main/java/org/apache/calcite/materialize/MaterializationService.java
@@ -28,8 +28,6 @@ import org.apache.calcite.jdbc.CalciteSchema;
 import org.apache.calcite.linq4j.AbstractQueryable;
 import org.apache.calcite.linq4j.Enumerator;
 import org.apache.calcite.linq4j.QueryProvider;
-import org.apache.calcite.linq4j.function.Function1;
-import org.apache.calcite.linq4j.function.Functions;
 import org.apache.calcite.linq4j.tree.Expression;
 import org.apache.calcite.prepare.Prepare;
 import org.apache.calcite.rel.type.RelDataType;
@@ -41,6 +39,7 @@ import org.apache.calcite.util.ImmutableBitSet;
 import org.apache.calcite.util.Pair;
 import org.apache.calcite.util.Util;
 
+import com.google.common.base.Function;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
@@ -123,8 +122,8 @@ public class MaterializationService {
       materializedTable =
           CloneSchema.createCloneTable(typeFactory,
               RelDataTypeImpl.proto(calciteSignature.rowType),
-              Functions.adapt(calciteSignature.columns,
-                  new Function1<ColumnMetaData, ColumnMetaData.Rep>() {
+              Lists.transform(calciteSignature.columns,
+                  new Function<ColumnMetaData, ColumnMetaData.Rep>() {
                     public ColumnMetaData.Rep apply(ColumnMetaData column) {
                       return column.type.rep;
                     }
@@ -245,7 +244,7 @@ public class MaterializationService {
     // through all tiles.
     if (!exact) {
       final PriorityQueue<Pair<CalciteSchema.TableEntry, TileKey>> queue =
-          new PriorityQueue<Pair<CalciteSchema.TableEntry, TileKey>>(1, C);
+          new PriorityQueue<>(1, C);
       for (Map.Entry<TileKey, MaterializationKey> entry
           : actor.keyByTile.entrySet()) {
         final TileKey tileKey2 = entry.getKey();
@@ -327,8 +326,7 @@ public class MaterializationService {
    * with the current schema. Especially in a test run, the contents of two
    * root schemas may look similar.) */
   public List<Prepare.Materialization> query(CalciteSchema rootSchema) {
-    final List<Prepare.Materialization> list =
-        new ArrayList<Prepare.Materialization>();
+    final List<Prepare.Materialization> list = new ArrayList<>();
     for (MaterializationActor.Materialization materialization
         : actor.keyMap.values()) {
       if (materialization.rootSchema == rootSchema

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/574dc7cc/core/src/main/java/org/apache/calcite/rel/core/Project.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/core/Project.java b/core/src/main/java/org/apache/calcite/rel/core/Project.java
index af24c58..09c2ec9 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/Project.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/Project.java
@@ -17,8 +17,6 @@
 package org.apache.calcite.rel.core;
 
 import org.apache.calcite.linq4j.Ord;
-import org.apache.calcite.linq4j.function.Function1;
-import org.apache.calcite.linq4j.function.Functions;
 import org.apache.calcite.plan.RelOptCluster;
 import org.apache.calcite.plan.RelOptCost;
 import org.apache.calcite.plan.RelOptPlanner;
@@ -46,7 +44,9 @@ import org.apache.calcite.util.Util;
 import org.apache.calcite.util.mapping.MappingType;
 import org.apache.calcite.util.mapping.Mappings;
 
+import com.google.common.base.Function;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
 
 import java.util.List;
 
@@ -202,9 +202,8 @@ public abstract class Project extends SingleRel {
     }
     //CHECKSTYLE: IGNORE 1
     if (false && !Util.isDistinct(
-        Functions.adapt(
-            exps,
-            new Function1<RexNode, Object>() {
+        Lists.transform(exps,
+            new Function<RexNode, Object>() {
               public Object apply(RexNode a0) {
                 return a0.toString();
               }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/574dc7cc/core/src/main/java/org/apache/calcite/rel/core/Values.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/core/Values.java b/core/src/main/java/org/apache/calcite/rel/core/Values.java
index e6a3bfe..2f4b6ba 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/Values.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/Values.java
@@ -16,8 +16,6 @@
  */
 package org.apache.calcite.rel.core;
 
-import org.apache.calcite.linq4j.function.Function1;
-import org.apache.calcite.linq4j.function.Functions;
 import org.apache.calcite.plan.RelOptCluster;
 import org.apache.calcite.plan.RelOptCost;
 import org.apache.calcite.plan.RelOptPlanner;
@@ -34,8 +32,10 @@ import org.apache.calcite.sql.SqlExplainLevel;
 import org.apache.calcite.sql.type.SqlTypeUtil;
 import org.apache.calcite.util.Pair;
 
+import com.google.common.base.Function;
 import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
 
 import java.util.List;
 
@@ -47,8 +47,8 @@ public abstract class Values extends AbstractRelNode {
   /**
    * Lambda that helps render tuples as strings.
    */
-  private static final Function1<ImmutableList<RexLiteral>, Object> F =
-      new Function1<ImmutableList<RexLiteral>, Object>() {
+  private static final Function<ImmutableList<RexLiteral>, Object> F =
+      new Function<ImmutableList<RexLiteral>, Object>() {
         public Object apply(ImmutableList<RexLiteral> tuple) {
           String s = tuple.toString();
           assert s.startsWith("[");
@@ -171,13 +171,10 @@ public abstract class Values extends AbstractRelNode {
     return super.explainTerms(pw)
         // For rel digest, include the row type since a rendered
         // literal may leave the type ambiguous (e.g. "null").
-        .itemIf(
-            "type", rowType,
+        .itemIf("type", rowType,
             pw.getDetailLevel() == SqlExplainLevel.DIGEST_ATTRIBUTES)
-        .itemIf(
-            "type", rowType.getFieldList(),
-            pw.nest())
-        .itemIf("tuples", Functions.adapt(tuples, F), !pw.nest())
+        .itemIf("type", rowType.getFieldList(), pw.nest())
+        .itemIf("tuples", Lists.transform(tuples, F), !pw.nest())
         .itemIf("tuples", tuples, pw.nest());
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/574dc7cc/linq4j/src/main/java/org/apache/calcite/linq4j/function/Functions.java
----------------------------------------------------------------------
diff --git a/linq4j/src/main/java/org/apache/calcite/linq4j/function/Functions.java b/linq4j/src/main/java/org/apache/calcite/linq4j/function/Functions.java
index 129c9a2..bd7a446 100644
--- a/linq4j/src/main/java/org/apache/calcite/linq4j/function/Functions.java
+++ b/linq4j/src/main/java/org/apache/calcite/linq4j/function/Functions.java
@@ -54,8 +54,7 @@ public abstract class Functions {
 
   private static final Map<Class, Class<? extends Function>> FUNCTION1_CLASSES
=
       Collections.unmodifiableMap(
-          new HashMap<Class, Class<? extends Function>>(
-              inverse(FUNCTION_RESULT_TYPES)));
+          new HashMap<>(inverse(FUNCTION_RESULT_TYPES)));
 
   private static final Comparator NULLS_FIRST_COMPARATOR =
       new NullsFirstComparator();
@@ -91,7 +90,7 @@ public abstract class Functions {
 
   @SuppressWarnings("unchecked")
   private static <K, V> Map<K, V> map(K k, V v, Object... rest) {
-    final Map<K, V> map = new HashMap<K, V>();
+    final Map<K, V> map = new HashMap<>();
     map.put(k, v);
     for (int i = 0; i < rest.length; i++) {
       map.put((K) rest[i++], (V) rest[i++]);
@@ -100,7 +99,7 @@ public abstract class Functions {
   }
 
   private static <K, V> Map<V, K> inverse(Map<K, V> map) {
-    HashMap<V, K> inverseMap = new HashMap<V, K>();
+    HashMap<V, K> inverseMap = new HashMap<>();
     for (Map.Entry<K, V> entry : map.entrySet()) {
       inverseMap.put(entry.getValue(), entry.getKey());
     }
@@ -306,7 +305,10 @@ public abstract class Functions {
 
   /**
    * Creates a view of a list that applies a function to each element.
+   *
+   * @deprecated Use {@link com.google.common.collect.Lists#transform}
    */
+  @Deprecated // to be removed before 2.0
   public static <T1, R> List<R> adapt(final List<T1> list,
       final Function1<T1, R> f) {
     return new AbstractList<R>() {
@@ -322,7 +324,11 @@ public abstract class Functions {
 
   /**
    * Creates a view of an array that applies a function to each element.
+   *
+   * @deprecated Use {@link com.google.common.collect.Lists#transform}
+   * and {@link Arrays#asList(Object[])}
    */
+  @Deprecated // to be removed before 2.0
   public static <T, R> List<R> adapt(final T[] ts,
       final Function1<T, R> f) {
     return new AbstractList<R>() {
@@ -341,7 +347,7 @@ public abstract class Functions {
    */
   public static <T1, R> List<R> apply(final List<T1> list,
       final Function1<T1, R> f) {
-    final ArrayList<R> list2 = new ArrayList<R>(list.size());
+    final List<R> list2 = new ArrayList<>(list.size());
     for (T1 t : list) {
       list2.add(f.apply(t));
     }
@@ -376,7 +382,7 @@ public abstract class Functions {
         return list;
       }
     }
-    final List<E> list2 = new ArrayList<E>(list.size());
+    final List<E> list2 = new ArrayList<>(list.size());
     for (E e : list) {
       if (predicate.apply(e)) {
         list2.add(e);
@@ -504,7 +510,7 @@ public abstract class Functions {
    */
   public static <T, T2> EqualityComparer<T> selectorComparer(
       Function1<T, T2> selector) {
-    return new SelectorEqualityComparer<T, T2>(selector);
+    return new SelectorEqualityComparer<>(selector);
   }
 
   /** Array equality comparer. */

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/574dc7cc/linq4j/src/main/java/org/apache/calcite/linq4j/tree/ConstantExpression.java
----------------------------------------------------------------------
diff --git a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/ConstantExpression.java b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/ConstantExpression.java
index dcc1962..c9a22de 100644
--- a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/ConstantExpression.java
+++ b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/ConstantExpression.java
@@ -16,14 +16,15 @@
  */
 package org.apache.calcite.linq4j.tree;
 
-import org.apache.calcite.linq4j.function.Function1;
-import org.apache.calcite.linq4j.function.Functions;
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Type;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -89,8 +90,7 @@ public class ConstantExpression extends Expression {
       case BYTE:
         return writer.append("(byte)").append(((Byte) value).intValue());
       case CHAR:
-        return writer.append("(char)")
-            .append((int) ((Character) value).charValue());
+        return writer.append("(char)").append((int) (Character) value);
       case SHORT:
         return writer.append("(short)").append(((Short) value).intValue());
       case LONG:
@@ -149,11 +149,10 @@ public class ConstantExpression extends Expression {
     }
     Constructor constructor = matchingConstructor(value);
     if (constructor != null) {
-      final Field[] fields = value.getClass().getFields();
       writer.append("new ").append(value.getClass());
       list(writer,
-          Functions.adapt(fields,
-              new Function1<Field, Object>() {
+          Lists.transform(Arrays.asList(value.getClass().getFields()),
+              new Function<Field, Object>() {
                 public Object apply(Field field) {
                   try {
                     return field.get(value);

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/574dc7cc/linq4j/src/main/java/org/apache/calcite/linq4j/tree/ConstructorDeclaration.java
----------------------------------------------------------------------
diff --git a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/ConstructorDeclaration.java
b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/ConstructorDeclaration.java
index 95b4f1c..835e94e 100644
--- a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/ConstructorDeclaration.java
+++ b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/ConstructorDeclaration.java
@@ -16,8 +16,8 @@
  */
 package org.apache.calcite.linq4j.tree;
 
-import org.apache.calcite.linq4j.function.Function1;
-import org.apache.calcite.linq4j.function.Functions;
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
 
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
@@ -63,8 +63,8 @@ public class ConstructorDeclaration extends MemberDeclaration {
     writer
         .append(resultType)
         .list("(", ", ", ")",
-            Functions.adapt(parameters,
-                new Function1<ParameterExpression, String>() {
+            Lists.transform(parameters,
+                new Function<ParameterExpression, String>() {
                   public String apply(ParameterExpression parameter) {
                     final String modifiers =
                         Modifier.toString(parameter.modifier);

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/574dc7cc/linq4j/src/main/java/org/apache/calcite/linq4j/tree/MethodDeclaration.java
----------------------------------------------------------------------
diff --git a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/MethodDeclaration.java b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/MethodDeclaration.java
index 0e4c99a..646a9cd 100644
--- a/linq4j/src/main/java/org/apache/calcite/linq4j/tree/MethodDeclaration.java
+++ b/linq4j/src/main/java/org/apache/calcite/linq4j/tree/MethodDeclaration.java
@@ -16,8 +16,8 @@
  */
 package org.apache.calcite.linq4j.tree;
 
-import org.apache.calcite.linq4j.function.Function1;
-import org.apache.calcite.linq4j.function.Functions;
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
 
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
@@ -64,8 +64,8 @@ public class MethodDeclaration extends MemberDeclaration {
         .append(' ')
         .append(name)
         .list("(", ", ", ")",
-            Functions.adapt(parameters,
-                new Function1<ParameterExpression, String>() {
+            Lists.transform(parameters,
+                new Function<ParameterExpression, String>() {
                   public String apply(ParameterExpression a0) {
                     return a0.declString();
                   }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/574dc7cc/linq4j/src/test/java/org/apache/calcite/linq4j/function/FunctionTest.java
----------------------------------------------------------------------
diff --git a/linq4j/src/test/java/org/apache/calcite/linq4j/function/FunctionTest.java b/linq4j/src/test/java/org/apache/calcite/linq4j/function/FunctionTest.java
index 9db57a5..998aed3 100644
--- a/linq4j/src/test/java/org/apache/calcite/linq4j/function/FunctionTest.java
+++ b/linq4j/src/test/java/org/apache/calcite/linq4j/function/FunctionTest.java
@@ -129,21 +129,6 @@ public class FunctionTest {
       // ok
     }
   }
-
-  /** Unit test for {@link Functions#adapt(Object[], Function1)}. */
-  @Test public void testAdaptArray() {
-    String[] abc = {"a", "b", "c"};
-    final Function1<String, String> toUpper =
-        new Function1<String, String>() {
-          public String apply(String s) {
-            return s.toUpperCase();
-          }
-        };
-    Assert.assertEquals("[A, B, C]",
-        Functions.adapt(abc, toUpper).toString());
-    Assert.assertEquals("[]",
-        Functions.adapt(new String[0], toUpper).toString());
-  }
 }
 
 // End FunctionTest.java


Mime
View raw message