Search in sources :

Example 56 with ResultSet

use of com.datastax.driver.core.ResultSet in project stargate-core by tuplejump.

the class AggregatesTest method shouldCalculateQuantileAggregate.

//    @Test
public void shouldCalculateQuantileAggregate() throws Exception {
    try {
        createEventStoreSchema(keyspace);
        String quantileQuery = "SELECT stargate FROM " + keyspace + ".event_store WHERE stargate = '{ function:{ type:\"aggregate\", aggregates:[{type:\"quantile\",field:\"measures.connection\"}], groupBy:[\"dimensions._browser\"]  }}' ;";
        ResultSet rows = getSession().execute(quantileQuery);
        printResultSet(true, rows);
        String quantileQuery2 = "SELECT stargate FROM " + keyspace + ".event_store WHERE stargate = '{ function:{ type:\"aggregate\", aggregates:[{type:\"sum\",field:\"measures.connection\"}]}}' ;";
        ResultSet rows2 = getSession().execute(quantileQuery2);
        printResultSet(true, rows2);
    } finally {
        dropKS(keyspace);
    }
}
Also used : ResultSet(com.datastax.driver.core.ResultSet)

Example 57 with ResultSet

use of com.datastax.driver.core.ResultSet in project stargate-core by tuplejump.

the class BasicIndexTest method shouldReportErrorRow.

@Test
public void shouldReportErrorRow() throws Exception {
    //hack to always create new Index during testing
    try {
        createKS(keyspace);
        createTableAndIndexForRow();
        ResultSet rs = getResults("TAG2", "magic = 'test'", true);
        List<Row> rows = rs.all();
        Assert.assertEquals(true, rows.toString().contains("error"));
    } finally {
        dropTable(keyspace, "TAG2");
        dropKS(keyspace);
    }
}
Also used : ResultSet(com.datastax.driver.core.ResultSet) Row(com.datastax.driver.core.Row) Test(org.junit.Test)

Example 58 with ResultSet

use of com.datastax.driver.core.ResultSet in project stargate-core by tuplejump.

the class DateIndexTest method shouldWorkForDateColumn.

@Test
public void shouldWorkForDateColumn() throws Exception {
    try {
        createEventStoreSchema(keyspace);
        //query that groups by 10mins granularity
        String query = "SELECT stargate FROM " + keyspace + ".event_store WHERE stargate = '{ function:{ type:\"aggregate\", aggregates:[{type:\"count\",field:\"event_id\"}], groupBy:[\"return DateUtils.getTimeByGranularity(event_ts,600000)\"],imports:[\"com.tuplejump.stargate.lucene\"]  }}' ;";
        ResultSet rows = getSession().execute(query);
        printResultSet(true, rows);
    } finally {
    // dropKS(keyspace);
    }
}
Also used : ResultSet(com.datastax.driver.core.ResultSet) Test(org.junit.Test)

Example 59 with ResultSet

use of com.datastax.driver.core.ResultSet in project stargate-core by tuplejump.

the class IndexTestBase method countStarResults.

protected int countStarResults(String tName, String where, boolean hasWhr, boolean log) {
    long before = System.nanoTime();
    String select = "select count(*) from ";
    String query = select + tName + (hasWhr ? (" where " + where) : "") + " ";
    ResultSet result = getSession().execute(query);
    long after = System.nanoTime();
    double taken = (after - before) / 1000000;
    if (log)
        logger.warn("Search for -" + query + " - results -");
    int count1 = printResultSet(log, result);
    System.out.println("Search query[" + query + "] in [" + taken + "] ms - count [" + count1 + "]");
    return count1;
}
Also used : ResultSet(com.datastax.driver.core.ResultSet)

Example 60 with ResultSet

use of com.datastax.driver.core.ResultSet in project stargate-core by tuplejump.

the class CQLDataLoaderD method initKeyspaceContext.

protected void initKeyspaceContext(Session session, CQLDataSet dataSet) {
    String keyspaceName = DEFAULT_KEYSPACE_NAME;
    if (dataSet.getKeyspaceName() != null) {
        keyspaceName = dataSet.getKeyspaceName();
    }
    log.debug("initKeyspaceContext : " + "keyspaceDeletion=" + dataSet.isKeyspaceDeletion() + "keyspaceCreation=" + dataSet.isKeyspaceCreation() + ";keyspaceName=" + keyspaceName);
    if (dataSet.isKeyspaceDeletion()) {
        String selectQuery = "SELECT keyspace_name FROM system.schema_keyspaces where keyspace_name='" + keyspaceName + "'";
        ResultSet keyspaceQueryResult = session.execute(selectQuery);
        if (keyspaceQueryResult.iterator().hasNext()) {
            String dropQuery = "DROP KEYSPACE " + keyspaceName;
            log.debug("executing : " + dropQuery);
            session.execute(dropQuery);
        }
    }
    if (dataSet.isKeyspaceCreation()) {
        String createQuery = "CREATE KEYSPACE " + keyspaceName + " WITH replication={'class' : 'SimpleStrategy', 'replication_factor':1}";
        log.debug("executing : " + createQuery);
        session.execute(createQuery);
    }
    String useQuery = "USE " + keyspaceName;
    log.debug("executing : " + useQuery);
    session.execute(useQuery);
}
Also used : ResultSet(com.datastax.driver.core.ResultSet)

Aggregations

ResultSet (com.datastax.driver.core.ResultSet)64 Row (com.datastax.driver.core.Row)35 Test (org.junit.Test)25 BoundStatement (com.datastax.driver.core.BoundStatement)11 Session (com.datastax.driver.core.Session)10 ArrayList (java.util.ArrayList)9 Cluster (com.datastax.driver.core.Cluster)8 Statement (com.datastax.driver.core.Statement)7 PreparedStatement (com.datastax.driver.core.PreparedStatement)5 List (java.util.List)5 ResultSetFuture (com.datastax.driver.core.ResultSetFuture)4 Select (com.datastax.driver.core.querybuilder.Select)4 TypeHint (org.apache.flink.api.common.typeinfo.TypeHint)4 BatchStatement (com.datastax.driver.core.BatchStatement)3 RegularStatement (com.datastax.driver.core.RegularStatement)3 Update (com.datastax.driver.core.querybuilder.Update)3 ImmutableList (com.google.common.collect.ImmutableList)3 IgniteException (org.apache.ignite.IgniteException)3 RandomSleeper (org.apache.ignite.cache.store.cassandra.common.RandomSleeper)3 ColumnDefinitions (com.datastax.driver.core.ColumnDefinitions)2