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

bugfix

parent 9139d122
No related branches found
No related tags found
No related merge requests found
...@@ -13,7 +13,7 @@ import java.util.List; ...@@ -13,7 +13,7 @@ import java.util.List;
public class DataUtil { public class DataUtil {
private static final int NB_ROWS_SAMPLING = 200; private static final int MAX_NB_SAMPLES = 200;
private static final int TABLESAMPLE_SEED = 42; private static final int TABLESAMPLE_SEED = 42;
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
...@@ -32,12 +32,12 @@ public class DataUtil { ...@@ -32,12 +32,12 @@ public class DataUtil {
for (String var : vars) { for (String var : vars) {
JsonArray currentVarData = new JsonArray(); JsonArray currentVarData = new JsonArray();
int nbRows = (int) countDatasetRows(); int nbRows = (int) countDatasetRows();
if (nbRows < 1) if (nbRows < 1) { return data; }
{
return data; int nb_samples = Math.min(nbRows, MAX_NB_SAMPLES);
} int samplingPercentage = 100 * nb_samples / nbRows;
int samplingPercentage = 100 * NB_ROWS_SAMPLING / nbRows;
List<Object> queryResult = jdbcTemplate.queryForList( List<Object> queryResult = jdbcTemplate.queryForList(
"SELECT " + var + " FROM "+scienceMainTable+" " + "SELECT " + var + " FROM "+scienceMainTable+" " +
"TABLESAMPLE SYSTEM ("+ samplingPercentage +") REPEATABLE ( "+ TABLESAMPLE_SEED +" )", Object.class); "TABLESAMPLE SYSTEM ("+ samplingPercentage +") REPEATABLE ( "+ TABLESAMPLE_SEED +" )", Object.class);
......
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