当前位置: 首页>>代码示例>>Java>>正文


Java SetView类代码示例

本文整理汇总了Java中com.google.common.collect.Sets.SetView的典型用法代码示例。如果您正苦于以下问题:Java SetView类的具体用法?Java SetView怎么用?Java SetView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SetView类属于com.google.common.collect.Sets包,在下文中一共展示了SetView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: diffMap

import com.google.common.collect.Sets.SetView; //导入依赖的package包/类
private static Map<String, Set<String>> diffMap(Map<String, Byte[]> oldNodeData,
		Map<String, Byte[]> nodeWithData) {
	Set<String> oldChildNode = oldNodeData.keySet();
	Set<String> newChildNode = nodeWithData.keySet();
	SetView<String> view1 = Sets.difference(oldChildNode, newChildNode);// 下线的
	SetView<String> view2 = Sets.difference(newChildNode, oldChildNode);// 上线的
	Map<String, Set<String>> resultMap = new ConcurrentHashMap<String, Set<String>>();
	Set<String> offlineSet = new HashSet<String>();
	Set<String> onlineSet = new HashSet<String>();
	long before = System.currentTimeMillis();
	offlineSet = view1.copyInto(offlineSet);
	onlineSet = view2.copyInto(onlineSet);
	long after = System.currentTimeMillis();
	
	//Long[] longList = new Long[]{after-before,new Long(onlineSet.size()),new Long(offlineSet.size())};
	//logger.debug("SAF diff set spend time:{},online node MAP size:{} offlien node MAP size:{}",longList);
	resultMap.put(PathCache.OFFLINESET, offlineSet);
	resultMap.put(PathCache.ONLINESET, onlineSet);
	return resultMap;

}
 
开发者ID:tiglabs,项目名称:jsf-core,代码行数:22,代码来源:PathCache.java

示例2: createRegistry

