public String readEvent(String db, String table, String prefix,String startTime, String endTime) {
JsonObject tbl = meta.runQuery(EntityType.SERIES, db+"."+table);
if (tbl == null) throw new RuntimeException("Table "+table+" does not exist");
JsonObject storageConf = meta.getStorageForTable(db+"."+table);
if (storageConf == null) throw new RuntimeException("Storage for "+table+" does not exist");
PaasConnection conn = fac.createConnection(storageConf,db);
String periodicity = tbl.getString("periodicity");
Long time = Long.parseLong(startTime);
Long startTimekey = (time/Long.parseLong(periodicity))*Long.parseLong(periodicity);
Long endTimeL = Long.parseLong(endTime);
Long endTimeKey = (endTimeL/Long.parseLong(periodicity))*Long.parseLong(periodicity);
if (prefix != null && !prefix.equals("")) prefix = prefix+":"; else prefix = "";
JsonObject response = new JsonObject();
for (Long current = startTimekey; current < endTimeKey;current = current+Long.parseLong(periodicity) ) {
JsonObject slice = new JsonObject(conn.read(db,table,"key",prefix+String.valueOf(current)));
for (String field:slice.getFieldNames()) {
response.putString(field, slice.getString(field));
}
}
return response.toString();