當前位置: 首頁>>代碼示例>>Java>>正文


Java ListMultimap類代碼示例

本文整理匯總了Java中com.google.common.collect.ListMultimap的典型用法代碼示例。如果您正苦於以下問題:Java ListMultimap類的具體用法?Java ListMultimap怎麽用?Java ListMultimap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ListMultimap類屬於com.google.common.collect包,在下文中一共展示了ListMultimap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addDependencyForRelocation

import com.google.common.collect.ListMultimap; //導入依賴的package包/類
public void addDependencyForRelocation(ModuleVersionSelector selector) {

        // Some POMs depend on themselves through their parent POM, don't add this dependency
        // since Ivy doesn't allow this!
        // Example: http://repo2.maven.org/maven2/com/atomikos/atomikos-util/3.6.4/atomikos-util-3.6.4.pom
        if (selector.getGroup().equals(descriptor.getComponentIdentifier().getGroup())
            && selector.getName().equals(descriptor.getComponentIdentifier().getModule())) {
            return;
        }

        // TODO - this is a constant
        ListMultimap<String, String> confMappings = ArrayListMultimap.create();
        // Map dependency on all public configurations
        for (Configuration m2Conf : GradlePomModuleDescriptorBuilder.MAVEN2_CONFIGURATIONS.values()) {
            if (m2Conf.isVisible()) {
                confMappings.put(m2Conf.getName(), m2Conf.getName());
            }
        }

        dependencies.add(new IvyDependencyMetadata(selector, confMappings));
    }
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:22,代碼來源:GradlePomModuleDescriptorBuilder.java

示例2: groupTasksByType

