java类com.google.common.collect.ArrayListMultimap的实例源码

TsvResourceInitializer.java 文件源码 项目:clearwsd 阅读 19 收藏 0 点赞 0 评论 0
@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;
}
ConfigManager.java 文件源码 项目:CustomWorldGen 阅读 32 收藏 0 点赞 0 评论 0
public static void loadData(ASMDataTable data)
{
    FMLLog.fine("Loading @Config anotation data");
    for (ASMData target : data.getAll(Config.class.getName()))
    {
        String modid = (String)target.getAnnotationInfo().get("modid");
        Multimap<Config.Type, ASMData> map = asm_data.get(modid);
        if (map == null)
        {
            map = ArrayListMultimap.create();
            asm_data.put(modid, map);
        }

        EnumHolder tholder = (EnumHolder)target.getAnnotationInfo().get("type");
        Config.Type type = tholder == null ? Config.Type.INSTANCE : Config.Type.valueOf(tholder.getValue());

        map.put(type, target);
    }
}
VerwerkerPublicatieServiceImpl.java 文件源码 项目:OperatieBRP 阅读 18 收藏 0 点赞 0 评论 0
@Override
public int publiceerSchrijfTaken(final SelectieVerwerkTaakBericht selectieTaak, final Collection<VerwerkPersoonResultaat> resultaten) {
    final ArrayListMultimap<Integer, VerwerkPersoonResultaat> berichtenPerSelectietaak = ArrayListMultimap.create();
    for (VerwerkPersoonResultaat resultaat : resultaten) {
        berichtenPerSelectietaak.put(resultaat.getSelectieTaakId(), resultaat);
    }

    final List<SelectieFragmentSchrijfBericht> schrijfTaken = new ArrayList<>();
    for (SelectieAutorisatieBericht selectieAutorisatie : selectieTaak.getSelectieAutorisaties()) {
        final List<VerwerkPersoonResultaat> berichtenVoorAutorisatie = berichtenPerSelectietaak.get(selectieAutorisatie.getSelectietaakId());
        if (!berichtenVoorAutorisatie.isEmpty()) {
            final SelectieFragmentSchrijfBericht bericht =
                    maakSelectieFragmentSchrijfBericht(selectieTaak, selectieAutorisatie, berichtenVoorAutorisatie);
            schrijfTaken.add(bericht);
        }
    }
    //publiceer xml berichten naar schrijf node
    if (!schrijfTaken.isEmpty()) {
        selectieSchrijfTaakPublicatieService.publiceerSchrijfTaken(schrijfTaken);
    }
    return schrijfTaken.size();
}
ProtobufUtil.java 文件源码 项目:ditb 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Convert a protobuf UserTablePermissions to a
 * ListMultimap&lt;String, TablePermission&gt; where key is username.
 *
 * @param proto the protobuf UserPermission
 * @return the converted UserPermission
 */
public static ListMultimap<String, TablePermission> toUserTablePermissions(
    AccessControlProtos.UsersAndPermissions proto) {
  ListMultimap<String, TablePermission> perms = ArrayListMultimap.create();
  AccessControlProtos.UsersAndPermissions.UserPermissions userPerm;

  for (int i = 0; i < proto.getUserPermissionsCount(); i++) {
    userPerm = proto.getUserPermissions(i);
    for (int j = 0; j < userPerm.getPermissionsCount(); j++) {
      TablePermission tablePerm = toTablePermission(userPerm.getPermissions(j));
      perms.put(userPerm.getUser().toStringUtf8(), tablePerm);
    }
  }

  return perms;
}
HiveFunctionRegistry.java 文件源码 项目:dremio-oss 阅读 26 收藏 0 点赞 0 评论 0
private <C,I> void register(Class<? extends I> clazz, ArrayListMultimap<String,Class<? extends I>> methods) {
  Description desc = clazz.getAnnotation(Description.class);
  String[] names;
  if (desc != null) {
    names = desc.name().split(",");
    for (int i=0; i<names.length; i++) {
      names[i] = names[i].trim();
    }
  }else{
    names = new String[]{clazz.getName().replace('.', '_')};
  }

  UDFType type = clazz.getAnnotation(UDFType.class);
  if (type != null && !type.deterministic()) {
    nonDeterministicUDFs.add(clazz);
  }


  for(int i=0; i<names.length;i++) {
    methods.put(names[i].toLowerCase(), clazz);
  }
}
AccessControlLists.java 文件源码 项目:ditb 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 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;
}
RoundRobinOperator.java 文件源码 项目:dremio-oss 阅读 21 收藏 0 点赞 0 评论 0
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());
}
JvmComponentPlugin.java 文件源码 项目:Reer 阅读 20 收藏 0 点赞 0 评论 0
private static ListMultimap<String, LocalJava> indexByPath(ModelMap<LocalJava> localJavaInstalls) {
    final ListMultimap<String, LocalJava> index = ArrayListMultimap.create();
    for (LocalJava localJava : localJavaInstalls) {
        try {
            index.put(localJava.getPath().getCanonicalPath(), localJava);
        } catch (IOException e) {
            // ignore this installation for validation, it will be caught later
        }
    }
    return index;
}
IvyModuleDescriptorConverter.java 文件源码 项目:Reer 阅读 20 收藏 0 点赞 0 评论 0
private static void addDependency(List<IvyDependencyMetadata> result, DependencyDescriptor dependencyDescriptor) {
    ModuleRevisionId revisionId = dependencyDescriptor.getDependencyRevisionId();
    ModuleVersionSelector requested = DefaultModuleVersionSelector.newSelector(revisionId.getOrganisation(), revisionId.getName(), revisionId.getRevision());

    ListMultimap<String, String> configMappings = ArrayListMultimap.create();
    for (Map.Entry<String, List<String>> entry : readConfigMappings(dependencyDescriptor).entrySet()) {
        configMappings.putAll(entry.getKey(), entry.getValue());
    }

    List<Artifact> artifacts = Lists.newArrayList();
    for (DependencyArtifactDescriptor ivyArtifact : dependencyDescriptor.getAllDependencyArtifacts()) {
        IvyArtifactName ivyArtifactName = new DefaultIvyArtifactName(ivyArtifact.getName(), ivyArtifact.getType(), ivyArtifact.getExt(), (String) ivyArtifact.getExtraAttributes().get(CLASSIFIER));
        artifacts.add(new Artifact(ivyArtifactName, Sets.newHashSet(ivyArtifact.getConfigurations())));
    }

    List<Exclude> excludes = Lists.newArrayList();
    for (ExcludeRule excludeRule : dependencyDescriptor.getAllExcludeRules()) {
        excludes.add(forIvyExclude(excludeRule));
    }

    result.add(new IvyDependencyMetadata(
        requested,
        dependencyDescriptor.getDynamicConstraintDependencyRevisionId().getRevision(),
        false,
        dependencyDescriptor.isChanging(),
        dependencyDescriptor.isTransitive(),
        configMappings,
        artifacts,
        excludes));
}
ComponentAttributeMatcher.java 文件源码 项目:Reer 阅读 18 收藏 0 点赞 0 评论 0
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;
}


问题


面经


文章

微信
公众号

扫码关注公众号