Commit 90880fb2 authored by Melanie Bruns's avatar Melanie Bruns
Browse files

Merge branch 'feature-#598-undo-deletion-threshold' into 'master'

Revert "Use x^21 instead of x^3"

See merge request !158
parents 906e60e7 52f7e388
Pipeline #16603 passed with stages
in 4 minutes and 38 seconds
......@@ -20,9 +20,7 @@ import java.util.stream.Collectors;
* Created by melanie on 07.04.17.
*/
public class LocalDatabase {
/** Utility threshold for deletion is computed using (used db percentage)^{THRESHOLD_EXPONENT}.*/
private static final int THRESHOLD_EXPONENT = 21;
private static final int CUBIC = 3;
private static final int METERS_IN_KILOMETER = 1000;
private static final int SECONDS_IN_HOUR = 3600;
......@@ -117,7 +115,7 @@ public class LocalDatabase {
* @return A threshold between 0 and 1 that is 0 for empty memory and 1 for full memory.
*/
private double computeDeletionThreshold() {
return Math.pow(getUsedMemoryPercentage(), THRESHOLD_EXPONENT);
return Math.pow(getUsedMemoryPercentage(), CUBIC);
}
/**
......
......@@ -36,8 +36,8 @@ public class DatabaseStatisticsTest {
private static final double HALF_AN_HOUR_LATER =3600;
/* Used locations for all DB operations. */
private static final Coord CURR_LOCATION = new Coord(3000, 4000);
private static final Coord CLOSE_TO_CURR_LOCATION = new Coord(4000, 4000);
private static final Coord CURR_LOCATION = new Coord(300, 400);
private static final Coord CLOSE_TO_CURR_LOCATION = new Coord(400, 400);
private static final Coord ORIGIN = new Coord(0,0);
/* Sizes for data items */
......
......@@ -27,10 +27,10 @@ import java.util.List;
public class EpidemicRouterTest extends AbstractRouterTest {
private static int TTL = 300;
private static final int NINE_HOURS = 9 * 60 * 60;
private static final int THREE_HOURS = 10_800;
/* Data base item sizes needed for tests. */
private static final int DB_SIZE = 100;
private static final int DB_SIZE = 50;
private static final int SMALL_SIZE_DIFFERENCE = 2;
private static final String EXPECTED_DATA_MESSAGE = "Data message should have been sent.";
......@@ -330,7 +330,7 @@ public class EpidemicRouterTest extends AbstractRouterTest {
assertEquals("Expected other data item to be sent.", data, message.getData().get(0));
// Add another, large one to replace the original object. It is more useful so it stays in the database.
this.clock.advance(NINE_HOURS);
this.clock.advance(THREE_HOURS);
DisasterData newData = new DisasterData(
DisasterData.DataType.SKILL, DB_SIZE - SMALL_SIZE_DIFFERENCE, SimClock.getTime(), h1.getLocation());
this.setUpAsDataCarrier(h1, newData);
......
......@@ -20,7 +20,7 @@ import java.util.List;
* Created by Britta Heymann on 09.04.2017.
*/
public class LocalDatabaseTest {
private static final int DB_SIZE = 1000;
private static final int DB_SIZE = 100;
/* Used locations for all DB operations. */
private static final Coord CURR_LOCATION = new Coord(300, 400);
......
Supports Markdown
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