public Future<List<Key>> put( Transaction txn, Iterable<Entity> entities) {
List<Entity> entityList = List.class.isAssignableFrom(entities.getClass()) ?
(List<Entity>) entities : Lists.newArrayList(entities);
PutContext prePutContext = new PutContext(this, entityList);
getDatastoreServiceConfig().getDatastoreCallbacks().executePrePutCallbacks(prePutContext);
PreMutationCachingResult preMutationCachingResult =
getEntityCachingStrategy().prePut(this, entityList);
List<IndexedItem<Key>> indexedKeysToSkip = Lists.newArrayList();
List<IndexedItem<Entity>> indexedEntitiesToPut = Lists.newArrayList();
Set<Key> mutationKeysToSkip = preMutationCachingResult.getMutationKeysToSkip();
int index = 0;
for (Entity entity : entityList) {
if (mutationKeysToSkip.contains(entity.getKey())) {
indexedKeysToSkip.add(new IndexedItem<Key>(entity.getKey(), index++));
} else {