cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ble...@apache.org
Subject cassandra git commit: Reduce the amount of object allocations caused by the getFunctions methods
Date Mon, 02 May 2016 12:16:52 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 de228c77b -> 89464ead4


Reduce the amount of object allocations caused by the getFunctions methods

patch by Benjamin Lerer; reviewed by Sam Tunnicliffe for CASSANDRA-11593


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/89464ead
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/89464ead
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/89464ead

Branch: refs/heads/cassandra-3.0
Commit: 89464ead48278f8e3ecfeaeaf9571714978b4f72
Parents: de228c7
Author: Benjamin Lerer <b.lerer@gmail.com>
Authored: Mon May 2 14:15:19 2016 +0200
Committer: Benjamin Lerer <b.lerer@gmail.com>
Committed: Mon May 2 14:15:19 2016 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/cql3/AbstractConditions.java      |  5 ++--
 .../apache/cassandra/cql3/AbstractMarker.java   |  4 +--
 .../org/apache/cassandra/cql3/Attributes.java   | 15 ++++------
 .../apache/cassandra/cql3/ColumnCondition.java  | 11 +++----
 .../apache/cassandra/cql3/ColumnConditions.java |  9 ++----
 .../org/apache/cassandra/cql3/Conditions.java   |  8 ++++--
 src/java/org/apache/cassandra/cql3/Json.java    |  4 +--
 src/java/org/apache/cassandra/cql3/Lists.java   |  4 +--
 src/java/org/apache/cassandra/cql3/Maps.java    |  8 ++----
 .../org/apache/cassandra/cql3/Operation.java    |  7 +++--
 .../org/apache/cassandra/cql3/Operations.java   |  9 ++----
 src/java/org/apache/cassandra/cql3/Sets.java    |  6 ++--
 src/java/org/apache/cassandra/cql3/Term.java    |  5 ++--
 src/java/org/apache/cassandra/cql3/Terms.java   | 22 +++-----------
 src/java/org/apache/cassandra/cql3/Tuples.java  |  4 +--
 .../org/apache/cassandra/cql3/UserTypes.java    |  4 +--
 .../cql3/functions/AbstractFunction.java        |  5 ++--
 .../cassandra/cql3/functions/Function.java      |  2 +-
 .../cassandra/cql3/functions/FunctionCall.java  |  7 ++---
 .../cassandra/cql3/functions/UDAggregate.java   | 18 ++++++------
 .../ForwardingPrimaryKeyRestrictions.java       |  4 +--
 .../restrictions/MultiColumnRestriction.java    | 18 ++++++------
 .../restrictions/PrimaryKeyRestrictionSet.java  |  4 +--
 .../cql3/restrictions/Restriction.java          |  8 +++---
 .../cql3/restrictions/RestrictionSet.java       | 18 ++++++------
 .../cql3/restrictions/Restrictions.java         |  9 +++---
 .../restrictions/SingleColumnRestriction.java   | 30 +++++++++-----------
 .../restrictions/StatementRestrictions.java     |  9 +++---
 .../cassandra/cql3/restrictions/TermSlice.java  | 19 +++++--------
 .../cql3/restrictions/TokenRestriction.java     |  8 +++---
 .../selection/AbstractFunctionSelector.java     |  7 ++---
 .../cassandra/cql3/selection/Selection.java     |  7 ++---
 .../cassandra/cql3/selection/Selector.java      |  5 ++--
 .../cql3/selection/SelectorFactories.java       |  9 ++----
 .../cql3/statements/BatchStatement.java         |  4 +--
 .../statements/CreateAggregateStatement.java    |  6 ++--
 .../cql3/statements/ModificationStatement.java  | 15 +++++++---
 .../cql3/statements/SelectStatement.java        | 15 ++++++++--
 39 files changed, 158 insertions(+), 195 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 1f715f4..95db7bc 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.6
+ * Reduce the amount of object allocations caused by the getFunctions methods (CASSANDRA-11593)
  * Potential error replaying commitlog with smallint/tinyint/date/time types (CASSANDRA-11618)
  * Fix queries with filtering on counter columns (CASSANDRA-11629)
  * Improve tombstone printing in sstabledump (CASSANDRA-11655)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/AbstractConditions.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/AbstractConditions.java b/src/java/org/apache/cassandra/cql3/AbstractConditions.java
index 71e3595..530d2b1 100644
--- a/src/java/org/apache/cassandra/cql3/AbstractConditions.java
+++ b/src/java/org/apache/cassandra/cql3/AbstractConditions.java
@@ -17,7 +17,7 @@
  */
 package org.apache.cassandra.cql3;
 
-import java.util.Collections;
+import java.util.List;
 
 import org.apache.cassandra.config.ColumnDefinition;
 import org.apache.cassandra.cql3.functions.Function;
@@ -28,9 +28,8 @@ import org.apache.cassandra.cql3.functions.Function;
  */
 abstract class AbstractConditions implements Conditions
 {
-    public Iterable<Function> getFunctions()
+    public void addFunctionsTo(List<Function> functions)
     {
-        return Collections.emptyList();
     }
 
     public Iterable<ColumnDefinition> getColumns()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/AbstractMarker.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/AbstractMarker.java b/src/java/org/apache/cassandra/cql3/AbstractMarker.java
index d2bc022..cd26bd7 100644
--- a/src/java/org/apache/cassandra/cql3/AbstractMarker.java
+++ b/src/java/org/apache/cassandra/cql3/AbstractMarker.java
@@ -18,6 +18,7 @@
 package org.apache.cassandra.cql3;
 
 import java.util.Collections;
+import java.util.List;
 
 import org.apache.cassandra.cql3.functions.Function;
 import org.apache.cassandra.db.marshal.CollectionType;
@@ -48,9 +49,8 @@ public abstract class AbstractMarker extends Term.NonTerminal
         return true;
     }
 
