mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-81 extend support for mapForkey to all maps.
This commit is contained in:
@@ -244,6 +244,11 @@ public class ReplicationCheckingMap<K, V> implements ChronicleMap<K, V> {
|
||||
return map1.getUsing(key, usingValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R> R mapForKey(K key, @NotNull Function<? super V, R> function) {
|
||||
return map1.mapForKey(key, function);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V acquireUsing(@NotNull K key, V usingValue) {
|
||||
return map1.acquireUsing(key, usingValue);
|
||||
|
||||
@@ -35,15 +35,15 @@ import java.util.Set;
|
||||
*/
|
||||
public class StatelessClientTest {
|
||||
|
||||
|
||||
public static final int SIZE = 100000;
|
||||
public static final int SIZE = 2500;
|
||||
|
||||
|
||||
static class StringBuilderToStringFunction implements Function<StringBuilder, String> {
|
||||
enum ToString implements Function<Object, String> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public String apply(StringBuilder stringBuilder) {
|
||||
return stringBuilder.toString();
|
||||
public String apply(Object obj) {
|
||||
return obj.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,7 @@ public class StatelessClientTest {
|
||||
.class, StringBuilder.class)
|
||||
.statelessClient(new InetSocketAddress("localhost", 8056)).create()) {
|
||||
|
||||
String actual = (String) ((StatelessChronicleMap) statelessMap).mapForKey(10, new
|
||||
StringBuilderToStringFunction());
|
||||
String actual = statelessMap.mapForKey(10, ToString.INSTANCE);
|
||||
|
||||
Assert.assertEquals("Hello World", actual);
|
||||
}
|
||||
@@ -87,8 +86,7 @@ public class StatelessClientTest {
|
||||
.class, StringBuilder.class)
|
||||
.statelessClient(new InetSocketAddress("localhost", 8056)).create()) {
|
||||
|
||||
String actual = (String) ((StatelessChronicleMap) statelessMap).mapForKey(11, new
|
||||
StringBuilderToStringFunction());
|
||||
String actual = statelessMap.mapForKey(11, ToString.INSTANCE);
|
||||
|
||||
Assert.assertEquals("", actual);
|
||||
}
|
||||
|
||||
@@ -19,10 +19,7 @@
|
||||
package net.openhft.chronicle.map.jrs166.map;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import net.openhft.chronicle.map.ChronicleMap;
|
||||
import net.openhft.chronicle.map.ChronicleMapBuilder;
|
||||
import net.openhft.chronicle.map.ReadContext;
|
||||
import net.openhft.chronicle.map.WriteContext;
|
||||
import net.openhft.chronicle.map.*;
|
||||
import net.openhft.chronicle.map.jrs166.JSR166TestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Ignore;
|
||||
@@ -169,6 +166,11 @@ public class StatelessChronicleMapTest extends JSR166TestCase {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R> R mapForKey(K key, @NotNull Function<? super V, R> function) {
|
||||
return d.mapForKey(key, function);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V putIfAbsent(K key, V value) {
|
||||
return d.putIfAbsent(key, value);
|
||||
|
||||
Reference in New Issue
Block a user