diff --git a/data-store/src/main/java/org/lucares/pdb/datastore/lang/QueryCompletionPdbLangParser.java b/data-store/src/main/java/org/lucares/pdb/datastore/lang/QueryCompletionPdbLangParser.java index d0c61fb..b9beb10 100644 --- a/data-store/src/main/java/org/lucares/pdb/datastore/lang/QueryCompletionPdbLangParser.java +++ b/data-store/src/main/java/org/lucares/pdb/datastore/lang/QueryCompletionPdbLangParser.java @@ -69,12 +69,10 @@ public class QueryCompletionPdbLangParser extends PdbLangParser { return new Proposal(v, newQuery.toString(), false, newQuery.toString(), start + v.length() + 1); }).map(p -> { - int count = 0; + int count = 0; try { count = dataStore.count(p.getProposedQuery()); - } - catch(SyntaxException e) - { + } catch (final SyntaxException e) { // ignore: if the query is not valid, then it does not find any results } return new Proposal(p, count > 0); @@ -139,23 +137,7 @@ public class QueryCompletionPdbLangParser extends PdbLangParser { return new Proposal(key, String.format(newQueryPattern, key + "=* "), true, newQuery, newCaretPosition); - }) -// .map(p -> { -// -// final String proposedQuery = p.getProposedQuery(); -// final int count = count(proposedQuery); -// return new Proposal(p, count > 0); -// }) - .forEach(proposals::add); - } - - private int count(final String proposedQuery) { - - try { - return dataStore.count(proposedQuery); - } catch (final SyntaxException e) { - return -1; - } + }).forEach(proposals::add); } private boolean isEOF(final Object offendingSymbol) { diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/PlotSettings.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/PlotSettings.java index 096a9d3..888c59b 100644 --- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/PlotSettings.java +++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/PlotSettings.java @@ -38,6 +38,10 @@ public class PlotSettings { private AggregateHandler aggregate; + private int yRangeMin; + private int yRangeMax; + private TimeRangeUnitInternal yRangeUnit = TimeRangeUnitInternal.AUTOMATIC; + private boolean keyOutside; private boolean generateThumbnail; @@ -183,7 +187,9 @@ public class PlotSettings { return "PlotSettings [query=" + query + ", height=" + height + ", width=" + width + ", thumbnailMaxWidth=" + thumbnailMaxWidth + ", thumbnailMaxHeight=" + thumbnailMaxHeight + ", groupBy=" + groupBy + ", limitBy=" + limitBy + ", limit=" + limit + ", dateFrom=" + dateFrom + ", dateRange=" + dateRange - + ", yAxisScale=" + yAxisScale + ", aggregate=" + aggregate + ", keyOutside=" + keyOutside + "]"; + + ", yAxisScale=" + yAxisScale + ", aggregate=" + aggregate + ", yRangeMin=" + yRangeMin + + ", yRangeMax=" + yRangeMax + ", yRangeUnit=" + yRangeUnit + ", keyOutside=" + keyOutside + + ", generateThumbnail=" + generateThumbnail + "]"; } public void setAggregate(final AggregateHandler aggregate) { @@ -209,4 +215,29 @@ public class PlotSettings { public boolean isGenerateThumbnail() { return generateThumbnail; } + + public int getYRangeMin() { + return yRangeMin; + } + + public void setYRangeMin(final int yRangeMin) { + this.yRangeMin = yRangeMin; + } + + public int getYRangeMax() { + return yRangeMax; + } + + public void setYRangeMax(final int yRangeMax) { + this.yRangeMax = yRangeMax; + } + + public TimeRangeUnitInternal getYRangeUnit() { + return yRangeUnit; + } + + public void setYRangeUnit(final TimeRangeUnitInternal yRangeUnit) { + this.yRangeUnit = yRangeUnit; + } + } diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/TimeRangeUnitInternal.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/TimeRangeUnitInternal.java new file mode 100644 index 0000000..362736b --- /dev/null +++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/TimeRangeUnitInternal.java @@ -0,0 +1,24 @@ +package org.lucares.pdb.plot.api; + +public enum TimeRangeUnitInternal { + AUTOMATIC, MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS; + + public int toMilliSeconds(final int value) { + + switch (this) { + case MILLISECONDS: + return value; + case SECONDS: + return value * 1000; + case MINUTES: + return value * 60 * 1000; + case HOURS: + return value * 60 * 60 * 1000; + case DAYS: + return value * 24 * 60 * 60 * 1000; + case AUTOMATIC: + return Integer.MAX_VALUE; + } + return Integer.MAX_VALUE; + } +} diff --git a/pdb-plotting/src/main/java/org/lucares/recommind/logs/GnuplotFileGenerator.java b/pdb-plotting/src/main/java/org/lucares/recommind/logs/GnuplotFileGenerator.java index 05b4cbe..56b16c1 100644 --- a/pdb-plotting/src/main/java/org/lucares/recommind/logs/GnuplotFileGenerator.java +++ b/pdb-plotting/src/main/java/org/lucares/recommind/logs/GnuplotFileGenerator.java @@ -28,8 +28,14 @@ public class GnuplotFileGenerator { appendfln(result, "set xlabel \"%s\"", xAxis.getXlabel()); appendfln(result, "set xrange [\"%s\":\"%s\"]", xAxis.getFrom(), xAxis.getTo()); - final long graphOffset = settings.getYAxisScale() == AxisScale.LINEAR ? 0 : 1; - appendfln(result, "set yrange [\"" + graphOffset + "\":]"); + final int graphOffset = settings.getYAxisScale() == AxisScale.LINEAR ? 0 : 1; + if (settings.hasYRange()) { + final int min = Math.max(settings.getYRangeMin(), graphOffset); + final int max = settings.getYRangeMax(); + appendfln(result, String.format("set yrange [\"%d\":\"%d\"]", min, max)); + } else { + appendfln(result, "set yrange [\"" + graphOffset + "\":]"); + } appendfln(result, "set ylabel \"%s\"", settings.getYlabel()); switch (settings.getYAxisScale()) { diff --git a/pdb-plotting/src/main/java/org/lucares/recommind/logs/GnuplotSettings.java b/pdb-plotting/src/main/java/org/lucares/recommind/logs/GnuplotSettings.java index 954f653..d7543b6 100644 --- a/pdb-plotting/src/main/java/org/lucares/recommind/logs/GnuplotSettings.java +++ b/pdb-plotting/src/main/java/org/lucares/recommind/logs/GnuplotSettings.java @@ -26,6 +26,8 @@ public class GnuplotSettings { private XAxisSettings xAxisSettings = new XAxisSettings(); private boolean renderLabels = true; + private int yRangeMin = -1; + private int yRangeMax = -1; public GnuplotSettings(final Path output) { this.output = output; @@ -123,6 +125,23 @@ public class GnuplotSettings { return renderLabels; } + public boolean hasYRange() { + return yRangeMin >= 0 && yRangeMax >= 0 && yRangeMin < yRangeMax; + } + + public void setYRange(final int yRangeMin, final int yRangeMax) { + this.yRangeMin = yRangeMin; + this.yRangeMax = yRangeMax; + } + + public int getYRangeMin() { + return yRangeMin; + } + + public int getYRangeMax() { + return yRangeMax; + } + // plot 'sample.txt' using 1:2 title 'Bytes' with linespoints 2 } diff --git a/pdb-plotting/src/main/java/org/lucares/recommind/logs/ScatterPlot.java b/pdb-plotting/src/main/java/org/lucares/recommind/logs/ScatterPlot.java index fb4334b..aa17ba7 100644 --- a/pdb-plotting/src/main/java/org/lucares/recommind/logs/ScatterPlot.java +++ b/pdb-plotting/src/main/java/org/lucares/recommind/logs/ScatterPlot.java @@ -30,6 +30,7 @@ import org.lucares.pdb.api.Tags; import org.lucares.pdb.plot.api.CustomAggregator; import org.lucares.pdb.plot.api.Limit; import org.lucares.pdb.plot.api.PlotSettings; +import org.lucares.pdb.plot.api.TimeRangeUnitInternal; import org.lucares.performance.db.PerformanceDb; import org.lucares.utils.file.FileUtils; import org.slf4j.Logger; @@ -120,6 +121,8 @@ public class ScatterPlot { gnuplotSettings.setYAxisScale(plotSettings.getYAxisScale()); gnuplotSettings.setAggregate(plotSettings.getAggregate()); + defineYRange(gnuplotSettings, plotSettings.getYRangeMin(), plotSettings.getYRangeMax(), + plotSettings.getYRangeUnit()); gnuplotSettings.setKeyOutside(plotSettings.isKeyOutside()); gnuplot.plot(gnuplotSettings, dataSeries); } @@ -135,6 +138,8 @@ public class ScatterPlot { gnuplotSettings.setYAxisScale(plotSettings.getYAxisScale()); gnuplotSettings.setAggregate(plotSettings.getAggregate()); + defineYRange(gnuplotSettings, plotSettings.getYRangeMin(), plotSettings.getYRangeMax(), + plotSettings.getYRangeUnit()); gnuplotSettings.setKeyOutside(false); gnuplotSettings.renderLabels(false); gnuplot.plot(gnuplotSettings, dataSeries); @@ -154,6 +159,16 @@ public class ScatterPlot { } } + private void defineYRange(final GnuplotSettings gnuplotSettings, final int yRangeMin, final int yRangeMax, + final TimeRangeUnitInternal yRangeUnit) { + + if (yRangeUnit != TimeRangeUnitInternal.AUTOMATIC) { + final int min = yRangeUnit.toMilliSeconds(yRangeMin); + final int max = yRangeUnit.toMilliSeconds(yRangeMax); + gnuplotSettings.setYRange(min, max); + } + } + private void defineXAxis(final GnuplotSettings gnuplotSettings, final OffsetDateTime minDate, final OffsetDateTime maxDate) { diff --git a/pdb-ui/src/main/java/org/lucares/pdbui/domain/PlotRequest.java b/pdb-ui/src/main/java/org/lucares/pdbui/domain/PlotRequest.java index e3e2a4d..77c1e6e 100644 --- a/pdb-ui/src/main/java/org/lucares/pdbui/domain/PlotRequest.java +++ b/pdb-ui/src/main/java/org/lucares/pdbui/domain/PlotRequest.java @@ -30,6 +30,10 @@ public class PlotRequest { private Aggregate aggregate = Aggregate.NONE; + private int yRangeMin; + private int yRangeMax; + private TimeRangeUnit yRangeUnit = TimeRangeUnit.AUTOMATIC; + private boolean keyOutside; private boolean generateThumbnail; @@ -154,4 +158,27 @@ public class PlotRequest { this.generateThumbnail = generateThumbnail; } + public int getyRangeMin() { + return yRangeMin; + } + + public void setyRangeMin(final int yRangeMin) { + this.yRangeMin = yRangeMin; + } + + public int getyRangeMax() { + return yRangeMax; + } + + public void setyRangeMax(final int yRangeMax) { + this.yRangeMax = yRangeMax; + } + + public TimeRangeUnit getyRangeUnit() { + return yRangeUnit; + } + + public void setyRangeUnit(final TimeRangeUnit yRangeUnit) { + this.yRangeUnit = yRangeUnit; + } } diff --git a/pdb-ui/src/main/java/org/lucares/pdbui/domain/TimeRangeUnit.java b/pdb-ui/src/main/java/org/lucares/pdbui/domain/TimeRangeUnit.java new file mode 100644 index 0000000..406ab36 --- /dev/null +++ b/pdb-ui/src/main/java/org/lucares/pdbui/domain/TimeRangeUnit.java @@ -0,0 +1,5 @@ +package org.lucares.pdbui.domain; + +public enum TimeRangeUnit { + AUTOMATIC, MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS +} diff --git a/pdb-ui/src/main/resources/resources/css/design.css b/pdb-ui/src/main/resources/resources/css/design.css index 2fdab3d..3f8ef2a 100644 --- a/pdb-ui/src/main/resources/resources/css/design.css +++ b/pdb-ui/src/main/resources/resources/css/design.css @@ -124,8 +124,8 @@ textarea { background: lightgrey; } -#search-limit-value { - width: 4em; +.number-input-1k { + width: 3em; } .input_date { diff --git a/pdb-ui/src/main/resources/resources/js/ui.js b/pdb-ui/src/main/resources/resources/js/ui.js index 19f5ea3..74fca00 100644 --- a/pdb-ui/src/main/resources/resources/js/ui.js +++ b/pdb-ui/src/main/resources/resources/js/ui.js @@ -599,6 +599,9 @@ Vue.component('search-bar', { 'dateRange': data.searchBar.dateRange, 'axisScale': data.searchBar.axisScale, 'aggregate': data.searchBar.aggregate, + 'yRangeMin': data.searchBar.yRange.min, + 'yRangeMax': data.searchBar.yRange.max, + 'yRangeUnit': data.searchBar.yRange.unit, 'keyOutside': data.searchBar.keyOutside, }; @@ -640,9 +643,10 @@ Vue.component('search-bar', { @@ -695,6 +699,34 @@ Vue.component('search-bar', { +
+ + + + +
+
@@ -775,6 +807,11 @@ var data = { dateRange: GetURLParameter('dateRange','1 week'), axisScale: GetURLParameter('axisScale','LOG10'), aggregate: GetURLParameter('aggregate','NONE'), + yRange: { + min: GetURLParameter('yRangeMin','0'), + max: GetURLParameter('yRangeMax','999'), + unit: GetURLParameter('yRangeUnit','AUTOMATIC') + }, keyOutside: GetURLParameterBoolean('keyOutside', 'false'), splitBy: { @@ -879,6 +916,9 @@ function createRequest(query, generateThumbnail){ request['aggregate'] = data.searchBar.aggregate; request['keyOutside'] = data.searchBar.keyOutside; request['generateThumbnail'] = generateThumbnail; + request['yRangeMin'] = data.searchBar.yRange.min; + request['yRangeMax'] = data.searchBar.yRange.max; + request['yRangeUnit'] = data.searchBar.yRange.unit; return request; } @@ -928,6 +968,9 @@ function updateImageLink(query) { 'dateRange': data.searchBar.dateRange, 'axisScale': data.searchBar.axisScale, 'aggregate': data.searchBar.aggregate, + 'yRangeMin': data.searchBar.yRange.min, + 'yRangeMax': data.searchBar.yRange.max, + 'yRangeUnit': data.searchBar.yRange.unit, 'keyOutside': data.searchBar.keyOutside, 'width': Math.floor($('#result').width()), 'height': Math.floor($('#result').height())