-    public Iterable<Function> getFunctions()
+    public void addFunctionsTo(List<Function> functions)
     {
-        return Collections.emptySet();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/Attributes.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Attributes.java b/src/java/org/apache/cassandra/cql3/Attributes.java
index 97bdcd1..e1d2522 100644
--- a/src/java/org/apache/cassandra/cql3/Attributes.java
+++ b/src/java/org/apache/cassandra/cql3/Attributes.java
@@ -19,6 +19,7 @@ package org.apache.cassandra.cql3;
 
 import java.nio.ByteBuffer;
 import java.util.Collections;
+import java.util.List;
 
 import com.google.common.collect.Iterables;
 
@@ -51,16 +52,12 @@ public class Attributes
         this.timeToLive = timeToLive;
     }
 
-    public Iterable<Function> getFunctions()
+    public void addFunctionsTo(List<Function> functions)
     {
-        if (timestamp != null && timeToLive != null)
-            return Iterables.concat(timestamp.getFunctions(), timeToLive.getFunctions());
-        else if (timestamp != null)
-            return timestamp.getFunctions();
-        else if (timeToLive != null)
-            return timeToLive.getFunctions();
-        else
-            return Collections.emptySet();
+        if (timestamp != null)
+            timestamp.addFunctionsTo(functions);
+        if (timeToLive != null)
+            timeToLive.addFunctionsTo(functions);
     }
 
     public boolean isTimestampSet()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/ColumnCondition.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/ColumnCondition.java b/src/java/org/apache/cassandra/cql3/ColumnCondition.java
index 0c2ea2a..b13e534 100644
--- a/src/java/org/apache/cassandra/cql3/ColumnCondition.java
+++ b/src/java/org/apache/cassandra/cql3/ColumnCondition.java
@@ -20,7 +20,6 @@ package org.apache.cassandra.cql3;
 import java.nio.ByteBuffer;
 import java.util.*;
 
-import com.google.common.collect.Iterables;
 import com.google.common.collect.Iterators;
 
 import org.apache.cassandra.config.ColumnDefinition;
@@ -90,18 +89,16 @@ public class ColumnCondition
         return new ColumnCondition(column, collectionElement, inMarker, null, Operator.IN);
     }
 
