remove dependency to Guava
This commit is contained in:
@@ -7,10 +7,10 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Function;
|
||||
import java.util.Objects;
|
||||
import java.util.Stack;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.lucares.collections.LongList;
|
||||
import org.lucares.pdb.diskstorage.DiskBlock;
|
||||
@@ -45,7 +45,7 @@ public class PersistentMap<K, V> implements AutoCloseable {
|
||||
return bytes -> this.decode(bytes);
|
||||
}
|
||||
|
||||
public default Function<O,byte[]> asEncoder() {
|
||||
public default Function<O, byte[]> asEncoder() {
|
||||
return plain -> this.encode(plain);
|
||||
}
|
||||
|
||||
@@ -64,8 +64,9 @@ public class PersistentMap<K, V> implements AutoCloseable {
|
||||
return bytes == null ? null : new String(bytes, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getEmptyValue() {
|
||||
return new byte[] {0};
|
||||
return new byte[] { 0 };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,8 +82,9 @@ public class PersistentMap<K, V> implements AutoCloseable {
|
||||
return bytes == null ? null : VariableByteEncoder.decodeFirstValue(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getEmptyValue() {
|
||||
return new byte[] {0};
|
||||
return new byte[] { 0 };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,8 +107,9 @@ public class PersistentMap<K, V> implements AutoCloseable {
|
||||
return new UUID(mostSignificantBits, leastSignificantBits);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getEmptyValue() {
|
||||
return new byte[] {0};
|
||||
return new byte[] { 0 };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,12 +124,12 @@ public class PersistentMap<K, V> implements AutoCloseable {
|
||||
|
||||
@Override
|
||||
public Empty decode(final byte[] bytes) {
|
||||
|
||||
Preconditions.checkEqual(bytes.length, 0, "");
|
||||
Preconditions.checkTrue(bytes.length == 0, "");
|
||||
|
||||
return Empty.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getEmptyValue() {
|
||||
return new byte[] {};
|
||||
}
|
||||
@@ -152,7 +155,8 @@ public class PersistentMap<K, V> implements AutoCloseable {
|
||||
|
||||
private final LRUCache<K, V> valueCache = new LRUCache<>(1_000);
|
||||
|
||||
public PersistentMap(final Path path, final Path storageBasePath, final EncoderDecoder<K> keyEncoder, final EncoderDecoder<V> valueEncoder) {
|
||||
public PersistentMap(final Path path, final Path storageBasePath, final EncoderDecoder<K> keyEncoder,
|
||||
final EncoderDecoder<V> valueEncoder) {
|
||||
this.diskStore = new DiskStorage(path, storageBasePath);
|
||||
this.keyEncoder = keyEncoder;
|
||||
this.valueEncoder = valueEncoder;
|
||||
|
||||
@@ -26,7 +26,6 @@ ext {
|
||||
|
||||
lib_commons_collections4 = 'org.apache.commons:commons-collections4:4.4'
|
||||
lib_commons_lang3 = 'org.apache.commons:commons-lang3:3.9'
|
||||
lib_guava = 'com.google.guava:guava:28.0-jre'
|
||||
lib_jackson_databind = 'com.fasterxml.jackson.core:jackson-databind:2.9.9.1'
|
||||
|
||||
lib_log4j2_api = "org.apache.logging.log4j:log4j-api:${version_log4j2}"
|
||||
|
||||
@@ -9,7 +9,6 @@ dependencies {
|
||||
|
||||
compile lib_primitive_collections
|
||||
compile lib_commons_lang3
|
||||
compile lib_guava
|
||||
|
||||
compile lib_log4j2_core
|
||||
compile lib_log4j2_slf4j_impl
|
||||
|
||||
@@ -3,6 +3,5 @@ dependencies {
|
||||
compile project(':performanceDb')
|
||||
compile lib_primitive_collections
|
||||
compile lib_jackson_databind
|
||||
compile lib_guava
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,7 @@ import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.lucares.pdb.api.DateTimeRange;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.lucares.utils.Preconditions;
|
||||
|
||||
public class PlotSettings {
|
||||
|
||||
@@ -120,7 +119,7 @@ public class PlotSettings {
|
||||
public DateTimeRange dateRange() {
|
||||
|
||||
final String[] startEnd = dateRangeAsString.split(Pattern.quote(" - "));
|
||||
Preconditions.checkArgument(startEnd.length == 2, "invalid date range");
|
||||
Preconditions.checkEqual(startEnd, 2, "invalid date range: ''{0}''", dateRangeAsString);
|
||||
|
||||
final OffsetDateTime startDate = LocalDateTime.parse(startEnd[0], DATE_FORMAT).atOffset(ZoneOffset.UTC);
|
||||
final OffsetDateTime endDate = LocalDateTime.parse(startEnd[1], DATE_FORMAT).atOffset(ZoneOffset.UTC);
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.ProcessBuilder.Redirect;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@@ -15,8 +16,6 @@ import java.util.concurrent.Executors;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
|
||||
public class Gnuplot {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Gnuplot.class);
|
||||
@@ -26,7 +25,8 @@ public class Gnuplot {
|
||||
private static final String PROPERTY_GNUPLOT_HOME = "gnuplot.home";
|
||||
private final Path tmpDirectory;
|
||||
|
||||
// This would be bad style if this code was executed in a web-container, because it would cause a memory leak.
|
||||
// This would be bad style if this code was executed in a web-container, because
|
||||
// it would cause a memory leak.
|
||||
// But this code is only (and will only) be executed as standalone application.
|
||||
private static final ExecutorService POOL = Executors.newCachedThreadPool();
|
||||
|
||||
@@ -43,14 +43,14 @@ public class Gnuplot {
|
||||
LOGGER.debug(gnuplotFileContent);
|
||||
|
||||
final File gnuplotFile = File.createTempFile("gnuplot", ".dem", tmpDirectory.toFile());
|
||||
Files.asCharSink(gnuplotFile, StandardCharsets.UTF_8).write(gnuplotFileContent);
|
||||
Files.writeString(gnuplotFile.toPath(), gnuplotFileContent, StandardCharsets.UTF_8);
|
||||
|
||||
final long start = System.nanoTime();
|
||||
|
||||
try {
|
||||
final ProcessBuilder processBuilder = new ProcessBuilder(gnuplotBinary(), gnuplotFile.getAbsolutePath())//
|
||||
.redirectOutput(Redirect.PIPE)//
|
||||
.redirectError(Redirect.PIPE);
|
||||
.redirectOutput(Redirect.PIPE)//
|
||||
.redirectError(Redirect.PIPE);
|
||||
|
||||
final Process process = processBuilder.start();
|
||||
logOutput("stderr", process.getErrorStream());
|
||||
@@ -69,18 +69,17 @@ public class Gnuplot {
|
||||
METRICS_LOGGER.debug("gnuplot: {}ms", (System.nanoTime() - start) / 1_000_000.0);
|
||||
}
|
||||
|
||||
private void logOutput(final String humanReadableType, final InputStream stream) throws IOException {
|
||||
private void logOutput(final String humanReadableType, final InputStream stream) throws IOException {
|
||||
|
||||
POOL.submit(()->{
|
||||
try{
|
||||
POOL.submit(() -> {
|
||||
try {
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
||||
String line;
|
||||
while(( line = reader.readLine()) != null){
|
||||
while ((line = reader.readLine()) != null) {
|
||||
LOGGER.info("gnuplot {}: {}", humanReadableType, line);
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
LOGGER.warn("Exception while reading "+ humanReadableType+ " of gnuplot command", e);
|
||||
} catch (final Exception e) {
|
||||
LOGGER.warn("Exception while reading " + humanReadableType + " of gnuplot command", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user