Java Code Examples for com.google.common.collect.Maps#newIdentityHashMap()

The following examples show how to use com.google.common.collect.Maps#newIdentityHashMap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DependencyManager.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: PulsarClientImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 3
Source File: TypeInference.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: DistributedSetProxy.java    From atomix with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example 5
Source File: Closure_112_TypeInference_t.java    From coming with MIT License 6 votes vote down vote up
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;
}
 
Example 6
Source File: AbstractAtomicMapProxy.java    From atomix with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example 7
Source File: AbstractTaskStoreTest.java    From attic-aurora with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 8
Source File: DefaultResourceDescription.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
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;
}
 
Example 9
Source File: TraceConfiguration.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 10
Source File: TraceConfiguration.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 11
Source File: SingleClassBindingResolver.java    From KodeBeagle with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 12
Source File: SingleClassBindingResolver.java    From KodeBeagle with Apache License 2.0 5 votes vote down vote up
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;
    }
 
Example 13
Source File: SingleClassBindingResolver.java    From KodeBeagle with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 14
Source File: RenderCrop.java    From AgriCraft with MIT License 4 votes vote down vote up
public RenderCrop(BlockCrop block) {
    super(block, new TileEntityCrop(), false, true, false);
    this.cropQuads = Maps.newIdentityHashMap();
}
 
Example 15
Source File: TsConditionEraser.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
public TsConditionEraser(TblColRef tsColumn, TupleFilter root) {
    this.tsColumn = tsColumn;
    this.root = root;
    this.isInTopLevelANDs = Maps.newIdentityHashMap();
}
 
Example 16
Source File: ConstraintReportTransformer.java    From ldp4j with Apache License 2.0 4 votes vote down vote up
private ShapeIndividualCache() {
	this.cache=Maps.newIdentityHashMap();
}
 
Example 17
Source File: BasicCounters.java    From attic-apex-malhar with Apache License 2.0 4 votes vote down vote up
/**
 * @param counterType type of counter
 */
public BasicCounters(@Nonnull Class<T> counterType)
{
  cache = Maps.newIdentityHashMap();
  this.counterType = counterType;
}
 
Example 18
Source File: ConstraintReportTransformer.java    From ldp4j with Apache License 2.0 4 votes vote down vote up
private IndividualTranslator() {
	this.individualCache=Maps.newIdentityHashMap();
}
 
Example 19
Source File: TimeConditionLiteralsReplacer.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
public TimeConditionLiteralsReplacer(TupleFilter root) {
    this.dateCompareTupleChildren = Maps.newIdentityHashMap();
}
 
Example 20
Source File: Multimaps.java    From caja with Apache License 2.0 votes vote down vote up
public Map<K, V> newInstance() { return Maps.newIdentityHashMap(); }