apply new code formatter and save action

This commit is contained in:
2019-11-24 10:20:43 +01:00
parent 5ea82c6a4c
commit 06b379494f
184 changed files with 13455 additions and 13489 deletions

View File

@@ -159,7 +159,8 @@ public class BSFile implements AutoCloseable {
public void flush() { public void flush() {
LOGGER.trace("flush bsFile={} dirty={} file={}", rootBlockOffset, dirty, diskStorage.getRelativeDatabaseFileForLogging()); LOGGER.trace("flush bsFile={} dirty={} file={}", rootBlockOffset, dirty,
diskStorage.getRelativeDatabaseFileForLogging());
if (dirty) { if (dirty) {
buffer.writeAsync(); buffer.writeAsync();
} }

View File

@@ -27,9 +27,9 @@ public class DiskStorage implements AutoCloseable {
private Path relativeDatabaseFileForLogging; private Path relativeDatabaseFileForLogging;
public DiskStorage(final Path databaseFile, Path storageBasePath) { public DiskStorage(final Path databaseFile, Path storageBasePath) {
this.relativeDatabaseFileForLogging = storageBasePath != null ? storageBasePath.relativize(databaseFile): databaseFile; this.relativeDatabaseFileForLogging = storageBasePath != null ? storageBasePath.relativize(databaseFile)
: databaseFile;
try { try {
Files.createDirectories(databaseFile.getParent()); Files.createDirectories(databaseFile.getParent());

View File

@@ -41,8 +41,8 @@ public class PersistentMapTest {
final String value = "value1"; final String value = "value1";
final String key = "key1"; final String key = "key1";
try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory, PersistentMap.STRING_CODER, try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,
PersistentMap.STRING_CODER)) { PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) {
Assert.assertNull(map.getValue(key)); Assert.assertNull(map.getValue(key));
@@ -50,8 +50,8 @@ public class PersistentMapTest {
Assert.assertEquals(map.getValue(key), value); Assert.assertEquals(map.getValue(key), value);
} }
try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,PersistentMap.STRING_CODER, try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,
PersistentMap.STRING_CODER)) { PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) {
Assert.assertEquals(map.getValue(key), value); Assert.assertEquals(map.getValue(key), value);
} }
@@ -64,8 +64,8 @@ public class PersistentMapTest {
final Random rnd = new Random(1); final Random rnd = new Random(1);
try (final PersistentMap<String, String> map = new PersistentMap<>(file,dataDirectory, PersistentMap.STRING_CODER, try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,
PersistentMap.STRING_CODER)) { PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) {
map.setMaxEntriesInNode(2); map.setMaxEntriesInNode(2);
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
@@ -98,8 +98,8 @@ public class PersistentMapTest {
} }
} }
try (final PersistentMap<String, String> map = new PersistentMap<>(file,dataDirectory, PersistentMap.STRING_CODER, try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,
PersistentMap.STRING_CODER)) { PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) {
// map.print(PersistentMap.STRING_DECODER, PersistentMap.STRING_DECODER); // map.print(PersistentMap.STRING_DECODER, PersistentMap.STRING_DECODER);
final AtomicInteger maxDepth = new AtomicInteger(); final AtomicInteger maxDepth = new AtomicInteger();
map.visitNodeEntriesPreOrder( map.visitNodeEntriesPreOrder(
@@ -179,6 +179,7 @@ public class PersistentMapTest {
} }
} }
@Test(invocationCount = 1) @Test(invocationCount = 1)
public void testManyEmptyValues() throws Exception { public void testManyEmptyValues() throws Exception {
final Path file = dataDirectory.resolve("map.db"); final Path file = dataDirectory.resolve("map.db");
@@ -247,8 +248,8 @@ public class PersistentMapTest {
final Queue<Integer> numbers = new LinkedList<>(Arrays.asList(1, 15, 11, 4, 16, 3, 13)); final Queue<Integer> numbers = new LinkedList<>(Arrays.asList(1, 15, 11, 4, 16, 3, 13));
try (final PersistentMap<String, String> map = new PersistentMap<>(file,dataDirectory, PersistentMap.STRING_CODER, try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,
PersistentMap.STRING_CODER)) { PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) {
final int numbersSize = numbers.size(); final int numbersSize = numbers.size();
for (int i = 0; i < numbersSize; i++) { for (int i = 0; i < numbersSize; i++) {
@@ -275,8 +276,8 @@ public class PersistentMapTest {
} }
} }
try (final PersistentMap<String, String> map = new PersistentMap<>(file,dataDirectory, PersistentMap.STRING_CODER, try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,
PersistentMap.STRING_CODER)) { PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) {
// map.print(PersistentMap.STRING_DECODER, PersistentMap.STRING_DECODER); // map.print(PersistentMap.STRING_DECODER, PersistentMap.STRING_DECODER);
final AtomicInteger counter = new AtomicInteger(); final AtomicInteger counter = new AtomicInteger();
@@ -309,14 +310,14 @@ public class PersistentMapTest {
input.put(UUID.randomUUID().toString(), UUID.randomUUID().toString()); input.put(UUID.randomUUID().toString(), UUID.randomUUID().toString());
} }
try (final PersistentMap<String, String> map = new PersistentMap<>(file,dataDirectory, PersistentMap.STRING_CODER, try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,
PersistentMap.STRING_CODER)) { PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) {
map.putAllValues(input); map.putAllValues(input);
} }
try (final PersistentMap<String, String> map = new PersistentMap<>(file,dataDirectory, PersistentMap.STRING_CODER, try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,
PersistentMap.STRING_CODER)) { PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) {
{ {
final LinkedHashMap<String, String> actualBar = new LinkedHashMap<>(); final LinkedHashMap<String, String> actualBar = new LinkedHashMap<>();

View File

@@ -150,7 +150,8 @@ public class ExpressionToDocIdVisitor extends ExpressionVisitor<PartitionLongLis
final List<LongList> docIdsForPartition = new ArrayList<>(); final List<LongList> docIdsForPartition = new ArrayList<>();
keyToValueToDocId.visitValues(partitionId, new Tag(propertyName, ""), (tags, blockOffsetToDocIds) -> { keyToValueToDocId.visitValues(partitionId, new Tag(propertyName, ""), (tags, blockOffsetToDocIds) -> {
if (valuePattern.matcher(tags.getValueAsString()).matches()) { if (valuePattern.matcher(tags.getValueAsString()).matches()) {
try (final LongStreamFile bsFile = diskStorage.streamExistingFile(blockOffsetToDocIds, partitionId)) { try (final LongStreamFile bsFile = diskStorage.streamExistingFile(blockOffsetToDocIds,
partitionId)) {
// We know that all LongLists coming from a BSFile are sorted, non-overlapping // We know that all LongLists coming from a BSFile are sorted, non-overlapping
// and increasing, that means we can just concatenate them and get a sorted // and increasing, that means we can just concatenate them and get a sorted

View File

@@ -124,7 +124,8 @@ public class ProposerTest {
new Proposal("Jenny", "name =Tim,Jenny", true, "name =Tim,Jenny", 15) // new Proposal("Jenny", "name =Tim,Jenny", true, "name =Tim,Jenny", 15) //
); );
// TODO this case is currently handled completely wrong - it is handled similar to an empty query // TODO this case is currently handled completely wrong - it is handled similar
// to an empty query
// assertProposals("|bird=eagle and name=Tim", ResultMode.FULL_VALUES, // // assertProposals("|bird=eagle and name=Tim", ResultMode.FULL_VALUES, //
// new Proposal("Jennifer", "name =Tim,Jennifer", true, "name =Tim,Jennifer", 18), // // new Proposal("Jennifer", "name =Tim,Jennifer", true, "name =Tim,Jennifer", 18), //
// new Proposal("Jenny", "name =Tim,Jenny", true, "name =Tim,Jenny", 15) // // new Proposal("Jenny", "name =Tim,Jenny", true, "name =Tim,Jenny", 15) //

View File

@@ -1,7 +1,8 @@
package org.lucares.pdb.plot.api; package org.lucares.pdb.plot.api;
/** /**
* Note: The order in this enum defines the order in which the aggregates are drawn. * Note: The order in this enum defines the order in which the aggregates are
* drawn.
*/ */
public enum Aggregate { public enum Aggregate {
PARALLEL, PARALLEL,

View File

@@ -21,7 +21,7 @@ public abstract class AggregateHandler implements Appender {
return xAxis; return xAxis;
} }
public void updateAxis(GnuplotAxis axis) { public void updateAxis(final GnuplotAxis axis) {
switch (axis) { switch (axis) {
case X1: case X1:
case X2: case X2:
@@ -52,12 +52,13 @@ public abstract class AggregateHandler implements Appender {
abstract AxisSettings createYAxisSettings(GnuplotSettings settings, Collection<DataSeries> dataSeries); abstract AxisSettings createYAxisSettings(GnuplotSettings settings, Collection<DataSeries> dataSeries);
abstract void addPlot(StringBuilder result, AggregatedData aggregatedData, LineStyle lineStyle, Optional<String> title); abstract void addPlot(StringBuilder result, AggregatedData aggregatedData, LineStyle lineStyle,
Optional<String> title);
abstract CustomAggregator createCustomAggregator(Path tmpDir, PlotSettings plotSettings, long fromEpochMilli, abstract CustomAggregator createCustomAggregator(Path tmpDir, PlotSettings plotSettings, long fromEpochMilli,
long toEpochMilli); long toEpochMilli);
protected String gnuplotTitle(Optional<String> title) { protected String gnuplotTitle(final Optional<String> title) {
return title.isPresent() ? "title '" + title.get() + "'" : "notitle"; return title.isPresent() ? "title '" + title.get() + "'" : "notitle";
} }

View File

@@ -17,11 +17,12 @@ import org.lucares.utils.CollectionUtils;
import org.lucares.utils.Preconditions; import org.lucares.utils.Preconditions;
public class AggregateHandlerCollection { public class AggregateHandlerCollection {
private static final Comparator<AggregateHandler> PLOTTING_ORDER = Comparator.comparing(AggregateHandler::getAggregateType); private static final Comparator<AggregateHandler> PLOTTING_ORDER = Comparator
.comparing(AggregateHandler::getAggregateType);
private final List<AggregateHandler> aggregateHandlers = new ArrayList<>(); private final List<AggregateHandler> aggregateHandlers = new ArrayList<>();
public void add(AggregateHandler aggregateHandler) { public void add(final AggregateHandler aggregateHandler) {
aggregateHandlers.add(aggregateHandler); aggregateHandlers.add(aggregateHandler);
} }
@@ -30,9 +31,9 @@ public class AggregateHandlerCollection {
updateAxisForHandlers(GnuplotAxis.Y1); updateAxisForHandlers(GnuplotAxis.Y1);
} }
private void updateAxisForHandlers(GnuplotAxis axis) { private void updateAxisForHandlers(final GnuplotAxis axis) {
final EnumSet<Type> result = EnumSet.noneOf(Type.class); final EnumSet<Type> result = EnumSet.noneOf(Type.class);
for (AggregateHandler handler : aggregateHandlers) { for (final AggregateHandler handler : aggregateHandlers) {
final Type type = handler.getAxisType(axis); final Type type = handler.getAxisType(axis);
if (result.isEmpty()) { if (result.isEmpty()) {
@@ -41,7 +42,8 @@ public class AggregateHandlerCollection {
final boolean containsType = result.contains(type); final boolean containsType = result.contains(type);
if (containsType) { if (containsType) {
// already has an axis of this type // already has an axis of this type
// TODO merge axis definitions and use the greater values for: range, ticsIncrement // TODO merge axis definitions and use the greater values for: range,
// ticsIncrement
} else { } else {
Preconditions.checkSmaller(result.size(), 2, "at most two different axis are supported"); Preconditions.checkSmaller(result.size(), 2, "at most two different axis are supported");
final GnuplotAxis mirrorAxis = axis.mirrorAxis(); final GnuplotAxis mirrorAxis = axis.mirrorAxis();
@@ -52,32 +54,34 @@ public class AggregateHandlerCollection {
} }
} }
public List<AxisSettings> getXAxisDefinitions(GnuplotSettings settings, Collection<DataSeries> dataSeries) { public List<AxisSettings> getXAxisDefinitions(final GnuplotSettings settings,
final Collection<DataSeries> dataSeries) {
final List<AxisSettings> result = new ArrayList<>(); final List<AxisSettings> result = new ArrayList<>();
for (AggregateHandler handler : aggregateHandlers) { for (final AggregateHandler handler : aggregateHandlers) {
AxisSettings axis = handler.createXAxisSettings(settings, dataSeries); final AxisSettings axis = handler.createXAxisSettings(settings, dataSeries);
result.add(axis); result.add(axis);
} }
return result; return result;
} }
public List<AxisSettings> getYAxisDefinitions(GnuplotSettings settings, Collection<DataSeries> dataSeries) { public List<AxisSettings> getYAxisDefinitions(final GnuplotSettings settings,
List<AxisSettings> result = new ArrayList<>(); final Collection<DataSeries> dataSeries) {
for (AggregateHandler handler : aggregateHandlers) { final List<AxisSettings> result = new ArrayList<>();
for (final AggregateHandler handler : aggregateHandlers) {
final AxisSettings axis = handler.createYAxisSettings(settings, dataSeries); final AxisSettings axis = handler.createYAxisSettings(settings, dataSeries);
result.add(axis); result.add(axis);
} }
return result; return result;
} }
public AggregatorCollection createCustomAggregator(final Path tmpDir, final PlotSettings plotSettings,
public AggregatorCollection createCustomAggregator(Path tmpDir, PlotSettings plotSettings, long fromEpochMilli, final long fromEpochMilli, final long toEpochMilli) {
long toEpochMilli) {
final List<CustomAggregator> aggregators = new ArrayList<>(); final List<CustomAggregator> aggregators = new ArrayList<>();
for (AggregateHandler handler : aggregateHandlers) { for (final AggregateHandler handler : aggregateHandlers) {
final CustomAggregator aggregator = handler.createCustomAggregator(tmpDir, plotSettings, fromEpochMilli, toEpochMilli); final CustomAggregator aggregator = handler.createCustomAggregator(tmpDir, plotSettings, fromEpochMilli,
toEpochMilli);
if (aggregator != null) { if (aggregator != null) {
aggregators.add(aggregator); aggregators.add(aggregator);
} }
@@ -86,16 +90,18 @@ public class AggregateHandlerCollection {
return new AggregatorCollection(aggregators); return new AggregatorCollection(aggregators);
} }
public void addPlots(StringBuilder result, Collection<DataSeries> dataSeries) { public void addPlots(final StringBuilder result, final Collection<DataSeries> dataSeries) {
boolean first = true; boolean first = true;
final List<AggregateHandler> handlersInPlottingOrder = CollectionUtils.copySort(aggregateHandlers, PLOTTING_ORDER); final List<AggregateHandler> handlersInPlottingOrder = CollectionUtils.copySort(aggregateHandlers,
for (AggregateHandler handler : handlersInPlottingOrder) { PLOTTING_ORDER);
for (final AggregateHandler handler : handlersInPlottingOrder) {
for (DataSeries dataSerie : dataSeries) { for (final DataSeries dataSerie : dataSeries) {
final Optional<String> title = first ? Optional.of(dataSerie.getTitle()) : Optional.empty(); final Optional<String> title = first ? Optional.of(dataSerie.getTitle()) : Optional.empty();
Optional<AggregatedData> aggregatedData = dataSerie.getAggregatedData().get(handler.getAggregateType()); final Optional<AggregatedData> aggregatedData = dataSerie.getAggregatedData()
.get(handler.getAggregateType());
if (aggregatedData.isPresent()) { if (aggregatedData.isPresent()) {
handler.addPlot(result, aggregatedData.get(), dataSerie.getStyle(), title); handler.addPlot(result, aggregatedData.get(), dataSerie.getStyle(), title);
} }

View File

@@ -7,7 +7,7 @@ import java.util.Optional;
public class AggregatedDataCollection implements Iterable<AggregatedData> { public class AggregatedDataCollection implements Iterable<AggregatedData> {
private final LinkedHashMap<Aggregate, AggregatedData> aggregatedDatas = new LinkedHashMap<>(); private final LinkedHashMap<Aggregate, AggregatedData> aggregatedDatas = new LinkedHashMap<>();
public void put(Aggregate aggregate, AggregatedData aggregatedData) { public void put(final Aggregate aggregate, final AggregatedData aggregatedData) {
aggregatedDatas.put(aggregate, aggregatedData); aggregatedDatas.put(aggregate, aggregatedData);
} }
@@ -16,7 +16,7 @@ public class AggregatedDataCollection implements Iterable<AggregatedData>{
return aggregatedDatas.values().iterator(); return aggregatedDatas.values().iterator();
} }
public Optional<AggregatedData> get(Aggregate aggregateType) { public Optional<AggregatedData> get(final Aggregate aggregateType) {
return Optional.ofNullable(aggregatedDatas.get(aggregateType)); return Optional.ofNullable(aggregatedDatas.get(aggregateType));
} }
} }

View File

@@ -3,14 +3,17 @@ package org.lucares.pdb.plot.api;
public class AggregatedDataEntry { public class AggregatedDataEntry {
private final double epochSeconds; private final double epochSeconds;
private final long value; private final long value;
public AggregatedDataEntry(double epochSeconds, long value) {
public AggregatedDataEntry(final double epochSeconds, final long value) {
super(); super();
this.epochSeconds = epochSeconds; this.epochSeconds = epochSeconds;
this.value = value; this.value = value;
} }
public double getEpochSeconds() { public double getEpochSeconds() {
return epochSeconds; return epochSeconds;
} }
public long getValue() { public long getValue() {
return value; return value;
} }

View File

@@ -6,21 +6,21 @@ import java.util.List;
public class AggregatorCollection { public class AggregatorCollection {
private final List<CustomAggregator> aggregators; private final List<CustomAggregator> aggregators;
public AggregatorCollection(List<CustomAggregator> aggregators) { public AggregatorCollection(final List<CustomAggregator> aggregators) {
this.aggregators = aggregators; this.aggregators = aggregators;
} }
public void addValue(boolean valueIsInYRange, long epochMilli, long value) { public void addValue(final boolean valueIsInYRange, final long epochMilli, final long value) {
for (CustomAggregator aggregator : aggregators) { for (final CustomAggregator aggregator : aggregators) {
aggregator.addValue(valueIsInYRange, epochMilli, value); aggregator.addValue(valueIsInYRange, epochMilli, value);
} }
} }
public AggregatedDataCollection getAggregatedData() throws IOException { public AggregatedDataCollection getAggregatedData() throws IOException {
AggregatedDataCollection result = new AggregatedDataCollection(); final AggregatedDataCollection result = new AggregatedDataCollection();
for (CustomAggregator aggregator : aggregators) { for (final CustomAggregator aggregator : aggregators) {
result.put(aggregator.getType(), aggregator.getAggregatedData()); result.put(aggregator.getType(), aggregator.getAggregatedData());
} }

View File

@@ -64,9 +64,8 @@ public class ScatterAggregator implements CustomAggregator {
long[] actualValuesWritten = new long[1]; long[] actualValuesWritten = new long[1];
final StringBuilder formattedDateBuilder = new StringBuilder(); final StringBuilder formattedDateBuilder = new StringBuilder();
try ( try (final LambdaFriendlyWriter output = new LambdaFriendlyWriter(new BufferedWriter(
final LambdaFriendlyWriter output = new LambdaFriendlyWriter( new OutputStreamWriter(new FileOutputStream(dataFile), StandardCharsets.ISO_8859_1)));
new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dataFile), StandardCharsets.ISO_8859_1)));
final Formatter formatter = new Formatter(formattedDateBuilder);) { final Formatter formatter = new Formatter(formattedDateBuilder);) {
matrix2d.forEach((epochMilli, value, __) -> { matrix2d.forEach((epochMilli, value, __) -> {

View File

@@ -122,7 +122,6 @@ public class AxisSettings {
return ticsLabels; return ticsLabels;
} }
public String toGnuplotDefinition(boolean renderLabels) { public String toGnuplotDefinition(boolean renderLabels) {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
if (type == Type.Time) { if (type == Type.Time) {
@@ -133,8 +132,7 @@ public class AxisSettings {
if (ticIncrement != 0) { if (ticIncrement != 0) {
appendfln(result, "set %stics %f nomirror", axis, ticIncrement); appendfln(result, "set %stics %f nomirror", axis, ticIncrement);
} } else if (ticsLabels != null && ticsLabels.size() > 0) {
else if (ticsLabels != null && ticsLabels.size() > 0) {
appendfln(result, "set %stics(%s) nomirror", axis, String.join(", ", ticsLabels)); appendfln(result, "set %stics(%s) nomirror", axis, String.join(", ", ticsLabels));
} else if (ticsEnabled) { } else if (ticsEnabled) {
appendfln(result, "set %stics nomirror", axis); appendfln(result, "set %stics nomirror", axis);

View File

@@ -75,45 +75,18 @@ public class AxisTime {
} }
private static long roundToTickIncrement(long milliseconds) { private static long roundToTickIncrement(long milliseconds) {
LongList increments = LongList.of( LongList increments = LongList.of(100, 200, 500, TimeUnit.SECONDS.toMillis(1), TimeUnit.SECONDS.toMillis(2),
100, TimeUnit.SECONDS.toMillis(5), TimeUnit.SECONDS.toMillis(10), TimeUnit.SECONDS.toMillis(15),
200, TimeUnit.SECONDS.toMillis(30), TimeUnit.MINUTES.toMillis(1), TimeUnit.MINUTES.toMillis(2),
500, TimeUnit.MINUTES.toMillis(5), TimeUnit.MINUTES.toMillis(10), TimeUnit.MINUTES.toMillis(15),
TimeUnit.SECONDS.toMillis(1), TimeUnit.MINUTES.toMillis(30), TimeUnit.HOURS.toMillis(1), TimeUnit.HOURS.toMillis(2),
TimeUnit.SECONDS.toMillis(2), TimeUnit.HOURS.toMillis(3), TimeUnit.HOURS.toMillis(6), TimeUnit.HOURS.toMillis(12),
TimeUnit.SECONDS.toMillis(5), TimeUnit.HOURS.toMillis(18), TimeUnit.DAYS.toMillis(1), TimeUnit.DAYS.toMillis(2),
TimeUnit.SECONDS.toMillis(10), TimeUnit.DAYS.toMillis(3), TimeUnit.DAYS.toMillis(4), TimeUnit.DAYS.toMillis(5),
TimeUnit.SECONDS.toMillis(15), TimeUnit.DAYS.toMillis(6), TimeUnit.DAYS.toMillis(7), TimeUnit.DAYS.toMillis(14),
TimeUnit.SECONDS.toMillis(30), TimeUnit.DAYS.toMillis(30), TimeUnit.DAYS.toMillis(90), TimeUnit.DAYS.toMillis(180),
TimeUnit.MINUTES.toMillis(1), TimeUnit.DAYS.toMillis(365), TimeUnit.DAYS.toMillis(365 * 2), TimeUnit.DAYS.toMillis(365 * 5),
TimeUnit.MINUTES.toMillis(2), TimeUnit.DAYS.toMillis(365 * 10), TimeUnit.DAYS.toMillis(365 * 20));
TimeUnit.MINUTES.toMillis(5),
TimeUnit.MINUTES.toMillis(10),
TimeUnit.MINUTES.toMillis(15),
TimeUnit.MINUTES.toMillis(30),
TimeUnit.HOURS.toMillis(1),
TimeUnit.HOURS.toMillis(2),
TimeUnit.HOURS.toMillis(3),
TimeUnit.HOURS.toMillis(6),
TimeUnit.HOURS.toMillis(12),
TimeUnit.HOURS.toMillis(18),
TimeUnit.DAYS.toMillis(1),
TimeUnit.DAYS.toMillis(2),
TimeUnit.DAYS.toMillis(3),
TimeUnit.DAYS.toMillis(4),
TimeUnit.DAYS.toMillis(5),
TimeUnit.DAYS.toMillis(6),
TimeUnit.DAYS.toMillis(7),
TimeUnit.DAYS.toMillis(14),
TimeUnit.DAYS.toMillis(30),
TimeUnit.DAYS.toMillis(90),
TimeUnit.DAYS.toMillis(180),
TimeUnit.DAYS.toMillis(365),
TimeUnit.DAYS.toMillis(365*2),
TimeUnit.DAYS.toMillis(365*5),
TimeUnit.DAYS.toMillis(365*10),
TimeUnit.DAYS.toMillis(365*20)
);
for (int i = 0; i < increments.size(); i++) { for (int i = 0; i < increments.size(); i++) {
if (increments.get(i) > milliseconds) { if (increments.get(i) > milliseconds) {

View File

@@ -9,8 +9,8 @@ class CsvSummary {
private final double statsAverage; private final double statsAverage;
private final int plottedValues; private final int plottedValues;
public CsvSummary(final int values, final int plottedValues, final long maxValue, public CsvSummary(final int values, final int plottedValues, final long maxValue, final double statsAverage,
final double statsAverage, final AggregatedDataCollection aggregatedData) { final AggregatedDataCollection aggregatedData) {
super(); super();
this.values = values; this.values = values;
this.plottedValues = plottedValues; this.plottedValues = plottedValues;
@@ -19,7 +19,6 @@ class CsvSummary {
this.aggregatedData = aggregatedData; this.aggregatedData = aggregatedData;
} }
/** /**
* Total number of values in the selected date range. * Total number of values in the selected date range.
* *

View File

@@ -2,8 +2,8 @@ package org.lucares.recommind.logs;
public enum DashTypes { public enum DashTypes {
DASH_TYPE_2("2"), DASH_TYPE_3("3"), DASH_TYPE_4("4"), DASH_TYPE_5("5"), DASH_TYPE_6("6"), DASH_TYPE_DOT( DASH_TYPE_2("2"), DASH_TYPE_3("3"), DASH_TYPE_4("4"), DASH_TYPE_5("5"), DASH_TYPE_6("6"), DASH_TYPE_DOT("\".\""),
"\".\""), DASH_TYPE_DASH("\"-\""), DASH_TYPE_DOT_DASH("\"._\""), DASH_TYPE_DOT_DOT_DASH("\"..- \""); DASH_TYPE_DASH("\"-\""), DASH_TYPE_DOT_DASH("\"._\""), DASH_TYPE_DOT_DOT_DASH("\"..- \"");
private final String gnuplotDashType; private final String gnuplotDashType;

View File

@@ -12,8 +12,7 @@ public class FileBackedDataSeries implements DataSeries {
private LineStyle style; private LineStyle style;
public FileBackedDataSeries(final int id, final String title, final CsvSummary csvSummary public FileBackedDataSeries(final int id, final String title, final CsvSummary csvSummary) {
) {
this.id = id; this.id = id;
this.title = title; this.title = title;
this.csvSummary = csvSummary; this.csvSummary = csvSummary;
@@ -39,7 +38,6 @@ public class FileBackedDataSeries implements DataSeries {
return style; return style;
} }
@Override @Override
public String getTitle() { public String getTitle() {
return title; return title;

View File

@@ -44,7 +44,6 @@ public class GnuplotColor {
final Color brighterColor = toAwtColor().brighter(); final Color brighterColor = toAwtColor().brighter();
return byAwtColor(brighterColor); return byAwtColor(brighterColor);
} }

View File

@@ -5,8 +5,6 @@ import java.util.List;
public interface GnuplotColorPalettes { public interface GnuplotColorPalettes {
/** /**
* *
* <div style="background-color: #9400D3; display:inline; padding: * <div style="background-color: #9400D3; display:inline; padding:
@@ -63,8 +61,7 @@ public interface GnuplotColorPalettes {
* <div style="background-color: #b3df72; display:inline; padding: * <div style="background-color: #b3df72; display:inline; padding:
* 8px;">#b3df72</div> * 8px;">#b3df72</div>
* <div style="background-color: #feffbe; display:inline; padding: * <div style="background-color: #feffbe; display:inline; padding:
* 8px;">#feffbe</div> * 8px;">#feffbe</div> --
* --
* <div style="background-color: #4660ff; display:inline; padding: * <div style="background-color: #4660ff; display:inline; padding:
* 8px;">#4660ff</div> * 8px;">#4660ff</div>
* *
@@ -80,6 +77,5 @@ public interface GnuplotColorPalettes {
GnuplotColor.byHex("feffbe")// light yellow GnuplotColor.byHex("feffbe")// light yellow
); );
List<GnuplotColor> DEFAULT = GNUPLOT_REORDERED; List<GnuplotColor> DEFAULT = GNUPLOT_REORDERED;
} }

View File

@@ -17,4 +17,3 @@ public enum GnuplotLineType {
} }
} }

View File

@@ -82,7 +82,8 @@ public class Plotter {
final AtomicInteger idCounter = new AtomicInteger(0); final AtomicInteger idCounter = new AtomicInteger(0);
result.getGroups().stream().parallel().forEach(groupResult -> { result.getGroups().stream().parallel().forEach(groupResult -> {
try { try {
final CsvSummary csvSummary = toCsvDeduplicated(groupResult, tmpDir, dateFrom, dateTo, plotSettings); final CsvSummary csvSummary = toCsvDeduplicated(groupResult, tmpDir, dateFrom, dateTo,
plotSettings);
final int id = idCounter.incrementAndGet(); final int id = idCounter.incrementAndGet();
final String title = title(groupResult.getGroupedBy(), csvSummary); final String title = title(groupResult.getGroupedBy(), csvSummary);
@@ -159,10 +160,9 @@ public class Plotter {
} }
} }
private static CsvSummary toCsvDeduplicated(final GroupResult groupResult, final Path tmpDir, private static CsvSummary toCsvDeduplicated(final GroupResult groupResult, final Path tmpDir,
final OffsetDateTime dateFrom, final OffsetDateTime dateTo, final PlotSettings plotSettings) throws IOException { final OffsetDateTime dateFrom, final OffsetDateTime dateTo, final PlotSettings plotSettings)
throws IOException {
final long start = System.nanoTime(); final long start = System.nanoTime();
final Stream<LongList> timeValueStream = groupResult.asStream(); final Stream<LongList> timeValueStream = groupResult.asStream();
@@ -175,8 +175,8 @@ public class Plotter {
final long maxValue = plotSettings.getYRangeUnit() == TimeRangeUnitInternal.AUTOMATIC ? Long.MAX_VALUE final long maxValue = plotSettings.getYRangeUnit() == TimeRangeUnitInternal.AUTOMATIC ? Long.MAX_VALUE
: plotSettings.getYRangeUnit().toMilliSeconds(plotSettings.getYRangeMax()); : plotSettings.getYRangeUnit().toMilliSeconds(plotSettings.getYRangeMax());
final AggregatorCollection aggregator = plotSettings.getAggregates().createCustomAggregator(tmpDir, plotSettings, fromEpochMilli, final AggregatorCollection aggregator = plotSettings.getAggregates().createCustomAggregator(tmpDir,
toEpochMilli); plotSettings, fromEpochMilli, toEpochMilli);
int count = 0; // number of values in the x-axis range (used to compute stats) int count = 0; // number of values in the x-axis range (used to compute stats)
int plottedValues = 0; int plottedValues = 0;
@@ -217,15 +217,10 @@ public class Plotter {
} }
} }
METRICS_LOGGER.debug("wrote {} values to csv in: {}ms (ignored {} values) use millis: {}, grouping={}",
plottedValues, (System.nanoTime() - start) / 1_000_000.0, ignoredValues, Boolean.toString(useMillis),
METRICS_LOGGER.debug(
"wrote {} values to csv in: {}ms (ignored {} values) use millis: {}, grouping={}",
plottedValues,
(System.nanoTime() - start) / 1_000_000.0, ignoredValues, Boolean.toString(useMillis),
groupResult.getGroupedBy().asString()); groupResult.getGroupedBy().asString());
return new CsvSummary( count, plottedValues, statsMaxValue, statsCurrentAverage, return new CsvSummary(count, plottedValues, statsMaxValue, statsCurrentAverage, aggregator.getAggregatedData());
aggregator.getAggregatedData());
} }

View File

@@ -14,7 +14,6 @@ import java.util.concurrent.TimeUnit;
class YAxisTicks { class YAxisTicks {
public static List<String> computeYTicks(final GnuplotSettings settings, final Collection<DataSeries> dataSeries) { public static List<String> computeYTicks(final GnuplotSettings settings, final Collection<DataSeries> dataSeries) {
List<String> result = new ArrayList<String>(); List<String> result = new ArrayList<String>();
@@ -77,9 +76,7 @@ private static List<String> computeLog10YTicks(final int height, final long yRan
"\"3 month\" 7776000000.0", // "\"3 month\" 7776000000.0", //
"\"1 year\" 31536000000.0", // "\"1 year\" 31536000000.0", //
"\"5 year\" 157680000000.0", // "\"5 year\" 157680000000.0", //
"\"10 year\" 315360000000.0" "\"10 year\" 315360000000.0");
);
return ticsLabels; return ticsLabels;
} }

View File

@@ -194,7 +194,8 @@ public class PdbController implements HardcodedValues, PropertyKeys {
plotSettings.setLimitBy(limitBy); plotSettings.setLimitBy(limitBy);
plotSettings.setDateRange(dateRange); plotSettings.setDateRange(dateRange);
plotSettings.setYAxisScale(axisScale); plotSettings.setYAxisScale(axisScale);
plotSettings.setAggregates(PlotSettingsTransformer.toAggregateInternal(plotSettings.getYRangeUnit(), plotSettings.getYAxisScale(), aggregate)); plotSettings.setAggregates(PlotSettingsTransformer.toAggregateInternal(plotSettings.getYRangeUnit(),
plotSettings.getYAxisScale(), aggregate));
plotSettings.setKeyOutside(keyOutside); plotSettings.setKeyOutside(keyOutside);
plotSettings.setGenerateThumbnail(false); plotSettings.setGenerateThumbnail(false);
@@ -231,8 +232,7 @@ public class PdbController implements HardcodedValues, PropertyKeys {
// TODO get date range from UI // TODO get date range from UI
final DateTimeRange dateRange = DateTimeRange.max(); final DateTimeRange dateRange = DateTimeRange.max();
final int zeroBasedCaretIndex = caretIndex - 1; final int zeroBasedCaretIndex = caretIndex - 1;
final QueryWithCaretMarker q = new QueryWithCaretMarker(query, dateRange, zeroBasedCaretIndex, final QueryWithCaretMarker q = new QueryWithCaretMarker(query, dateRange, zeroBasedCaretIndex, resultMode);
resultMode);
final AutocompleteResponse result = new AutocompleteResponse(); final AutocompleteResponse result = new AutocompleteResponse();

View File

@@ -11,12 +11,10 @@ public class PdbWebapp {
Thread t = new Thread(() -> { Thread t = new Thread(() -> {
while (true) { while (true) {
try { try {
TimeUnit.MINUTES.sleep(10); TimeUnit.MINUTES.sleep(10);
}catch(InterruptedException e) } catch (InterruptedException e) {
{
// ignore // ignore
} }
System.gc(); System.gc();

View File

@@ -31,7 +31,8 @@ class PlotSettingsTransformer {
result.setYRangeMin(request.getyRangeMin()); result.setYRangeMin(request.getyRangeMin());
result.setYRangeMax(request.getyRangeMax()); result.setYRangeMax(request.getyRangeMax());
result.setYRangeUnit(toTimeRangeUnitInternal(request.getyRangeUnit())); result.setYRangeUnit(toTimeRangeUnitInternal(request.getyRangeUnit()));
result.setAggregates(toAggregateInternal(result.getYRangeUnit(), result.getYAxisScale(), request.getAggregates())); result.setAggregates(
toAggregateInternal(result.getYRangeUnit(), result.getYAxisScale(), request.getAggregates()));
return result; return result;
} }
@@ -69,8 +70,10 @@ class PlotSettingsTransformer {
break; break;
case SCATTER: case SCATTER:
if (yRangeUnit == TimeRangeUnitInternal.AUTOMATIC && yAxisScale == AxisScale.LINEAR) { if (yRangeUnit == TimeRangeUnitInternal.AUTOMATIC && yAxisScale == AxisScale.LINEAR) {
// TODO need a second ScatterAggregateHandler for YRangeUnit() == TimeRangeUnitInternal.AUTOMATIC // TODO need a second ScatterAggregateHandler for YRangeUnit() ==
throw new UnsupportedOperationException("linear axis with automatic y range does not work, use logarthmic y-axis, or define a y-axis range"); // TimeRangeUnitInternal.AUTOMATIC
throw new UnsupportedOperationException(
"linear axis with automatic y range does not work, use logarthmic y-axis, or define a y-axis range");
} else { } else {
aggregateHandlerCollection.add(new ScatterAggregateHandler()); aggregateHandlerCollection.add(new ScatterAggregateHandler());
} }

View File

@@ -62,7 +62,6 @@ public class PdbTestUtil {
public static final void sendAsCsv(Collection<String> keys, final Collection<Map<String, Object>> entries) public static final void sendAsCsv(Collection<String> keys, final Collection<Map<String, Object>> entries)
throws IOException, InterruptedException { throws IOException, InterruptedException {
final StringBuilder csv = new StringBuilder(); final StringBuilder csv = new StringBuilder();
csv.append(String.join(",", keys)); csv.append(String.join(",", keys));

View File

@@ -282,7 +282,6 @@ public class TcpIngestorTest {
} }
} }
public void testCsvIngestorHandlesDurationAtEnd() throws Exception { public void testCsvIngestorHandlesDurationAtEnd() throws Exception {
String host = "someHost"; String host = "someHost";

View File

@@ -38,7 +38,6 @@ public class CollectionUtils {
} }
} }
public static <T> List<T> copySort(Collection<? extends T> collection, Comparator<T> comparator) { public static <T> List<T> copySort(Collection<? extends T> collection, Comparator<T> comparator) {
final List<T> result = new ArrayList<T>(collection); final List<T> result = new ArrayList<T>(collection);
Collections.sort(result, comparator); Collections.sort(result, comparator);