/** * Creates an empty {@code Set} that uses identity to determine equality. It compares object * references, instead of calling {@code equals}, to determine whether a provided object matches * an element in the set. For example, {@code contains} returns {@code false} when passed an * object that equals a set member, but isn't the same instance. This behavior is similar to the * way {@code IdentityHashMap} handles key lookups. * * @since 8.0 */ public static <E> Set<E> newIdentityHashSet() { return Collections.newSetFromMap(Maps.<E, Boolean>newIdentityHashMap()); }
/** * Creates an empty {@code Set} that uses identity to determine equality. It compares object * references, instead of calling {@code equals}, to determine whether a provided object matches * an element in the set. For example, {@code contains} returns {@code false} when passed an * object that equals a set member, but isn't the same instance. This behavior is similar to the * way {@code IdentityHashMap} handles key lookups. * * @since 8.0 */ public static <E> Set<E> newIdentityHashSet() { return Collections.newSetFromMap(Maps.<E, Boolean>newIdentityHashMap()); }
public TsConditionEraser(TblColRef tsColumn, TupleFilter root) { this.tsColumn = tsColumn; this.root = root; this.isInTopLevelANDs = Maps.newIdentityHashMap(); }
public TimeConditionLiteralsReplacer(TupleFilter root) { this.dateCompareTupleChildren = Maps.newIdentityHashMap(); }
/** * Creates an empty {@code Set} that uses identity to determine equality. It compares object * references, instead of calling {@code equals}, to determine whether a provided object matches * an element in the set. For example, {@code contains} returns {@code false} when passed an * object that equals a set member, but isn't the same instance. This behavior is similar to the * way {@code IdentityHashMap} handles key lookups. * * @since 8.0 */ public static <E> Set<E> newIdentityHashSet() { return Collections.newSetFromMap(Maps.<E, Boolean>newIdentityHashMap()); }
private Function<Object, Integer> bindingsToSourceOrder(SourceTypeBinding sourceBinding) { IdentityHashMap<Object, Integer> bindings = Maps.newIdentityHashMap(); if (sourceBinding.scope.referenceContext.methods != null) { for (AbstractMethodDeclaration declaration : sourceBinding.scope.referenceContext.methods) { bindings.put(declaration.binding, declaration.declarationSourceStart); } } if (sourceBinding.scope.referenceContext.fields != null) { for (FieldDeclaration declaration : sourceBinding.scope.referenceContext.fields) { bindings.put(declaration.binding, declaration.declarationSourceStart); } } if (sourceBinding.scope.referenceContext.memberTypes != null) { for (TypeDeclaration declaration : sourceBinding.scope.referenceContext.memberTypes) { bindings.put(declaration.binding, declaration.declarationSourceStart); } } return Functions.forMap(bindings); } }
public void testIdentityHashMap() { IdentityHashMap<Integer, Integer> map = Maps.newIdentityHashMap(); assertEquals(Collections.emptyMap(), map); }
@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(getProxyClient().getPartitionId(update.key().toString()), 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)); }
@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)); }
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; this.conf = conf; 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.isUseTls(), externalExecutorProvider.getExecutor()); } timer = new HashedWheelTimer(getThreadFactory("pulsar-timer"), 1, TimeUnit.MILLISECONDS); producers = Maps.newIdentityHashMap(); consumers = Maps.newIdentityHashMap(); state.set(State.Open); }
/** * @param counterType type of counter */ public BasicCounters(@Nonnull Class<T> counterType) { cache = Maps.newIdentityHashMap(); this.counterType = counterType; }
/** * Creates an empty {@code Set} that uses identity to determine equality. It compares object * references, instead of calling {@code equals}, to determine whether a provided object matches * an element in the set. For example, {@code contains} returns {@code false} when passed an * object that equals a set member, but isn't the same instance. This behavior is similar to the * way {@code IdentityHashMap} handles key lookups. * * @since 8.0 */ public static <E> Set<E> newIdentityHashSet() { return Collections.newSetFromMap(Maps.<E, Boolean>newIdentityHashMap()); }
private static IdentityHashMap<Component, String> computeInverseCache(ImmutableMap<String, Component> delegate) { IdentityHashMap<Component, String> map = Maps.newIdentityHashMap(); for (Entry<String, Component> entry : delegate.entrySet()) { map.put(entry.getValue(), entry.getKey()); } return map; }
public static <K, V> SetMultimap<K, V> newSetMultimap(boolean identityKeys, boolean identityValues) { Map<K, Collection<V>> keys = identityKeys ? Maps.newIdentityHashMap() : new LinkedHashMap<>(); com.google.common.base.Supplier<Set<V>> values = identityValues ? Sets::newIdentityHashSet : LinkedHashSet::new; return Multimaps.newSetMultimap(keys, values); }
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; }
private BeanDynamicObject asDynamicObject(Object object) { if (dynamicObjects == null) { dynamicObjects = Maps.newIdentityHashMap(); } BeanDynamicObject dynamicObject = dynamicObjects.get(object); if (dynamicObject == null) { dynamicObject = new BeanDynamicObject(object); dynamicObjects.put(object, dynamicObject); } return dynamicObject; } }
@SuppressWarnings("unchecked") public ReflectionDatumReader(Schema schema, TypeToken<T> type) { this.schema = schema; this.type = type; this.creatorFactory = new InstantiatorFactory(true); this.creators = Maps.newIdentityHashMap(); this.fieldAccessorFactory = new ReflectionFieldAccessorFactory(); }
public void destroy() { Set<HttpServlet> destroyedSoFar = Sets.newSetFromMap(Maps.<HttpServlet, Boolean>newIdentityHashMap()); for (ServletDefinition servletDefinition : servletDefinitions) { servletDefinition.destroy(destroyedSoFar); } }
protected ReflectionReader(Schema schema, TypeToken<TO> type) { this.creatorFactory = new InstantiatorFactory(true); this.creators = Maps.newIdentityHashMap(); this.fieldAccessorFactory = new ReflectionFieldAccessorFactory(); this.schema = schema; this.type = type; }
protected ReflectionReader(Schema schema, TypeToken<TO> type) { this.creatorFactory = new InstantiatorFactory(true); this.creators = Maps.newIdentityHashMap(); this.fieldAccessorFactory = new ReflectionFieldAccessorFactory(); this.schema = schema; this.type = type; }