Search in sources :

Example 1 with Compare

use of org.apache.cassandra.fqltool.commands.Compare in project cassandra by apache.

the class FQLReplayTest method readResultFile.

private static List<Pair<FQLQuery, ResultHandler.ComparableResultSet>> readResultFile(File dir, File queryDir) {
    List<Pair<FQLQuery, ResultHandler.ComparableResultSet>> resultSets = new ArrayList<>();
    try (ChronicleQueue q = SingleChronicleQueueBuilder.single(dir).build();
        ChronicleQueue queryQ = SingleChronicleQueueBuilder.single(queryDir).build()) {
        ExcerptTailer queryTailer = queryQ.createTailer();
        FQLQueryReader queryReader = new FQLQueryReader();
        Compare.StoredResultSetIterator resultSetIterator = new Compare.StoredResultSetIterator(q.createTailer());
        // we need to materialize the rows in-memory to compare them easier in these tests
        while (resultSetIterator.hasNext()) {
            ResultHandler.ComparableResultSet resultSetFromDisk = resultSetIterator.next();
            Iterator<ResultHandler.ComparableRow> rowIterFromDisk = resultSetFromDisk.iterator();
            queryTailer.readDocument(queryReader);
            FQLQuery query = queryReader.getQuery();
            List<ResultHandler.ComparableRow> rows = new ArrayList<>();
            while (rowIterFromDisk.hasNext()) {
                rows.add(rowIterFromDisk.next());
            }
            resultSets.add(Pair.create(query, new StoredResultSet(resultSetFromDisk.getColumnDefinitions(), resultSetIterator.hasNext(), resultSetFromDisk.wasFailed(), resultSetFromDisk.getFailureException(), rows::iterator)));
        }
    }
    return resultSets;
}
Also used : ArrayList(java.util.ArrayList) ExcerptTailer(net.openhft.chronicle.queue.ExcerptTailer) ChronicleQueue(net.openhft.chronicle.queue.ChronicleQueue) Compare(org.apache.cassandra.fqltool.commands.Compare) Pair(org.apache.cassandra.utils.Pair)

Aggregations

ArrayList (java.util.ArrayList)1 ChronicleQueue (net.openhft.chronicle.queue.ChronicleQueue)1 ExcerptTailer (net.openhft.chronicle.queue.ExcerptTailer)1 Compare (org.apache.cassandra.fqltool.commands.Compare)1 Pair (org.apache.cassandra.utils.Pair)1