當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。