Java Code Examples for com.google.common.collect.LinkedHashMultimap#putAll()

The following examples show how to use com.google.common.collect.LinkedHashMultimap#putAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleSearchProviderImpl.java    From swellrt with Apache License 2.0 6 votes vote down vote up
private LinkedHashMultimap<WaveId, WaveletId> createWavesViewToFilter(final ParticipantId user,
    final boolean isAllQuery) {
  LinkedHashMultimap<WaveId, WaveletId> currentUserWavesView;
  currentUserWavesView = LinkedHashMultimap.create();
  currentUserWavesView.putAll(waveViewProvider.retrievePerUserWaveView(user));
  if (isAllQuery) {
    // If it is the "all" query - we need to include also waves view of the
    // shared domain participant.
    currentUserWavesView.putAll(waveViewProvider.retrievePerUserWaveView(sharedDomainParticipantId));
  }

  if(LOG.isFineLoggable()) {
    for (Map.Entry<WaveId, WaveletId> e : currentUserWavesView.entries()) {
      LOG.fine("unfiltered view contains: " + e.getKey() + " " + e.getValue());
    }
  }

  return currentUserWavesView;
}
 
Example 2
Source File: SimpleSearchProviderImpl.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
private LinkedHashMultimap<WaveId, WaveletId> createWavesViewToFilter(final ParticipantId user,
    final boolean isAllQuery) {
  LinkedHashMultimap<WaveId, WaveletId> currentUserWavesView;
  currentUserWavesView = LinkedHashMultimap.create();
  currentUserWavesView.putAll(waveViewProvider.retrievePerUserWaveView(user));
  if (isAllQuery) {
    // If it is the "all" query - we need to include also waves view of the
    // shared domain participant.
    currentUserWavesView.putAll(waveViewProvider.retrievePerUserWaveView(sharedDomainParticipantId));
  }

  if(LOG.isFineLoggable()) {
    for (Map.Entry<WaveId, WaveletId> e : currentUserWavesView.entries()) {
      LOG.fine("unfiltered view contains: " + e.getKey() + " " + e.getValue());
    }
  }

  return currentUserWavesView;
}
 
Example 3
Source File: TargetSpecResolver.java    From buck with Apache License 2.0 6 votes vote down vote up
private ImmutableList<ImmutableSet<BuildTarget>> collectTargets(
    int specsCount,
    List<ListenableFuture<Entry<Integer, ImmutableSet<BuildTarget>>>> targetFutures)
    throws InterruptedException {
  // Walk through and resolve all the futures, and place their results in a multimap that
  // is indexed by the integer representing the input target spec order.
  LinkedHashMultimap<Integer, BuildTarget> targetsMap = LinkedHashMultimap.create();
  try {
    for (ListenableFuture<Map.Entry<Integer, ImmutableSet<BuildTarget>>> targetFuture :
        targetFutures) {
      Map.Entry<Integer, ImmutableSet<BuildTarget>> result = targetFuture.get();
      targetsMap.putAll(result.getKey(), result.getValue());
    }
  } catch (ExecutionException e) {
    MoreThrowables.throwIfAnyCauseInstanceOf(e, InterruptedException.class);
    HumanReadableExceptions.throwIfHumanReadableUnchecked(e.getCause());
    throw new RuntimeException(e);
  }
  // Finally, pull out the final build target results in input target spec order, and place them
  // into a list of sets that exactly matches the ihput order.
  ImmutableList.Builder<ImmutableSet<BuildTarget>> targets = ImmutableList.builder();
  for (int index = 0; index < specsCount; index++) {
    targets.add(ImmutableSet.copyOf(targetsMap.get(index)));
  }
  return targets.build();
}
 
Example 4
Source File: ExpandCompositeTerms.java    From datawave with Apache License 2.0 3 votes vote down vote up
/**
 * This function is to order collections by size, this is useful so building composites can skip shorter composites ex. if KEY1_KEY2_KEY3 existed we would
 * not want to create KEY1_KEY2 or KEY1_KEY3 so could be skipped.
 * 
 * @param mm
 *            Multimap to sort by size of the {@code collection<v>}
 * @param <K>
 *            Key type for mm, not relevant to sort
 * @param <V>
 *            Value type for mm, not relevant to sort
 * @return Sorted linked hash multimap to keep order
 */
private <K,V> LinkedHashMultimap<K,V> orderByCollectionSize(Multimap<K,V> mm) {
    List<Entry<K,Collection<V>>> orderedCompositeToFieldMap = new ArrayList<>(mm.asMap().entrySet());
    Collections.sort(orderedCompositeToFieldMap, (o1, o2) -> Integer.compare(o2.getValue().size(), o1.getValue().size()));
    
    LinkedHashMultimap<K,V> orderedMm = LinkedHashMultimap.create();
    for (Map.Entry<K,Collection<V>> foundEntry : orderedCompositeToFieldMap) {
        orderedMm.putAll(foundEntry.getKey(), foundEntry.getValue());
    }
    return orderedMm;
}