@Test public void testCreateShards() { Shardable<PostShard, PostEntity> shardable = PostShardService.create(); Key<Account> accountKey = factory().allocateId(Account.class); Key<PostEntity> postKey1 = factory().allocateId(accountKey, PostEntity.class); Key<PostEntity> postKey2 = factory().allocateId(accountKey, PostEntity.class); Key<PostEntity> postKey3 = factory().allocateId(accountKey, PostEntity.class); List<Key<PostEntity>> keys = new ArrayList<>(); keys.add(postKey1); keys.add(postKey2); keys.add(postKey3); Map<Ref<PostShard>, PostShard> map = shardable.createShardMapWithRef(keys); assertEquals(ShardConfig.POST_SHARD_COUNTER * keys.size(), map.size()); for (Key<PostEntity> postKey : keys) { for (int shardNum = 1; shardNum <= ShardConfig.POST_SHARD_COUNTER; shardNum++) { Ref<PostShard> ref = Ref.create(PostShard.createKey(postKey, shardNum)); assertTrue(map.containsKey(ref)); } } }
@Override public Map<Ref<PostShard>, PostShard> createShardMapWithRef(Iterable<Key<PostEntity>> keys) { return Observable .fromIterable(keys) .flatMap(this::createShardsFromPostKey) .toMap(Ref::create) .blockingGet(); }
PostShardService implements Shardable<PostShard, PostEntity> { @Override public Map<Ref<PostShard>, PostShard> createShardMapWithRef(Iterable<Key<PostEntity>> keys) { return Observable .fromIterable(keys) .flatMap(this::createShardsFromPostKey) .toMap(Ref::create) .blockingGet(); } }
PostShardService implements Shardable<PostShard, PostEntity> { @Override public Map<Ref<PostShard>, PostShard> createShardMapWithRef(Iterable<Key<PostEntity>> keys) { return Observable .fromIterable(keys) .flatMap(this::createShardsFromPostKey) .toMap(Ref::create) .blockingGet(); }  }
PostShardService implements Shardable<PostShard, PostEntity> { @Override public Map<Ref<PostShard>, PostShard> createShardMapWithRef(Iterable<Key<PostEntity>> keys) { return Observable .fromIterable(keys) .flatMap(this::createShardsFromPostKey) .toMap(Ref::create) .blockingGet(); }  @Override Map<Ref<PostShard>, PostShard> createShardMapWithRef(Iterable<Key<PostEntity>> keys); @Override Map<Key<PostShard>, PostShard> createShardMapWithKey(Iterable<Key<PostEntity>> keys); @Override Map<Ref<PostShard>, PostShard> createShardMapWithRef(Key<PostEntity> key); @Override Map<Key<PostShard>, PostShard> createShardMapWithKey(Key<PostEntity> key); @Override Key<PostShard> getRandomShardKey(Key<PostEntity> entityKey); @Override Observable<List<PostEntity>> mergeShards(Collection<? extends PostEntity> entities); Observable<List<PostEntity>> mergeShards(Collection<? extends PostEntity> entities,
      Key<Account> accountKey); @Override Observable<PostEntity> mergeShards(PostEntity entity); Observable<PostEntity> mergeShards(PostEntity entity, Key<Account> accountKey); }
PostShardService implements Shardable<PostShard, PostEntity> { @Override public Map<Ref<PostShard>, PostShard> createShardMapWithRef(Iterable<Key<PostEntity>> keys) { return Observable .fromIterable(keys) .flatMap(this::createShardsFromPostKey) .toMap(Ref::create) .blockingGet(); }  @Override Map<Ref<PostShard>, PostShard> createShardMapWithRef(Iterable<Key<PostEntity>> keys); @Override Map<Key<PostShard>, PostShard> createShardMapWithKey(Iterable<Key<PostEntity>> keys); @Override Map<Ref<PostShard>, PostShard> createShardMapWithRef(Key<PostEntity> key); @Override Map<Key<PostShard>, PostShard> createShardMapWithKey(Key<PostEntity> key); @Override Key<PostShard> getRandomShardKey(Key<PostEntity> entityKey); @Override Observable<List<PostEntity>> mergeShards(Collection<? extends PostEntity> entities); Observable<List<PostEntity>> mergeShards(Collection<? extends PostEntity> entities,
      Key<Account> accountKey); @Override Observable<PostEntity> mergeShards(PostEntity entity); Observable<PostEntity> mergeShards(PostEntity entity, Key<Account> accountKey);  }