cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clohfink <...@git.apache.org>
Subject [GitHub] cassandra pull request #161: (refactor) some opportunities to use lambda fun...
Date Fri, 06 Oct 2017 16:19:56 GMT
Github user clohfink commented on a diff in the pull request:

    https://github.com/apache/cassandra/pull/161#discussion_r143230080
  
    --- Diff: src/java/org/apache/cassandra/cql3/CQL3Type.java ---
    @@ -826,13 +827,18 @@ public CQL3Type prepare(String keyspace, Types udts) throws InvalidRequestExcept
                         freeze();
     
                     List<AbstractType<?>> ts = new ArrayList<>(types.size());
    -                for (CQL3Type.Raw t : types)
    -                {
    -                    if (t.isCounter())
    -                        throw new InvalidRequestException("Counters are not allowed inside
tuples");
    -
    -                    ts.add(t.prepare(keyspace, udts).getType());
    -                }
    +                types.stream()
    +                        .map(
    +                                t -> {
    +                                    if (t.isCounter())
    +                                        throw new InvalidRequestException(
    +                                                "Counters are not allowed inside tuples");
    +                                    return t;
    +                                })
    +                        .forEach(
    +                                t -> {
    +                                    ts.add(t.prepare(keyspace, udts).getType());
    +                                });
    --- End diff --
    
    This looks worse, and if your going to convert to a new list you can just do the mapping
like
    
    ```
    types.stream().map(t ->
    {
        if (t.isCounter())
            throw new InvalidRequestException("Counters are not allowed inside tuples");
        return t.prepare(keyspace, udts).getType()
    }
    ```


---

---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Mime
View raw message