Update to 0.2.0

This commit is contained in:
Andrea Cavalli 2023-07-22 00:56:13 +02:00
parent b603d78db5
commit ec093acbc2
3 changed files with 11 additions and 31 deletions

View File

@ -23,7 +23,7 @@
<groupId>org.warp.filesponge</groupId> <groupId>org.warp.filesponge</groupId>
<artifactId>FileSponge</artifactId> <artifactId>FileSponge</artifactId>
<version>0.1.0</version> <version>0.2.0</version>
<name>FileSponge</name> <name>FileSponge</name>

View File

@ -31,7 +31,7 @@ import java.util.function.Predicate;
import java.util.stream.Stream; import java.util.stream.Stream;
import reactor.util.function.Tuple2; import reactor.util.function.Tuple2;
public interface DiskCache extends URLsDiskHandler, URLsWriter, IBackuppable, SafeCloseable { public interface DiskCache extends URLsDiskHandler, URLsWriter, SafeCloseable {
void writeMetadataSync(URL url, Metadata metadata); void writeMetadataSync(URL url, Metadata metadata);
@ -58,10 +58,9 @@ public interface DiskCache extends URLsDiskHandler, URLsWriter, IBackuppable, Sa
return new DiskCacheImpl(db, dict1, dict2, shouldCache); return new DiskCacheImpl(db, dict1, dict2, shouldCache);
} }
static DiskCache openCustom(LLKeyValueDatabase db, static DiskCache openCustom(LLDictionary fileContent,
LLDictionary fileContent,
LLDictionary fileMetadata, LLDictionary fileMetadata,
Predicate<URL> shouldCache) { Predicate<URL> shouldCache) {
return new DiskCacheImpl(db, fileContent, fileMetadata, shouldCache); return new DiskCacheImpl(null, fileContent, fileMetadata, shouldCache);
} }
} }

View File

@ -24,19 +24,13 @@ import static org.warp.filesponge.FileSponge.BLOCK_SIZE;
import it.cavallium.buffer.Buf; import it.cavallium.buffer.Buf;
import it.cavallium.buffer.BufDataInput; import it.cavallium.buffer.BufDataInput;
import it.cavallium.buffer.BufDataOutput; import it.cavallium.buffer.BufDataOutput;
import it.cavallium.dbengine.client.IBackuppable;
import it.cavallium.dbengine.database.ColumnUtils;
import it.cavallium.dbengine.database.LLDatabaseConnection;
import it.cavallium.dbengine.database.LLDictionary; import it.cavallium.dbengine.database.LLDictionary;
import it.cavallium.dbengine.database.LLDictionaryResultType; import it.cavallium.dbengine.database.LLDictionaryResultType;
import it.cavallium.dbengine.database.LLKeyValueDatabase; import it.cavallium.dbengine.database.LLKeyValueDatabase;
import it.cavallium.dbengine.database.UpdateMode;
import it.cavallium.dbengine.database.UpdateReturnMode; import it.cavallium.dbengine.database.UpdateReturnMode;
import it.cavallium.dbengine.database.serialization.SerializationException; import it.cavallium.dbengine.database.serialization.SerializationException;
import it.cavallium.dbengine.rpc.current.data.DatabaseOptions;
import it.cavallium.dbengine.utils.StreamUtils; import it.cavallium.dbengine.utils.StreamUtils;
import it.unimi.dsi.fastutil.booleans.BooleanArrayList; import it.unimi.dsi.fastutil.booleans.BooleanArrayList;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -51,17 +45,17 @@ import reactor.util.function.Tuples;
class DiskCacheImpl implements DiskCache { class DiskCacheImpl implements DiskCache {
private final DiskMetadataSerializer diskMetadataSerializer; private final DiskMetadataSerializer diskMetadataSerializer;
@Nullable
private final LLKeyValueDatabase db; private final LLKeyValueDatabase ownedDb;
private final LLDictionary fileContent; private final LLDictionary fileContent;
private final LLDictionary fileMetadata; private final LLDictionary fileMetadata;
private final Predicate<URL> shouldCache; private final Predicate<URL> shouldCache;
public DiskCacheImpl(LLKeyValueDatabase db, DiskCacheImpl(@Nullable LLKeyValueDatabase ownedDb,
LLDictionary fileContent, LLDictionary fileContent,
LLDictionary fileMetadata, LLDictionary fileMetadata,
Predicate<URL> shouldCache) { Predicate<URL> shouldCache) {
this.db = db; this.ownedDb = ownedDb;
this.fileContent = fileContent; this.fileContent = fileContent;
this.fileMetadata = fileMetadata; this.fileMetadata = fileMetadata;
this.diskMetadataSerializer = new DiskMetadataSerializer(); this.diskMetadataSerializer = new DiskMetadataSerializer();
@ -305,21 +299,8 @@ class DiskCacheImpl implements DiskCache {
@Override @Override
public void close() { public void close() {
db.close(); if (ownedDb != null) {
} ownedDb.close();
}
@Override
public void pauseForBackup() {
db.pauseForBackup();
}
@Override
public void resumeAfterBackup() {
db.resumeAfterBackup();
}
@Override
public boolean isPaused() {
return db.isPaused();
} }
} }