com.google.common.collect.Maps#newIdentityHashMap ( )源码实例Demo

下面列出了com.google.common.collect.Maps#newIdentityHashMap ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: javaide   文件: DependencyManager.java
private static List<LibraryDependencyImpl> convertLibraryInfoIntoDependency(
        @NonNull List<LibInfo> libInfos,
        @NonNull Multimap<LibraryDependency, VariantDependencies> reverseMap) {
    List<LibraryDependencyImpl> list = Lists.newArrayListWithCapacity(libInfos.size());

    // since the LibInfos is a graph and the previous "foundLibraries" map ensure we reuse
    // instance where applicable, we'll create a map to keep track of what we have already
    // converted.
    Map<LibInfo, LibraryDependencyImpl> convertedMap = Maps.newIdentityHashMap();

    for (LibInfo libInfo : libInfos) {
        list.add(convertLibInfo(libInfo, reverseMap, convertedMap));
    }

    return list;
}
 
源代码2 项目: pulsar   文件: PulsarClientImpl.java
public PulsarClientImpl(ClientConfigurationData conf, EventLoopGroup eventLoopGroup, ConnectionPool cnxPool)
        throws PulsarClientException {
    if (conf == null || isBlank(conf.getServiceUrl()) || eventLoopGroup == null) {
        throw new PulsarClientException.InvalidConfigurationException("Invalid client configuration");
    }
    this.eventLoopGroup = eventLoopGroup;
    setAuth(conf);
    this.conf = conf;
    this.clientClock = conf.getClock();
    conf.getAuthentication().start();
    this.cnxPool = cnxPool;
    externalExecutorProvider = new ExecutorProvider(conf.getNumListenerThreads(), getThreadFactory("pulsar-external-listener"));
    if (conf.getServiceUrl().startsWith("http")) {
        lookup = new HttpLookupService(conf, eventLoopGroup);
    } else {
        lookup = new BinaryProtoLookupService(this, conf.getServiceUrl(), conf.getListenerName(), conf.isUseTls(), externalExecutorProvider.getExecutor());
    }
    timer = new HashedWheelTimer(getThreadFactory("pulsar-timer"), 1, TimeUnit.MILLISECONDS);
    producers = Maps.newIdentityHashMap();
    consumers = Maps.newIdentityHashMap();
    state.set(State.Open);
}
 
源代码3 项目: coming   文件: Closure_112_TypeInference_t.java
private Map<TemplateType, JSType> inferTemplateTypesFromParameters(
    FunctionType fnType, Node call) {
  if (fnType.getTemplateTypeMap().getTemplateKeys().isEmpty()) {
    return Collections.emptyMap();
  }

  Map<TemplateType, JSType> resolvedTypes = Maps.newIdentityHashMap();

  Node callTarget = call.getFirstChild();
  if (NodeUtil.isGet(callTarget)) {
    Node obj = callTarget.getFirstChild();
    maybeResolveTemplatedType(
        fnType.getTypeOfThis(),
        getJSType(obj),
        resolvedTypes);
  }

  if (call.hasMoreThanOneChild()) {
    maybeResolveTemplateTypeFromNodes(
        fnType.getParameters(),
        call.getChildAtIndex(1).siblings(),
        resolvedTypes);
  }
  return resolvedTypes;
}
 
源代码4 项目: attic-aurora   文件: AbstractTaskStoreTest.java
@Test
public void testCanonicalTaskConfigs() {
  IScheduledTask a = createTask("a");
  IScheduledTask b = createTask("a");
  IScheduledTask c = createTask("a");
  saveTasks(a, b, c);
  Set<IScheduledTask> inserted = ImmutableSet.of(a, b, c);

  Set<ITaskConfig> storedConfigs = FluentIterable.from(fetchTasks(Query.unscoped()))
      .transform(Tasks::getConfig)
      .toSet();
  assertEquals(
      FluentIterable.from(inserted).transform(Tasks::getConfig).toSet(),
      storedConfigs);
  Map<ITaskConfig, ITaskConfig> identityMap = Maps.newIdentityHashMap();
  for (ITaskConfig stored : storedConfigs) {
    identityMap.put(stored, stored);
  }
  assertEquals(
      ImmutableMap.of(Tasks.getConfig(a), Tasks.getConfig(a)),
      identityMap);
}
 
