当前位置: 首页>>代码示例>>Java>>正文


Java ArrayListMultimap.create方法代码示例

本文整理汇总了Java中com.google.common.collect.ArrayListMultimap.create方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayListMultimap.create方法的具体用法?Java ArrayListMultimap.create怎么用?Java ArrayListMultimap.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.ArrayListMultimap的用法示例。


在下文中一共展示了ArrayListMultimap.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RoundRobinOperator

import com.google.common.collect.ArrayListMultimap; //导入方法依赖的package包/类
public RoundRobinOperator(TunnelProvider tunnelProvider, OperatorContext context, RoundRobinSender config) throws OutOfMemoryException {
  super(config);
  this.config = config;
  this.allocator = context.getAllocator();
  this.handle = context.getFragmentHandle();
  this.stats = context.getStats();

  List<MinorFragmentEndpoint> destinations = config.getDestinations();
  final ArrayListMultimap<NodeEndpoint, Integer> dests = ArrayListMultimap.create();
  for(MinorFragmentEndpoint destination : destinations) {
    dests.put(destination.getEndpoint(), destination.getId());
  }

  this.tunnels = new ArrayList<>();
  this.minorFragments = new ArrayList<>();
  for(final NodeEndpoint ep : dests.keySet()){
    List<Integer> minorsList= dests.get(ep);
    minorFragments.add(minorsList);
    tunnels.add(tunnelProvider.getExecTunnel(ep));
  }

  int destCount = dests.keySet().size();
  this.currentTunnelsIndex = ThreadLocalRandom.current().nextInt(destCount);
  this.currentMinorFragmentsIndex = ThreadLocalRandom.current().nextInt(minorFragments.get(currentTunnelsIndex).size());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:26,代码来源:RoundRobinOperator.java

示例2: assertErrorsOnLines

import com.google.common.collect.ArrayListMultimap; //导入方法依赖的package包/类
/**
 * Asserts that the given diagnostics contain errors with a message containing "[CheckerName]"
 * on the given lines of the given file. If there should be multiple errors on a line, the line
 * number must appear multiple times. There may not be any errors in any other file.
 */
public void assertErrorsOnLines(String file,
    List<Diagnostic<? extends JavaFileObject>> diagnostics, long... lines) {
  ListMultimap<String, Long> actualErrors = ArrayListMultimap.create();
  for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics) {
    String message = diagnostic.getMessage(Locale.US);

    // The source may be null, e.g. for diagnostics about command-line flags
    assertNotNull(message, diagnostic.getSource());
    String sourceName = diagnostic.getSource().getName();

    assertEquals(
        "unexpected error in source file " + sourceName + ": " + message,
        file, sourceName);

    actualErrors.put(diagnostic.getSource().getName(), diagnostic.getLineNumber());

    // any errors from the compiler that are not related to this checker should fail
    assertThat(message).contains("[" + checker.getAnnotation(BugPattern.class).name() + "]");
  }

  assertEquals(
      ImmutableMultiset.copyOf(Longs.asList(lines)),
      ImmutableMultiset.copyOf(actualErrors.get(file)));
}
 
开发者ID:google,项目名称:guava-beta-checker,代码行数:30,代码来源:TestCompiler.java

示例3: groupTasksByType

import com.google.common.collect.ArrayListMultimap; //导入方法依赖的package包/类
private ListMultimap<Class, Task> groupTasksByType(List<Task> tasks) {
    final Set<Class> taskTypes = new TreeSet<Class>(new Comparator<Class>() {
        public int compare(Class o1, Class o2) {
            return o1.getSimpleName().compareTo(o2.getSimpleName());
        }
    });
    taskTypes.addAll(collect(tasks, new Transformer<Class, Task>() {
        public Class transform(Task original) {
            return getDeclaredTaskType(original);
        }
    }));

    ListMultimap<Class, Task> tasksGroupedByType = ArrayListMultimap.create();
    for (final Class taskType : taskTypes) {
        tasksGroupedByType.putAll(taskType, filter(tasks, new Spec<Task>() {
            public boolean isSatisfiedBy(Task element) {
                return getDeclaredTaskType(element).equals(taskType);
            }
        }));
    }
    return tasksGroupedByType;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:TaskDetailPrinter.java

示例4: get

import com.google.common.collect.ArrayListMultimap; //导入方法依赖的package包/类
@Override
public MultimapResource<K> get() {
    ListMultimap<String, String> multimap = ArrayListMultimap.create();
    MultimapResource<K> resource = new MultimapResource<>(key);
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(path.openStream()))) {
        String line;
        while ((line = reader.readLine()) != null) {
            line = line.trim();
            if (line.trim().isEmpty()) {
                continue;
            }
            List<String> fields = Arrays.asList(line.split("\t"));
            apply(fields, multimap);
        }
    } catch (Exception e) {
        throw new RuntimeException("Error initializing TSV resource.", e);
    }
    resource.multimap(ImmutableListMultimap.copyOf(multimap));
    resource.mappingFunction(mappingFunction);
    return resource;
}
 
