Search in sources :

Example 1 with ResultHandler

use of org.apache.cassandra.fqltool.ResultHandler in project cassandra by apache.

the class Compare method compare.

public static void compare(String querylog, List<String> arguments) {
    List<ChronicleQueue> readQueues = null;
    try (ResultHandler rh = new ResultHandler(arguments, null, null);
        ChronicleQueue queryQ = SingleChronicleQueueBuilder.single(querylog).readOnly(true).build();
        FQLQueryIterator queries = new FQLQueryIterator(queryQ.createTailer(), 1)) {
        readQueues = arguments.stream().map(s -> SingleChronicleQueueBuilder.single(s).readOnly(true).build()).collect(Collectors.toList());
        List<Iterator<ResultHandler.ComparableResultSet>> its = readQueues.stream().map(q -> new StoredResultSetIterator(q.createTailer())).collect(Collectors.toList());
        while (queries.hasNext()) rh.handleResults(queries.next(), resultSets(its));
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        if (readQueues != null)
            readQueues.forEach(Closeable::close);
    }
}
Also used : ExcerptTailer(net.openhft.chronicle.queue.ExcerptTailer) Iterator(java.util.Iterator) ChronicleQueue(net.openhft.chronicle.queue.ChronicleQueue) AbstractIterator(com.google.common.collect.AbstractIterator) Closeable(net.openhft.chronicle.core.io.Closeable) StoredResultSet(org.apache.cassandra.fqltool.StoredResultSet) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Command(io.airlift.airline.Command) SingleChronicleQueueBuilder(net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder) List(java.util.List) Option(io.airlift.airline.Option) ResultHandler(org.apache.cassandra.fqltool.ResultHandler) VisibleForTesting(com.google.common.annotations.VisibleForTesting) FQLQueryIterator(org.apache.cassandra.fqltool.FQLQueryIterator) Arguments(io.airlift.airline.Arguments) ChronicleQueue(net.openhft.chronicle.queue.ChronicleQueue) Iterator(java.util.Iterator) AbstractIterator(com.google.common.collect.AbstractIterator) FQLQueryIterator(org.apache.cassandra.fqltool.FQLQueryIterator) ResultHandler(org.apache.cassandra.fqltool.ResultHandler) FQLQueryIterator(org.apache.cassandra.fqltool.FQLQueryIterator)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 AbstractIterator (com.google.common.collect.AbstractIterator)1 Arguments (io.airlift.airline.Arguments)1 Command (io.airlift.airline.Command)1 Option (io.airlift.airline.Option)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Closeable (net.openhft.chronicle.core.io.Closeable)1 ChronicleQueue (net.openhft.chronicle.queue.ChronicleQueue)1 ExcerptTailer (net.openhft.chronicle.queue.ExcerptTailer)1 SingleChronicleQueueBuilder (net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder)1 FQLQueryIterator (org.apache.cassandra.fqltool.FQLQueryIterator)1 ResultHandler (org.apache.cassandra.fqltool.ResultHandler)1 StoredResultSet (org.apache.cassandra.fqltool.StoredResultSet)1