Package net.morimekta.providence.storage
Class DirectoryMessageListStore<K,M extends PMessage<M>>
- java.lang.Object
-
- net.morimekta.providence.storage.DirectoryMessageListStore<K,M>
-
- Type Parameters:
K
- The key type.M
- The stored message type.
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,MessageListReadOnlyStore<K,M>
,MessageListStore<K,M>
,ReadOnlyStore<K,java.util.List<M>>
,ReadWriteStore<K,java.util.List<M>>
public class DirectoryMessageListStore<K,M extends PMessage<M>> extends java.lang.Object implements MessageListStore<K,M>, java.io.Closeable
Simple file-based storage of lists of providence messages that keeps an in-memory key index, a message cache, and stores message lists to individual files in a single directly.Note that the directory store is not parallel compatible between instances, as all of them would be able to read, write etc all the files all the time.
TL;DR Each directory can only have one
DirectoryMessageListStore
instance active at a time.
-
-
Constructor Summary
Constructors Constructor Description DirectoryMessageListStore(FileManager<K> manager, PMessageDescriptor<M> descriptor, Serializer serializer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
containsKey(K key)
java.util.Map<K,java.util.List<M>>
getAll(java.util.Collection<K> keys)
Look up a set of keys from the storage.java.util.Collection<K>
keys()
Get a collection of all the keys in the store.void
putAll(java.util.Map<K,java.util.List<M>> values)
void
removeAll(java.util.Collection<K> keys)
Remove the values for the given keys.int
size()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.morimekta.providence.storage.MessageListReadOnlyStore
getAllBuilders, getBuilders
-
Methods inherited from interface net.morimekta.providence.storage.MessageListStore
putAllBuilders, putBuilders
-
Methods inherited from interface net.morimekta.providence.storage.ReadOnlyStore
get
-
Methods inherited from interface net.morimekta.providence.storage.ReadWriteStore
put, remove
-
-
-
-
Constructor Detail
-
DirectoryMessageListStore
public DirectoryMessageListStore(@Nonnull FileManager<K> manager, @Nonnull PMessageDescriptor<M> descriptor, @Nonnull Serializer serializer)
-
-
Method Detail
-
containsKey
public boolean containsKey(@Nonnull K key)
- Specified by:
containsKey
in interfaceReadOnlyStore<K,M extends PMessage<M>>
- Parameters:
key
- The key to look up.- Returns:
- True if the key was contained in the map.
-
keys
@Nonnull public java.util.Collection<K> keys()
Description copied from interface:ReadOnlyStore
Get a collection of all the keys in the store.
-
size
public int size()
-
getAll
@Nonnull public java.util.Map<K,java.util.List<M>> getAll(@Nonnull java.util.Collection<K> keys)
Description copied from interface:ReadOnlyStore
Look up a set of keys from the storage.
-
removeAll
public void removeAll(java.util.Collection<K> keys)
Description copied from interface:ReadWriteStore
Remove the values for the given keys.
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
-