源代码5 项目: atomix   文件: AbstractAtomicMapProxy.java
@Override
public CompletableFuture<Boolean> prepare(TransactionLog<MapUpdate<K, byte[]>> transactionLog) {
  Map<PartitionId, List<MapUpdate<K, byte[]>>> updatesGroupedByMap = Maps.newIdentityHashMap();
  transactionLog.records().forEach(update -> {
    updatesGroupedByMap.computeIfAbsent(getPartition(update.key()), k -> Lists.newLinkedList()).add(update);
  });
  Map<PartitionId, TransactionLog<MapUpdate<K, byte[]>>> transactionsByMap =
      Maps.transformValues(updatesGroupedByMap, list -> new TransactionLog<>(transactionLog.transactionId(), transactionLog.version(), list));

  return Futures.allOf(transactionsByMap.entrySet()
      .stream()
      .map(e -> getProxyClient().applyOn(e.getKey(), service -> service.prepare(e.getValue()))
          .thenApply(v -> v == PrepareResult.OK || v == PrepareResult.PARTIAL_FAILURE))
      .collect(Collectors.toList()))
      .thenApply(list -> list.stream().reduce(Boolean::logicalAnd).orElse(true));
}
 
源代码6 项目: atomix   文件: DistributedSetProxy.java
@Override
public CompletableFuture<Boolean> prepare(TransactionLog<SetUpdate<String>> transactionLog) {
  Map<PartitionId, List<SetUpdate<String>>> updatesGroupedBySet = Maps.newIdentityHashMap();
  transactionLog.records().forEach(update -> {
    updatesGroupedBySet.computeIfAbsent(getProxyClient().getPartitionId(update.element()), k -> Lists.newLinkedList()).add(update);
  });
  Map<PartitionId, TransactionLog<SetUpdate<String>>> transactionsBySet =
      Maps.transformValues(updatesGroupedBySet, list -> new TransactionLog<>(transactionLog.transactionId(), transactionLog.version(), list));

  return Futures.allOf(transactionsBySet.entrySet()
      .stream()
      .map(e -> getProxyClient().applyOn(e.getKey(), service -> service.prepare(e.getValue()))
          .thenApply(v -> v == PrepareResult.OK || v == PrepareResult.PARTIAL_FAILURE))
      .collect(Collectors.toList()))
      .thenApply(list -> list.stream().reduce(Boolean::logicalAnd).orElse(true));
}
 
源代码7 项目: astor   文件: TypeInference.java
private Map<TemplateType, JSType> inferTemplateTypesFromParameters(
    FunctionType fnType, Node call) {
  if (fnType.getTemplateKeys().isEmpty()) {
    return Collections.emptyMap();
  }

  Map<TemplateType, JSType> resolvedTypes = Maps.newIdentityHashMap();

  Node callTarget = call.getFirstChild();
  if (NodeUtil.isGet(callTarget)) {
    Node obj = callTarget.getFirstChild();
    maybeResolveTemplatedType(
        fnType.getTypeOfThis(),
        getJSType(obj),
        resolvedTypes);
  }

  if (call.hasMoreThanOneChild()) {
    maybeResolveTemplateTypeFromNodes(
        fnType.getParameters(),
        call.getChildAtIndex(1).siblings(),
        resolvedTypes);
  }
  return resolvedTypes;
}
 
源代码8 项目: xtext-core   文件: DefaultResourceDescription.java
protected Map<EObject, IEObjectDescription> createEObject2ExportedEObjectsMap(
		Iterable<IEObjectDescription> exportedObjects) {
	Map<EObject, IEObjectDescription> uri2exportedEObjects = Maps.newIdentityHashMap();
	for (IEObjectDescription eObjectDescription : exportedObjects) {
		uri2exportedEObjects.put(eObjectDescription.getEObjectOrProxy(), eObjectDescription);
	}
	return uri2exportedEObjects;
}
 
源代码9 项目: dsl-devkit   文件: TraceConfiguration.java
/**
 * Creates a new trace configuration which enables all tracing <b>except</b> for the given event types.
 *
 * @param excludedTraceClasses
 *          event types to disable tracing for
 * @return trace configuration, never {@code null}
 */
@SafeVarargs
static TraceConfiguration enableAllExcept(final Class<? extends TraceEvent>... excludedTraceClasses) {
  Map<Class<? extends TraceEvent>, Boolean> excludedTraceClassMap = Maps.newIdentityHashMap();
  for (Class<? extends TraceEvent> traceClass : excludedTraceClasses) {
    excludedTraceClassMap.put(traceClass, Boolean.TRUE);
  }
  return c -> !excludedTraceClassMap.containsKey(c);
}
 
