apply new code formatter and save action
This commit is contained in:
@@ -159,7 +159,8 @@ public class BSFile implements AutoCloseable {
|
||||
|
||||
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) {
|
||||
buffer.writeAsync();
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ public class DiskStorage implements AutoCloseable {
|
||||
|
||||
private Path relativeDatabaseFileForLogging;
|
||||
|
||||
|
||||
public DiskStorage(final Path databaseFile, Path storageBasePath) {
|
||||
this.relativeDatabaseFileForLogging = storageBasePath != null ? storageBasePath.relativize(databaseFile): databaseFile;
|
||||
this.relativeDatabaseFileForLogging = storageBasePath != null ? storageBasePath.relativize(databaseFile)
|
||||
: databaseFile;
|
||||
try {
|
||||
Files.createDirectories(databaseFile.getParent());
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ public class PersistentMapTest {
|
||||
final String value = "value1";
|
||||
final String key = "key1";
|
||||
|
||||
try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory, PersistentMap.STRING_CODER,
|
||||
PersistentMap.STRING_CODER)) {
|
||||
try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,
|
||||
PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) {
|
||||
|
||||
Assert.assertNull(map.getValue(key));
|
||||
|
||||
@@ -50,8 +50,8 @@ public class PersistentMapTest {
|
||||
|
||||
Assert.assertEquals(map.getValue(key), value);
|
||||
}
|
||||
try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,PersistentMap.STRING_CODER,
|
||||
PersistentMap.STRING_CODER)) {
|
||||
try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,
|
||||
PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) {
|
||||
|
||||
Assert.assertEquals(map.getValue(key), value);
|
||||
}
|
||||
@@ -64,8 +64,8 @@ public class PersistentMapTest {
|
||||
|
||||
final Random rnd = new Random(1);
|
||||
|
||||
try (final PersistentMap<String, String> map = new PersistentMap<>(file,dataDirectory, PersistentMap.STRING_CODER,
|
||||
PersistentMap.STRING_CODER)) {
|
||||
try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,
|
||||
PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) {
|
||||
map.setMaxEntriesInNode(2);
|
||||
|
||||
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,
|
||||
PersistentMap.STRING_CODER)) {
|
||||
try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,
|
||||
PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) {
|
||||
// map.print(PersistentMap.STRING_DECODER, PersistentMap.STRING_DECODER);
|
||||
final AtomicInteger maxDepth = new AtomicInteger();
|
||||
map.visitNodeEntriesPreOrder(
|
||||
@@ -179,6 +179,7 @@ public class PersistentMapTest {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Test(invocationCount = 1)
|
||||
public void testManyEmptyValues() throws Exception {
|
||||
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));
|
||||
|
||||
try (final PersistentMap<String, String> map = new PersistentMap<>(file,dataDirectory, PersistentMap.STRING_CODER,
|
||||
PersistentMap.STRING_CODER)) {
|
||||
try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,
|
||||
PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) {
|
||||
|
||||
final int numbersSize = numbers.size();
|
||||
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,
|
||||
PersistentMap.STRING_CODER)) {
|
||||
try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,
|
||||
PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) {
|
||||
// map.print(PersistentMap.STRING_DECODER, PersistentMap.STRING_DECODER);
|
||||
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
@@ -309,14 +310,14 @@ public class PersistentMapTest {
|
||||
input.put(UUID.randomUUID().toString(), UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
try (final PersistentMap<String, String> map = new PersistentMap<>(file,dataDirectory, PersistentMap.STRING_CODER,
|
||||
PersistentMap.STRING_CODER)) {
|
||||
try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,
|
||||
PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) {
|
||||
|
||||
map.putAllValues(input);
|
||||
}
|
||||
|
||||
try (final PersistentMap<String, String> map = new PersistentMap<>(file,dataDirectory, PersistentMap.STRING_CODER,
|
||||
PersistentMap.STRING_CODER)) {
|
||||
try (final PersistentMap<String, String> map = new PersistentMap<>(file, dataDirectory,
|
||||
PersistentMap.STRING_CODER, PersistentMap.STRING_CODER)) {
|
||||
|
||||
{
|
||||
final LinkedHashMap<String, String> actualBar = new LinkedHashMap<>();
|
||||
|
||||
@@ -150,7 +150,8 @@ public class ExpressionToDocIdVisitor extends ExpressionVisitor<PartitionLongLis
|
||||
final List<LongList> docIdsForPartition = new ArrayList<>();
|
||||
keyToValueToDocId.visitValues(partitionId, new Tag(propertyName, ""), (tags, blockOffsetToDocIds) -> {
|
||||
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
|
||||
// and increasing, that means we can just concatenate them and get a sorted
|
||||
|
||||
@@ -124,7 +124,8 @@ public class ProposerTest {
|
||||
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, //
|
||||
// new Proposal("Jennifer", "name =Tim,Jennifer", true, "name =Tim,Jennifer", 18), //
|
||||
// new Proposal("Jenny", "name =Tim,Jenny", true, "name =Tim,Jenny", 15) //
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
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 {
|
||||
PARALLEL,
|
||||
|
||||
@@ -21,7 +21,7 @@ public abstract class AggregateHandler implements Appender {
|
||||
return xAxis;
|
||||
}
|
||||
|
||||
public void updateAxis(GnuplotAxis axis) {
|
||||
public void updateAxis(final GnuplotAxis axis) {
|
||||
switch (axis) {
|
||||
case X1:
|
||||
case X2:
|
||||
@@ -52,12 +52,13 @@ public abstract class AggregateHandler implements Appender {
|
||||
|
||||
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,
|
||||
long toEpochMilli);
|
||||
|
||||
protected String gnuplotTitle(Optional<String> title) {
|
||||
protected String gnuplotTitle(final Optional<String> title) {
|
||||
|
||||
return title.isPresent() ? "title '" + title.get() + "'" : "notitle";
|
||||
}
|
||||
|
||||
@@ -17,11 +17,12 @@ import org.lucares.utils.CollectionUtils;
|
||||
import org.lucares.utils.Preconditions;
|
||||
|
||||
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<>();
|
||||
|
||||
public void add(AggregateHandler aggregateHandler) {
|
||||
public void add(final AggregateHandler aggregateHandler) {
|
||||
aggregateHandlers.add(aggregateHandler);
|
||||
}
|
||||
|
||||
@@ -30,9 +31,9 @@ public class AggregateHandlerCollection {
|
||||
updateAxisForHandlers(GnuplotAxis.Y1);
|
||||
}
|
||||
|
||||
private void updateAxisForHandlers(GnuplotAxis axis) {
|
||||
private void updateAxisForHandlers(final GnuplotAxis axis) {
|
||||
final EnumSet<Type> result = EnumSet.noneOf(Type.class);
|
||||
for (AggregateHandler handler : aggregateHandlers) {
|
||||
for (final AggregateHandler handler : aggregateHandlers) {
|
||||
final Type type = handler.getAxisType(axis);
|
||||
|
||||
if (result.isEmpty()) {
|
||||
@@ -41,7 +42,8 @@ public class AggregateHandlerCollection {
|
||||
final boolean containsType = result.contains(type);
|
||||
if (containsType) {
|
||||
// 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 {
|
||||
Preconditions.checkSmaller(result.size(), 2, "at most two different axis are supported");
|
||||
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<>();
|
||||
for (AggregateHandler handler : aggregateHandlers) {
|
||||
AxisSettings axis = handler.createXAxisSettings(settings, dataSeries);
|
||||
for (final AggregateHandler handler : aggregateHandlers) {
|
||||
final AxisSettings axis = handler.createXAxisSettings(settings, dataSeries);
|
||||
result.add(axis);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<AxisSettings> getYAxisDefinitions(GnuplotSettings settings, Collection<DataSeries> dataSeries) {
|
||||
List<AxisSettings> result = new ArrayList<>();
|
||||
for (AggregateHandler handler : aggregateHandlers) {
|
||||
public List<AxisSettings> getYAxisDefinitions(final GnuplotSettings settings,
|
||||
final Collection<DataSeries> dataSeries) {
|
||||
final List<AxisSettings> result = new ArrayList<>();
|
||||
for (final AggregateHandler handler : aggregateHandlers) {
|
||||
final AxisSettings axis = handler.createYAxisSettings(settings, dataSeries);
|
||||
result.add(axis);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public AggregatorCollection createCustomAggregator(Path tmpDir, PlotSettings plotSettings, long fromEpochMilli,
|
||||
long toEpochMilli) {
|
||||
public AggregatorCollection createCustomAggregator(final Path tmpDir, final PlotSettings plotSettings,
|
||||
final long fromEpochMilli, final long toEpochMilli) {
|
||||
|
||||
final List<CustomAggregator> aggregators = new ArrayList<>();
|
||||
|
||||
for (AggregateHandler handler : aggregateHandlers) {
|
||||
final CustomAggregator aggregator = handler.createCustomAggregator(tmpDir, plotSettings, fromEpochMilli, toEpochMilli);
|
||||
for (final AggregateHandler handler : aggregateHandlers) {
|
||||
final CustomAggregator aggregator = handler.createCustomAggregator(tmpDir, plotSettings, fromEpochMilli,
|
||||
toEpochMilli);
|
||||
if (aggregator != null) {
|
||||
aggregators.add(aggregator);
|
||||
}
|
||||
@@ -86,16 +90,18 @@ public class AggregateHandlerCollection {
|
||||
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;
|
||||
final List<AggregateHandler> handlersInPlottingOrder = CollectionUtils.copySort(aggregateHandlers, PLOTTING_ORDER);
|
||||
for (AggregateHandler handler : handlersInPlottingOrder) {
|
||||
final List<AggregateHandler> handlersInPlottingOrder = CollectionUtils.copySort(aggregateHandlers,
|
||||
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();
|
||||
|
||||
Optional<AggregatedData> aggregatedData = dataSerie.getAggregatedData().get(handler.getAggregateType());
|
||||
final Optional<AggregatedData> aggregatedData = dataSerie.getAggregatedData()
|
||||
.get(handler.getAggregateType());
|
||||
if (aggregatedData.isPresent()) {
|
||||
handler.addPlot(result, aggregatedData.get(), dataSerie.getStyle(), title);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.Optional;
|
||||
public class AggregatedDataCollection implements Iterable<AggregatedData> {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class AggregatedDataCollection implements Iterable<AggregatedData>{
|
||||
return aggregatedDatas.values().iterator();
|
||||
}
|
||||
|
||||
public Optional<AggregatedData> get(Aggregate aggregateType) {
|
||||
public Optional<AggregatedData> get(final Aggregate aggregateType) {
|
||||
return Optional.ofNullable(aggregatedDatas.get(aggregateType));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,17 @@ package org.lucares.pdb.plot.api;
|
||||
public class AggregatedDataEntry {
|
||||
private final double epochSeconds;
|
||||
private final long value;
|
||||
public AggregatedDataEntry(double epochSeconds, long value) {
|
||||
|
||||
public AggregatedDataEntry(final double epochSeconds, final long value) {
|
||||
super();
|
||||
this.epochSeconds = epochSeconds;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public double getEpochSeconds() {
|
||||
return epochSeconds;
|
||||
}
|
||||
|
||||
public long getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -6,21 +6,21 @@ import java.util.List;
|
||||
public class AggregatorCollection {
|
||||
private final List<CustomAggregator> aggregators;
|
||||
|
||||
public AggregatorCollection(List<CustomAggregator> aggregators) {
|
||||
public AggregatorCollection(final List<CustomAggregator> aggregators) {
|
||||
this.aggregators = aggregators;
|
||||
}
|
||||
|
||||
public void addValue(boolean valueIsInYRange, long epochMilli, long value) {
|
||||
for (CustomAggregator aggregator : aggregators) {
|
||||
public void addValue(final boolean valueIsInYRange, final long epochMilli, final long value) {
|
||||
for (final CustomAggregator aggregator : aggregators) {
|
||||
aggregator.addValue(valueIsInYRange, epochMilli, value);
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
@@ -64,9 +64,8 @@ public class ScatterAggregator implements CustomAggregator {
|
||||
|
||||
long[] actualValuesWritten = new long[1];
|
||||
final StringBuilder formattedDateBuilder = new StringBuilder();
|
||||
try (
|
||||
final LambdaFriendlyWriter output = new LambdaFriendlyWriter(
|
||||
new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dataFile), StandardCharsets.ISO_8859_1)));
|
||||
try (final LambdaFriendlyWriter output = new LambdaFriendlyWriter(new BufferedWriter(
|
||||
new OutputStreamWriter(new FileOutputStream(dataFile), StandardCharsets.ISO_8859_1)));
|
||||
final Formatter formatter = new Formatter(formattedDateBuilder);) {
|
||||
|
||||
matrix2d.forEach((epochMilli, value, __) -> {
|
||||
|
||||
@@ -122,7 +122,6 @@ public class AxisSettings {
|
||||
return ticsLabels;
|
||||
}
|
||||
|
||||
|
||||
public String toGnuplotDefinition(boolean renderLabels) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
if (type == Type.Time) {
|
||||
@@ -133,8 +132,7 @@ public class AxisSettings {
|
||||
|
||||
if (ticIncrement != 0) {
|
||||
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));
|
||||
} else if (ticsEnabled) {
|
||||
appendfln(result, "set %stics nomirror", axis);
|
||||
|
||||
@@ -75,45 +75,18 @@ public class AxisTime {
|
||||
}
|
||||
|
||||
private static long roundToTickIncrement(long milliseconds) {
|
||||
LongList increments = LongList.of(
|
||||
100,
|
||||
200,
|
||||
500,
|
||||
TimeUnit.SECONDS.toMillis(1),
|
||||
TimeUnit.SECONDS.toMillis(2),
|
||||
TimeUnit.SECONDS.toMillis(5),
|
||||
TimeUnit.SECONDS.toMillis(10),
|
||||
TimeUnit.SECONDS.toMillis(15),
|
||||
TimeUnit.SECONDS.toMillis(30),
|
||||
TimeUnit.MINUTES.toMillis(1),
|
||||
TimeUnit.MINUTES.toMillis(2),
|
||||
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)
|
||||
);
|
||||
LongList increments = LongList.of(100, 200, 500, TimeUnit.SECONDS.toMillis(1), TimeUnit.SECONDS.toMillis(2),
|
||||
TimeUnit.SECONDS.toMillis(5), TimeUnit.SECONDS.toMillis(10), TimeUnit.SECONDS.toMillis(15),
|
||||
TimeUnit.SECONDS.toMillis(30), TimeUnit.MINUTES.toMillis(1), TimeUnit.MINUTES.toMillis(2),
|
||||
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++) {
|
||||
if (increments.get(i) > milliseconds) {
|
||||
|
||||
@@ -9,8 +9,8 @@ class CsvSummary {
|
||||
private final double statsAverage;
|
||||
private final int plottedValues;
|
||||
|
||||
public CsvSummary(final int values, final int plottedValues, final long maxValue,
|
||||
final double statsAverage, final AggregatedDataCollection aggregatedData) {
|
||||
public CsvSummary(final int values, final int plottedValues, final long maxValue, final double statsAverage,
|
||||
final AggregatedDataCollection aggregatedData) {
|
||||
super();
|
||||
this.values = values;
|
||||
this.plottedValues = plottedValues;
|
||||
@@ -19,7 +19,6 @@ class CsvSummary {
|
||||
this.aggregatedData = aggregatedData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Total number of values in the selected date range.
|
||||
*
|
||||
|
||||
@@ -2,8 +2,8 @@ package org.lucares.recommind.logs;
|
||||
|
||||
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_DASH("\"-\""), DASH_TYPE_DOT_DASH("\"._\""), DASH_TYPE_DOT_DOT_DASH("\"..- \"");
|
||||
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("\"..- \"");
|
||||
|
||||
private final String gnuplotDashType;
|
||||
|
||||
|
||||
@@ -12,8 +12,7 @@ public class FileBackedDataSeries implements DataSeries {
|
||||
|
||||
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.title = title;
|
||||
this.csvSummary = csvSummary;
|
||||
@@ -39,7 +38,6 @@ public class FileBackedDataSeries implements DataSeries {
|
||||
return style;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return title;
|
||||
|
||||
@@ -44,7 +44,6 @@ public class GnuplotColor {
|
||||
|
||||
final Color brighterColor = toAwtColor().brighter();
|
||||
|
||||
|
||||
return byAwtColor(brighterColor);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@ import java.util.List;
|
||||
|
||||
public interface GnuplotColorPalettes {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* <div style="background-color: #9400D3; display:inline; padding:
|
||||
@@ -63,8 +61,7 @@ public interface GnuplotColorPalettes {
|
||||
* <div style="background-color: #b3df72; display:inline; padding:
|
||||
* 8px;">#b3df72</div>
|
||||
* <div style="background-color: #feffbe; display:inline; padding:
|
||||
* 8px;">#feffbe</div>
|
||||
* --
|
||||
* 8px;">#feffbe</div> --
|
||||
* <div style="background-color: #4660ff; display:inline; padding:
|
||||
* 8px;">#4660ff</div>
|
||||
*
|
||||
@@ -80,6 +77,5 @@ public interface GnuplotColorPalettes {
|
||||
GnuplotColor.byHex("feffbe")// light yellow
|
||||
);
|
||||
|
||||
|
||||
List<GnuplotColor> DEFAULT = GNUPLOT_REORDERED;
|
||||
}
|
||||
|
||||
@@ -17,4 +17,3 @@ public enum GnuplotLineType {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,8 @@ public class Plotter {
|
||||
final AtomicInteger idCounter = new AtomicInteger(0);
|
||||
result.getGroups().stream().parallel().forEach(groupResult -> {
|
||||
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 String title = title(groupResult.getGroupedBy(), csvSummary);
|
||||
@@ -159,10 +160,9 @@ public class Plotter {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 Stream<LongList> timeValueStream = groupResult.asStream();
|
||||
@@ -175,8 +175,8 @@ public class Plotter {
|
||||
final long maxValue = plotSettings.getYRangeUnit() == TimeRangeUnitInternal.AUTOMATIC ? Long.MAX_VALUE
|
||||
: plotSettings.getYRangeUnit().toMilliSeconds(plotSettings.getYRangeMax());
|
||||
|
||||
final AggregatorCollection aggregator = plotSettings.getAggregates().createCustomAggregator(tmpDir, plotSettings, fromEpochMilli,
|
||||
toEpochMilli);
|
||||
final AggregatorCollection aggregator = plotSettings.getAggregates().createCustomAggregator(tmpDir,
|
||||
plotSettings, fromEpochMilli, toEpochMilli);
|
||||
|
||||
int count = 0; // number of values in the x-axis range (used to compute stats)
|
||||
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());
|
||||
return new CsvSummary( count, plottedValues, statsMaxValue, statsCurrentAverage,
|
||||
aggregator.getAggregatedData());
|
||||
return new CsvSummary(count, plottedValues, statsMaxValue, statsCurrentAverage, aggregator.getAggregatedData());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
class YAxisTicks {
|
||||
|
||||
|
||||
public static List<String> computeYTicks(final GnuplotSettings settings, final Collection<DataSeries> dataSeries) {
|
||||
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", //
|
||||
"\"1 year\" 31536000000.0", //
|
||||
"\"5 year\" 157680000000.0", //
|
||||
"\"10 year\" 315360000000.0"
|
||||
);
|
||||
|
||||
"\"10 year\" 315360000000.0");
|
||||
|
||||
return ticsLabels;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,8 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
plotSettings.setLimitBy(limitBy);
|
||||
plotSettings.setDateRange(dateRange);
|
||||
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.setGenerateThumbnail(false);
|
||||
|
||||
@@ -231,8 +232,7 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
// TODO get date range from UI
|
||||
final DateTimeRange dateRange = DateTimeRange.max();
|
||||
final int zeroBasedCaretIndex = caretIndex - 1;
|
||||
final QueryWithCaretMarker q = new QueryWithCaretMarker(query, dateRange, zeroBasedCaretIndex,
|
||||
resultMode);
|
||||
final QueryWithCaretMarker q = new QueryWithCaretMarker(query, dateRange, zeroBasedCaretIndex, resultMode);
|
||||
|
||||
final AutocompleteResponse result = new AutocompleteResponse();
|
||||
|
||||
|
||||
@@ -11,12 +11,10 @@ public class PdbWebapp {
|
||||
|
||||
Thread t = new Thread(() -> {
|
||||
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
TimeUnit.MINUTES.sleep(10);
|
||||
}catch(InterruptedException e)
|
||||
{
|
||||
} catch (InterruptedException e) {
|
||||
// ignore
|
||||
}
|
||||
System.gc();
|
||||
|
||||
@@ -31,7 +31,8 @@ class PlotSettingsTransformer {
|
||||
result.setYRangeMin(request.getyRangeMin());
|
||||
result.setYRangeMax(request.getyRangeMax());
|
||||
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;
|
||||
}
|
||||
@@ -69,8 +70,10 @@ class PlotSettingsTransformer {
|
||||
break;
|
||||
case SCATTER:
|
||||
if (yRangeUnit == TimeRangeUnitInternal.AUTOMATIC && yAxisScale == AxisScale.LINEAR) {
|
||||
// TODO need a second ScatterAggregateHandler for YRangeUnit() == TimeRangeUnitInternal.AUTOMATIC
|
||||
throw new UnsupportedOperationException("linear axis with automatic y range does not work, use logarthmic y-axis, or define a y-axis range");
|
||||
// TODO need a second ScatterAggregateHandler for YRangeUnit() ==
|
||||
// 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 {
|
||||
aggregateHandlerCollection.add(new ScatterAggregateHandler());
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ public class PdbTestUtil {
|
||||
public static final void sendAsCsv(Collection<String> keys, final Collection<Map<String, Object>> entries)
|
||||
throws IOException, InterruptedException {
|
||||
|
||||
|
||||
final StringBuilder csv = new StringBuilder();
|
||||
|
||||
csv.append(String.join(",", keys));
|
||||
|
||||
@@ -282,7 +282,6 @@ public class TcpIngestorTest {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testCsvIngestorHandlesDurationAtEnd() throws Exception {
|
||||
|
||||
String host = "someHost";
|
||||
|
||||
@@ -38,7 +38,6 @@ public class CollectionUtils {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static <T> List<T> copySort(Collection<? extends T> collection, Comparator<T> comparator) {
|
||||
final List<T> result = new ArrayList<T>(collection);
|
||||
Collections.sort(result, comparator);
|
||||
|
||||
Reference in New Issue
Block a user