diff --git a/CHANGELOG.md b/CHANGELOG.md index 74df120d051b1f33e209c3b123897b0d2e33b298..e7e632c551b7f062408d007e6982c30985ee9740 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ Upcoming version: ----------------- + - fixed problems with node queue creation (added missing case) (Nikolaus Krismer) - fixed broken tests (Nikolaus Krismer) - slightly reworked speed estimatino (added abstract classes to improve class hierarchy) (Nikolaus Krismer) - also changed speed estimation for cycling mode (Nikolaus Krismer) diff --git a/src/main/java/it/unibz/inf/isochrone/algorithm/queue/NodeQueueFactory.java b/src/main/java/it/unibz/inf/isochrone/algorithm/queue/NodeQueueFactory.java index e2d2097c21292eac7ca683132cc8c0f5738e1495..2df63c21594bbb97d940f46423e64ed9a7aa90fa 100644 --- a/src/main/java/it/unibz/inf/isochrone/algorithm/queue/NodeQueueFactory.java +++ b/src/main/java/it/unibz/inf/isochrone/algorithm/queue/NodeQueueFactory.java @@ -7,14 +7,26 @@ public final class NodeQueueFactory { private NodeQueueFactory() { } public static <T extends INode> INodeQueue<T> getInstance(final QueueType type) { - if (type == QueueType.BINARY_HEAP) { - return new NodeQueueBinaryHeap<>(); + final INodeQueue<T> result; + switch (type) { + case BINARY_HEAP: + result = new NodeQueueBinaryHeap<>(); + break; + case FIBONACCI_HEAP: + result = new NodeQueueFibonacciHeap<>(); + break; + case PRIORITY_QUEUE: + result = new NodeQueuePriorityQueue<>(); + break; + default: + result = null; } - if (type == QueueType.FIBONACCI_HEAP) { - return new NodeQueueFibonacciHeap<>(); + + if (result == null) { + throw new IllegalStateException("Unsupported queue type \"" + type + "\" specified!"); } - throw new IllegalStateException("Unsupported queue type specified!"); + return result; } } diff --git a/src/main/java/it/unibz/inf/isochrone/db/Database.java b/src/main/java/it/unibz/inf/isochrone/db/Database.java index cc2ca5dfc7025fbb1d41697513094fad17311885..976f3a4d3d0781483fe9902b5c529a514f83167d 100644 --- a/src/main/java/it/unibz/inf/isochrone/db/Database.java +++ b/src/main/java/it/unibz/inf/isochrone/db/Database.java @@ -12,7 +12,6 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.sql.Statement; import java.sql.Wrapper; import java.time.DayOfWeek; import java.time.LocalDate; @@ -1021,8 +1020,8 @@ public class Database implements AutoCloseable { int result = -1; try ( - Statement stmt = getConnection().createStatement(); - ResultSet rs = stmt.executeQuery(dbQuery.getSql()); + PreparedStatement stmt = getPstmt(dbQuery.getSql()); + ResultSet rs = stmt.executeQuery(); ) { if (rs.next()) { result = rs.getInt(1); diff --git a/src/performance/java/it/unibz/inf/isochrone/plot/sample/SampleRunner.java b/src/performance/java/it/unibz/inf/isochrone/plot/sample/SampleRunner.java index 9ea9c41d8602add0e551677eaae23f5f59c8797e..aa5f792b7337e566e24c6482d729e347b0cff216 100644 --- a/src/performance/java/it/unibz/inf/isochrone/plot/sample/SampleRunner.java +++ b/src/performance/java/it/unibz/inf/isochrone/plot/sample/SampleRunner.java @@ -280,7 +280,7 @@ public final class SampleRunner { public <T extends MemoryOutput> void sample( final Logger logger, final Function<TestConfiguration, AlgorithmResult<T>> fn, - final Collection<Algorithm> classes, + final Collection<Algorithm> algorithms, final Object... params ) { final Set<Entry<String, Collection<ConfigAlgorithm>>> datasets = dsConfigurations.entrySet(); @@ -289,7 +289,7 @@ public final class SampleRunner { final Map<Algorithm, Map<SampleProperty, Long>> propertyDurationSums = new HashMap<>(); final Map<Algorithm, Map<SampleProperty, Long>> propertyNodeSums = new HashMap<>(); - for (final Algorithm algorithm : classes) { + for (final Algorithm alg : algorithms) { final Map<SampleProperty, Long> pd = new EnumMap<>(SampleProperty.class); final Map<SampleProperty, Long> pn = new EnumMap<>(SampleProperty.class); @@ -298,19 +298,19 @@ public final class SampleRunner { pn.put(p, 0L); } - propertyDurationSums.put(algorithm, pd); - propertyNodeSums.put(algorithm, pn); + propertyDurationSums.put(alg, pd); + propertyNodeSums.put(alg, pn); } final Collection<ConfigAlgorithm> configAlgorithms = dataset.getValue(); for (final ConfigAlgorithm config : configAlgorithms) { - for (final Algorithm algorithm : classes) { - final String algorithmName = algorithm.toString() + nameSuffix; + for (final Algorithm alg : algorithms) { + final String algorithmName = alg.toString() + nameSuffix; final LimitType limitType = config.getLimitType(); final long limitValue = config.getLimit(); final String limitTypeName = limitType.name().toLowerCase(Locale.ENGLISH); - final TestConfiguration testConf = new TestConfiguration(algorithm, dsName, config, params); + final TestConfiguration testConf = new TestConfiguration(alg, dsName, config, params); logger.info("Executing \"{}\" for dataset \"{}\" ({}: {})", algorithmName, dsName, limitTypeName, limitValue); logger.trace(" testConfiguration is {}", testConf); @@ -331,11 +331,11 @@ public final class SampleRunner { final Long pValue = (p == SampleProperty.RUNTIME) ? runtime : p.getSamplingInformation(stats); if (containsDurationSamples) { samples.get(SampleType.DURATION).get(p).add(config.getLimit(), algorithmName, dsName, pValue.doubleValue()); - propertyDurationSums.get(algorithm).put(p, propertyDurationSums.get(algorithm).get(p) + pValue); + propertyDurationSums.get(alg).put(p, propertyDurationSums.get(alg).get(p) + pValue); } if (containsNodeSamples) { samples.get(SampleType.NODES).get(p).add(config.getLimit(), algorithmName, dsName, pValue.doubleValue()); - propertyNodeSums.get(algorithm).put(p, propertyNodeSums.get(algorithm).get(p) + pValue); + propertyNodeSums.get(alg).put(p, propertyNodeSums.get(alg).get(p) + pValue); } } diff --git a/src/performance/resources/performanceTests.xml b/src/performance/resources/performanceTests.xml index 4fb976bc1034f6076d8235b14789986fd29a209c..033daf7ec48cf32131917bceeeb01e1b5a2ef370 100644 --- a/src/performance/resources/performanceTests.xml +++ b/src/performance/resources/performanceTests.xml @@ -10,8 +10,9 @@ <class name="it.unibz.inf.isochrone.algorithm.MemoryTest" /> <class name="it.unibz.inf.isochrone.algorithm.QueryPointRWTest" /> <class name="it.unibz.inf.isochrone.algorithm.QueryPointSyntheticTest" /> - <class name="it.unibz.inf.isochrone.algorithm.TileInformationTest" /> - <class name="it.unibz.inf.isochrone.algorithm.TileSizeTest" /> + <class name="it.unibz.inf.isochrone.algorithm.queue.QueueTypeTest" /> + <class name="it.unibz.inf.isochrone.algorithm.tile.TileInformationTest" /> + <class name="it.unibz.inf.isochrone.algorithm.tile.TileSizeTest" /> <class name="it.unibz.inf.isochrone.db.QueryQuantifierTest" /> <class name="it.unibz.inf.isochrone.db.QueryRuntimeTest" />