remove dependency to Guava
This commit is contained in:
@@ -7,10 +7,10 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
import org.lucares.collections.LongList;
|
import org.lucares.collections.LongList;
|
||||||
import org.lucares.pdb.diskstorage.DiskBlock;
|
import org.lucares.pdb.diskstorage.DiskBlock;
|
||||||
@@ -64,6 +64,7 @@ public class PersistentMap<K, V> implements AutoCloseable {
|
|||||||
return bytes == null ? null : new String(bytes, StandardCharsets.UTF_8);
|
return bytes == null ? null : new String(bytes, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getEmptyValue() {
|
public byte[] getEmptyValue() {
|
||||||
return new byte[] { 0 };
|
return new byte[] { 0 };
|
||||||
}
|
}
|
||||||
@@ -81,6 +82,7 @@ public class PersistentMap<K, V> implements AutoCloseable {
|
|||||||
return bytes == null ? null : VariableByteEncoder.decodeFirstValue(bytes);
|
return bytes == null ? null : VariableByteEncoder.decodeFirstValue(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getEmptyValue() {
|
public byte[] getEmptyValue() {
|
||||||
return new byte[] { 0 };
|
return new byte[] { 0 };
|
||||||
}
|
}
|
||||||
@@ -105,6 +107,7 @@ public class PersistentMap<K, V> implements AutoCloseable {
|
|||||||
return new UUID(mostSignificantBits, leastSignificantBits);
|
return new UUID(mostSignificantBits, leastSignificantBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getEmptyValue() {
|
public byte[] getEmptyValue() {
|
||||||
return new byte[] { 0 };
|
return new byte[] { 0 };
|
||||||
}
|
}
|
||||||
@@ -121,12 +124,12 @@ public class PersistentMap<K, V> implements AutoCloseable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Empty decode(final byte[] bytes) {
|
public Empty decode(final byte[] bytes) {
|
||||||
|
Preconditions.checkTrue(bytes.length == 0, "");
|
||||||
Preconditions.checkEqual(bytes.length, 0, "");
|
|
||||||
|
|
||||||
return Empty.INSTANCE;
|
return Empty.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getEmptyValue() {
|
public byte[] getEmptyValue() {
|
||||||
return new byte[] {};
|
return new byte[] {};
|
||||||
}
|
}
|
||||||
@@ -152,7 +155,8 @@ public class PersistentMap<K, V> implements AutoCloseable {
|
|||||||
|
|
||||||
private final LRUCache<K, V> valueCache = new LRUCache<>(1_000);
|
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.diskStore = new DiskStorage(path, storageBasePath);
|
||||||
this.keyEncoder = keyEncoder;
|
this.keyEncoder = keyEncoder;
|
||||||
this.valueEncoder = valueEncoder;
|
this.valueEncoder = valueEncoder;
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ ext {
|
|||||||
|
|
||||||
lib_commons_collections4 = 'org.apache.commons:commons-collections4:4.4'
|
lib_commons_collections4 = 'org.apache.commons:commons-collections4:4.4'
|
||||||
lib_commons_lang3 = 'org.apache.commons:commons-lang3:3.9'
|
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_jackson_databind = 'com.fasterxml.jackson.core:jackson-databind:2.9.9.1'
|
||||||
|
|
||||||
lib_log4j2_api = "org.apache.logging.log4j:log4j-api:${version_log4j2}"
|
lib_log4j2_api = "org.apache.logging.log4j:log4j-api:${version_log4j2}"
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ dependencies {
|
|||||||
|
|
||||||
compile lib_primitive_collections
|
compile lib_primitive_collections
|
||||||
compile lib_commons_lang3
|
compile lib_commons_lang3
|
||||||
compile lib_guava
|
|
||||||
|
|
||||||
compile lib_log4j2_core
|
compile lib_log4j2_core
|
||||||
compile lib_log4j2_slf4j_impl
|
compile lib_log4j2_slf4j_impl
|
||||||
|
|||||||
@@ -3,6 +3,5 @@ dependencies {
|
|||||||
compile project(':performanceDb')
|
compile project(':performanceDb')
|
||||||
compile lib_primitive_collections
|
compile lib_primitive_collections
|
||||||
compile lib_jackson_databind
|
compile lib_jackson_databind
|
||||||
compile lib_guava
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ import java.util.List;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.lucares.pdb.api.DateTimeRange;
|
import org.lucares.pdb.api.DateTimeRange;
|
||||||
|
import org.lucares.utils.Preconditions;
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
|
|
||||||
public class PlotSettings {
|
public class PlotSettings {
|
||||||
|
|
||||||
@@ -120,7 +119,7 @@ public class PlotSettings {
|
|||||||
public DateTimeRange dateRange() {
|
public DateTimeRange dateRange() {
|
||||||
|
|
||||||
final String[] startEnd = dateRangeAsString.split(Pattern.quote(" - "));
|
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 startDate = LocalDateTime.parse(startEnd[0], DATE_FORMAT).atOffset(ZoneOffset.UTC);
|
||||||
final OffsetDateTime endDate = LocalDateTime.parse(startEnd[1], 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.io.InputStreamReader;
|
||||||
import java.lang.ProcessBuilder.Redirect;
|
import java.lang.ProcessBuilder.Redirect;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
@@ -15,8 +16,6 @@ import java.util.concurrent.Executors;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.common.io.Files;
|
|
||||||
|
|
||||||
public class Gnuplot {
|
public class Gnuplot {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Gnuplot.class);
|
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 static final String PROPERTY_GNUPLOT_HOME = "gnuplot.home";
|
||||||
private final Path tmpDirectory;
|
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.
|
// But this code is only (and will only) be executed as standalone application.
|
||||||
private static final ExecutorService POOL = Executors.newCachedThreadPool();
|
private static final ExecutorService POOL = Executors.newCachedThreadPool();
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ public class Gnuplot {
|
|||||||
LOGGER.debug(gnuplotFileContent);
|
LOGGER.debug(gnuplotFileContent);
|
||||||
|
|
||||||
final File gnuplotFile = File.createTempFile("gnuplot", ".dem", tmpDirectory.toFile());
|
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();
|
final long start = System.nanoTime();
|
||||||
|
|
||||||
@@ -78,8 +78,7 @@ public class Gnuplot {
|
|||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
LOGGER.info("gnuplot {}: {}", humanReadableType, line);
|
LOGGER.info("gnuplot {}: {}", humanReadableType, line);
|
||||||
}
|
}
|
||||||
}
|
} catch (final Exception e) {
|
||||||
catch (Exception e){
|
|
||||||
LOGGER.warn("Exception while reading " + humanReadableType + " of gnuplot command", e);
|
LOGGER.warn("Exception while reading " + humanReadableType + " of gnuplot command", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user