-    public Iterable<Function> getFunctions()
+    public void addFunctionsTo(List<Function> functions)
     {
-        Iterable<Function> iter = Collections.emptyList();
         if (collectionElement != null)
-           iter = Iterables.concat(iter, collectionElement.getFunctions());
+           collectionElement.addFunctionsTo(functions);
         if (value != null)
-            iter = Iterables.concat(iter, value.getFunctions());
+           value.addFunctionsTo(functions);
         if (inValues != null)
             for (Term value : inValues)
                 if (value != null)
-                    iter = Iterables.concat(iter, value.getFunctions());
-        return iter;
+                    value.addFunctionsTo(functions);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/ColumnConditions.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/ColumnConditions.java b/src/java/org/apache/cassandra/cql3/ColumnConditions.java
index 5ac8119..cb09b1a 100644
--- a/src/java/org/apache/cassandra/cql3/ColumnConditions.java
+++ b/src/java/org/apache/cassandra/cql3/ColumnConditions.java
@@ -29,8 +29,6 @@ import org.apache.cassandra.cql3.functions.Function;
 import org.apache.cassandra.cql3.statements.CQL3CasRequest;
 import org.apache.cassandra.db.Clustering;
 
-import static java.util.stream.StreamSupport.stream;
-
 /**
  * A set of <code>ColumnCondition</code>s.
  *
@@ -100,11 +98,10 @@ public final class ColumnConditions extends AbstractConditions
     }
 
     @Override
-    public Iterable<Function> getFunctions()
+    public void addFunctionsTo(List<Function> functions)
     {
-        return Stream.concat(columnConditions.stream(), staticConditions.stream())
-                     .flatMap(e -> stream(e.getFunctions().spliterator(), false))
-                     .collect(Collectors.toList());
+        columnConditions.forEach(p -> p.addFunctionsTo(functions));
+        staticConditions.forEach(p -> p.addFunctionsTo(functions));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/Conditions.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Conditions.java b/src/java/org/apache/cassandra/cql3/Conditions.java
index 85459c4..16fa4aa 100644
--- a/src/java/org/apache/cassandra/cql3/Conditions.java
+++ b/src/java/org/apache/cassandra/cql3/Conditions.java
@@ -17,6 +17,8 @@
  */
 package org.apache.cassandra.cql3;
 
+import java.util.List;
+
 import org.apache.cassandra.config.ColumnDefinition;
 import org.apache.cassandra.cql3.functions.Function;
 import org.apache.cassandra.cql3.statements.CQL3CasRequest;
@@ -44,10 +46,10 @@ public interface Conditions
     static final Conditions IF_NOT_EXISTS_CONDITION = new IfNotExistsCondition();
 
     /**
-     * Returns the functions used by the conditions.
-     * @return the functions used by the conditions
+     * Adds the functions used by the conditions to the specified list.
+     * @param functions the list to add to
      */
-    Iterable<Function> getFunctions();
+    void addFunctionsTo(List<Function> functions);
 
     /**
      * Returns the column definitions to which apply the conditions.

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/Json.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Json.java b/src/java/org/apache/cassandra/cql3/Json.java
index a0b226a..ab02fb6 100644
--- a/src/java/org/apache/cassandra/cql3/Json.java
+++ b/src/java/org/apache/cassandra/cql3/Json.java
@@ -252,11 +252,9 @@ public class Json
         }
 
         @Override
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return Collections.emptyList();
         }
-
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/Lists.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Lists.java b/src/java/org/apache/cassandra/cql3/Lists.java
index 18b382b..559cf3f 100644
--- a/src/java/org/apache/cassandra/cql3/Lists.java
+++ b/src/java/org/apache/cassandra/cql3/Lists.java
@@ -215,9 +215,9 @@ public abstract class Lists
             return new Value(buffers);
         }
 
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return Terms.getFunctions(elements);
+            Terms.addFunctions(elements, functions);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/Maps.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Maps.java b/src/java/org/apache/cassandra/cql3/Maps.java
index fbb7ee3..4772369 100644
--- a/src/java/org/apache/cassandra/cql3/Maps.java
+++ b/src/java/org/apache/cassandra/cql3/Maps.java
@@ -23,8 +23,6 @@ import java.nio.ByteBuffer;
 import java.util.*;
 import java.util.stream.Collectors;
 
-import com.google.common.collect.Iterables;
-
 import org.apache.cassandra.config.ColumnDefinition;
 import org.apache.cassandra.cql3.functions.Function;
 import org.apache.cassandra.db.DecoratedKey;
@@ -241,10 +239,10 @@ public abstract class Maps
             return new Value(buffers);
         }
 
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return Iterables.concat(Terms.getFunctions(elements.keySet()),
-                                    Terms.getFunctions(elements.values()));
+            Terms.addFunctions(elements.keySet(), functions);
+            Terms.addFunctions(elements.values(), functions);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/Operation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Operation.java b/src/java/org/apache/cassandra/cql3/Operation.java
index 51c8969..ecd37c4 100644
--- a/src/java/org/apache/cassandra/cql3/Operation.java
+++ b/src/java/org/apache/cassandra/cql3/Operation.java
@@ -17,7 +17,7 @@
  */
 package org.apache.cassandra.cql3;
 
-import java.util.Collections;
+import java.util.List;
 
 import org.apache.cassandra.config.ColumnDefinition;
 import org.apache.cassandra.cql3.functions.Function;
@@ -55,9 +55,10 @@ public abstract class Operation
         this.t = t;
     }
 