开发者ID:clearwsd,项目名称:clearwsd,代码行数:22,代码来源:TsvResourceInitializer.java

示例5: getExistingEntriesForVirtualNodes

import com.google.common.collect.ArrayListMultimap; //导入方法依赖的package包/类
@Override
@Transactional
public ListMultimap<String, AccessEntry> getExistingEntriesForVirtualNodes(Node... nodes)
{
	Collection<Integer> priorities = Lists.newArrayList();
	for( Node node : nodes )
	{
		if( !node.isVirtual() )
		{
			throw new IllegalArgumentException("Not a virtual node");
		}
		priorities.add(node.getOverridePriority());
		priorities.add(-node.getOverridePriority());
	}
	List<AccessEntry> entries = aclDao.getVirtualAccessEntries(priorities);
	ArrayListMultimap<String, AccessEntry> map = ArrayListMultimap.create();
	for( AccessEntry accessEntry : entries )
	{
		map.put(accessEntry.getTargetObject() + Integer.toString(Math.abs(accessEntry.getAclPriority())),
			accessEntry);
	}
	return map;
}
 
开发者ID:equella,项目名称:Equella,代码行数:24,代码来源:TLEAclManagerImpl.java

示例6: getPermissions

import com.google.common.collect.ArrayListMultimap; //导入方法依赖的package包/类
/**
 * Reads user permission assignments stored in the <code>l:</code> column
 * family of the first table row in <code>_acl_</code>.
 *
 * <p>
 * See {@link AccessControlLists class documentation} for the key structure
 * used for storage.
 * </p>
 */
