本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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));
}
}
}
示例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);
}
}
}
}
示例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);
}
示例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;
}
}
示例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();
}
示例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);
}
}
}
示例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();
}
示例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;
}
示例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;
}