cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dineshjoshi <...@git.apache.org>
Subject [GitHub] cassandra pull request #255: Marcuse/14618
Date Wed, 29 Aug 2018 07:04:01 GMT
Github user dineshjoshi commented on a diff in the pull request:

    https://github.com/apache/cassandra/pull/255#discussion_r213562282
  
    --- Diff: src/java/org/apache/cassandra/tools/fqltool/DriverResultSet.java ---
    @@ -0,0 +1,253 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.cassandra.tools.fqltool;
    +
    +import java.nio.ByteBuffer;
    +import java.util.Collections;
    +import java.util.Iterator;
    +import java.util.List;
    +import java.util.stream.Collectors;
    +
    +import com.google.common.collect.AbstractIterator;
    +
    +import com.datastax.driver.core.ColumnDefinitions;
    +import com.datastax.driver.core.ResultSet;
    +import com.datastax.driver.core.Row;
    +import org.apache.cassandra.utils.ByteBufferUtil;
    +
    +
    +/**
    + * Wraps a result set from the driver so that we can reuse the compare code when reading
    + * up a result set produced by ResultStore.
    + */
    +public class DriverResultSet implements ResultHandler.ComparableResultSet
    +{
    +    private final ResultSet resultSet;
    +    private final Throwable failureException;
    +
    +    public DriverResultSet(ResultSet resultSet)
    +    {
    +        this(resultSet, null);
    +    }
    +
    +    private DriverResultSet(ResultSet res, Throwable failureException)
    +    {
    +        resultSet = res;
    +        this.failureException = failureException;
    +    }
    +
    +    public static DriverResultSet failed(Throwable ex)
    +    {
    +        return new DriverResultSet(null, ex);
    +    }
    +
    +    public ResultHandler.ComparableColumnDefinitions getColumnDefinitions()
    +    {
    +        if (wasFailed())
    +            return new DriverColumnDefinitions(null, true);
    +
    +        return new DriverColumnDefinitions(resultSet.getColumnDefinitions());
    +    }
    +
    +    public boolean wasFailed()
    +    {
    +        return failureException != null;
    +    }
    +
    +    public Throwable getFailureException()
    +    {
    +        return failureException;
    +    }
    +
    +    public Iterator<ResultHandler.ComparableRow> iterator()
    +    {
    +        if (wasFailed())
    +            return Collections.emptyListIterator();
    +        return new AbstractIterator<ResultHandler.ComparableRow>()
    +        {
    +            Iterator<Row> iter = resultSet.iterator();
    +            protected ResultHandler.ComparableRow computeNext()
    +            {
    +                if (iter.hasNext())
    +                {
    --- End diff --
    
    Unnecessary braces for single statement block (there are bunch of these in this file).


---

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


Mime
View raw message