use of io.atomix.core.multimap.AsyncConsistentMultimap in project atomix by atomix.
the class ConsistentMultimapProxyBuilder method buildAsync.
@Override
@SuppressWarnings("unchecked")
public CompletableFuture<ConsistentMultimap<K, V>> buildAsync() {
PrimitiveProtocol protocol = protocol();
return managementService.getPartitionService().getPartitionGroup(protocol).getPartition(name()).getPrimitiveClient().newProxy(name(), primitiveType(), protocol).connect().thenApply(proxy -> {
AsyncConsistentMultimap<String, byte[]> rawMap = new ConsistentSetMultimapProxy(proxy);
Serializer serializer = serializer();
return new TranscodingAsyncConsistentMultimap<K, V, String, byte[]>(rawMap, key -> BaseEncoding.base16().encode(serializer.encode(key)), string -> serializer.decode(BaseEncoding.base16().decode(string)), value -> serializer.encode(value), bytes -> serializer.decode(bytes)).sync();
});
}
Aggregations