Skip to content
Snippets Groups Projects
Commit 9c3c31e6 authored by Mirco Nasuti's avatar Mirco Nasuti
Browse files

only send a sample of the original data to the frontend (200 points)

parent 00b68184
No related branches found
No related tags found
No related merge requests found
......@@ -276,7 +276,7 @@ public class ModelsApi {
datasetRepository.save(model.getDataset());
modelRepository.save(model);
LOGGER.info("Model updated (also saved/updated model.config, model.query and model.dataset)");
LOGGER.info("Model updated (also saved/updated model.config and model.query)");
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
......
......@@ -13,6 +13,8 @@ import java.util.Map;
public class DataUtil {
private static final int NB_ROWS_SAMPLING = 200;
private JdbcTemplate jdbcTemplate;
public DataUtil(JdbcTemplate jdbcTemplate)
......@@ -26,7 +28,10 @@ public class DataUtil {
for (String var : vars) {
JsonArray currentVarData = new JsonArray();
List<Map<String, Object>> queryResult = jdbcTemplate.queryForList("SELECT " + var + " FROM science.adni_merge");
int samplingPercentage = (int) countAdniRows()/NB_ROWS_SAMPLING;
List<Map<String, Object>> queryResult = jdbcTemplate.queryForList(
"SELECT " + var + " FROM science.adni_merge " +
"TABLESAMPLE SYSTEM ("+ samplingPercentage +") REPEATABLE ( 42 )");
for (Map resultMap : queryResult)
{
String strValue = String.valueOf(resultMap.get(var));
......@@ -51,4 +56,11 @@ public class DataUtil {
return count;
}
public long countAdniRows()
{
long count = jdbcTemplate.queryForObject(
"SELECT COUNT(*) FROM science.adni_merge", Long.class);
return count;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment