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;
|
||||
@@ -40,12 +40,12 @@ public class PersistentMap<K, V> implements AutoCloseable {
|
||||
public byte[] encode(O object);
|
||||
|
||||
public O decode(byte[] bytes);
|
||||
|
||||
|
||||
public default Function<byte[], O> asDecoder() {
|
||||
return bytes -> this.decode(bytes);
|
||||
}
|
||||
|
||||
public default Function<O,byte[]> asEncoder() {
|
||||
|
||||
public default Function<O, byte[]> asEncoder() {
|
||||
return plain -> this.encode(plain);
|
||||
}
|
||||
|
||||
@@ -63,9 +63,10 @@ public class PersistentMap<K, V> implements AutoCloseable {
|
||||
public String decode(final byte[] bytes) {
|
||||
return bytes == null ? null : new String(bytes, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte[] getEmptyValue() {
|
||||
return new byte[] {0};
|
||||
return new byte[] { 0 };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,9 +81,10 @@ public class PersistentMap<K, V> implements AutoCloseable {
|
||||
public Long decode(final byte[] bytes) {
|
||||
return bytes == null ? null : VariableByteEncoder.decodeFirstValue(bytes);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte[] getEmptyValue() {
|
||||
return new byte[] {0};
|
||||
return new byte[] { 0 };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,9 +106,10 @@ 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;
|
||||
|
||||
Reference in New Issue
Block a user