本文整理汇总了Java中com.google.common.collect.ImmutableSetMultimap类的典型用法代码示例。如果您正苦于以下问题:Java ImmutableSetMultimap类的具体用法?Java ImmutableSetMultimap怎么用?Java ImmutableSetMultimap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImmutableSetMultimap类属于com.google.common.collect包,在下文中一共展示了ImmutableSetMultimap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getActions
import com.google.common.collect.ImmutableSetMultimap; //导入依赖的package包/类
@Override
public Multimap<ModelActionRole, ModelAction> getActions(ModelReference<?> subject, ModelRuleDescriptor descriptor) {
return ImmutableSetMultimap.<ModelActionRole, ModelAction>builder()
.put(ModelActionRole.Discover, AddProjectionsAction.of(subject, descriptor,
ModelMapModelProjection.managed(schema.getType(), schema.getElementType(), ChildNodeInitializerStrategyAccessors.fromPrivateData())
))
.put(ModelActionRole.Create, DirectNodeInputUsingModelAction.of(subject, descriptor,
ModelReference.of(NodeInitializerRegistry.class),
new BiAction<MutableModelNode, NodeInitializerRegistry>() {
@Override
public void execute(MutableModelNode modelNode, NodeInitializerRegistry nodeInitializerRegistry) {
ChildNodeInitializerStrategy<E> childStrategy = NodeBackedModelMap.createUsingRegistry(nodeInitializerRegistry);
modelNode.setPrivateData(ChildNodeInitializerStrategy.class, childStrategy);
}
}
))
.build();
}
示例2: getActions
import com.google.common.collect.ImmutableSetMultimap; //导入依赖的package包/类
@Override
public Multimap<ModelActionRole, ModelAction> getActions(ModelReference<?> subject, ModelRuleDescriptor descriptor) {
return ImmutableSetMultimap.<ModelActionRole, ModelAction>builder()
.put(ModelActionRole.Discover, AddProjectionsAction.of(subject, descriptor,
TypedModelProjection.of(
ModelTypes.modelSet(schema.getElementType()),
new ModelSetModelViewFactory<E>(schema.getElementType())
)
))
.put(ModelActionRole.Create, DirectNodeInputUsingModelAction.of(subject, descriptor,
ModelReference.of(NodeInitializerRegistry.class),
new BiAction<MutableModelNode, NodeInitializerRegistry>() {
@Override
public void execute(MutableModelNode modelNode, NodeInitializerRegistry nodeInitializerRegistry) {
ChildNodeInitializerStrategy<T> childStrategy = new ManagedChildNodeCreatorStrategy<T>(nodeInitializerRegistry);
modelNode.setPrivateData(ChildNodeInitializerStrategy.class, childStrategy);
}
}
))
.build();
}
示例3: createUsingParentNode
import com.google.common.collect.ImmutableSetMultimap; //导入依赖的package包/类
public static <T> ChildNodeInitializerStrategy<T> createUsingParentNode(final Transformer<? extends NamedEntityInstantiator<T>, ? super MutableModelNode> instantiatorTransform) {
return new ChildNodeInitializerStrategy<T>() {
@Override
public <S extends T> NodeInitializer initializer(final ModelType<S> type, Spec<ModelType<?>> constraints) {
return new NodeInitializer() {
@Override
public Multimap<ModelActionRole, ModelAction> getActions(ModelReference<?> subject, ModelRuleDescriptor descriptor) {
return ImmutableSetMultimap.<ModelActionRole, ModelAction>builder()
.put(ModelActionRole.Discover, AddProjectionsAction.of(subject, descriptor,
UnmanagedModelProjection.of(type),
new ModelElementProjection(type)
))
.put(ModelActionRole.Create, DirectNodeNoInputsModelAction.of(subject, descriptor, new Action<MutableModelNode>() {
@Override
public void execute(MutableModelNode modelNode) {
NamedEntityInstantiator<T> instantiator = instantiatorTransform.transform(modelNode.getParent());
S item = instantiator.create(modelNode.getPath().getName(), type.getConcreteClass());
modelNode.setPrivateData(type, item);
}
}))
.build();
}
};
}
};
}
示例4: buildSubtyping
import com.google.common.collect.ImmutableSetMultimap; //导入依赖的package包/类
private static SetMultimap<String, ValueType> buildSubtyping(List<ValueType> implementationTypes) {
ImmutableSetMultimap.Builder<String, ValueType> builder = ImmutableSetMultimap.builder();
for (ValueType type : implementationTypes) {
String abstractValueTypeName = type.typeAbstract().toString();
builder.put(abstractValueTypeName, type);
for (String className : type.getExtendedClassesNames()) {
if (!className.equals(abstractValueTypeName)) {
builder.put(className, type);
}
}
for (String interfaceName : type.getImplementedInterfacesNames()) {
if (!interfaceName.equals(abstractValueTypeName)) {
builder.put(interfaceName, type);
}
}
}
return builder.build();
}
示例5: EventArgScoringAlignment
import com.google.common.collect.ImmutableSetMultimap; //导入依赖的package包/类
private EventArgScoringAlignment(final Symbol docID,
final ArgumentOutput argumentOutput,
final AnswerKey answerKey,
final Iterable<EquivClassType> truePositiveECs,
final Iterable<EquivClassType> falsePositiveECs,
final Iterable<EquivClassType> falseNegativeECs,
final Iterable<EquivClassType> unassessed,
final Multimap<EquivClassType, AssessedResponse> ecsToAnswerKey,
final Multimap<EquivClassType, Response> ecsToSystem) {
this.docID = checkNotNull(docID);
this.argumentOutput = checkNotNull(argumentOutput);
this.answerKey = checkNotNull(answerKey);
this.truePositiveECs = ImmutableSet.copyOf(truePositiveECs);
this.falsePositiveECs = ImmutableSet.copyOf(falsePositiveECs);
this.falseNegativeECs = ImmutableSet.copyOf(falseNegativeECs);
this.unassessed = ImmutableSet.copyOf(unassessed);
this.ecsToAnswerKey = ImmutableSetMultimap.copyOf(ecsToAnswerKey);
this.ecsToSystem = ImmutableSetMultimap.copyOf(ecsToSystem);
}
示例6: response2016CollapsedJustifications
import com.google.common.collect.ImmutableSetMultimap; //导入依赖的package包/类
/**
* Collapses DocEventFrameReferences into their PJs for the particular document at hand.
*/
public static ImmutableSetMultimap<Symbol, QueryResponse2016> response2016CollapsedJustifications(
final Iterable<Map.Entry<Symbol, Collection<DocEventFrameReference>>> matchesByDocument,
final SystemOutputStore2016 store, final CorpusQuery2016 query)
throws IOException {
final ImmutableSetMultimap.Builder<Symbol, QueryResponse2016> retB =
ImmutableSetMultimap.builder();
for (final Map.Entry<Symbol, Collection<DocEventFrameReference>> matchEntry : matchesByDocument) {
final Symbol docID = matchEntry.getKey();
final Collection<DocEventFrameReference> eventFramesMatchedInDoc =
matchEntry.getValue();
final DocumentSystemOutput2015 docSystemOutput = store.read(docID);
final ImmutableSet<CharOffsetSpan> matchJustifications =
matchJustificationsForDoc(eventFramesMatchedInDoc, docSystemOutput);
final QueryResponse2016 queryResponse2016 =
QueryResponse2016.builder().docID(docID).queryID(query.id())
.addAllPredicateJustifications(matchJustifications).build();
retB.put(docID, queryResponse2016);
}
return retB.build();
}
示例7: finish
import com.google.common.collect.ImmutableSetMultimap; //导入依赖的package包/类
public void finish() throws IOException {
outputDir.mkdirs();
final ImmutableSetMultimap<String, String> mentionAlignmentFailures =
mentionAlignmentFailuresB.build();
log.info("Of {} system responses, got {} mention alignment failures",
numResponses.size(), mentionAlignmentFailures.size());
final File serializedFailuresFile = new File(outputDir, "alignmentFailures.json");
final JacksonSerializer serializer =
JacksonSerializer.builder().forJson().prettyOutput().build();
serializer.serializeTo(mentionAlignmentFailures, Files.asByteSink(serializedFailuresFile));
final File failuresCount = new File(outputDir, "alignmentFailures.count.txt");
serializer.serializeTo(mentionAlignmentFailures.size(), Files.asByteSink(failuresCount));
}
示例8: getPersistentChunksIterableFor
import com.google.common.collect.ImmutableSetMultimap; //导入依赖的package包/类
public static Iterator<Chunk> getPersistentChunksIterableFor(final World world, Iterator<Chunk> chunkIterator)
{
final ImmutableSetMultimap<ChunkPos, Ticket> persistentChunksFor = getPersistentChunksFor(world);
final ImmutableSet.Builder<Chunk> builder = ImmutableSet.builder();
world.theProfiler.startSection("forcedChunkLoading");
builder.addAll(Iterators.transform(persistentChunksFor.keys().iterator(), new Function<ChunkPos, Chunk>() {
@Nullable
@Override
public Chunk apply(@Nullable ChunkPos input)
{
return world.getChunkFromChunkCoords(input.chunkXPos, input.chunkZPos);
}
}));
world.theProfiler.endStartSection("regularChunkLoading");
builder.addAll(chunkIterator);
world.theProfiler.endSection();
return builder.build().iterator();
}
示例9: getType2Name2DependenciesMap
import com.google.common.collect.ImmutableSetMultimap; //导入依赖的package包/类
private ImmutableMap<DependencyType, Multimap<String, String>> getType2Name2DependenciesMap()
{
final ImmutableMap.Builder<DependencyType, Multimap<String, String>> builder = ImmutableMap.builder();
for (final Entry<DependencyType, ImmutableSetMultimap.Builder<String, String>> e : type2name2dependencies.entrySet())
{
final DependencyType dependencyType = e.getKey();
final Multimap<String, String> name2dependencies = e.getValue().build();
if (name2dependencies.isEmpty())
{
continue;
}
builder.put(dependencyType, name2dependencies);
}
return builder.build();
}
示例10: add
import com.google.common.collect.ImmutableSetMultimap; //导入依赖的package包/类
public Builder add(final String fieldName, final Collection<String> dependsOnFieldNames, final DependencyType dependencyType)
{
if (dependsOnFieldNames == null || dependsOnFieldNames.isEmpty())
{
return this;
}
ImmutableSetMultimap.Builder<String, String> fieldName2dependsOnFieldNames = type2name2dependencies.get(dependencyType);
if (fieldName2dependsOnFieldNames == null)
{
fieldName2dependsOnFieldNames = ImmutableSetMultimap.builder();
type2name2dependencies.put(dependencyType, fieldName2dependsOnFieldNames);
}
for (final String dependsOnFieldName : dependsOnFieldNames)
{
fieldName2dependsOnFieldNames.put(dependsOnFieldName, fieldName);
}
return this;
}
示例11: entriesThatIncreaseGap_treatsIndexesSeparately
import com.google.common.collect.ImmutableSetMultimap; //导入依赖的package包/类
/**
* Most partition keys will not clash, as they are delimited differently. For example, spans index
* partition keys are delimited with dots, and annotations with colons.
*
* <p>This tests an edge case, where a delimiter exists in a service name.
*/
@Test
public void entriesThatIncreaseGap_treatsIndexesSeparately() throws Exception {
ConcurrentMap<PartitionKeyToTraceId, Pair<Long>> sharedState = Maps.newConcurrentMap();
// If indexes were not implemented properly, the span index app.foo would be mistaken as the
// first service index
ImmutableSetMultimap<PartitionKeyToTraceId, Long> parsed =
ImmutableSetMultimap.<PartitionKeyToTraceId, Long>builder()
.put(new PartitionKeyToTraceId(SERVICE_NAME_INDEX, "app.foo", 20), 1467676800050L)
.put(new PartitionKeyToTraceId(SERVICE_NAME_INDEX, "app.foo", 20), 1467676800110L)
.put(new PartitionKeyToTraceId(SERVICE_NAME_INDEX, "app.foo", 20), 1467676800125L)
.put(new PartitionKeyToTraceId(SERVICE_SPAN_NAME_INDEX, "app.foo", 20), 1467676800000L)
.build();
assertThat(Indexer.entriesThatIncreaseGap(sharedState, parsed)).hasSameEntriesAs(
ImmutableSetMultimap.<PartitionKeyToTraceId, Long>builder()
.put(new PartitionKeyToTraceId(SERVICE_NAME_INDEX, "app.foo", 20), 1467676800050L)
.put(new PartitionKeyToTraceId(SERVICE_NAME_INDEX, "app.foo", 20), 1467676800125L)
.put(new PartitionKeyToTraceId(SERVICE_SPAN_NAME_INDEX, "app.foo", 20), 1467676800000L)
.build()
);
}
示例12: testRoleInference_RoleHierarchyInvolved
import com.google.common.collect.ImmutableSetMultimap; //导入依赖的package包/类
@Test //missing role is ambiguous without cardinality constraints
public void testRoleInference_RoleHierarchyInvolved() {
GraknTx graph = unificationTestSet.tx();
String relationString = "{($p, subRole2: $gc) isa binary;}";
String relationString2 = "{(subRole1: $gp, $p) isa binary;}";
RelationshipAtom relation = (RelationshipAtom) ReasonerQueries.atomic(conjunction(relationString, graph), graph).getAtom();
RelationshipAtom relation2 = (RelationshipAtom) ReasonerQueries.atomic(conjunction(relationString2, graph), graph).getAtom();
Multimap<Role, Var> roleMap = roleSetMap(relation.getRoleVarMap());
Multimap<Role, Var> roleMap2 = roleSetMap(relation2.getRoleVarMap());
ImmutableSetMultimap<Role, Var> correctRoleMap = ImmutableSetMultimap.of(
graph.getRole("role"), var("p"),
graph.getRole("subRole2"), var("gc"));
ImmutableSetMultimap<Role, Var> correctRoleMap2 = ImmutableSetMultimap.of(
graph.getRole("role"), var("p"),
graph.getRole("subRole1"), var("gp"));
assertEquals(correctRoleMap, roleMap);
assertEquals(correctRoleMap2, roleMap2);
}
示例13: selectPipelines
import com.google.common.collect.ImmutableSetMultimap; //导入依赖的package包/类
private ImmutableSet<Pipeline> selectPipelines(InterpreterListener interpreterListener,
Set<Tuple2<String, String>> processingBlacklist,
Message message,
Set<String> initialStreamIds,
ImmutableSetMultimap<String, Pipeline> streamConnection) {
final String msgId = message.getId();
// if a message-stream combination has already been processed (is in the set), skip that execution
final Set<String> streamsIds = initialStreamIds.stream()
.filter(streamId -> !processingBlacklist.contains(tuple(msgId, streamId)))
.filter(streamConnection::containsKey)
.collect(Collectors.toSet());
final ImmutableSet<Pipeline> pipelinesToRun = streamsIds.stream()
.flatMap(streamId -> streamConnection.get(streamId).stream())
.collect(ImmutableSet.toImmutableSet());
interpreterListener.processStreams(message, pipelinesToRun, streamsIds);
log.debug("[{}] running pipelines {} for streams {}", msgId, pipelinesToRun, streamsIds);
return pipelinesToRun;
}
示例14: State
import com.google.common.collect.ImmutableSetMultimap; //导入依赖的package包/类
@AssistedInject
public State(@Assisted ImmutableMap<String, Pipeline> currentPipelines,
@Assisted ImmutableSetMultimap<String, Pipeline> streamPipelineConnections,
MetricRegistry metricRegistry,
@Named("processbuffer_processors") int processorCount,
@Named("cached_stageiterators") boolean cachedIterators) {
this.currentPipelines = currentPipelines;
this.streamPipelineConnections = streamPipelineConnections;
this.cachedIterators = cachedIterators;
cache = CacheBuilder.newBuilder()
.concurrencyLevel(processorCount)
.recordStats()
.build(new CacheLoader<Set<Pipeline>, StageIterator.Configuration>() {
@Override
public StageIterator.Configuration load(@Nonnull Set<Pipeline> pipelines) throws Exception {
return new StageIterator.Configuration(pipelines);
}
});
// we have to remove the metrics, because otherwise we leak references to the cache (and the register call with throw)
metricRegistry.removeMatching((name, metric) -> name.startsWith(name(PipelineInterpreter.class, "stage-cache")));
MetricUtils.safelyRegisterAll(metricRegistry, new CacheStatsSet(name(PipelineInterpreter.class, "stage-cache"), cache));
}
示例15: getChunkCount
import com.google.common.collect.ImmutableSetMultimap; //导入依赖的package包/类
public int getChunkCount(ImmutableSetMultimap<ChunkPos, ForgeChunkManager.Ticket> tickets)
{
int count = 0;
for(ChunkPos key : tickets.asMap().keySet())
{
Collection<ForgeChunkManager.Ticket> ticketList = tickets.asMap().get(key);
for(ForgeChunkManager.Ticket ticket : ticketList)
{
if(Reference.MOD_ID.equals(ticket.getModId()))
{
count++;
}
}
}
return count;
}