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);
}
}
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);
}
}
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);
}
}
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;
}
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);
}
Aggregations