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());
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class NodeEntry {
|
||||
+ valueAsString + "]";
|
||||
}
|
||||
|
||||
public <K,V> String toString(final Function<byte[], K> keyDecoder, final Function<byte[], V> valueDecoder) {
|
||||
public <K, V> String toString(final Function<byte[], K> keyDecoder, final Function<byte[], V> valueDecoder) {
|
||||
final String valueAsString = isInnerNode() ? String.valueOf(VariableByteEncoder.decodeFirstValue(value))
|
||||
: String.valueOf(valueDecoder.apply(value));
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ public class PersistentMapDiskNode {
|
||||
+ String.join("\n", entries.values().stream().map(NodeEntry::toString).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public <K,V> String toString(Function<byte[], K> keyDecoder, Function<byte[], V> valueDecoder) {
|
||||
public <K, V> String toString(Function<byte[], K> keyDecoder, Function<byte[], V> valueDecoder) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append("@");
|
||||
result.append(nodeOffset);
|
||||
|
||||
@@ -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(
|
||||
@@ -127,7 +127,7 @@ public class PersistentMapTest {
|
||||
final SecureRandom rnd = new SecureRandom();
|
||||
rnd.setSeed(1);
|
||||
|
||||
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file,dataDirectory, PersistentMap.LONG_CODER,
|
||||
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file, dataDirectory, PersistentMap.LONG_CODER,
|
||||
PersistentMap.LONG_CODER)) {
|
||||
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
@@ -159,7 +159,7 @@ public class PersistentMapTest {
|
||||
}
|
||||
}
|
||||
|
||||
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file,dataDirectory, PersistentMap.LONG_CODER,
|
||||
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file, dataDirectory, PersistentMap.LONG_CODER,
|
||||
PersistentMap.LONG_CODER)) {
|
||||
// map.print(PersistentMap.LONG_DECODER, PersistentMap.LONG_DECODER);
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
@@ -179,6 +179,7 @@ public class PersistentMapTest {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Test(invocationCount = 1)
|
||||
public void testManyEmptyValues() throws Exception {
|
||||
final Path file = dataDirectory.resolve("map.db");
|
||||
@@ -187,7 +188,7 @@ public class PersistentMapTest {
|
||||
final SecureRandom rnd = new SecureRandom();
|
||||
rnd.setSeed(1);
|
||||
|
||||
try (final PersistentMap<Long, Empty> map = new PersistentMap<>(file,dataDirectory, PersistentMap.LONG_CODER,
|
||||
try (final PersistentMap<Long, Empty> map = new PersistentMap<>(file, dataDirectory, PersistentMap.LONG_CODER,
|
||||
PersistentMap.EMPTY_ENCODER)) {
|
||||
|
||||
for (int i = 0; i < 1500; i++) {
|
||||
@@ -219,7 +220,7 @@ public class PersistentMapTest {
|
||||
}
|
||||
}
|
||||
|
||||
try (final PersistentMap<Long, Empty> map = new PersistentMap<>(file,dataDirectory, PersistentMap.LONG_CODER,
|
||||
try (final PersistentMap<Long, Empty> map = new PersistentMap<>(file, dataDirectory, PersistentMap.LONG_CODER,
|
||||
PersistentMap.EMPTY_ENCODER)) {
|
||||
map.print();
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
@@ -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<>();
|
||||
@@ -336,7 +337,7 @@ public class PersistentMapTest {
|
||||
final SecureRandom rnd = new SecureRandom();
|
||||
rnd.setSeed(1);
|
||||
|
||||
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file,dataDirectory, PersistentMap.LONG_CODER,
|
||||
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file, dataDirectory, PersistentMap.LONG_CODER,
|
||||
PersistentMap.LONG_CODER)) {
|
||||
|
||||
for (int i = 0; i < 1_000; i++) {
|
||||
@@ -368,7 +369,7 @@ public class PersistentMapTest {
|
||||
}
|
||||
}
|
||||
|
||||
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file,dataDirectory, PersistentMap.LONG_CODER,
|
||||
try (final PersistentMap<Long, Long> map = new PersistentMap<>(file, dataDirectory, PersistentMap.LONG_CODER,
|
||||
PersistentMap.LONG_CODER)) {
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
final AtomicInteger maxDepth = new AtomicInteger();
|
||||
|
||||
@@ -66,7 +66,7 @@ public class PdbFile {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PdbFile [tags=" + tags + ", rootBlockNumber=" + rootBlockNumber + ", partitionId="+partitionId+"]";
|
||||
return "PdbFile [tags=" + tags + ", rootBlockNumber=" + rootBlockNumber + ", partitionId=" + partitionId + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,6 +45,6 @@ class DocEncoderDecoder implements PartitionAwareEncoderDecoder<Doc, Doc> {
|
||||
}
|
||||
|
||||
public byte[] getEmptyValue() {
|
||||
return new byte[] {0};
|
||||
return new byte[] { 0 };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,6 @@ class TagEncoderDecoder implements EncoderDecoder<Tag> {
|
||||
|
||||
@Override
|
||||
public byte[] getEmptyValue() {
|
||||
return new byte[] {0};
|
||||
return new byte[] { 0 };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
@@ -41,7 +41,7 @@ public abstract class AggregateHandler implements Appender {
|
||||
}
|
||||
|
||||
protected String gnuplotXYAxis() {
|
||||
return xAxis.getAxisNameForPlots()+yAxis.getAxisNameForPlots();
|
||||
return xAxis.getAxisNameForPlots() + yAxis.getAxisNameForPlots();
|
||||
}
|
||||
|
||||
abstract Type getAxisType(GnuplotAxis axis);
|
||||
@@ -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,19 +31,20 @@ 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()) {
|
||||
result.add(type);
|
||||
}else {
|
||||
} else {
|
||||
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
|
||||
} else{
|
||||
// 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();
|
||||
handler.updateAxis(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,17 +90,19 @@ 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());
|
||||
if(aggregatedData.isPresent()) {
|
||||
final Optional<AggregatedData> aggregatedData = dataSerie.getAggregatedData()
|
||||
.get(handler.getAggregateType());
|
||||
if (aggregatedData.isPresent()) {
|
||||
handler.addPlot(result, aggregatedData.get(), dataSerie.getStyle(), title);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Optional;
|
||||
|
||||
public class AggregatedDataCollection implements Iterable<AggregatedData>{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
package org.lucares.pdb.plot.api;
|
||||
|
||||
public class AggregatedDataEntry {
|
||||
private final double epochSeconds;
|
||||
private final long value;
|
||||
public AggregatedDataEntry(double epochSeconds, long value) {
|
||||
private final double epochSeconds;
|
||||
private final long value;
|
||||
|
||||
public AggregatedDataEntry(final double epochSeconds, final long value) {
|
||||
super();
|
||||
this.epochSeconds = epochSeconds;
|
||||
this.value = value;
|
||||
}
|
||||
public double getEpochSeconds() {
|
||||
}
|
||||
|
||||
public double getEpochSeconds() {
|
||||
return epochSeconds;
|
||||
}
|
||||
public long getValue() {
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,13 +5,13 @@ import java.util.Locale;
|
||||
public interface Appender {
|
||||
default void appendln(final StringBuilder builder, final String string) {
|
||||
builder.append(string + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
default void appendfln(final StringBuilder builder, final String format, final Object... args) {
|
||||
builder.append(String.format(Locale.US,format + "\n", args));
|
||||
}
|
||||
default void appendfln(final StringBuilder builder, final String format, final Object... args) {
|
||||
builder.append(String.format(Locale.US, format + "\n", args));
|
||||
}
|
||||
|
||||
default void appendf(final StringBuilder builder, final String format, final Object... args) {
|
||||
builder.append(String.format(Locale.US,format, args));
|
||||
}
|
||||
default void appendf(final StringBuilder builder, final String format, final Object... args) {
|
||||
builder.append(String.format(Locale.US, format, args));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ public class ParallelRequestsAggregator implements CustomAggregator {
|
||||
this.toEpochMilli = toEpochMilli;
|
||||
|
||||
final int milliseconds = (int) (toEpochMilli - fromEpochMilli);
|
||||
increments = new short[milliseconds+1];
|
||||
increments = new short[milliseconds + 1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addValue(boolean valueIsInYRange,final long epochMilli, final long value) {
|
||||
public void addValue(boolean valueIsInYRange, final long epochMilli, final long value) {
|
||||
|
||||
final int endPos = (int) (epochMilli - fromEpochMilli);
|
||||
increments[endPos]--;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ScatterAggregateHandler extends AggregateHandler {
|
||||
aggregatedData.getDataFile(), //
|
||||
gnuplotTitle(title), //
|
||||
GnuplotLineType.Points, //
|
||||
gnuplotXYAxis(),//
|
||||
gnuplotXYAxis(), //
|
||||
lineStyle//
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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,10 +132,9 @@ public class AxisSettings {
|
||||
|
||||
if (ticIncrement != 0) {
|
||||
appendfln(result, "set %stics %f nomirror", axis, ticIncrement);
|
||||
}
|
||||
else if (ticsLabels != null && ticsLabels.size() > 0) {
|
||||
appendfln(result,"set %stics(%s) nomirror", axis, String.join(", ", ticsLabels));
|
||||
}else if(ticsEnabled) {
|
||||
} 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);
|
||||
}
|
||||
|
||||
@@ -150,15 +148,15 @@ public class AxisSettings {
|
||||
if (StringUtils.isNotBlank(label)) {
|
||||
appendfln(result, "set %slabel \"%s\"", axis, label);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
|
||||
appendfln(result, "set format %s \"\"", axis);
|
||||
appendfln(result, "set %slabel \"\"", axis);
|
||||
}
|
||||
|
||||
if (!StringUtils.isAllBlank(from, to)) {
|
||||
final String f = StringUtils.isEmpty(from) ? "" : "\""+from+"\"";
|
||||
final String t = StringUtils.isEmpty(to) ? "" : "\""+to+"\"";
|
||||
final String f = StringUtils.isEmpty(from) ? "" : "\"" + from + "\"";
|
||||
final String t = StringUtils.isEmpty(to) ? "" : "\"" + to + "\"";
|
||||
appendfln(result, "set %srange [%s:%s]", axis, f, t);
|
||||
}
|
||||
if (logscale) {
|
||||
|
||||
@@ -71,56 +71,29 @@ public class AxisTime {
|
||||
final long maxLabels = Math.max(1, widthInPx / (GnuplotSettings.TICKS_FONT_SIZE * 8));
|
||||
|
||||
final long tickIncrement = roundToTickIncrement(rangeInMs / maxLabels);
|
||||
return tickIncrement/1000.0;
|
||||
return tickIncrement / 1000.0;
|
||||
}
|
||||
|
||||
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++) {
|
||||
for (int i = 0; i < increments.size(); i++) {
|
||||
if (increments.get(i) > milliseconds) {
|
||||
return increments.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
return TimeUnit.DAYS.toMillis(365*10);
|
||||
return TimeUnit.DAYS.toMillis(365 * 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -15,9 +15,9 @@ public class GnuplotColor {
|
||||
|
||||
public static GnuplotColor byAwtColor(Color color) {
|
||||
|
||||
final String hex = String.format("%02x%02x%02x",//
|
||||
color.getRed(),//
|
||||
color.getGreen(),//
|
||||
final String hex = String.format("%02x%02x%02x", //
|
||||
color.getRed(), //
|
||||
color.getGreen(), //
|
||||
color.getBlue()//
|
||||
);
|
||||
|
||||
@@ -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:
|
||||
@@ -36,13 +34,13 @@ public interface GnuplotColorPalettes {
|
||||
GnuplotColor.byHex("0072b2"), // blue
|
||||
GnuplotColor.byHex("e51e10"), // red
|
||||
GnuplotColor.byHex("FF69B4")// magenta
|
||||
);
|
||||
);
|
||||
|
||||
List<GnuplotColor> GNUPLOT_REORDERED = Arrays.asList(//
|
||||
GnuplotColor.byHex("0072b2"), // blue
|
||||
GnuplotColor.byHex("e69f00"), // orange
|
||||
GnuplotColor.byHex("9400D3"), //purple
|
||||
GnuplotColor.byHex("009e73"), //green
|
||||
GnuplotColor.byHex("9400D3"), // purple
|
||||
GnuplotColor.byHex("009e73"), // green
|
||||
GnuplotColor.byHex("f0e442"), // yellow
|
||||
GnuplotColor.byHex("e51e10"), // red
|
||||
GnuplotColor.byHex("56b4e9"), // lightblue
|
||||
@@ -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>
|
||||
*
|
||||
@@ -78,8 +75,7 @@ public interface GnuplotColorPalettes {
|
||||
GnuplotColor.byHex("fdbb6c"), // light orange
|
||||
GnuplotColor.byHex("b3df72"), // light green
|
||||
GnuplotColor.byHex("feffbe")// light yellow
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
List<GnuplotColor> DEFAULT = GNUPLOT_REORDERED;
|
||||
}
|
||||
|
||||
@@ -17,4 +17,3 @@ public enum GnuplotLineType {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public class GnuplotSettings {
|
||||
public final static int GNUPLOT_TOP_MARGIN = 57; // The top margin configured for gnuplot
|
||||
public final static int GNUPLOT_BOTTOM_MARGIN = 76; // The bottom margin configured for gnuplot
|
||||
public final static int GNUPLOT_TOP_BOTTOM_MARGIN = GNUPLOT_TOP_MARGIN + GNUPLOT_BOTTOM_MARGIN;
|
||||
public final static int GNUPLOT_LEFT_RIGHT_MARGIN = GNUPLOT_LEFT_MARGIN+GNUPLOT_RIGHT_MARGIN;
|
||||
public final static int GNUPLOT_LEFT_RIGHT_MARGIN = GNUPLOT_LEFT_MARGIN + GNUPLOT_RIGHT_MARGIN;
|
||||
public static final int TICKS_FONT_SIZE = 12;
|
||||
|
||||
private String terminal = "png";
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.io.Writer;
|
||||
|
||||
import org.lucares.pdb.api.RuntimeIOException;
|
||||
|
||||
public class LambdaFriendlyWriter extends Writer{
|
||||
public class LambdaFriendlyWriter extends Writer {
|
||||
|
||||
private final Writer writer;
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -209,7 +209,7 @@ public class Plotter {
|
||||
boolean valueIsInYRange = value < minValue || value > maxValue;
|
||||
if (valueIsInYRange) {
|
||||
ignoredValues++;
|
||||
}else {
|
||||
} else {
|
||||
plottedValues++;
|
||||
}
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -40,9 +39,9 @@ class YAxisTicks {
|
||||
// use the default
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> computeLog10YTicks(final int height, final long yRangeMin, final long yRangeMax) {
|
||||
private static List<String> computeLog10YTicks(final int height, final long yRangeMin, final long yRangeMax) {
|
||||
|
||||
final List<String> ticsLabels = Arrays.asList(//
|
||||
"\"1ms\" 1", //
|
||||
@@ -77,14 +76,12 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> computeLinearYTicks(final long height, final long yRangeMin, final long yRangeMax) {
|
||||
private static List<String> computeLinearYTicks(final long height, final long yRangeMin, final long yRangeMax) {
|
||||
|
||||
final long plotHeight = height - GnuplotSettings.GNUPLOT_TOP_BOTTOM_MARGIN;
|
||||
final long maxLabels = plotHeight / (GnuplotSettings.TICKS_FONT_SIZE * 5);
|
||||
@@ -98,9 +95,9 @@ private static List<String> computeLinearYTicks(final long height, final long yR
|
||||
}
|
||||
|
||||
return ticsLabels;
|
||||
}
|
||||
}
|
||||
|
||||
private static long roundToLinearLabelSteps(final long msPerLabel) {
|
||||
private static long roundToLinearLabelSteps(final long msPerLabel) {
|
||||
final List<Long> steps = Arrays.asList(2L, 5L, 10L, 20L, 50L, 100L, 200L, 500L, 1000L, 2000L, 5000L, 10_000L,
|
||||
20_000L, MINUTES.toMillis(1), MINUTES.toMillis(2), MINUTES.toMillis(5), MINUTES.toMillis(10),
|
||||
MINUTES.toMillis(15), MINUTES.toMillis(30), HOURS.toMillis(1), HOURS.toMillis(2), HOURS.toMillis(5),
|
||||
@@ -114,17 +111,17 @@ private static long roundToLinearLabelSteps(final long msPerLabel) {
|
||||
}
|
||||
|
||||
return msPerLabel;
|
||||
}
|
||||
}
|
||||
|
||||
private static String msToTic(final long ms, final double msPerLabel) {
|
||||
private static String msToTic(final long ms, final double msPerLabel) {
|
||||
|
||||
if (ms < 1000) {
|
||||
return ms + "ms";
|
||||
} else if (ms < MINUTES.toMillis(1)) {
|
||||
if (msPerLabel % 1000 == 0) {
|
||||
return String.format(Locale.US,"%ds", ms / 1_000);
|
||||
return String.format(Locale.US, "%ds", ms / 1_000);
|
||||
} else {
|
||||
return String.format(Locale.US,"%.1fs", ms / 1_000.0);
|
||||
return String.format(Locale.US, "%.1fs", ms / 1_000.0);
|
||||
}
|
||||
} else if (ms < TimeUnit.HOURS.toMillis(1)) {
|
||||
|
||||
@@ -155,5 +152,5 @@ private static String msToTic(final long ms, final double msPerLabel) {
|
||||
|
||||
return day + "d " + hour + "h ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@Controller
|
||||
@EnableAutoConfiguration
|
||||
@CrossOrigin(origins = {"http://localhost:4200", "http://127.0.0.1:4200"})
|
||||
@CrossOrigin(origins = { "http://localhost:4200", "http://127.0.0.1:4200" })
|
||||
public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PdbController.class);
|
||||
@@ -78,13 +78,13 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
@Value("${" + PRODUCTION_MODE + ":true}")
|
||||
private boolean modeProduction;
|
||||
|
||||
@Value("${"+DEFAULTS_QUERY_EXAMPLES+":}")
|
||||
@Value("${" + DEFAULTS_QUERY_EXAMPLES + ":}")
|
||||
private String queryExamples;
|
||||
|
||||
@Value("${"+DEFAULTS_GROUP_BY+":}")
|
||||
@Value("${" + DEFAULTS_GROUP_BY + ":}")
|
||||
private String defaultsGroupBy;
|
||||
|
||||
@Value("${"+DEFAULTS_SPLIT_BY+":}")
|
||||
@Value("${" + DEFAULTS_SPLIT_BY + ":}")
|
||||
private String defaultsSplitBy;
|
||||
|
||||
public PdbController(final PerformanceDb db, final Plotter plotter) {
|
||||
@@ -151,7 +151,7 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
|
||||
return ResponseEntity.ok().body(plotResponse);
|
||||
} catch (final NoDataPointsException e) {
|
||||
throw new NotFoundException("No data was found. Try another query, or change the date range.",e);
|
||||
throw new NotFoundException("No data was found. Try another query, or change the date range.", e);
|
||||
} finally {
|
||||
plotterLock.unlock();
|
||||
}
|
||||
@@ -171,7 +171,7 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
@RequestParam(name = "limitBy.selected", defaultValue = "NO_LIMIT") final Limit limitBy,
|
||||
@RequestParam(name = "dateRange") final String dateRange,
|
||||
@RequestParam(name = "axisScale", defaultValue = "LINEAR") final AxisScale axisScale,
|
||||
@RequestParam(name = "aggregates") final EnumSet<Aggregate>aggregate,
|
||||
@RequestParam(name = "aggregates") final EnumSet<Aggregate> aggregate,
|
||||
@RequestParam(name = "keyOutside", defaultValue = "false") final boolean keyOutside,
|
||||
@RequestParam(name = "width", defaultValue = "1920") final int hidth,
|
||||
@RequestParam(name = "height", defaultValue = "1080") final int height) {
|
||||
@@ -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);
|
||||
|
||||
@@ -226,13 +227,12 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
@ResponseBody
|
||||
AutocompleteResponse autocomplete(@RequestParam(name = "query") final String query,
|
||||
@RequestParam(name = "caretIndex") final int caretIndex,
|
||||
@RequestParam(name="resultMode", defaultValue = "CUT_AT_DOT") ResultMode resultMode) {
|
||||
@RequestParam(name = "resultMode", defaultValue = "CUT_AT_DOT") ResultMode resultMode) {
|
||||
|
||||
// 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();
|
||||
|
||||
@@ -254,7 +254,7 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
if (queryExamples.length() > 0) {
|
||||
final String[] exampleQueries = queryExamples.split(Pattern.quote(";"));
|
||||
for (String example : exampleQueries) {
|
||||
Proposal p = new Proposal(" Example: "+example, example, true, example+" ", example.length()+1);
|
||||
Proposal p = new Proposal(" Example: " + example, example, true, example + " ", example.length() + 1);
|
||||
result.add(p);
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
|
||||
@RequestMapping(path = "/fields", //
|
||||
method = RequestMethod.GET, //
|
||||
//consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, //
|
||||
// consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, //
|
||||
produces = MediaType.APPLICATION_JSON_VALUE //
|
||||
)
|
||||
@ResponseBody
|
||||
|
||||
@@ -9,14 +9,12 @@ public class PdbWebapp {
|
||||
public static void main(final String[] args) throws Exception {
|
||||
SpringApplication.run(MySpringConfiguration.class, args);
|
||||
|
||||
Thread t = new Thread(()-> {
|
||||
Thread t = new Thread(() -> {
|
||||
|
||||
|
||||
while(true){
|
||||
try{
|
||||
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,9 +70,11 @@ 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");
|
||||
}else {
|
||||
// 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());
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -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,12 +282,11 @@ public class TcpIngestorTest {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testCsvIngestorHandlesDurationAtEnd() throws Exception {
|
||||
|
||||
String host = "someHost";
|
||||
long value1 = 222;
|
||||
long value2= 1;
|
||||
long value2 = 1;
|
||||
try (TcpIngestor ingestor = new TcpIngestor(dataDirectory)) {
|
||||
|
||||
ingestor.start();
|
||||
@@ -304,7 +303,7 @@ public class TcpIngestorTest {
|
||||
entry2.put("host", host);
|
||||
entry2.put("duration", value2);
|
||||
|
||||
PdbTestUtil.sendAsCsv(List.of("@timestamp","host","duration"), List.of(entry1, entry2));
|
||||
PdbTestUtil.sendAsCsv(List.of("@timestamp", "host", "duration"), List.of(entry1, entry2));
|
||||
} catch (final Exception e) {
|
||||
LOGGER.error("", e);
|
||||
throw e;
|
||||
|
||||
@@ -38,8 +38,7 @@ 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);
|
||||
Collections.sort(result, comparator);
|
||||
return result;
|
||||
@@ -119,7 +118,7 @@ public class CollectionUtils {
|
||||
public static <T> boolean contains(Collection<T> collection, final Compare<T> compare) {
|
||||
for (T t : collection) {
|
||||
boolean found = compare.test(t);
|
||||
if (found ) {
|
||||
if (found) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -130,7 +129,7 @@ public class CollectionUtils {
|
||||
long count = 0;
|
||||
for (T t : collection) {
|
||||
boolean found = compare.test(t);
|
||||
if (found ) {
|
||||
if (found) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user