@Test public void testFindShardKeys_collection() throws Exception { KeyRange<Tag> hashTagKeyRange = ofy().factory().allocateIds(Tag.class, 5); TagShardService shardService = TagShardService.create(); Map<Key<TagShard>, TagShard> map = shardService.createShardMapWithKey(hashTagKeyRange); assertEquals(TagShard.SHARD_COUNT * 5, map.keySet().size()); }
@Override public Map<Key<TagShard>, TagShard> createShardMapWithKey(Iterable<Key<Tag>> keys) { return Observable.fromIterable(keys) .flatMap(postKey -> Observable.range(1, ShardConfig.TAG_SHARD_COUNTER) .map(shardNum -> TagShard.builder() .id(ShardUtil.generateShardId(postKey, shardNum)) .posts(0L) .build())) .toMap(Key::create) .blockingGet(); }
TagShardService implements Shardable<TagShard, Tag> { @Override public Map<Key<TagShard>, TagShard> createShardMapWithKey(Iterable<Key<Tag>> keys) { return Observable.fromIterable(keys) .flatMap(postKey -> Observable.range(1, ShardConfig.TAG_SHARD_COUNTER) .map(shardNum -> TagShard.builder() .id(ShardUtil.generateShardId(postKey, shardNum)) .posts(0L) .build())) .toMap(Key::create) .blockingGet(); } }
TagShardService implements Shardable<TagShard, Tag> { @Override public Map<Key<TagShard>, TagShard> createShardMapWithKey(Iterable<Key<Tag>> keys) { return Observable.fromIterable(keys) .flatMap(postKey -> Observable.range(1, ShardConfig.TAG_SHARD_COUNTER) .map(shardNum -> TagShard.builder() .id(ShardUtil.generateShardId(postKey, shardNum)) .posts(0L) .build())) .toMap(Key::create) .blockingGet(); }  }
TagShardService implements Shardable<TagShard, Tag> { @Override public Map<Key<TagShard>, TagShard> createShardMapWithKey(Iterable<Key<Tag>> keys) { return Observable.fromIterable(keys) .flatMap(postKey -> Observable.range(1, ShardConfig.TAG_SHARD_COUNTER) .map(shardNum -> TagShard.builder() .id(ShardUtil.generateShardId(postKey, shardNum)) .posts(0L) .build())) .toMap(Key::create) .blockingGet(); }  @Override Map<Ref<TagShard>, TagShard> createShardMapWithRef(Iterable<Key<Tag>> keys); @Override Map<Key<TagShard>, TagShard> createShardMapWithKey(Iterable<Key<Tag>> keys); @Override Map<Ref<TagShard>, TagShard> createShardMapWithRef(Key<Tag> key); @Override Map<Key<TagShard>, TagShard> createShardMapWithKey(Key<Tag> key); @Override Key<TagShard> getRandomShardKey(Key<Tag> entityKey); @Override Observable<List<Tag>> mergeShards(Collection<? extends Tag> entities); @Override Observable<Tag> mergeShards(Tag entity); Collection<TagShard> updateShards(Iterable<String> tagNames); }
TagShardService implements Shardable<TagShard, Tag> { @Override public Map<Key<TagShard>, TagShard> createShardMapWithKey(Iterable<Key<Tag>> keys) { return Observable.fromIterable(keys) .flatMap(postKey -> Observable.range(1, ShardConfig.TAG_SHARD_COUNTER) .map(shardNum -> TagShard.builder() .id(ShardUtil.generateShardId(postKey, shardNum)) .posts(0L) .build())) .toMap(Key::create) .blockingGet(); }  @Override Map<Ref<TagShard>, TagShard> createShardMapWithRef(Iterable<Key<Tag>> keys); @Override Map<Key<TagShard>, TagShard> createShardMapWithKey(Iterable<Key<Tag>> keys); @Override Map<Ref<TagShard>, TagShard> createShardMapWithRef(Key<Tag> key); @Override Map<Key<TagShard>, TagShard> createShardMapWithKey(Key<Tag> key); @Override Key<TagShard> getRandomShardKey(Key<Tag> entityKey); @Override Observable<List<Tag>> mergeShards(Collection<? extends Tag> entities); @Override Observable<Tag> mergeShards(Tag entity); Collection<TagShard> updateShards(Iterable<String> tagNames);  }