當前位置: 首頁>>代碼示例>>Java>>正文


Java Multimap類代碼示例

本文整理匯總了Java中com.google.common.collect.Multimap的典型用法代碼示例。如果您正苦於以下問題:Java Multimap類的具體用法?Java Multimap怎麽用?Java Multimap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Multimap類屬於com.google.common.collect包,在下文中一共展示了Multimap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: spFile

import com.google.common.collect.Multimap; //導入依賴的package包/類
private static Multimap<Long, SignPostPath> spFile(TomtomFolder folder) {
    File file = new File(folder.getFile("sp.dbf"));
    Multimap<Long, SignPostPath> result = TreeMultimap.create();
    if (!file.exists()) {
        return result;
    }
    log.info("Reading SP {}", file);
    try (DbfReader reader = new DbfReader(file)) {
        DbfRow row;
        while ((row = reader.nextRow()) != null) {
            SignPostPath path = SignPostPath.fromRow(row);
            result.put(path.getId(), path);
        }
    }
    log.info("Loaded {} sign paths", result.size());
    return result;
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:18,代碼來源:SignPosts.java

示例2: binarize

import com.google.common.collect.Multimap; //導入依賴的package包/類
/**
 * Binarize embeddings as described in "Revisiting Embedding Features for Simple Semi-supervised Learning" (Guo et al. 2014).
 * Output is a map of indices, where negative-valued indices are negative, and positive-valued indices are positive. Indices
 * start at 1, so as to avoid loss of information on 0.
 *
 * @param embeddings map from identifiers onto corresponding vectors
 * @return map from identifiers onto indices
 */
public static Multimap<String, Integer> binarize(Map<String, float[]> embeddings) {
    float[] posMean = filteredMean(embeddings.values(), v -> v >= 0);
    float[] negMean = filteredMean(embeddings.values(), v -> v < 0);
    Multimap<String, Integer> binarizedEmbeddings = HashMultimap.create();
    for (Map.Entry<String, float[]> embedding : embeddings.entrySet()) {
        int index = 0;
        for (float val : embedding.getValue()) {
            if (val > posMean[index]) {
                binarizedEmbeddings.put(embedding.getKey(), -(index + 1));
            } else if (val < negMean[index]) {
                binarizedEmbeddings.put(embedding.getKey(), index + 1);
            }
            ++index;
        }
    }
    return binarizedEmbeddings;
}
 
開發者ID:clearwsd,項目名稱:clearwsd,代碼行數:26,代碼來源:EmbeddingIoUtils.java

示例3: calcCoverage

import com.google.common.collect.Multimap; //導入依賴的package包/類
/**
 * Generates a coverage multimap from split key to Regions that start with the
 * split key.
 * 
 * @return coverage multimap
 */
public Multimap<byte[], R> calcCoverage() {
  // This needs to be sorted to force the use of the comparator on the values,
  // otherwise byte array comparison isn't used
  Multimap<byte[], R> regions = TreeMultimap.create(BYTES_COMPARATOR,
      rangeCmp);

  // march through all splits from the start points
  for (Entry<byte[], Collection<R>> start : starts.asMap().entrySet()) {
    byte[] key = start.getKey();
    for (R r : start.getValue()) {
      regions.put(key, r);

      for (byte[] coveredSplit : splits.subSet(r.getStartKey(),
          specialEndKey(r))) {
        regions.put(coveredSplit, r);
      }
    }
  }
  return regions;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:27,代碼來源:RegionSplitCalculator.java

示例4: build

import com.google.common.collect.Multimap; //導入依賴的package包/類
/**
 * Bouwt het MetaObject.
 * @param parentObject het parent meta object
 * @return het MetaObject
 */
MetaObject build(final MetaObject parentObject) {
    final MetaObject gebouwdObject = new MetaObject();
    gebouwdObject.parentObject = parentObject;
    gebouwdObject.objectsleutel = objectsleutel;
    gebouwdObject.objectElement = objectElement;

    final Multimap<ObjectElement, MetaObject> tempObjectenMap = HashMultimap.create();
    for (final Builder builder : objectBuilderList) {
        final MetaObject object = builder.build(gebouwdObject);
        tempObjectenMap.put(object.getObjectElement(), object);
    }
    gebouwdObject.elementObjectMap = ImmutableMultimap.copyOf(tempObjectenMap);
    gebouwdObject.objecten = ImmutableSet.copyOf(tempObjectenMap.values());

    final Map<GroepElement, MetaGroep> tempGroepenMap = Maps.newHashMap();
    for (final MetaGroep.Builder groepBuilder : groepBuilderList) {
        final MetaGroep groep = groepBuilder.build(gebouwdObject);
        tempGroepenMap.put(groep.getGroepElement(), groep);
    }
    gebouwdObject.elementGroepMap = ImmutableMap.copyOf(tempGroepenMap);
    gebouwdObject.groepen = ImmutableSet.copyOf(tempGroepenMap.values());
    return gebouwdObject;
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:29,代碼來源:MetaObject.java

示例5: findUpdate

import com.google.common.collect.Multimap; //導入依賴的package包/類
private static RemotePkgInfo findUpdate(@NonNull LocalPkgInfo local,
                                        @NonNull Multimap<PkgType, RemotePkgInfo> remotePkgs,
                                        @NonNull UpdateResult result) {
    RemotePkgInfo currUpdatePkg = null;
    IPkgDesc currUpdateDesc = null;
    IPkgDesc localDesc = local.getDesc();

    for (RemotePkgInfo remote: remotePkgs.get(localDesc.getType())) {
        IPkgDesc remoteDesc = remote.getDesc();
        if ((currUpdateDesc == null && remoteDesc.isUpdateFor(localDesc)) ||
                (currUpdateDesc != null && remoteDesc.isUpdateFor(currUpdateDesc))) {
            currUpdatePkg = remote;
            currUpdateDesc = remoteDesc;
        }
    }

    local.setUpdate(currUpdatePkg);
    if (currUpdatePkg != null) {
        result.addUpdatedPkgs(local);
    }

    return currUpdatePkg;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:24,代碼來源:Update.java

示例6: register

import com.google.common.collect.Multimap; //導入依賴的package包/類
/**
 * Registers all subscriber methods on the given listener object.
 */
void register(Object listener) {
  Multimap<Class<?>, Subscriber> listenerMethods = findAllSubscribers(listener);

  for (Map.Entry<Class<?>, Collection<Subscriber>> entry : listenerMethods.asMap().entrySet()) {
    Class<?> eventType = entry.getKey();
    Collection<Subscriber> eventMethodsInListener = entry.getValue();

    CopyOnWriteArraySet<Subscriber> eventSubscribers = subscribers.get(eventType);

    if (eventSubscribers == null) {
      CopyOnWriteArraySet<Subscriber> newSet = new CopyOnWriteArraySet<Subscriber>();
      eventSubscribers =
          MoreObjects.firstNonNull(subscribers.putIfAbsent(eventType, newSet), newSet);
    }

    eventSubscribers.addAll(eventMethodsInListener);
  }
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:22,代碼來源:SubscriberRegistry.java

示例7: handleMisssingInstancesOnTransaction

import com.google.common.collect.Multimap; //導入依賴的package包/類
private void handleMisssingInstancesOnTransaction(final ConfigTransactionClient ta, final ConfigExecution execution)
        throws DocumentedException {

    for (Multimap<String, ModuleElementDefinition> modulesToResolved : execution.getModulesDefinition(ta)
            .values()) {
        for (Map.Entry<String, ModuleElementDefinition> moduleToResolved : modulesToResolved.entries()) {
            String moduleName = moduleToResolved.getKey();

            ModuleElementDefinition moduleElementDefinition = moduleToResolved.getValue();

            EditConfigStrategy strategy = moduleElementDefinition.getEditStrategy();
            strategy.executeConfiguration(moduleName, moduleElementDefinition.getInstanceName(), null, ta,
                    execution.getServiceRegistryWrapper(ta));
        }
    }
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:17,代碼來源:ConfigSubsystemFacade.java

示例8: addResolvedDependencyInfo

import com.google.common.collect.Multimap; //導入依賴的package包/類
/**
 * A recursive approach to dependency resolution
 *
 * @param parentDependency
 * @param resolvedDependenciesMap
 */
private void addResolvedDependencyInfo(ResolvedDependencyInfo parentDependency,
                                       Multimap<ModuleVersionIdentifier, ResolvedDependencyInfo>
                                           resolvedDependenciesMap) {
    int indent = parentDependency.getIndent();
    ModuleVersionIdentifier identifier = parentDependency.getModuleVersionIdentifier();
    Collection<ResolvedDependencyInfo> childDependencies = resolvedDependenciesMap.get(identifier);

    //TODO here
    for (ResolvedDependencyInfo childDependency : childDependencies) {
        if (childDependency.getIndent() > indent) {
            //                System.out.println(parentDependency + " indent " + indent + "->" + childDependency
            // +  " indent " + childDependency.getIndent());
            parentDependency.getChildren().add(childDependency);
            if (childDependency.getIndent() <= 1) {
                addResolvedDependencyInfo(childDependency, resolvedDependenciesMap);
            }
        }
    }
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:26,代碼來源:DependencyResolver.java

示例9: merge

import com.google.common.collect.Multimap; //導入依賴的package包/類
/**
 * merges this and other together into a new result object
 * @param other
 * @return the resulting merge
 */
public ScanResult merge(ScanResult other) {
  final Multimap<String, ChildClassDescriptor> newImpls = HashMultimap.create();
  for (Collection<ParentClassDescriptor> impls : asList(implementations, other.implementations)) {
    for (ParentClassDescriptor c : impls) {
      newImpls.putAll(c.getName(), c.getChildren());
    }
  }
  List<ParentClassDescriptor> newImplementations = new ArrayList<>();
  for (Entry<String, Collection<ChildClassDescriptor>> entry : newImpls.asMap().entrySet()) {
    newImplementations.add(new ParentClassDescriptor(entry.getKey(), new ArrayList<>(entry.getValue())));
  }

  return new ScanResult(
      merge(scannedPackages, other.scannedPackages),
      merge(scannedClasses, other.scannedClasses),
      merge(scannedAnnotations, other.scannedAnnotations),
      merge(annotatedClasses, other.annotatedClasses),
      newImplementations);
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:25,代碼來源:ScanResult.java

示例10: institutionEvent

import com.google.common.collect.Multimap; //導入依賴的package包/類
@Override
public void institutionEvent(final InstitutionEvent event)
{
	switch( event.getEventType() )
	{
		case AVAILABLE:
			Multimap<Long, Institution> schema2inst = event.getChanges();
			Set<Long> schemas = schema2inst.keySet();
			for( Long schemaId : schemas )
			{
				backgroundIndexers.getUnchecked(schemaId).synchronizeFull(schema2inst.get(schemaId));
			}
			break;
		default:
			break;
	}

}
 
開發者ID:equella,項目名稱:Equella,代碼行數:19,代碼來源:FreeTextServiceImpl.java

示例11: createIntent

import com.google.common.collect.Multimap; //導入依賴的package包/類
private Intent createIntent(Key key, long mac, NodeId node, Multimap<NodeId, Device> devices) {
    // choose a random device for which this node is master
    List<Device> deviceList = devices.get(node).stream().collect(Collectors.toList());
    Device device = deviceList.get(RandomUtils.nextInt(deviceList.size()));

    //FIXME we currently ignore the path length and always use the same device
    TrafficSelector selector = DefaultTrafficSelector.builder()
            .matchEthDst(MacAddress.valueOf(mac)).build();
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    ConnectPoint ingress = new ConnectPoint(device.id(), PortNumber.portNumber(1));
    ConnectPoint egress = new ConnectPoint(device.id(), PortNumber.portNumber(2));

    return PointToPointIntent.builder()
            .appId(appId)
            .key(key)
            .selector(selector)
            .treatment(treatment)
            .ingressPoint(ingress)
            .egressPoint(egress)
            .build();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:22,代碼來源:IntentPerfInstaller.java

示例12: computeBuildOrderDepthFirst

import com.google.common.collect.Multimap; //導入依賴的package包/類
/**
 * Recursive part of {@link #computeBuildOrderDepthFirst(Map, Multimap, Multimap, Collection)}. If all dependencies
 * of the given project have already been processed, it is added to the build order. Then, all projects that depend
 * on the given project are processed recursively.
 *
 * @param project
 *            the project to process
 * @param markedProjects
 *            the marked projects
 * @param pendencies
 *            maps projects to the projects that depend on them
 * @param dependencies
 *            maps projects to the projects they depend on
 * @param result
 *            the build order being computed
 */
private static void computeBuildOrderDepthFirst(IN4JSProject project,
		Map<IN4JSProject, MarkedProject> markedProjects, Multimap<IN4JSProject, IN4JSProject> pendencies,
		Multimap<IN4JSProject, IN4JSProject> dependencies, List<MarkedProject> result) {

	// once all dependencies of the current project have been processed, we can add it to the build and
	// process its children.
	if (dependencies.get(project).isEmpty()) {
		// The current project is ready to be processed.
		result.add(markedProjects.get(project));

		// Remove this project from the dependencies of all pending projects.
		for (IN4JSProject dependentProject : pendencies.get(project)) {
			dependencies.get(dependentProject).remove(project);

			// Now process the pending project itself.
			computeBuildOrderDepthFirst(dependentProject, markedProjects, pendencies, dependencies, result);
		}
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:36,代碼來源:N4HeadlessCompiler.java

示例13: collectExternalProjectDependents

import com.google.common.collect.Multimap; //導入依賴的package包/類
/**
 * Sugar for collecting {@link IWorkspace Eclipse workspace} projects that have any direct dependency to any
 * external projects. Same as {@link #collectExternalProjectDependents()} but does not consider all the available
 * projects but only those that are given as the argument.
 *
 * @param externalProjects
 *            the external projects that has to be considered as a possible dependency of an Eclipse workspace based
 *            project.
 * @return a map where each entry maps an external project to the workspace projects that depend on it.
 */
public Map<IProject, Collection<IProject>> collectExternalProjectDependents(
		final Iterable<? extends IProject> externalProjects) {
	final Multimap<IProject, IProject> mapping = Multimaps2.newLinkedHashListMultimap();

	if (Platform.isRunning()) {

		final Map<String, IProject> externalsMapping = new HashMap<>();
		externalProjects.forEach(p -> externalsMapping.put(p.getName(), p));

		asList(getWorkspace().getRoot().getProjects()).forEach(p -> {
			getDirectExternalDependencyIds(p).forEach(eID -> {
				IProject externalDependency = externalsMapping.get(eID);
				if (externalDependency != null) {
					mapping.put(externalDependency, p);
				}
			});
		});

	}

	return mapping.asMap();
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:33,代碼來源:ExternalProjectsCollector.java

示例14: newResult

import com.google.common.collect.Multimap; //導入依賴的package包/類
/**
 * Create SampleResult in XML format.
 * @param context
 * @param isError
 * @param statusCode
 * @param statusMessage
 * @param columnsForEachSqlStatement
 * @param valuesForEachColumn
 * @param includeQueryResults
 * @return
 */
private static SampleResult newResult(final Context context, final boolean isError, final String statusCode,
		final String statusMessage, final Multimap<String, String> columnsForEachSqlStatement,
		final Multimap<String, String> valuesForEachColumn, boolean includeQueryResults, final Optional<Long> duration) {
	final SampleResult result = new SampleResult();
	result.setStatusCode(statusCode);
	result.setError(isError);
	if(duration.isPresent())
	result.setDuration(duration.get());
	context.getLogger().debug("SQL Action execution finished with status code: " + statusCode + " (" + statusMessage + ")");

	final State state = isError ? State.ERROR : State.OK;
	try {
		result.setResponseContent(generateXMLOutput(state, statusMessage, columnsForEachSqlStatement,
				valuesForEachColumn, includeQueryResults));
	} catch (TransformerException e) {
		result.setError(true);
		context.getLogger().error("An error occurred while creating XML output: " + e.toString());
	}
	return result;
}
 
開發者ID:Neotys-Labs,項目名稱:Database-Advanced-Actions,代碼行數:32,代碼來源:sqlresultfactory.java

示例15: loadTimeDomains

import com.google.common.collect.Multimap; //導入依賴的package包/類
private Multimap<Long, TimeDomains> loadTimeDomains(String filename) {
    Multimap<Long, TimeDomains> times = TreeMultimap.create();
    File file = new File(filename);
    if (!file.exists()) {
        log.info("File not found : {}", file.getAbsolutePath());
        return times;
    }

    log.info("Reading TD {}", file);
    processDbf(file, row -> {
        TimeDomains restriction = new TimeDomains(((Double)row[0]).longValue(), new String((byte[]) row[3]).trim());
        times.put(restriction.getId(), restriction);
    });

    log.info("Loaded {} times domains", times.size());

    return times;
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:19,代碼來源:TdDbf.java


注:本文中的com.google.common.collect.Multimap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。