- final Multimap<DOMDataTreeShard, DOMDataTreeIdentifier> shardToIdentifiers = ArrayListMultimap.create();
- // map which identifier belongs to which shard
- for (final Entry<DOMDataTreeIdentifier, DOMDataTreeShard> entry : shardMap.entrySet()) {
- shardToIdentifiers.put(entry.getValue(), entry.getKey());
- }
-
- return new ShardedDOMDataTreeProducer(dataTree, subtrees, shardMap, shardToIdentifiers);
- }
-
- private static BiMap<DOMDataTreeIdentifier, DOMDataTreeShardProducer> mapIdsToProducer(
- final Multimap<DOMDataTreeShard, DOMDataTreeIdentifier> shardToId) {
- final Builder<DOMDataTreeIdentifier, DOMDataTreeShardProducer> idToProducerBuilder = ImmutableBiMap.builder();
- for (final Entry<DOMDataTreeShard, Collection<DOMDataTreeIdentifier>> entry : shardToId.asMap().entrySet()) {
- if (entry.getKey() instanceof WriteableDOMDataTreeShard) {
- //create a single producer for all prefixes in a single shard
- final DOMDataTreeShardProducer producer = ((WriteableDOMDataTreeShard) entry.getKey())
- .createProducer(entry.getValue());
- // id mapped to producers
- for (final DOMDataTreeIdentifier id : entry.getValue()) {
- idToProducerBuilder.put(id, producer);
- }
- } else {
- LOG.error("Unable to create a producer for shard that's not a WriteableDOMDataTreeShard");
- }
- }
-
- return idToProducerBuilder.build();