源代码10 项目: dsl-devkit   文件: TraceConfiguration.java
/**
 * Creates a new trace configuration which enables tracing <b>only</b> for the given event types.
 *
 * @param includedTraceClasses
 *          event types to enable tracing for
 * @return trace configuration, never {@code null}
 */
@SafeVarargs
static TraceConfiguration enableOnly(final Class<? extends TraceEvent>... includedTraceClasses) {
  Map<Class<? extends TraceEvent>, Boolean> includedTraceClassMap = Maps.newIdentityHashMap();
  for (Class<? extends TraceEvent> traceClass : includedTraceClasses) {
    includedTraceClassMap.put(traceClass, Boolean.TRUE);
  }
  return includedTraceClassMap::containsKey;
}
 
源代码11 项目: KodeBeagle   文件: SingleClassBindingResolver.java
/**
 * Returns the location and type of all the variables.
 *
 * @return
 */
public Map<ASTNode, String> getVariableTypesAtPosition() {
    final Map<ASTNode, String> variableTypes = Maps.newIdentityHashMap();

    for (final Entry<Integer, List<ASTNode>> variableBinding : resolver.getVariableBinding()
            .entrySet()) {
        Integer bindingId = variableBinding.getKey();
        final String varType = checkNotNull(resolver.getVariableTypes()
                .get(bindingId));
        for (final ASTNode node : variableBinding.getValue()) {
            variableTypes.put(node, varType);
        }
    }
    return variableTypes;
}
 
源代码12 项目: KodeBeagle   文件: SingleClassBindingResolver.java
public Map<ASTNode, ASTNode> getVariableDependencies() {

        final Map<ASTNode, ASTNode> variableTypes = Maps.newIdentityHashMap();

        for (final Entry<Integer, List<ASTNode>> variableBinding : resolver.getVariableBinding()
                .entrySet()) {
            Integer bindingId = variableBinding.getKey();
            final ASTNode parent = resolver.getVariableDeclarationBinding().get(bindingId);
            for (final ASTNode node : variableBinding.getValue()) {
                variableTypes.put(node, parent);
            }
        }
        return variableTypes;
    }
 
源代码13 项目: KodeBeagle   文件: SingleClassBindingResolver.java
/**
 * Returns the locations where a type is mentioned and its actual
 * fully qualified type name.
 *
 * @return
 */
public Map<ASTNode, String> getTypesAtPosition() {
    final Map<ASTNode, String> nodeTypes = Maps.newIdentityHashMap();

    for (final Entry<ASTNode, String> typeBinding : resolver.getNodeTypeBinding()
            .entrySet()) {
        if (!typeBinding.getValue().contains("<")) {
            nodeTypes.put(typeBinding.getKey(), typeBinding.getValue());
        }
    }
    return nodeTypes;
}
 
源代码14 项目: kylin-on-parquet-v2   文件: TsConditionEraser.java
public TsConditionEraser(TblColRef tsColumn, TupleFilter root) {
    this.tsColumn = tsColumn;
    this.root = root;
    this.isInTopLevelANDs = Maps.newIdentityHashMap();
}
 
public TimeConditionLiteralsReplacer(TupleFilter root) {
    this.dateCompareTupleChildren = Maps.newIdentityHashMap();
}
 
源代码16 项目: ldp4j   文件: ConstraintReportTransformer.java
private IndividualTranslator() {
	this.individualCache=Maps.newIdentityHashMap();
}
 
源代码17 项目: attic-apex-malhar   文件: BasicCounters.java
/**
 * @param counterType type of counter
 */
public BasicCounters(@Nonnull Class<T> counterType)
{
  cache = Maps.newIdentityHashMap();
  this.counterType = counterType;
}
 
源代码18 项目: ldp4j   文件: ConstraintReportTransformer.java
private ShapeIndividualCache() {
	this.cache=Maps.newIdentityHashMap();
}
 
源代码19 项目: AgriCraft   文件: RenderCrop.java
public RenderCrop(BlockCrop block) {
    super(block, new TileEntityCrop(), false, true, false);
    this.cropQuads = Maps.newIdentityHashMap();
}
 
源代码20 项目: caja   文件: Multimaps.java
public Map<K, V> newInstance() { return Maps.newIdentityHashMap(); }