import com.google.common.collect.ListMultimap; //導入依賴的package包/類
private ListMultimap<Class, Task> groupTasksByType(List<Task> tasks) {
    final Set<Class> taskTypes = new TreeSet<Class>(new Comparator<Class>() {
        public int compare(Class o1, Class o2) {
            return o1.getSimpleName().compareTo(o2.getSimpleName());
        }
    });
    taskTypes.addAll(collect(tasks, new Transformer<Class, Task>() {
        public Class transform(Task original) {
            return getDeclaredTaskType(original);
        }
    }));

    ListMultimap<Class, Task> tasksGroupedByType = ArrayListMultimap.create();
    for (final Class taskType : taskTypes) {
        tasksGroupedByType.putAll(taskType, filter(tasks, new Spec<Task>() {
            public boolean isSatisfiedBy(Task element) {
                return getDeclaredTaskType(element).equals(taskType);
            }
        }));
    }
    return tasksGroupedByType;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:23,代碼來源:TaskDetailPrinter.java

示例3: initialize

import com.google.common.collect.ListMultimap; //導入依賴的package包/類
void initialize(RegionCoprocessorEnvironment e) throws IOException {
  final Region region = e.getRegion();
  Configuration conf = e.getConfiguration();
  Map<byte[], ListMultimap<String,TablePermission>> tables =
      AccessControlLists.loadAll(region);
  // For each table, write out the table's permissions to the respective
  // znode for that table.
  for (Map.Entry<byte[], ListMultimap<String,TablePermission>> t:
    tables.entrySet()) {
    byte[] entry = t.getKey();
    ListMultimap<String,TablePermission> perms = t.getValue();
    byte[] serialized = AccessControlLists.writePermissionsAsBytes(perms, conf);
    this.authManager.getZKPermissionWatcher().writeToZookeeper(entry, serialized);
  }
  initialized = true;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:17,代碼來源:AccessController.java

示例4: twoFilesOnSameHost

import com.google.common.collect.ListMultimap; //導入依賴的package包/類
@Test
public void twoFilesOnSameHost() throws Exception {
  final List<CompleteWork> workUnits = asList(
      newWork("/10.0.0.1/table/foo1", 1024, ENDPOINT_1_1, 0.33),
      newWork("/10.0.0.1/table/foo2", 2048, ENDPOINT_1_2, 0.66)
  );

  ListMultimap<Integer, CompleteWork> mappings;
  List<NodeEndpoint> endpoints;

  endpoints = asList(ENDPOINT_1_1, ENDPOINT_1_2);
  mappings = INSTANCE.getMappings(endpoints, workUnits);
  verifyAssignments(mappings, endpoints, workUnits);

  // Assign only one endpoint from 10.0.0.1
  endpoints = asList(ENDPOINT_1_2);
  mappings = INSTANCE.getMappings(endpoints, workUnits);
  verifyAssignments(mappings, endpoints, workUnits);

  // Negative case - fails because the assigned list contains ENDPOINTS running on 10.0.0.2, but there are no files on
  // 10.0.0.2
  verifyAssignmentFails(workUnits, ENDPOINT_1_1, ENDPOINT_2_1);
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:24,代碼來源:TestHardAssignmentCreator.java

示例5: findClashingMembersByName

import com.google.common.collect.ListMultimap; //導入依賴的package包/類
/**
 * Find clashes by name.
 *
 * @param myPolyMember
 *            current validated Polyfill
 * @param pivotPolyMember
 *            other polyfill in same project
 * @return pairs of contrandicting or same polyfills.
 */
private ListMultimap<TMember, TMember> findClashingMembersByName(EList<TMember> myPolyMember,
		EList<TMember> pivotPolyMember) {
	ListMultimap<TMember, TMember> ret = LinkedListMultimap.create();
	for (TMember my : myPolyMember) {
		String myName = my.getName();
		if (myName == null)
			continue; // broken AST
		for (TMember other : pivotPolyMember) {
			String otherName = other.getName();
			if (myName.equals(otherName)) {
				ret.put(my, other);
			}
		}
	}
	return ret;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:26,代碼來源:PolyfillValidatorFragment.java

示例6: vertexIsMatch

import com.google.common.collect.ListMultimap; //導入依賴的package包/類
private boolean vertexIsMatch(
        MemgraphCypherQueryContext ctx,
        Vertex vertex,
        List<String> labelNames,
        ListMultimap<String, CypherAstBase> propertiesMap,
        ExpressionScope scope
) {
    Set<String> vertexLabelNames = ctx.getVertexLabels(vertex);
    for (String labelName : labelNames) {
        if (!vertexLabelNames.contains(labelName)) {
            return false;
        }
    }

    return propertyMapMatch(ctx, vertex, propertiesMap, scope);
}
 
開發者ID:mware-solutions,項目名稱:memory-graph,代碼行數:17,代碼來源:MatchClauseExecutor.java

示例7: computeMultimapAsMapGetTestSuite

import com.google.common.collect.ListMultimap; //導入依賴的package包/類
@Override
TestSuite computeMultimapAsMapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?, ? extends OneSizeTestContainerGenerator<ListMultimap<K, V>, Entry<K, V>>>
        parentBuilder) {
  Set<Feature<?>> features = computeMultimapAsMapGetFeatures(parentBuilder.getFeatures());
  if (Collections.disjoint(features, EnumSet.allOf(CollectionSize.class))) {
    return new TestSuite();
  } else {
    return ListTestSuiteBuilder.using(
            new MultimapAsMapGetGenerator<K, V>(parentBuilder.getSubjectGenerator()))
        .withFeatures(features)
        .named(parentBuilder.getName() + ".asMap[].get[key]")
        .suppressing(parentBuilder.getSuppressedTests())
        .createTestSuite();
  }
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:18,代碼來源:ListMultimapTestSuiteBuilder.java

示例8: testOrderingAffectsEqualsComparisons

import com.google.common.collect.ListMultimap; //導入依賴的package包/類
@CollectionSize.Require(SEVERAL)
public void testOrderingAffectsEqualsComparisons() {
  ListMultimap<K, V> multimap1 =
      getSubjectGenerator()
          .create(
              Helpers.mapEntry(k0(), v0()),
              Helpers.mapEntry(k0(), v1()),
              Helpers.mapEntry(k0(), v0()));
  ListMultimap<K, V> multimap2 =
      getSubjectGenerator()
          .create(
              Helpers.mapEntry(k0(), v1()),
              Helpers.mapEntry(k0(), v0()),
              Helpers.mapEntry(k0(), v0()));
  new EqualsTester().addEqualityGroup(multimap1).addEqualityGroup(multimap2).testEquals();
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:17,代碼來源:ListMultimapEqualsTester.java

示例9: verifyAssignments

import com.google.common.collect.ListMultimap; //導入依賴的package包/類
private static final void verifyAssignments(ListMultimap<Integer, CompleteWork> assignments,
    List<NodeEndpoint> inputEps, List<CompleteWork> inputWorks) {
  final String summary = summary(assignments, inputEps, inputWorks);
  final Set<CompleteWork> assignedSet = Sets.newHashSet(assignments.values());
  for(CompleteWork cw : inputWorks) {
    assertTrue("Input work not present in assigned work unit list: " + summary,
        assignedSet.contains(cw));
    assertTrue(summary, assignedSet.remove(cw));
  }

  assertTrue("There are some extra works in assigned work unit list: " + summary, assignedSet.size() == 0);

  int i = 0;
  HashSet<CompleteWork> inputWorkSet = new HashSet<>(inputWorks);
  for(NodeEndpoint ep : inputEps) {
    Collection<CompleteWork> assignedWorks = assignments.get(i);
    for(CompleteWork assignedWork : assignedWorks) {
      assertEquals("Wrong endpoint assigned: " + summary,
          ep.getAddress(), assignedWork.getAffinity().get(0).getEndpoint().getAddress());
      assertTrue(summary, inputWorkSet.remove(assignedWork));
    }
    i++;
  }

}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:26,代碼來源:TestHardAssignmentCreator.java

示例10: playerTicketsLoaded

import com.google.common.collect.ListMultimap; //導入依賴的package包/類
@Override
public ListMultimap<String, ForgeChunkManager.Ticket> playerTicketsLoaded(ListMultimap<String, ForgeChunkManager.Ticket> tickets, World world)
{
	// We don't care what order the tickets are in, but filter out the invalid ones
	ListMultimap<String, ForgeChunkManager.Ticket> validTickets = ArrayListMultimap.create();

	for (String playerName : tickets.keySet())
	{
		List<ForgeChunkManager.Ticket> playerTickets = new ArrayList<>();

		for (ForgeChunkManager.Ticket tkt : tickets.get(playerName))
		{
			BlockPos ticketPosition = NBTUtil.getPosFromTag(tkt.getModData().getCompoundTag("position"));
			TileEntity te = world.getTileEntity(ticketPosition);
			if (te instanceof TileEntityChunkLoader)
			{
				playerTickets.add(tkt);
			}
		}

		validTickets.putAll(playerName, playerTickets);
	}

	return validTickets;
}
 
開發者ID:DarkMorford,項目名稱:Simple-Chunks,代碼行數:26,代碼來源:ChunkLoadingHandler.java

示例11: updateTableCache

import com.google.common.collect.ListMultimap; //導入依賴的package包/類
/**
 * Updates the internal permissions cache for a single table, splitting
 * the permissions listed into separate caches for users and groups to optimize
 * group lookups.
 *
 * @param table
 * @param tablePerms
 */
private void updateTableCache(TableName table,
                              ListMultimap<String,TablePermission> tablePerms) {
  PermissionCache<TablePermission> newTablePerms = new PermissionCache<TablePermission>();

  for (Map.Entry<String,TablePermission> entry : tablePerms.entries()) {
    if (AuthUtil.isGroupPrincipal(entry.getKey())) {
      newTablePerms.putGroup(AuthUtil.getGroupName(entry.getKey()), entry.getValue());
    } else {
      newTablePerms.putUser(entry.getKey(), entry.getValue());
    }
  }

  tableCache.put(table, newTablePerms);
  mtime.incrementAndGet();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:24,代碼來源:TableAuthManager.java

示例12: getMappings

import com.google.common.collect.ListMultimap; //導入依賴的package包/類
/**
 * Does the work of creating the mappings for this AssignmentCreator
 * @return the minor fragment id to work units mapping
 */
private ListMultimap<Integer, T> getMappings() {
  Stopwatch watch = Stopwatch.createStarted();
  maxWork = (int) Math.ceil(units.size() / ((float) incomingEndpoints.size()));
  LinkedList<WorkEndpointListPair<T>> workList = getWorkList();
  LinkedList<WorkEndpointListPair<T>> unassignedWorkList;
  Map<NodeEndpoint,FragIteratorWrapper> endpointIterators = getEndpointIterators();

  unassignedWorkList = assign(workList, endpointIterators, true);

  assignLeftovers(unassignedWorkList, endpointIterators, true);
  assignLeftovers(unassignedWorkList, endpointIterators, false);

  if (!unassignedWorkList.isEmpty()) {
    throw new IllegalStateException("There are still unassigned work units");
  }

  logger.debug("Took {} ms to assign {} work units to {} fragments", watch.elapsed(TimeUnit.MILLISECONDS), units.size(), incomingEndpoints.size());
  return mappings;
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:24,代碼來源:AssignmentCreator.java

示例13: get

import com.google.common.collect.ListMultimap; //導入依賴的package包/類
@Override
public MultimapResource<K> get() {
    ListMultimap<String, String> multimap = ArrayListMultimap.create();
    MultimapResource<K> resource = new MultimapResource<>(key);
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(path.openStream()))) {
        String line;
        while ((line = reader.readLine()) != null) {
            line = line.trim();
            if (line.trim().isEmpty()) {
                continue;
            }
            List<String> fields = Arrays.asList(line.split("\t"));
            apply(fields, multimap);
        }
    } catch (Exception e) {
        throw new RuntimeException("Error initializing TSV resource.", e);
    }
    resource.multimap(ImmutableListMultimap.copyOf(multimap));
    resource.mappingFunction(mappingFunction);
    return resource;
}
 
開發者ID:clearwsd,項目名稱:clearwsd,代碼行數:22,代碼來源:TsvResourceInitializer.java

示例14: manyFiles

import com.google.common.collect.ListMultimap; //導入依賴的package包/類
@Test
public void manyFiles() throws Exception {
  List<CompleteWork> chunks = generateChunks(1000);

  Iterator<NodeEndpoint> incomingEndpointsIterator = Iterators.cycle(endpoints);

  List<NodeEndpoint> incomingEndpoints = Lists.newArrayList();

  final int width = 28 * 30;
  for (int i = 0; i < width; i++) {
    incomingEndpoints.add(incomingEndpointsIterator.next());
  }

  ListMultimap<Integer, CompleteWork> mappings = AssignmentCreator.getMappings(incomingEndpoints, chunks);
  System.out.println(mappings.keySet().size());
  for (int i = 0; i < width; i++) {
    Assert.assertTrue("no mapping for entry " + i, mappings.get(i) != null && mappings.get(i).size() > 0);
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:20,代碼來源:TestAssignment.java

示例15: updateGlobalCache

import com.google.common.collect.ListMultimap; //導入依賴的package包/類
/**
 * Updates the internal global permissions cache
 *
 * @param userPerms
 */
private void updateGlobalCache(ListMultimap<String,TablePermission> userPerms) {
  PermissionCache<Permission> newCache = null;
  try {
    newCache = initGlobal(conf);
    for (Map.Entry<String,TablePermission> entry : userPerms.entries()) {
      if (AuthUtil.isGroupPrincipal(entry.getKey())) {
        newCache.putGroup(AuthUtil.getGroupName(entry.getKey()),
            new Permission(entry.getValue().getActions()));
      } else {
        newCache.putUser(entry.getKey(), new Permission(entry.getValue().getActions()));
      }
    }
    globalCache = newCache;
    mtime.incrementAndGet();
  } catch (IOException e) {
    // Never happens
    LOG.error("Error occured while updating the global cache", e);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:25,代碼來源:TableAuthManager.java


注:本文中的com.google.common.collect.ListMultimap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。