-    public Iterable<Function> getFunctions()
+    public void addFunctionsTo(List<Function> functions)
     {
-        return t != null ? t.getFunctions() : Collections.<Function>emptySet();
+        if (t != null)
+            t.addFunctionsTo(functions);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/Operations.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Operations.java b/src/java/org/apache/cassandra/cql3/Operations.java
index 0ef8517..a9451d7 100644
--- a/src/java/org/apache/cassandra/cql3/Operations.java
+++ b/src/java/org/apache/cassandra/cql3/Operations.java
@@ -24,7 +24,6 @@ import java.util.List;
 import org.apache.cassandra.cql3.functions.Function;
 import org.apache.cassandra.cql3.statements.StatementType;
 
-import com.google.common.collect.Iterables;
 import com.google.common.collect.Iterators;
 
 /**
@@ -139,11 +138,9 @@ public final class Operations implements Iterable<Operation>
         return Iterators.concat(staticOperations.iterator(), regularOperations.iterator());
     }
 
-    public Iterable<? extends Function> getFunctions()
+    public void addFunctionsTo(List<Function> functions)
     {
-        List<Function> functions = new ArrayList<>();
-        for (Operation operation : this)
-            Iterables.addAll(functions, operation.getFunctions());
-        return functions;
+        regularOperations.forEach(p -> p.addFunctionsTo(functions));
+        staticOperations.forEach(p -> p.addFunctionsTo(functions));
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/Sets.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Sets.java b/src/java/org/apache/cassandra/cql3/Sets.java
index 1e93144..622bb23 100644
--- a/src/java/org/apache/cassandra/cql3/Sets.java
+++ b/src/java/org/apache/cassandra/cql3/Sets.java
@@ -23,8 +23,6 @@ import java.nio.ByteBuffer;
 import java.util.*;
 import java.util.stream.Collectors;
 
-import com.google.common.base.Joiner;
-
 import org.apache.cassandra.config.ColumnDefinition;
 import org.apache.cassandra.cql3.functions.Function;
 import org.apache.cassandra.db.DecoratedKey;
@@ -217,9 +215,9 @@ public abstract class Sets
             return new Value(buffers);
         }
 
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return Terms.getFunctions(elements);
+            Terms.addFunctions(elements, functions);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/Term.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Term.java b/src/java/org/apache/cassandra/cql3/Term.java
index 1f6bc62..5ae9c18 100644
--- a/src/java/org/apache/cassandra/cql3/Term.java
+++ b/src/java/org/apache/cassandra/cql3/Term.java
@@ -70,7 +70,7 @@ public interface Term
      */
     public abstract boolean containsBindMarker();
 
-    Iterable<Function> getFunctions();
+    public void addFunctionsTo(List<Function> functions);
 
     /**
      * A parsed, non prepared (thus untyped) term.
@@ -131,9 +131,8 @@ public interface Term
         public void collectMarkerSpecification(VariableSpecifications boundNames) {}
         public Terminal bind(QueryOptions options) { return this; }
 
-        public Set<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return Collections.emptySet();
         }
 
         // While some NonTerminal may not have bind markers, no Term can be Terminal

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/Terms.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Terms.java b/src/java/org/apache/cassandra/cql3/Terms.java
index ae4bc13..7d3948a 100644
--- a/src/java/org/apache/cassandra/cql3/Terms.java
+++ b/src/java/org/apache/cassandra/cql3/Terms.java
@@ -18,31 +18,17 @@
 package org.apache.cassandra.cql3;
 
 import java.nio.ByteBuffer;
-import java.util.Collections;
-
-import com.google.common.collect.Iterables;
+import java.util.List;
 
 import org.apache.cassandra.cql3.functions.Function;
 import org.apache.cassandra.db.marshal.AbstractType;
 
 public class Terms
 {
-
-    private static com.google.common.base.Function<Term, Iterable<Function>> TO_FUNCTION_ITERABLE =
-    new com.google.common.base.Function<Term, Iterable<Function>>()
+    public static void addFunctions(Iterable<Term> terms, List<Function> functions)
     {
-        public Iterable<Function> apply(Term term)
-        {
-            return term.getFunctions();
-        }
-    };
-
-    public static Iterable<Function> getFunctions(Iterable<Term> terms)
-    {
-        if (terms == null)
-            return Collections.emptySet();
-
-        return Iterables.concat(Iterables.transform(terms, TO_FUNCTION_ITERABLE));
+        if (terms != null)
+            terms.forEach(t -> t.addFunctionsTo(functions));
     }
 
     public static ByteBuffer asBytes(String keyspace, String term, AbstractType type)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/Tuples.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Tuples.java b/src/java/org/apache/cassandra/cql3/Tuples.java
index 6c7df47..ee08efe 100644
--- a/src/java/org/apache/cassandra/cql3/Tuples.java
+++ b/src/java/org/apache/cassandra/cql3/Tuples.java
@@ -228,9 +228,9 @@ public class Tuples
             return tupleToString(elements);
         }
 
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return Terms.getFunctions(elements);
+            Terms.addFunctions(elements, functions);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/UserTypes.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/UserTypes.java b/src/java/org/apache/cassandra/cql3/UserTypes.java
index 0beff06..89cfe4b 100644
--- a/src/java/org/apache/cassandra/cql3/UserTypes.java
+++ b/src/java/org/apache/cassandra/cql3/UserTypes.java
@@ -147,9 +147,9 @@ public abstract class UserTypes
             this.values = values;
         }
 
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return Terms.getFunctions(values);
+            Terms.addFunctions(values, functions);
         }
 
         public boolean containsBindMarker()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/functions/AbstractFunction.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/AbstractFunction.java b/src/java/org/apache/cassandra/cql3/functions/AbstractFunction.java
index b77f4d5..0cf11a5 100644
--- a/src/java/org/apache/cassandra/cql3/functions/AbstractFunction.java
+++ b/src/java/org/apache/cassandra/cql3/functions/AbstractFunction.java
@@ -20,7 +20,6 @@ package org.apache.cassandra.cql3.functions;
 import java.util.List;
 
 import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableSet;
 
 import org.apache.cassandra.cql3.AssignmentTestable;
 import org.apache.cassandra.cql3.ColumnSpecification;
@@ -69,9 +68,9 @@ public abstract class AbstractFunction implements Function
             && Objects.equal(this.returnType, that.returnType);
     }
 
-    public Iterable<Function> getFunctions()
+    public void addFunctionsTo(List<Function> functions)
     {
-        return ImmutableSet.<Function>of(this);
+        functions.add(this);
     }
 
     public boolean hasReferenceTo(Function function)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/functions/Function.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/Function.java b/src/java/org/apache/cassandra/cql3/functions/Function.java
index ed6e2a7..f93f14b 100644
--- a/src/java/org/apache/cassandra/cql3/functions/Function.java
+++ b/src/java/org/apache/cassandra/cql3/functions/Function.java
@@ -44,7 +44,7 @@ public interface Function extends AssignmentTestable
      */
     public boolean isAggregate();
 
-    public Iterable<Function> getFunctions();
+    public void addFunctionsTo(List<Function> functions);
 
     public boolean hasReferenceTo(Function function);
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/functions/FunctionCall.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/FunctionCall.java b/src/java/org/apache/cassandra/cql3/functions/FunctionCall.java
index 1766a79..be3081a 100644
--- a/src/java/org/apache/cassandra/cql3/functions/FunctionCall.java
+++ b/src/java/org/apache/cassandra/cql3/functions/FunctionCall.java
@@ -22,8 +22,6 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
-import com.google.common.collect.Iterables;
-
 import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.cql3.statements.RequestValidations;
 import org.apache.cassandra.db.marshal.*;
@@ -42,9 +40,10 @@ public class FunctionCall extends Term.NonTerminal
         this.terms = terms;
     }
 