import com.google.common.collect.Sets.SetView; //导入依赖的package包/类
private <T extends IForgeRegistryEntry<T>> FMLControlledNamespacedRegistry<T> createRegistry(ResourceLocation registryName, Class<T> type, ResourceLocation defaultObjectKey, int minId, int maxId, IForgeRegistry.AddCallback<T> addCallback, IForgeRegistry.ClearCallback<T> clearCallback, IForgeRegistry.CreateCallback<T> createCallback, IForgeRegistry.SubstitutionCallback<T> substitutionCallback)
{
    Set<Class<?>> parents = Sets.newHashSet();
    findSuperTypes(type, parents);
    SetView<Class<?>> overlappedTypes = Sets.intersection(parents, registrySuperTypes.keySet());
    if (!overlappedTypes.isEmpty())
    {
        Class<?> foundType = overlappedTypes.iterator().next();
        FMLLog.severe("Found existing registry of type %1s named %2s, you cannot create a new registry (%3s) with type %4s, as %4s has a parent of that type", foundType, registrySuperTypes.get(foundType), registryName, type);
        throw new IllegalArgumentException("Duplicate registry parent type found - you can only have one registry for a particular super type");
    }
    FMLControlledNamespacedRegistry<T> fmlControlledNamespacedRegistry = new FMLControlledNamespacedRegistry<T>(defaultObjectKey, minId, maxId, type, registries, addCallback, clearCallback, createCallback, substitutionCallback);
    registries.put(registryName, fmlControlledNamespacedRegistry);
    registrySuperTypes.put(type, registryName);
    return getRegistry(registryName, type);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:PersistentRegistryManager.java

示例3: notifyGroupChange

import com.google.common.collect.Sets.SetView; //导入依赖的package包/类
private synchronized void notifyGroupChange(Iterable<String> memberIds) {
  ImmutableSet<String> newMemberIds = ImmutableSortedSet.copyOf(memberIds);
  Set<String> existingMemberIds = servicesByMemberId.asMap().keySet();

  // Ignore no-op state changes except for the 1st when we've seen no group yet.
  if ((serverSet == null) || !newMemberIds.equals(existingMemberIds)) {
    SetView<String> deletedMemberIds = Sets.difference(existingMemberIds, newMemberIds);
    // Implicit removal from servicesByMemberId.
    existingMemberIds.removeAll(ImmutableSet.copyOf(deletedMemberIds));

    Iterable<ServiceInstance> serviceInstances = Iterables.filter(
        Iterables.transform(newMemberIds, MAYBE_FETCH_NODE), Predicates.notNull());

    notifyServerSetChange(ImmutableSet.copyOf(serviceInstances));
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:17,代码来源:ServerSetImpl.java

示例4: logChange

import com.google.common.collect.Sets.SetView; //导入依赖的package包/类
private void logChange(ImmutableSet<ServiceInstance> newServerSet) {
  StringBuilder message = new StringBuilder("server set " + group.getPath() + " change: ");
  if (serverSet.size() != newServerSet.size()) {
    message.append("from ").append(serverSet.size())
        .append(" members to ").append(newServerSet.size());
  }

  Joiner joiner = Joiner.on("\n\t\t");

  SetView<ServiceInstance> left = Sets.difference(serverSet, newServerSet);
  if (!left.isEmpty()) {
    message.append("\n\tleft:\n\t\t").append(joiner.join(left));
  }

  SetView<ServiceInstance> joined = Sets.difference(newServerSet, serverSet);
  if (!joined.isEmpty()) {
    message.append("\n\tjoined:\n\t\t").append(joiner.join(joined));
  }

  LOG.info(message.toString());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:22,代码来源:ServerSetImpl.java

示例5: createSqlCompleter

import com.google.common.collect.Sets.SetView; //导入依赖的package包/类
private SqlCompleter createSqlCompleter(Connection jdbcConnection) {

        SqlCompleter completer = null;
        try {
            Set<String> keywordsCompletions = SqlCompleter.getSqlKeywordsCompletions(jdbcConnection);
            Set<String> dataModelCompletions =
                    SqlCompleter.getDataModelMetadataCompletions(jdbcConnection);
            SetView<String> allCompletions = Sets.union(keywordsCompletions, dataModelCompletions);
            completer = new SqlCompleter(allCompletions, dataModelCompletions);

        } catch (IOException | SQLException e) {
            logger.error("Cannot create SQL completer", e);
        }

        return completer;
    }
 
开发者ID:cas-bigdatalab,项目名称:zeppelin-impala-interpreter,代码行数:17,代码来源:ImpalaInterpreter.java

示例6: updateDataModelMetaData

import com.google.common.collect.Sets.SetView; //导入依赖的package包/类
public void updateDataModelMetaData(Connection connection) {

    try {
      Set<String> newModelCompletions = getDataModelMetadataCompletions(connection);
      logger.debug("New model metadata is:" + Joiner.on(',').join(newModelCompletions));

      // Sets.difference(set1, set2) - returned set contains all elements that are contained by set1
      // and not contained by set2. set2 may also contain elements not present in set1; these are
      // simply ignored.
      SetView<String> removedCompletions = Sets.difference(modelCompletions, newModelCompletions);
      logger.debug("Removed Model Completions: " + Joiner.on(',').join(removedCompletions));
      this.getStrings().removeAll(removedCompletions);

      SetView<String> newCompletions = Sets.difference(newModelCompletions, modelCompletions);
      logger.debug("New Completions: " + Joiner.on(',').join(newCompletions));
      this.getStrings().addAll(newCompletions);

      modelCompletions = newModelCompletions;

    } catch (SQLException e) {
      logger.error("Failed to update the metadata conmpletions", e);
    }
  }
 
开发者ID:cas-bigdatalab,项目名称:zeppelin-impala-interpreter,代码行数:24,代码来源:SqlCompleter.java

示例7: validatePeerClusterConflict

import com.google.common.collect.Sets.SetView; //导入依赖的package包/类
/**
 * It validates that peer-clusters can't coexist in replication-clusters
 * 
 * @param clusterName:
 *            given cluster whose peer-clusters can't be present into replication-cluster list
 * @param clusters:
 *            replication-cluster list
 */
private void validatePeerClusterConflict(String clusterName, Set<String> replicationClusters) {
    try {
        ClusterData clusterData = clustersCache().get(path("clusters", clusterName)).orElseThrow(
                () -> new RestException(Status.PRECONDITION_FAILED, "Invalid replication cluster " + clusterName));
        Set<String> peerClusters = clusterData.getPeerClusterNames();
        if (peerClusters != null && !peerClusters.isEmpty()) {
            SetView<String> conflictPeerClusters = Sets.intersection(peerClusters, replicationClusters);
            if (!conflictPeerClusters.isEmpty()) {
                log.warn("[{}] {}'s peer cluster can't be part of replication clusters {}", clientAppId(),
                        clusterName, conflictPeerClusters);
                throw new RestException(Status.CONFLICT,
                        String.format("%s's peer-clusters %s can't be part of replication-clusters %s", clusterName,
                                conflictPeerClusters, replicationClusters));
            }
        }
    } catch (RestException re) {
        throw re;
    } catch (Exception e) {
        log.warn("[{}] Failed to get cluster-data for {}", clientAppId(), clusterName, e);
    }
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:30,代码来源:Namespaces.java

示例8: createSqlCompleter

import com.google.common.collect.Sets.SetView; //导入依赖的package包/类
private SqlCompleter createSqlCompleter(Connection jdbcConnection) {

    SqlCompleter completer = null;
    try {
      Set<String> keywordsCompletions = SqlCompleter.getSqlKeywordsCompletions(jdbcConnection);
      Set<String> dataModelCompletions =
          SqlCompleter.getDataModelMetadataCompletions(jdbcConnection);
      SetView<String> allCompletions = Sets.union(keywordsCompletions, dataModelCompletions);
      completer = new SqlCompleter(allCompletions, dataModelCompletions);

    } catch (IOException | SQLException e) {
      logger.error("Cannot create SQL completer", e);
    }

    return completer;
  }
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:17,代码来源:PostgreSqlInterpreter.java

示例9: doRun

import com.google.common.collect.Sets.SetView; //导入依赖的package包/类
@Override
protected void doRun(boolean write, File outputFile) throws Exception {
  boolean dropExisting = getCommandLine().hasOption(DROP_EXISTING_OPTION);
  if (getCommandLine().hasOption(SCHEMA_NAME_FILTER)) {
    String[] nameArgs = getCommandLine().getOptionValues(SCHEMA_NAME_FILTER);
    Set<String> includeNames = ImmutableSet.copyOf(nameArgs);
    Set<String> allNames = getDbToolContext().getSchemaNames();
    SetView<String> filteredNames = Sets.intersection(allNames, includeNames);
    if (write) {
      System.out.println("Filtered " + allNames + " to " + filteredNames);
    }
    getDbToolContext().setSchemaNames(filteredNames);
  }
  if (getDbToolContext().getSchemaNames().isEmpty()) {
    System.out.println("No schemas specified, or all filtered out");
  } else {
    new DbCreateOperation(getDbToolContext(), write, outputFile, dropExisting).execute();
    if (write) {
      System.out.println("Database objects created successfully");
    }
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:23,代码来源:DbCreateTool.java

示例10: analyze

import com.google.common.collect.Sets.SetView; //导入依赖的package包/类
public void analyze() {
	log.info("Starting analyzing for user: " + twitterUser);
	
	//Create the CSVFormat object
	createFileIfNotExisting(filenameFollowerIDsDelta());
	createFileIfNotExisting(filenameFollowerIDsCurrent());
	
	Set<String> currentIDsFromFile = readAllIDsFromCurrentFile(); 
	currentIDsFromTwitter = getAllFollwerIDsFromTwitter();
	
	SetView<String> symmetricDifference = Sets.symmetricDifference(currentIDsFromFile, currentIDsFromTwitter);
	
	if (symmetricDifference.size() == 0) {
		log.info("No new followers were found.");
	} else {
		processSyncDifferences(currentIDsFromFile, symmetricDifference);

		deleteAndRecreateFile(filenameFollowerIDsCurrent());
		writeCurrentFollowerIDFile(currentIDsFromTwitter);
	}
}
 
开发者ID:jojomay24,项目名称:TwitterAnalyzer,代码行数:22,代码来源:Main.java

示例11: syncListenedChannels

import com.google.common.collect.Sets.SetView; //导入依赖的package包/类
private void syncListenedChannels() {
  if (m_channels.equals(m_currentListenedChannels)) {
    return;
  }

  final Set<NotificationChannel> channels = Sets.newHashSet(m_channels);
  final SetView<NotificationChannel> toUnlisten =
      Sets.difference(m_currentListenedChannels, channels);
  final SetView<NotificationChannel> toListen =
      Sets.difference(channels, m_currentListenedChannels);

  if (!toUnlisten.isEmpty()) {
    sendUnlistens(toUnlisten);
  }
  if (!toListen.isEmpty()) {
    sendListens(toListen);
  }
  if (!toUnlisten.isEmpty() || !toListen.isEmpty()) {
    m_currentListenedChannels.clear();
    m_currentListenedChannels.addAll(channels);
  }
}
 
开发者ID:google,项目名称:binnavi,代码行数:23,代码来源:PostgreSQLNotificationProvider.java

示例12: defineClasses

import com.google.common.collect.Sets.SetView; //导入依赖的package包/类
public Map<String, Class<?>> defineClasses(Map<String, byte[]> newClasses)
{
    SetView<String> conflicts = Sets.intersection(pendingClasses.keySet(), newClasses.keySet());
    Preconditions.checkArgument(conflicts.isEmpty(), "The classes %s have already been defined", conflicts);

    pendingClasses.putAll(newClasses);
    try {
        Map<String, Class<?>> classes = new HashMap<>();
        for (String className : newClasses.keySet()) {
            try {
                Class<?> clazz = loadClass(className);
                classes.put(className, clazz);
            }
            catch (ClassNotFoundException e) {
                // this should never happen
                throw Throwables.propagate(e);
            }
        }
        return classes;
    }
    finally {
        pendingClasses.keySet().removeAll(newClasses.keySet());
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:25,代码来源:DynamicClassLoader.java

示例13: testFilterProjectMembers

import com.google.common.collect.Sets.SetView; //导入依赖的package包/类
/**
 * @author 胡天翔
 */
@Test
public void testFilterProjectMembers() {
    List<User> list1 = new ArrayList<User>(), list2 = new ArrayList<User>();
    list1.add(getASampleUser(0));
    list1.add(getASampleUser(1));
    list1.add(getASampleUser(2));
    list2.add(getASampleUser(1));
    list2.add(getASampleUser(2));
    list2.add(getASampleUser(3));
    SetView<User> intersection = Sets.intersection(new HashSet<User>(list1), new HashSet<User>(list2));
    
    UserServiceImpl spyUserServiceImpl = Mockito.spy(testedUserServiceImpl);
    Mockito.doReturn(list2).when(spyUserServiceImpl).getUserByProjectId(ModuleHelper.projectId);
    
    List<User> user = spyUserServiceImpl.filterProjectMembers(list1, ModuleHelper.projectId);
    
    Mockito.verify(spyUserServiceImpl).filterProjectMembers(list1, ModuleHelper.projectId);
    Mockito.verify(spyUserServiceImpl).getUserByProjectId(ModuleHelper.projectId);
    Mockito.verifyNoMoreInteractions(spyUserServiceImpl);
    
    assertEquals(intersection.size(), Sets.intersection(intersection, new HashSet<User>(user)).size());
}
 
开发者ID:sercxtyf,项目名称:onboard,代码行数:26,代码来源:UserServiceImplTest.java

示例14: validateRequest

import com.google.common.collect.Sets.SetView; //导入依赖的package包/类
/** Returns an error message if request is not valid. Checks basic request formatting. */
static String validateRequest(RPC.CreateOrganizationRequest request) {
  if (Strings.isNullOrEmpty(request.name)) {
    return "name cannot be empty";
  }
  if (Strings.isNullOrEmpty(request.publicKey)) {
    return "publicKey cannot be empty";
  }
  if (request.adminEncryptedKeys == null || request.adminEncryptedKeys.isEmpty()) {
    return "adminEncryptedKeys cannot be empty";
  }
  if (request.memberGroupKeys == null || request.memberGroupKeys.isEmpty()) {
    return "memberGroupKeys cannot be empty";
  }

  // ensure that every admin is also a member
  SetView<String> adminsNotInMembers = Sets.difference(
      request.adminEncryptedKeys.keySet(), request.memberGroupKeys.keySet());
  if (!adminsNotInMembers.isEmpty()) {
    return "each admin must be a member";
  }
  return null;
}
 
开发者ID:WeAreWizards,项目名称:passopolis-server,代码行数:24,代码来源:CreateOrganization.java

示例15: equals

import com.google.common.collect.Sets.SetView; //导入依赖的package包/类
/**
 * Two instances of {@link PackageInventory} are identical if they
 * contain the same set packages.
 */
@Override
public boolean equals(Object obj) {
	if (!(obj instanceof PackageInventory)){
		return false;
	}
	PackageInventory ref = (PackageInventory) obj;
	// comparison of the PIDs is sufficient
	SetView<PID> symmDiff;
	// synchronized access to the underlying maps
	synchronized (packagesByIdMap){
		synchronized (ref.packagesByIdMap) {
			symmDiff = Sets.symmetricDifference(ref.packagesByIdMap.keySet(), this.packagesByIdMap.keySet());
		}
	}
	return symmDiff.isEmpty();
}
 
开发者ID:52North,项目名称:movingcode,代码行数:21,代码来源:PackageInventory.java


注:本文中的com.google.common.collect.Sets.SetView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。