Package com.datastax.driver.core

Examples of com.datastax.driver.core.ResultSet


        AggregateNumericMetricMapper mapper = new AggregateNumericMetricMapper();

        List<AggregateNumericMetric> result = new ArrayList<AggregateNumericMetric>(pks.size());
        for (StorageResultSetFuture f : futureResults) {
            ResultSet r = f.get();

            // this should always get exactly 1 row
            if (!r.isExhausted()) {
                AggregateNumericMetric aggregate = mapper.mapOne(r);
                result.add(aggregate);
            }
        }
View Full Code Here


     * This method moves to the next page of data if one exists. If the result set is empty, we query the next
     * partition. If we have queried the last partition, then we wrap around to the first partition of the next time
     * slice. We continue searching for a non-empty result set until  we hit endTime.
     */
    private void nextPage(ResultSet resultSet) {
        ResultSet nextResultSet = resultSet;
        while (nextResultSet.isExhausted() && time.isBefore(endTime)) {
            if (partition < numPartitions - 1) {
                ++partition;
            } else {
                partition = 0;
                time = time.plus(duration);
            }
            nextResultSet = findIndexEntries();
        }
        if (time.isBefore(endTime)) {
            List<Row> rows = nextResultSet.all();
            rowCount = rows.size();
            rowIterator = rows.iterator();
        } else {
            rowCount = 0;
            rowIterator = Iterators.emptyIterator();
View Full Code Here

    }

    public List<RawNumericMetric> findRawMetrics(int scheduleId, long startTime, long endTime) {
        RawNumericMetricMapper mapper = new RawNumericMetricMapper();
        BoundStatement boundStatement = rawMetricsQuery.bind(scheduleId, new Date(startTime), new Date(endTime));
        ResultSet resultSet = storageSession.execute(boundStatement);

        return mapper.mapAll(resultSet);
    }
View Full Code Here

    }

    public RawNumericMetric findLatestRawMetric(int scheduleId) {
        RawNumericMetricMapper mapper = new RawNumericMetricMapper();
        BoundStatement boundStatement = findLatestRawMetric.bind(scheduleId);
        ResultSet resultSet = storageSession.execute(boundStatement);

        return mapper.mapOne(resultSet);
    }
View Full Code Here

    public List<AggregateNumericMetric> findAggregateMetrics(int scheduleId, Bucket bucket, long startTime,
        long endTime) {
        BoundStatement statement = findAggregateMetricsByDateRange.bind(scheduleId, bucket.toString(),
            new Date(startTime), new Date(endTime));
        ResultSet resultSet = storageSession.execute(statement);
        AggregateNumericMetricMapper mapper = new AggregateNumericMetricMapper();
        return mapper.mapAll(resultSet);
    }
View Full Code Here

        DateTime endTime = hour(3);
        RawNumericMetricMapper mapper = new RawNumericMetricMapper();
        Map<Integer, List<RawNumericMetric>> rawDataMp = new HashMap<Integer, List<RawNumericMetric>>(100);

        for (int i = 0; i < NUM_SCHEDULES; ++i) {
            ResultSet resultSet = dao.findRawMetricsSync(i, startTime.getMillis(), endTime.getMillis());
            rawDataMp.put(i, mapper.mapAll(resultSet));
        }

        log.info("Finished raw data sync query in " + (System.currentTimeMillis() - start) + " ms");
    }
View Full Code Here

        assertRawDataEquals(scheduleId, startTime, endTime, emptyRaws);
    }

    protected void assertRawDataEquals(int scheduleId, DateTime startTime, DateTime endTime,
        List<RawNumericMetric> expected) {
        ResultSet resultSet = dao.findRawMetricsAsync(scheduleId, startTime.getMillis(), endTime.getMillis()).get();
        List<RawNumericMetric> actual = rawMapper.mapAll(resultSet);

        assertEquals(actual, expected, "The raw metrics do not match the expected value");

    }
View Full Code Here

    protected void assertMetricDataEquals(int scheduleId, Bucket bucket, AggregateNumericMetric... expected) {
        assertMetricDataEquals(scheduleId, bucket, asList(expected));
    }

    protected void assertMetricDataEquals(int scheduleId, Bucket bucket, List<AggregateNumericMetric> expected) {
        ResultSet resultSet = session.execute(
            "select schedule_id, bucket, time, avg, max, min " +
            "from " + MetricsTable.AGGREGATE + " " +
            "where schedule_id = " + scheduleId + " and bucket = '" + bucket + "'");
        List<AggregateNumericMetric> actual = aggregateMapper.mapAll(resultSet);
        assertCollectionMatchesNoOrder("Metric data for schedule id " + scheduleId + " in bucket " + bucket +
View Full Code Here

            assert24HourDataEmpty(scheduleId);
        }
    }

    private void assertMetricDataEmpty(int scheduleId, Bucket bucket) {
        ResultSet resultSet = session.execute(
            "select schedule_id, bucket, time, avg, max, min " +
            "from " + MetricsTable.AGGREGATE + " " +
            "where schedule_id = " + scheduleId + " and bucket = '" + bucket + "'");
        List<AggregateNumericMetric> metrics = aggregateMapper.mapAll(resultSet);
View Full Code Here

        dao.updateIndex(IndexBucket.RAW, hour(2).getMillis(), 105).get();

        List<IndexEntry> expected = asList(entry1, entry2);
        List<IndexEntry> actual = new ArrayList<IndexEntry>();

        ResultSet resultSet = dao.findIndexEntries(IndexBucket.RAW, 0, hour(2).getMillis()).get();
        for (Row row : resultSet) {
            actual.add(new IndexEntry(IndexBucket.RAW, 0, hour(2).getMillis(), row.getInt(0)));
        }
        assertEquals(actual, expected, "The first page of index entries is wrong");
        actual.clear();
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.ResultSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.