-    public Iterable<Function> getFunctions()
+    public void addFunctionsTo(List<Function> functions)
     {
-        return Iterables.concat(Terms.getFunctions(terms), fun.getFunctions());
+        Terms.addFunctions(terms, functions);
+        fun.addFunctionsTo(functions);
     }
 
     public void collectMarkerSpecification(VariableSpecifications boundNames)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/functions/UDAggregate.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/UDAggregate.java b/src/java/org/apache/cassandra/cql3/functions/UDAggregate.java
index ade69dd..96e19de 100644
--- a/src/java/org/apache/cassandra/cql3/functions/UDAggregate.java
+++ b/src/java/org/apache/cassandra/cql3/functions/UDAggregate.java
@@ -21,7 +21,6 @@ import java.nio.ByteBuffer;
 import java.util.*;
 
 import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableSet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -101,14 +100,17 @@ public class UDAggregate extends AbstractFunction implements AggregateFunction
         return stateFunction == function || finalFunction == function;
     }
 
-    public Iterable<Function> getFunctions()
+    @Override
+    public void addFunctionsTo(List<Function> functions)
     {
-        if (stateFunction == null)
-            return Collections.emptySet();
-        if (finalFunction != null)
-            return ImmutableSet.of(this, stateFunction, finalFunction);
-        else
-            return ImmutableSet.of(this, stateFunction);
+        functions.add(this);
+        if (stateFunction != null)
+        {
+            stateFunction.addFunctionsTo(functions);
+
+            if (finalFunction != null)
+                finalFunction.addFunctionsTo(functions);
+        }
     }
 
     public boolean isAggregate()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/restrictions/ForwardingPrimaryKeyRestrictions.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/restrictions/ForwardingPrimaryKeyRestrictions.java b/src/java/org/apache/cassandra/cql3/restrictions/ForwardingPrimaryKeyRestrictions.java
index 723ebc3..71305b9 100644
--- a/src/java/org/apache/cassandra/cql3/restrictions/ForwardingPrimaryKeyRestrictions.java
+++ b/src/java/org/apache/cassandra/cql3/restrictions/ForwardingPrimaryKeyRestrictions.java
@@ -46,9 +46,9 @@ abstract class ForwardingPrimaryKeyRestrictions implements PrimaryKeyRestriction
     protected abstract PrimaryKeyRestrictions getDelegate();
 
     @Override
-    public Iterable<Function> getFunctions()
+    public void addFunctionsTo(List<Function> functions)
     {
-        return getDelegate().getFunctions();
+        getDelegate().addFunctionsTo(functions);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/restrictions/MultiColumnRestriction.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/restrictions/MultiColumnRestriction.java b/src/java/org/apache/cassandra/cql3/restrictions/MultiColumnRestriction.java
index ec02d06..4329b6e 100644
--- a/src/java/org/apache/cassandra/cql3/restrictions/MultiColumnRestriction.java
+++ b/src/java/org/apache/cassandra/cql3/restrictions/MultiColumnRestriction.java
@@ -138,9 +138,9 @@ public abstract class MultiColumnRestriction extends AbstractRestriction
         }
 
         @Override
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return value.getFunctions();
+            value.addFunctionsTo(functions);
         }
 
         @Override
@@ -269,9 +269,9 @@ public abstract class MultiColumnRestriction extends AbstractRestriction
         }
 
         @Override
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return Terms.getFunctions(values);
+            Terms.addFunctions(values, functions);
         }
 
         @Override
@@ -308,9 +308,8 @@ public abstract class MultiColumnRestriction extends AbstractRestriction
         }
 
         @Override
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return Collections.emptySet();
         }
 
         @Override
@@ -433,9 +432,9 @@ public abstract class MultiColumnRestriction extends AbstractRestriction
         }
 
         @Override
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return slice.getFunctions();
+            slice.addFunctionsTo(functions);
         }
 
         @Override
@@ -525,9 +524,8 @@ public abstract class MultiColumnRestriction extends AbstractRestriction
         }
 
         @Override
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return Collections.emptyList();
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/restrictions/PrimaryKeyRestrictionSet.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/restrictions/PrimaryKeyRestrictionSet.java b/src/java/org/apache/cassandra/cql3/restrictions/PrimaryKeyRestrictionSet.java
index e063f91..061284b 100644
--- a/src/java/org/apache/cassandra/cql3/restrictions/PrimaryKeyRestrictionSet.java
+++ b/src/java/org/apache/cassandra/cql3/restrictions/PrimaryKeyRestrictionSet.java
@@ -194,9 +194,9 @@ final class PrimaryKeyRestrictionSet extends AbstractPrimaryKeyRestrictions
     }
 
     @Override
