diff --git a/dhfs-parent/objects/src/main/java/com/usatiuk/objects/snapshot/Snapshot.java b/dhfs-parent/objects/src/main/java/com/usatiuk/objects/snapshot/Snapshot.java index bd67866f..9e74e32f 100644 --- a/dhfs-parent/objects/src/main/java/com/usatiuk/objects/snapshot/Snapshot.java +++ b/dhfs-parent/objects/src/main/java/com/usatiuk/objects/snapshot/Snapshot.java @@ -8,12 +8,36 @@ import javax.annotation.Nonnull; import java.util.List; import java.util.Optional; +/** + * Interface for a snapshot of a database. + * Represents a point-in-time view of a storage, with a unique ID. + * + * @param the type of the key + * @param the type of the value + */ public interface Snapshot, V> extends AutoCloseable { + /** + * Get a list of iterators representing the snapshot. + * The iterators have priority: the first one in the list is the highest. + * The data type of the iterator is a tombstone: a tombstone represents a deleted value that does not exist anymore. + * The list of iterators is intended to be consumed by {@link com.usatiuk.objects.iterators.TombstoneSkippingIterator} + * + * @return a list of iterators + */ List>> getIterator(IteratorStart start, K key); + /** + * Read an object from the snapshot. + * @param name the name of the object + * @return an optional containing the object if it exists, or an empty optional if it does not + */ @Nonnull Optional readObject(K name); + /** + * Get the ID of the snapshot. + * @return the ID of the snapshot + */ long id(); @Override diff --git a/dhfs-parent/objects/src/main/java/com/usatiuk/objects/stores/CachingObjectPersistentStore.java b/dhfs-parent/objects/src/main/java/com/usatiuk/objects/stores/CachingObjectPersistentStore.java index 8f4b36d6..4df9488b 100644 --- a/dhfs-parent/objects/src/main/java/com/usatiuk/objects/stores/CachingObjectPersistentStore.java +++ b/dhfs-parent/objects/src/main/java/com/usatiuk/objects/stores/CachingObjectPersistentStore.java @@ -24,6 +24,11 @@ import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; +/** + * CachingObjectPersistentStore is a caching layer for the SerializingObjectPersistentStore + * It stores the already deserialized objects in memory. + * + */ @ApplicationScoped public class CachingObjectPersistentStore { private final AtomicReference _cache;