Author: mduerig
Date: Mon Jul 25 16:06:18 2016
New Revision: 1754034
URL: http://svn.apache.org/viewvc?rev=1754034&view=rev
Log:
OAK-4277: Finalise de-duplication caches
Javadoc
Modified:
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/RecordCache.java
Modified:
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/RecordCache.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/RecordCache.java?rev=1754034&r1=1754033&r2=1754034&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/RecordCache.java
(original)
+++
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/RecordCache.java
Mon Jul 25 16:06:18 2016
@@ -29,15 +29,33 @@ import com.google.common.base.Supplier;
// FIXME OAK-4277: Finalise de-duplication caches
// implement configuration, monitoring and management
-// add unit tests
-// document, nullability
+/**
+ * Partial mapping of keys of type {@code T} to values of type {@link
RecordId}. This is
+ * typically used for de-duplicating values that have already been persisted
and thus
+ * already have a {@code RecordId}.
+ * @param <T>
+ */
public abstract class RecordCache<T> {
+ /**
+ * Add a mapping from {@code key} to {@code value}. Any existing mapping
is replaced.
+ */
public abstract void put(T key, RecordId value);
+ /**
+ * @return The mapping for {@code key}, or {@code null} if none.
+ */
@CheckForNull
public abstract RecordId get(T key);
+ /**
+ * Factory method for creating {@code RecordCache} instances. The returned
+ * instances are all thread safe. They implement a simple LRU behaviour
where
+ * the least recently accessed mapping would be replaced when inserting a
+ * new mapping would exceed {@code size}.
+ *
+ * @return A new {@code RecordCache} instance of the given {@code size}.
+ */
@Nonnull
public static <T> RecordCache<T> newRecordCache(int size) {
if (size <= 0) {
@@ -47,6 +65,10 @@ public abstract class RecordCache<T> {
}
}
+ /**
+ * @return A factory returning {@code RecordCache} instances of the given
size when invoked.
+ * @see #newRecordCache(int)
+ */
@Nonnull
public static <T> Supplier<RecordCache<T>> factory(int size) {
if (size <= 0) {