-    public Iterable<Function> getFunctions()
+    public void addFunctionsTo(List<Function> functions)
     {
-        return restrictions.getFunctions();
+        restrictions.addFunctionsTo(functions);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/restrictions/Restriction.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/restrictions/Restriction.java b/src/java/org/apache/cassandra/cql3/restrictions/Restriction.java
index 09c3893..987fd30 100644
--- a/src/java/org/apache/cassandra/cql3/restrictions/Restriction.java
+++ b/src/java/org/apache/cassandra/cql3/restrictions/Restriction.java
@@ -63,11 +63,11 @@ public interface Restriction
     public List<ColumnDefinition> getColumnDefs();
 
     /**
-     * Return an Iterable over all of the functions (both native and user-defined) used by any component
-     * of the restriction
-     * @return functions all functions found (may contain duplicates)
+     * Adds all functions (native and user-defined) used by any component of the restriction
+     * to the specified list.
+     * @param functions the list to add to
      */
-    public Iterable<Function> getFunctions();
+    void addFunctionsTo(List<Function> functions);
 
     /**
      * Checks if the specified bound is set or not.

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/restrictions/RestrictionSet.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/restrictions/RestrictionSet.java b/src/java/org/apache/cassandra/cql3/restrictions/RestrictionSet.java
index 4868416..9aeea69 100644
--- a/src/java/org/apache/cassandra/cql3/restrictions/RestrictionSet.java
+++ b/src/java/org/apache/cassandra/cql3/restrictions/RestrictionSet.java
@@ -19,8 +19,6 @@ package org.apache.cassandra.cql3.restrictions;
 
 import java.util.*;
 
-import com.google.common.collect.Iterables;
-
 import org.apache.cassandra.config.ColumnDefinition;
 import org.apache.cassandra.cql3.QueryOptions;
 import org.apache.cassandra.cql3.functions.Function;
@@ -79,18 +77,18 @@ final class RestrictionSet implements Restrictions, Iterable<Restriction>
     }
 
     @Override
-    public Iterable<Function> getFunctions()
+    public void addFunctionsTo(List<Function> functions)
     {
-        com.google.common.base.Function<Restriction, Iterable<Function>> transform =
-            new com.google.common.base.Function<Restriction, Iterable<Function>>()
+        Restriction previous = null;
+        for (Restriction restriction : restrictions.values())
         {
-            public Iterable<Function> apply(Restriction restriction)
+            // For muti-column restriction, we can have multiple time the same restriction.
+            if (!restriction.equals(previous))
             {
-                return restriction.getFunctions();
+                previous = restriction;
+                restriction.addFunctionsTo(functions);
             }
-        };
-
-        return Iterables.concat(Iterables.transform(restrictions.values(), transform));
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/restrictions/Restrictions.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/restrictions/Restrictions.java b/src/java/org/apache/cassandra/cql3/restrictions/Restrictions.java
index 705d66d..5fa3170 100644
--- a/src/java/org/apache/cassandra/cql3/restrictions/Restrictions.java
+++ b/src/java/org/apache/cassandra/cql3/restrictions/Restrictions.java
@@ -18,6 +18,7 @@
 package org.apache.cassandra.cql3.restrictions;
 
 import java.util.Collection;
+import java.util.List;
 
 import org.apache.cassandra.config.ColumnDefinition;
 import org.apache.cassandra.cql3.QueryOptions;
@@ -38,11 +39,11 @@ interface Restrictions
     public Collection<ColumnDefinition> getColumnDefs();
 
     /**
-     * Return an Iterable over all of the functions (both native and user-defined) used by any component
-     * of the restrictions
-     * @return functions all functions found (may contain duplicates)
+     * Adds all functions (native and user-defined) used by any component of the restriction
+     * to the specified list.
+     * @param functions the list to add to
      */
-    public Iterable<Function> getFunctions();
+    public void addFunctionsTo(List<Function> functions);
 
     /**
      * Check if the restriction is on indexed columns.

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/restrictions/SingleColumnRestriction.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/restrictions/SingleColumnRestriction.java b/src/java/org/apache/cassandra/cql3/restrictions/SingleColumnRestriction.java
index 3a61616..6296b97 100644
--- a/src/java/org/apache/cassandra/cql3/restrictions/SingleColumnRestriction.java
+++ b/src/java/org/apache/cassandra/cql3/restrictions/SingleColumnRestriction.java
@@ -20,8 +20,6 @@ package org.apache.cassandra.cql3.restrictions;
 import java.nio.ByteBuffer;
 import java.util.*;
 
-import com.google.common.collect.Iterables;
-
 import org.apache.cassandra.config.ColumnDefinition;
 import org.apache.cassandra.cql3.*;
 import org.apache.cassandra.cql3.Term.Terminal;
@@ -131,9 +129,9 @@ public abstract class SingleColumnRestriction extends AbstractRestriction
         }
 
         @Override
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return value.getFunctions();
+            value.addFunctionsTo(functions);
         }
 
         @Override
@@ -249,9 +247,9 @@ public abstract class SingleColumnRestriction extends AbstractRestriction
         }
 
         @Override
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return Terms.getFunctions(values);
+            Terms.addFunctions(values, functions);
         }
 
         @Override
@@ -281,9 +279,8 @@ public abstract class SingleColumnRestriction extends AbstractRestriction
         }
 
         @Override
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return Collections.emptySet();
         }
 
         @Override
@@ -320,9 +317,9 @@ public abstract class SingleColumnRestriction extends AbstractRestriction
         }
 
         @Override
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return slice.getFunctions();
+            slice.addFunctionsTo(functions);
         }
 
         @Override
@@ -525,12 +522,12 @@ public abstract class SingleColumnRestriction extends AbstractRestriction
         }
 
         @Override
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return Iterables.concat(Terms.getFunctions(values),
-                                    Terms.getFunctions(keys),
-                                    Terms.getFunctions(entryKeys),
-                                    Terms.getFunctions(entryValues));
+            Terms.addFunctions(values, functions);
+            Terms.addFunctions(keys, functions);
+            Terms.addFunctions(entryKeys, functions);
+            Terms.addFunctions(entryValues, functions);
         }
 
         @Override
@@ -601,9 +598,8 @@ public abstract class SingleColumnRestriction extends AbstractRestriction
         }
 
         @Override
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return Collections.emptyList();
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java b/src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java
index 942d1f9..6ee554e 100644
--- a/src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java
+++ b/src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java
@@ -21,7 +21,6 @@ import java.nio.ByteBuffer;
 import java.util.*;
 
 import com.google.common.base.Joiner;
-import com.google.common.collect.Iterables;
 
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.ColumnDefinition;
@@ -251,11 +250,11 @@ public final class StatementRestrictions
             addSingleColumnRestriction((SingleColumnRestriction) restriction);
     }
 
-    public Iterable<Function> getFunctions()
+    public void addFunctionsTo(List<Function> functions)
     {
-        return Iterables.concat(partitionKeyRestrictions.getFunctions(),
-                                clusteringColumnsRestrictions.getFunctions(),
-                                nonPrimaryKeyRestrictions.getFunctions());
+        partitionKeyRestrictions.addFunctionsTo(functions);
+        clusteringColumnsRestrictions.addFunctionsTo(functions);
+        nonPrimaryKeyRestrictions.addFunctionsTo(functions);
     }
 
     private void addSingleColumnRestriction(SingleColumnRestriction restriction)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/restrictions/TermSlice.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/restrictions/TermSlice.java b/src/java/org/apache/cassandra/cql3/restrictions/TermSlice.java
index 6423be3..ac66b96 100644
--- a/src/java/org/apache/cassandra/cql3/restrictions/TermSlice.java
+++ b/src/java/org/apache/cassandra/cql3/restrictions/TermSlice.java
@@ -17,9 +17,7 @@
  */
 package org.apache.cassandra.cql3.restrictions;
 
-import java.util.Collections;
-
-import com.google.common.collect.Iterables;
+import java.util.List;
 
 import org.apache.cassandra.config.ColumnDefinition;
 import org.apache.cassandra.cql3.Operator;
@@ -171,15 +169,12 @@ final class TermSlice
         return supported;
     }
 
