下面列出了com.google.common.collect.Sets#union ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public boolean isLeq(final DBM that, final Collection<? extends VarDecl<RatType>> activeVars) {
final Set<VarDecl<RatType>> vars = Sets.union(this.signature.toSet(), that.signature.toSet());
for (final VarDecl<RatType> x : vars) {
if (!activeVars.contains(x)) {
continue;
}
for (final VarDecl<RatType> y : vars) {
if (!activeVars.contains(y)) {
continue;
}
if (this.getOrDefault(x, y) > that.getOrDefault(x, y)) {
return false;
}
}
}
return true;
}
/**
* Returns a list of {@link ServerPort}s which consists of distinct port numbers except for the port
* {@code 0}. If there are the same port numbers with different {@link SessionProtocol}s,
* their {@link SessionProtocol}s will be merged into a single {@link ServerPort} instance.
* The returned list is sorted as the same order of the specified {@code ports}.
*/
private static List<ServerPort> resolveDistinctPorts(List<ServerPort> ports) {
final List<ServerPort> distinctPorts = new ArrayList<>();
for (final ServerPort p : ports) {
boolean found = false;
// Do not check the port number 0 because a user may want his or her server to be bound
// on multiple arbitrary ports.
if (p.localAddress().getPort() > 0) {
for (int i = 0; i < distinctPorts.size(); i++) {
final ServerPort port = distinctPorts.get(i);
if (port.localAddress().equals(p.localAddress())) {
final ServerPort merged =
new ServerPort(port.localAddress(),
Sets.union(port.protocols(), p.protocols()));
distinctPorts.set(i, merged);
found = true;
break;
}
}
}
if (!found) {
distinctPorts.add(p);
}
}
return Collections.unmodifiableList(distinctPorts);
}
private static Map<String, Pair<Object, Object>> diffStarlarkOptions(
BuildConfiguration config1, BuildConfiguration config2) {
Map<Label, Object> starlarkOptions1 = config1.getOptions().getStarlarkOptions();
Map<Label, Object> starlarkOptions2 = config2.getOptions().getStarlarkOptions();
Map<String, Pair<Object, Object>> diffs = new HashMap<>();
for (Label option : Sets.union(starlarkOptions1.keySet(), starlarkOptions2.keySet())) {
Object value1 = starlarkOptions1.get(option);
Object value2 = starlarkOptions2.get(option);
if (!Objects.equals(value1, value2)) {
diffs.put(option.toString(), Pair.of(value1, value2));
}
}
return diffs;
}
@Override
public Set<E> adjacentEdges(Object edge) {
Iterator<N> incidentNodesIterator = incidentNodes(edge).iterator();
Set<E> endpointsIncidentEdges = incidentEdges(incidentNodesIterator.next());
while (incidentNodesIterator.hasNext()) {
endpointsIncidentEdges =
Sets.union(incidentEdges(incidentNodesIterator.next()), endpointsIncidentEdges);
}
return Sets.difference(endpointsIncidentEdges, ImmutableSet.of(edge));
}
@Override
public Set<MatchPlayer> getPlayers() {
final Change change = CHANGE.get();
if(change != null) {
if(equals(change.oldTeam)) {
return Sets.difference(super.getPlayers(), Collections.singleton(change.player));
} else if(equals(change.newTeam)) {
return Sets.union(super.getPlayers(), Collections.singleton(change.player));
}
}
return super.getPlayers();
}
EnumValueSets<T> union(EnumValueSets<T> sets2) {
return new EnumValueSets<>(
Sets.union(_including, sets2._including),
Sets.union(_excluding, sets2._excluding),
_allValues,
_groupValues);
}
static void retryTasksAndRequiredParents(final PlanStateManager planStateManager,
final BlockManagerMaster blockManagerMaster,
final Set<String> tasks) {
final Set<String> requiredParents =
recursivelyGetParentTasksForLostBlocks(planStateManager, blockManagerMaster, tasks);
final Set<String> tasksToRetry = Sets.union(tasks, requiredParents);
LOG.info("Will be retried: {}", tasksToRetry);
tasksToRetry.forEach(
taskToReExecute -> planStateManager.onTaskStateChanged(taskToReExecute, TaskState.State.SHOULD_RETRY));
}
public boolean isLeq(final DBM that) {
final Set<VarDecl<RatType>> vars = Sets.union(this.signature.toSet(), that.signature.toSet());
for (final VarDecl<RatType> x : vars) {
for (final VarDecl<RatType> y : vars) {
if (this.getOrDefault(x, y) > that.getOrDefault(x, y)) {
return false;
}
}
}
return true;
}
private DefaultManifest mergeManifest(DefaultManifest baseManifest, DefaultManifest toMergeManifest, FileResolver fileResolver) {
DefaultManifest mergedManifest = new DefaultManifest(fileResolver);
mergeSection(null, mergedManifest, baseManifest.getAttributes(), toMergeManifest.getAttributes());
Set<String> allSections = Sets.union(baseManifest.getSections().keySet(), toMergeManifest.getSections().keySet());
for (String section : allSections) {
mergeSection(section, mergedManifest,
GUtil.elvis(baseManifest.getSections().get(section), new DefaultAttributes()),
GUtil.elvis(toMergeManifest.getSections().get(section), new DefaultAttributes()));
}
return mergedManifest;
}
private Set<ItemFilter> retrieveFilters(List<String> filters) {
Set<ItemFilter> filterSet = new HashSet<>();
if(filters==null) return alwaysOnFilters;
for (String filter : filters){
filterSet.add(applicationContext.getBean(filter, ItemFilter.class));
}
return Sets.union(filterSet, alwaysOnFilters);
}
@Override
public Set<String> tokens(Security security) {
MetaBean metaBean = MetaBean.of(security.getClass());
return Sets.union(
Sets.union(metaBean.metaPropertyMap().keySet(), security.getInfo().propertyNames()),
security.getInfo().getPriceInfo().propertyNames());
}
@Override
public Set<N> adjacentNodes() {
return Sets.union(predecessors(), successors());
}
public static StackTrace computeStackTrace(Object obj, Set<Class<?>> skip) {
return obj instanceof Traceable ? ((Traceable) obj).stackTrace()
: new StackTrace(Sets.union(ImmutableSet.of(Traceables.class), skip));
}
@Override
public Set<String> visitUnionNodeAstNode(UnionNodeAstNode unionNodeAstNode) {
return Sets.union(
unionNodeAstNode.getLeft().accept(this), unionNodeAstNode.getRight().accept(this));
}
@Override
public Set<String> keySet() {
return Sets.union(Sets.union(manual.keySet(), Holidays.keys()), permanent().getKeys(false));
}
private Set<String> extendedTags(final Set<String> tags, final Server server) {
final String portTag = "httpPort-" + server.getPort();
final String contextPathTag = "contextPath-" + server.getContextPath();
return Sets.union(tags, Sets.newHashSet(contextPathTag, portTag));
}
@Override
public Set<E> incidentEdges() {
return Sets.union(inEdges(), outEdges());
}
public StackTrace(Set<Class<?>> skip) {
this(new Throwable().getStackTrace(), Sets.union(ImmutableSet.of(StackTrace.class), skip));
}
@Override
public List<WorkUnit> getWorkunits(SourceState state) {
initLogger(state);
lineageInfo = LineageInfo.getLineageInfo(state.getBroker());
List<WorkUnit> workUnits = Lists.newArrayList();
// Map<String, String> tableNameToEntityMap = Maps.newHashMap();
Set<SourceEntity> entities = getFilteredSourceEntities(state);
Map<SourceEntity, State> tableSpecificPropsMap = shouldObtainTablePropsFromConfigStore(state)
? getTableSpecificPropsFromConfigStore(entities, state)
: getTableSpecificPropsFromState(entities, state);
Map<SourceEntity, Long> prevWatermarksByTable = getPreviousWatermarksForAllTables(state);
for (SourceEntity sourceEntity : Sets.union(entities, prevWatermarksByTable.keySet())) {
log.info("Source entity to be processed: {}, carry-over from previous state: {} ",
sourceEntity, !entities.contains(sourceEntity));
SourceState combinedState = getCombinedState(state, tableSpecificPropsMap.get(sourceEntity));
long previousWatermark = prevWatermarksByTable.containsKey(sourceEntity) ?
prevWatermarksByTable.get(sourceEntity)
: ConfigurationKeys.DEFAULT_WATERMARK_VALUE;
// If a table name exists in prevWatermarksByTable (i.e., it has a previous watermark) but does not exist
// in talbeNameToEntityMap, create an empty workunit for it, so that its previous watermark is preserved.
// This is done by overriding the high watermark to be the same as the previous watermark.
if (!entities.contains(sourceEntity)) {
combinedState.setProp(ConfigurationKeys.SOURCE_QUERYBASED_END_VALUE, previousWatermark);
}
workUnits.addAll(generateWorkUnits(sourceEntity, combinedState, previousWatermark));
}
log.info("Total number of workunits for the current run: " + workUnits.size());
List<WorkUnit> previousWorkUnits = this.getPreviousWorkUnitsForRetry(state);
log.info("Total number of incomplete tasks from the previous run: " + previousWorkUnits.size());
workUnits.addAll(previousWorkUnits);
int numOfMultiWorkunits =
state.getPropAsInt(ConfigurationKeys.MR_JOB_MAX_MAPPERS_KEY, ConfigurationKeys.DEFAULT_MR_JOB_MAX_MAPPERS);
return pack(workUnits, numOfMultiWorkunits);
}
/**
* Get the set of vertices connected to v by incoming or outgoing edges
* @param v a non-null vertex
* @return a set of vertices {X} connected X -> v or v -> Y
*/
public final Set<V> neighboringVerticesOf(final V v) {
Utils.nonNull(v);
return Sets.union(incomingVerticesOf(v), outgoingVerticesOf(v));
}