static ListMultimap<String, TablePermission> getPermissions(Configuration conf,
    byte[] entryName) throws IOException {
  if (entryName == null) entryName = ACL_GLOBAL_NAME;

  // for normal user tables, we just read the table row from _acl_
  ListMultimap<String, TablePermission> perms = ArrayListMultimap.create();
  // TODO: Pass in a Connection rather than create one each time.
  try (Connection connection = ConnectionFactory.createConnection(conf)) {
    try (Table table = connection.getTable(ACL_TABLE_NAME)) {
      Get get = new Get(entryName);
      get.addFamily(ACL_LIST_FAMILY);
      Result row = table.get(get);
      if (!row.isEmpty()) {
        perms = parsePermissions(entryName, row);
      } else {
        LOG.info("No permissions found in " + ACL_TABLE_NAME + " for acl entry "
            + Bytes.toString(entryName));
      }
    }
  }

  return perms;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:33,代码来源:AccessControlLists.java

示例7: mapSorteerAttributen

import com.google.common.collect.ArrayListMultimap; //导入方法依赖的package包/类
private void mapSorteerAttributen() {
    final Map<Integer, GroepElement> objectSorteerGroepTemp = Maps.newHashMap();
    final ArrayListMultimap<GroepElement, AttribuutElement> sorteerElementenVoorGroep = ArrayListMultimap.create();
    for (final AttribuutElement attribuutElement : idAttribuutMap.values()) {
        if (attribuutElement.getElement().getElementWaarde().getSorteervolgorde() != null) {
            objectSorteerGroepTemp.put(attribuutElement.getObjectType(), idGroepMap.get(attribuutElement.getGroepId()));
            sorteerElementenVoorGroep.put(idGroepMap.get(attribuutElement.getGroepId()), attribuutElement);
        }
    }
    objectSorteerGroepMap = ImmutableMap.copyOf(objectSorteerGroepTemp);
    final Map<GroepElement, List<AttribuutElement>> gesorteerdeElementenVoorGroepTemp = new HashMap<>();

    for (GroepElement groepElement : sorteerElementenVoorGroep.keySet()) {
        final List<AttribuutElement> sorteerAttributen = sorteerElementenVoorGroep.get(groepElement);
        sorteerAttributen.sort(
                Comparator.comparing(o -> o.getElement().getElementWaarde().getSorteervolgorde()));
        gesorteerdeElementenVoorGroepTemp.put(groepElement, sorteerAttributen);
    }
    sorteerAttributenVoorGroep = ImmutableMap.copyOf(gesorteerdeElementenVoorGroepTemp);
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:21,代码来源:ElementHelper.java

示例8: loadHsnp

import com.google.common.collect.ArrayListMultimap; //导入方法依赖的package包/类
private static ArrayListMultimap<Long, Speed> loadHsnp(String filename) {
    File file = new File(filename);
    ArrayListMultimap<Long, Speed> speeds = ArrayListMultimap.create();
    if (!file.exists()) {
        log.info("File not found : {}", file.getAbsolutePath());
        return speeds;
    }

    log.info("Reading HSNP {}", file);
    try (DbfReader reader = new DbfReader(file)) {
        DbfRow row;
        while ((row = reader.nextRow()) != null) {
            Speed speed = parse(row);
            speeds.put(speed.getId(), speed);
        }
    }
    log.info("Loaded {} speed profile", speeds.size());
    return speeds;
}
 
开发者ID:Mappy,项目名称:fpm,代码行数:20,代码来源:HsnpDbf.java

示例9: BroadcastSenderRootExec

import com.google.common.collect.ArrayListMultimap; //导入方法依赖的package包/类
public BroadcastSenderRootExec(FragmentContext context,
                               RecordBatch incoming,
                               BroadcastSender config) throws OutOfMemoryException {
  super(context, context.newOperatorContext(config, null, false), config);
  this.ok = true;
  this.incoming = incoming;
  this.config = config;
  this.handle = context.getHandle();
  List<MinorFragmentEndpoint> destinations = config.getDestinations();
  ArrayListMultimap<DrillbitEndpoint, Integer> dests = ArrayListMultimap.create();

  for(MinorFragmentEndpoint destination : destinations) {
    dests.put(destination.getEndpoint(), destination.getId());
  }

  int destCount = dests.keySet().size();
  int i = 0;

  this.tunnels = new AccountingDataTunnel[destCount];
  this.receivingMinorFragments = new int[destCount][];
  for(final DrillbitEndpoint ep : dests.keySet()){
    List<Integer> minorsList= dests.get(ep);
    int[] minorsArray = new int[minorsList.size()];
    int x = 0;
    for(Integer m : minorsList){
      minorsArray[x++] = m;
    }
    receivingMinorFragments[i] = minorsArray;
    tunnels[i] = context.getDataTunnel(ep);
    i++;
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:33,代码来源:BroadcastSenderRootExec.java

示例10: selectClosestMatches

import com.google.common.collect.ArrayListMultimap; //导入方法依赖的package包/类
private List<HasAttributes> selectClosestMatches(List<HasAttributes> fullMatches) {
    Set<Attribute<?>> requestedAttributes = consumerAttributesContainer.keySet();
    // if there's more than one compatible match, prefer the closest. However there's a catch.
    // We need to look at all candidates globally, and select the closest match for each attribute
    // then see if there's a non-empty intersection.
    List<HasAttributes> remainingMatches = Lists.newArrayList(fullMatches);
    List<HasAttributes> best = Lists.newArrayListWithCapacity(fullMatches.size());
    final ListMultimap<AttributeValue<Object>, HasAttributes> candidatesByValue = ArrayListMultimap.create();
    for (Attribute<?> attribute : requestedAttributes) {
        Object requestedValue = consumerAttributesContainer.getAttribute(attribute);
        for (HasAttributes match : fullMatches) {
            Map<Attribute<Object>, AttributeValue<Object>> matchedAttributes = matchDetails.get(match).matchesByAttribute;
            candidatesByValue.put(matchedAttributes.get(attribute), match);
        }
        final AttributeValue<Object> requested = AttributeValue.of(requestedValue);
        disambiguate(remainingMatches, candidatesByValue, requested, consumerAttributeSchema.getMatchingStrategy(attribute), best);
        if (remainingMatches.isEmpty()) {
            // the intersection is empty, so we cannot choose
            return fullMatches;
        }
        candidatesByValue.clear();
        best.clear();
    }
    if (!remainingMatches.isEmpty()) {
        // there's a subset (or not) of best matches
        return remainingMatches;
    }
    return null;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:30,代码来源:ComponentAttributeMatcher.java

示例11: createNewMap

import com.google.common.collect.ArrayListMultimap; //导入方法依赖的package包/类
private Multimap<DataPointKey, DataPoint> createNewMap()
{
	Multimap<DataPointKey, DataPoint> ret;
	synchronized (m_mapLock)
	{
		ret = m_dataPointMultimap;

		m_dataPointMultimap = ArrayListMultimap.<DataPointKey, DataPoint>create();
	}

	return ret;
}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:13,代码来源:RemoteDatastore.java

示例12: BroadcastOperator

import com.google.common.collect.ArrayListMultimap; //导入方法依赖的package包/类
public BroadcastOperator(TunnelProvider tunnelProvider, OperatorContext context, BroadcastSender config) throws OutOfMemoryException {
  super(config);
  this.config = config;
  this.context = context;
  this.handle = context.getFragmentHandle();
  this.stats = context.getStats();

  final List<MinorFragmentEndpoint> destinations = config.getDestinations();
  final ArrayListMultimap<NodeEndpoint, Integer> dests = ArrayListMultimap.create();

  for(MinorFragmentEndpoint destination : destinations) {
    dests.put(destination.getEndpoint(), destination.getId());
  }

  int destCount = dests.keySet().size();
  int i = 0;

  this.tunnels = new AccountingExecTunnel[destCount];
  this.receivingMinorFragments = new int[destCount][];
  for(final NodeEndpoint ep : dests.keySet()){
    List<Integer> minorsList= dests.get(ep);
    int[] minorsArray = new int[minorsList.size()];
    int x = 0;
    for(Integer m : minorsList){
      minorsArray[x++] = m;
    }
    receivingMinorFragments[i] = minorsArray;
    tunnels[i] = tunnelProvider.getExecTunnel(ep);
    i++;
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:32,代码来源:BroadcastOperator.java

示例13: createSenderReceiverMapping

import com.google.common.collect.ArrayListMultimap; //导入方法依赖的package包/类
protected void createSenderReceiverMapping() {
  if (isSenderReceiverMappingCreated) {
    return;
  }

  senderToReceiverMapping = Maps.newHashMap();
  receiverToSenderMapping = ArrayListMultimap.create();

  // Find the list of sender fragment ids assigned to each SabotNode endpoint.
  ArrayListMultimap<NodeEndpoint, Integer> endpointSenderList = ArrayListMultimap.create();

  int senderFragmentId = 0;
  for(NodeEndpoint senderLocation : senderLocations) {
    endpointSenderList.put(senderLocation, senderFragmentId);
    senderFragmentId++;
  }

  int receiverFragmentId = 0;
  for(NodeEndpoint receiverLocation : receiverLocations) {
    List<Integer> senderFragmentIds = endpointSenderList.get(receiverLocation);

    for(Integer senderId : senderFragmentIds) {
      senderToReceiverMapping.put(senderId, new MinorFragmentEndpoint(receiverFragmentId, receiverLocation));

      receiverToSenderMapping.put(receiverFragmentId,
          new MinorFragmentEndpoint(senderId, senderLocations.get(senderId)));
    }
    receiverFragmentId++;
  }

  isSenderReceiverMappingCreated = true;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:33,代码来源:AbstractMuxExchange.java

示例14: getPossessiveSpecificMap

import com.google.common.collect.ArrayListMultimap; //导入方法依赖的package包/类
/**
 * For possessive languages, it makes sense to keep an enum map around for that
 */
public static <A extends NounForm> EnumMap<LanguagePossessive,NounFormMap<A>> getPossessiveSpecificMap(Collection<? extends A> forms) {
    Multimap<LanguagePossessive,A> mm = ArrayListMultimap.create();
    for (A form : forms) {
        mm.put(form.getPossessive(), form);
    }
    EnumMap<LanguagePossessive,NounFormMap<A>> result = new EnumMap<LanguagePossessive,NounFormMap<A>>(LanguagePossessive.class);
    for (LanguagePossessive poss : LanguagePossessive.values()) {
        result.put(poss, new NounFormMap<A>(mm.get(poss)));
    }
    return result;
}
 
开发者ID:salesforce,项目名称:grammaticus,代码行数:15,代码来源:ComplexGrammaticalForm.java

示例15: collectMethodBindings

import com.google.common.collect.ArrayListMultimap; //导入方法依赖的package包/类
private static <T> Set<StructMethodBinding> collectMethodBindings(StructBindingExtractionContext<T> extractionContext, Map<String, Multimap<PropertyAccessorType, StructMethodBinding>> propertyBindings) {
    Collection<WeaklyTypeReferencingMethod<?, ?>> implementedMethods = collectImplementedMethods(extractionContext.getImplementedSchemas());
    Map<Wrapper<Method>, WeaklyTypeReferencingMethod<?, ?>> publicViewImplMethods = collectPublicViewImplMethods(extractionContext.getPublicSchema());
    Map<Wrapper<Method>, WeaklyTypeReferencingMethod<?, ?>> delegateMethods = collectDelegateMethods(extractionContext.getDelegateSchema());

    ImmutableSet.Builder<StructMethodBinding> methodBindingsBuilder = ImmutableSet.builder();
    for (WeaklyTypeReferencingMethod<?, ?> weakImplementedMethod : implementedMethods) {
        Method implementedMethod = weakImplementedMethod.getMethod();
        PropertyAccessorType accessorType = PropertyAccessorType.of(implementedMethod);

        Wrapper<Method> methodKey = SIGNATURE_EQUIVALENCE.wrap(implementedMethod);
        WeaklyTypeReferencingMethod<?, ?> weakDelegateImplMethod = delegateMethods.get(methodKey);
        WeaklyTypeReferencingMethod<?, ?> weakPublicImplMethod = publicViewImplMethods.get(methodKey);
        if (weakDelegateImplMethod != null && weakPublicImplMethod != null) {
            extractionContext.add(weakImplementedMethod, String.format("it is both implemented by the view '%s' and the delegate type '%s'",
                extractionContext.getPublicSchema().getType().getDisplayName(),
                extractionContext.getDelegateSchema().getType().getDisplayName()));
        }

        String propertyName = accessorType == null ? null : accessorType.propertyNameFor(implementedMethod);

        StructMethodBinding binding;
        if (!Modifier.isAbstract(implementedMethod.getModifiers())) {
            binding = new DirectMethodBinding(weakImplementedMethod, accessorType);
        } else if (weakPublicImplMethod != null) {
            binding = new BridgeMethodBinding(weakImplementedMethod, weakPublicImplMethod, accessorType);
        } else if (weakDelegateImplMethod != null) {
            binding = new DelegateMethodBinding(weakImplementedMethod, weakDelegateImplMethod, accessorType);
        } else if (propertyName != null) {
            binding = new ManagedPropertyMethodBinding(weakImplementedMethod, propertyName, accessorType);
        } else {
            handleNoMethodImplementation(extractionContext, weakImplementedMethod);
            continue;
        }
        methodBindingsBuilder.add(binding);

        if (accessorType != null) {
            Multimap<PropertyAccessorType, StructMethodBinding> accessorBindings = propertyBindings.get(propertyName);
            if (accessorBindings == null) {
                accessorBindings = ArrayListMultimap.create();
                propertyBindings.put(propertyName, accessorBindings);
            }
            accessorBindings.put(accessorType, binding);
        }
    }
    return methodBindingsBuilder.build();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:48,代码来源:DefaultStructBindingsStore.java


注:本文中的com.google.common.collect.ArrayListMultimap.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。