-    public Iterable<Function> getFunctions()
+    public void addFunctionsTo(List<Function> functions)
     {
-        if (hasBound(Bound.START) && hasBound(Bound.END))
-            return Iterables.concat(bound(Bound.START).getFunctions(), bound(Bound.END).getFunctions());
-        else if (hasBound(Bound.START))
-            return bound(Bound.START).getFunctions();
-        else if (hasBound(Bound.END))
-            return bound(Bound.END).getFunctions();
-        else
-            return Collections.emptySet();
+        if (hasBound(Bound.START))
+            bound(Bound.START).addFunctionsTo(functions);
+
+        if (hasBound(Bound.END))
+            bound(Bound.END).addFunctionsTo(functions);
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/restrictions/TokenRestriction.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/restrictions/TokenRestriction.java b/src/java/org/apache/cassandra/cql3/restrictions/TokenRestriction.java
index eaaafca..14d2cb7 100644
--- a/src/java/org/apache/cassandra/cql3/restrictions/TokenRestriction.java
+++ b/src/java/org/apache/cassandra/cql3/restrictions/TokenRestriction.java
@@ -172,9 +172,9 @@ public abstract class TokenRestriction extends AbstractPrimaryKeyRestrictions
         }
 
         @Override
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return value.getFunctions();
+            value.addFunctionsTo(functions);
         }
 
         @Override
@@ -226,9 +226,9 @@ public abstract class TokenRestriction extends AbstractPrimaryKeyRestrictions
         }
 
         @Override
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return slice.getFunctions();
+            slice.addFunctionsTo(functions);
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/selection/AbstractFunctionSelector.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/selection/AbstractFunctionSelector.java b/src/java/org/apache/cassandra/cql3/selection/AbstractFunctionSelector.java
index bf1234f..c48b93c 100644
--- a/src/java/org/apache/cassandra/cql3/selection/AbstractFunctionSelector.java
+++ b/src/java/org/apache/cassandra/cql3/selection/AbstractFunctionSelector.java
@@ -21,8 +21,6 @@ import java.nio.ByteBuffer;
 import java.util.Arrays;
 import java.util.List;
 
-import com.google.common.collect.Iterables;
-
 import org.apache.commons.lang3.text.StrBuilder;
 
 import org.apache.cassandra.cql3.functions.AggregateFcts;
@@ -85,9 +83,10 @@ abstract class AbstractFunctionSelector<T extends Function> extends Selector
                     mapping.addMapping(resultsColumn, tmpMapping.getMappings().values());
             }
 
-            public Iterable<Function> getFunctions()
+            public void addFunctionsTo(List<Function> functions)
             {
-                return Iterables.concat(fun.getFunctions(), factories.getFunctions());
+                fun.addFunctionsTo(functions);
+                factories.addFunctionsTo(functions);
             }
 
             public Selector newInstance() throws InvalidRequestException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/selection/Selection.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/selection/Selection.java b/src/java/org/apache/cassandra/cql3/selection/Selection.java
index 4518f02..8a27314 100644
--- a/src/java/org/apache/cassandra/cql3/selection/Selection.java
+++ b/src/java/org/apache/cassandra/cql3/selection/Selection.java
@@ -154,9 +154,8 @@ public abstract class Selection
         return columns.size() - 1;
     }
 
-    public Iterable<Function> getFunctions()
+    public void addFunctionsTo(List<Function> functions)
     {
-        return Collections.emptySet();
     }
 
     private static boolean processesSelection(List<RawSelector> rawSelectors)
@@ -498,9 +497,9 @@ public abstract class Selection
         }
 
         @Override
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return factories.getFunctions();
+            factories.addFunctionsTo(functions);
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/selection/Selector.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/selection/Selector.java b/src/java/org/apache/cassandra/cql3/selection/Selector.java
index 4515cd0..7249d22 100644
--- a/src/java/org/apache/cassandra/cql3/selection/Selector.java
+++ b/src/java/org/apache/cassandra/cql3/selection/Selector.java
@@ -18,7 +18,7 @@
 package org.apache.cassandra.cql3.selection;
 
 import java.nio.ByteBuffer;
-import java.util.Collections;
+import java.util.List;
 
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.cql3.AssignmentTestable;
@@ -43,9 +43,8 @@ public abstract class Selector implements AssignmentTestable
      */
     public static abstract class Factory
     {
-        public Iterable<Function> getFunctions()
+        public void addFunctionsTo(List<Function> functions)
         {
-            return Collections.emptySet();
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/selection/SelectorFactories.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/selection/SelectorFactories.java b/src/java/org/apache/cassandra/cql3/selection/SelectorFactories.java
index fbbfbb5..97a1198 100644
--- a/src/java/org/apache/cassandra/cql3/selection/SelectorFactories.java
+++ b/src/java/org/apache/cassandra/cql3/selection/SelectorFactories.java
@@ -19,7 +19,6 @@ package org.apache.cassandra.cql3.selection;
 
 import java.util.*;
 
-import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 
 import org.apache.cassandra.config.CFMetaData;
@@ -89,13 +88,9 @@ final class SelectorFactories implements Iterable<Selector.Factory>
         }
     }
 
-    public Iterable<Function> getFunctions()
+    public void addFunctionsTo(List<Function> functions)
     {
-        Iterable<Function> functions = Collections.emptySet();
-        for (Factory factory : factories)
-            if (factory != null)
-                functions = Iterables.concat(functions, factory.getFunctions());
-        return functions;
+        factories.forEach(p -> p.addFunctionsTo(functions));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
index 1c395a5..f0aa835 100644
--- a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
@@ -120,9 +120,9 @@ public class BatchStatement implements CQLStatement
 
     public Iterable<org.apache.cassandra.cql3.functions.Function> getFunctions()
     {
-        Iterable<org.apache.cassandra.cql3.functions.Function> functions = attrs.getFunctions();
+        List<org.apache.cassandra.cql3.functions.Function> functions = new ArrayList<>();
         for (ModificationStatement statement : statements)
-            functions = Iterables.concat(functions, statement.getFunctions());
+            statement.addFunctionsTo(functions);
         return functions;
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/statements/CreateAggregateStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/CreateAggregateStatement.java b/src/java/org/apache/cassandra/cql3/statements/CreateAggregateStatement.java
index 7066570..98e2433 100644
--- a/src/java/org/apache/cassandra/cql3/statements/CreateAggregateStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateAggregateStatement.java
@@ -193,12 +193,10 @@ public final class CreateAggregateStatement extends SchemaAlteringStatement
         else
             state.ensureHasPermission(Permission.CREATE, FunctionResource.keyspace(functionName.keyspace));
 
-        for (Function referencedFunction : stateFunction.getFunctions())
-            state.ensureHasPermission(Permission.EXECUTE, referencedFunction);
+        state.ensureHasPermission(Permission.EXECUTE, stateFunction);
 
         if (finalFunction != null)
-            for (Function referencedFunction : finalFunction.getFunctions())
-                state.ensureHasPermission(Permission.EXECUTE, referencedFunction);
+            state.ensureHasPermission(Permission.EXECUTE, finalFunction);
     }
 
     public void validate(ClientState state) throws InvalidRequestException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
index 71597f4..12bade5 100644
--- a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java
@@ -141,10 +141,17 @@ public abstract class ModificationStatement implements CQLStatement
 
     public Iterable<Function> getFunctions()
     {
-        return Iterables.concat(attrs.getFunctions(),
-                                restrictions.getFunctions(),
-                                operations.getFunctions(),
-                                conditions.getFunctions());
+        List<Function> functions = new ArrayList<>();
+        addFunctionsTo(functions);
+        return functions;
+    }
+
+    public void addFunctionsTo(List<Function> functions)
+    {
+        attrs.addFunctionsTo(functions);
+        restrictions.addFunctionsTo(functions);
+        operations.addFunctionsTo(functions);
+        conditions.addFunctionsTo(functions);
     }
 
     public abstract void addUpdateForKey(PartitionUpdate update, Clustering clustering, UpdateParameters params);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/89464ead/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
index b4215ac..c3e13f4 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -120,9 +120,18 @@ public class SelectStatement implements CQLStatement
 
     public Iterable<Function> getFunctions()
     {
-        return Iterables.concat(selection.getFunctions(),
-                                restrictions.getFunctions(),
-                                limit != null ? limit.getFunctions() : Collections.<Function>emptySet());
+        List<Function> functions = new ArrayList<>();
+        addFunctionsTo(functions);
+        return functions;
+    }
+
+    private void addFunctionsTo(List<Function> functions)
+    {
+        selection.addFunctionsTo(functions);
+        restrictions.addFunctionsTo(functions);
+
+        if (limit != null)
+            limit.addFunctionsTo(functions);
     }
 
     // Note that the queried columns internally is different from the one selected by the


Mime
View raw message