List of usage examples for com.google.common.collect Maps newIdentityHashMap
public static <K, V> IdentityHashMap<K, V> newIdentityHashMap()
From source file:com.spotify.folsom.ketama.KetamaMemcacheClient.java
private <T> ListenableFuture<List<T>> sendSplitRequest(final MultiRequest<T> multiRequest) { final List<byte[]> keys = multiRequest.getKeys(); final Map<RawMemcacheClient, List<byte[]>> routing = Maps.newIdentityHashMap(); final List<RawMemcacheClient> routing2 = Lists.newArrayListWithCapacity(keys.size()); for (final byte[] key : keys) { final RawMemcacheClient client = getClient(key); List<byte[]> subKeys = routing.get(client); if (subKeys == null) { subKeys = Lists.newArrayList(); routing.put(client, subKeys); }//from w w w .j a va 2 s . c o m subKeys.add(key); routing2.add(client); } final Map<RawMemcacheClient, ListenableFuture<List<T>>> futures = Maps.newIdentityHashMap(); for (final Map.Entry<RawMemcacheClient, List<byte[]>> entry : routing.entrySet()) { final List<byte[]> subKeys = entry.getValue(); final Request<List<T>> subRequest = multiRequest.create(subKeys); final RawMemcacheClient client = entry.getKey(); ListenableFuture<List<T>> send = client.send(subRequest); futures.put(client, send); } final ListenableFuture<List<List<T>>> allFutures = Futures.allAsList(futures.values()); return Utils.transform(allFutures, new Assembler<>(futures, routing2)); }
From source file:com.kodebeagle.javaparser.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); }//from www .jav a2 s . c o m } return variableTypes; }
From source file:com.google.devtools.build.lib.testutil.MoreAsserts.java
private static boolean isRetained(Predicate<Object> predicate, Object start) { Map<Object, Object> visited = Maps.newIdentityHashMap(); visited.put(start, start);//w ww .ja v a 2 s. c o m Queue<Object> toScan = new ArrayDeque<>(); toScan.add(start); while (!toScan.isEmpty()) { Object current = toScan.poll(); if (current.getClass().isArray()) { if (current.getClass().getComponentType().isPrimitive()) { continue; } for (Object ref : (Object[]) current) { if (ref != null) { if (predicate.apply(ref)) { return true; } if (visited.put(ref, ref) == null) { toScan.add(ref); } } } } else { // iterate *all* fields (getFields() returns only accessible ones) for (Class<?> clazz = current.getClass(); clazz != null; clazz = clazz.getSuperclass()) { for (Field f : clazz.getDeclaredFields()) { if (f.getType().isPrimitive() || ALL_STRONG_REFS.apply(f)) { continue; } f.setAccessible(true); try { Object ref = f.get(current); if (ref != null) { if (predicate.apply(ref)) { return true; } if (visited.put(ref, ref) == null) { toScan.add(ref); } } } catch (IllegalArgumentException | IllegalAccessException e) { throw new IllegalStateException("Error when scanning the heap", e); } } } } } return false; }
From source file:com.ardor3d.extension.model.collada.jdom.data.DataCache.java
public DataCache() { _boundMaterials = Maps.newHashMap(); _textures = Maps.newHashMap();/*from www.j a v a 2 s . co m*/ _idCache = Maps.newHashMap(); _sidCache = Maps.newHashMap(); _xPathExpressions = Maps.newHashMap(); _pattern = Pattern.compile("\\s"); _transformTypes = Collections .unmodifiableList(Lists.newArrayList("lookat", "matrix", "rotate", "scale", "scew", "translate")); _floatArrays = Maps.newHashMap(); _doubleArrays = Maps.newHashMap(); _booleanArrays = Maps.newHashMap(); _intArrays = Maps.newHashMap(); _stringArrays = Maps.newHashMap(); _vertMappings = ArrayListMultimap.create(); _meshVertMap = Maps.newIdentityHashMap(); _parsedVertexColors = ArrayListMultimap.create(); _materialInfoMap = Maps.newHashMap(); _meshMaterialMap = Maps.newIdentityHashMap(); _elementSpatialMapping = Maps.newHashMap(); _elementJointMapping = Maps.newHashMap(); _externalJointMapping = Maps.newHashMap(); _skeletons = Lists.newArrayList(); _jointSkeletonMapping = Maps.newHashMap(); _skeletonPoseMapping = Maps.newHashMap(); _controllers = Lists.newArrayList(); }
From source file:com.kodebeagle.javaparser.SingleClassBindingResolver.java
/** * Returns the locations where a type is mentioned and its actual * fully qualified type name.//from w w w . ja v a2 s.c om * * @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; }
From source file:com.android.tools.idea.model.DeclaredPermissionsLookup.java
@NonNull private LibraryPermissions getLibraryPermissions(@NonNull AndroidLibrary library) { if (myLibraryPermissions == null) { myLibraryPermissions = Maps.newIdentityHashMap(); }// ww w. ja v a 2s. c om LibraryPermissions libraryPermissions = myLibraryPermissions.get(library); if (libraryPermissions == null) { libraryPermissions = new LibraryPermissions(library); myLibraryPermissions.put(library, libraryPermissions); } return libraryPermissions; }
From source file:com.yahoo.pulsar.client.impl.PulsarClientImpl.java
public PulsarClientImpl(String serviceUrl, ClientConfiguration conf, EventLoopGroup eventLoopGroup) throws PulsarClientException { if (serviceUrl == null || conf == null || eventLoopGroup == null) { throw new PulsarClientException.InvalidConfigurationException("Invalid client configuration"); }//from ww w .j a va 2 s .co m this.eventLoopGroup = eventLoopGroup; this.conf = conf; conf.getAuthentication().start(); cnxPool = new ConnectionPool(this, eventLoopGroup); if (serviceUrl.startsWith("http")) { httpClient = new HttpClient(serviceUrl, conf.getAuthentication(), eventLoopGroup, conf.isTlsAllowInsecureConnection(), conf.getTlsTrustCertsFilePath()); lookup = new HttpLookupService(httpClient, conf.isUseTls()); } else { lookup = new BinaryProtoLookupService(this, serviceUrl, conf.isUseTls()); } timer = new HashedWheelTimer(new DefaultThreadFactory("pulsar-timer"), 1, TimeUnit.MILLISECONDS); externalExecutorProvider = new ExecutorProvider(conf.getListenerThreads(), "pulsar-external-listener"); producers = Maps.newIdentityHashMap(); consumers = Maps.newIdentityHashMap(); state.set(State.Open); }
From source file:com.android.tools.idea.model.DeclaredPermissionsLookup.java
@NonNull private ModulePermissions getModulePermissions(@NonNull Module module) { if (myModulePermissionsMap == null) { myModulePermissionsMap = Maps.newIdentityHashMap(); }//from w ww.j a va2s . com ModulePermissions modulePermissions = myModulePermissionsMap.get(module); if (modulePermissions == null) { modulePermissions = new ModulePermissions(module); myModulePermissionsMap.put(module, modulePermissions); } return modulePermissions; }
From source file:org.apache.pulsar.client.impl.PulsarClientImpl.java
public PulsarClientImpl(String serviceUrl, ClientConfiguration conf, EventLoopGroup eventLoopGroup) throws PulsarClientException { if (serviceUrl == null || conf == null || eventLoopGroup == null) { throw new PulsarClientException.InvalidConfigurationException("Invalid client configuration"); }/*from ww w. j a v a2 s. co m*/ this.eventLoopGroup = eventLoopGroup; this.conf = conf; conf.getAuthentication().start(); cnxPool = new ConnectionPool(this, eventLoopGroup); if (serviceUrl.startsWith("http")) { lookup = new HttpLookupService(serviceUrl, conf, eventLoopGroup); } else { lookup = new BinaryProtoLookupService(this, serviceUrl, conf.isUseTls()); } timer = new HashedWheelTimer(new DefaultThreadFactory("pulsar-timer"), 1, TimeUnit.MILLISECONDS); externalExecutorProvider = new ExecutorProvider(conf.getListenerThreads(), "pulsar-external-listener"); producers = Maps.newIdentityHashMap(); consumers = Maps.newIdentityHashMap(); state.set(State.Open); }
From source file:com.android.tools.idea.model.DeclaredPermissionsLookup.java
private ManifestPermissions getManifestPermissions(VirtualFile manifest) { if (myManifestPermissionsMap == null) { myManifestPermissionsMap = Maps.newIdentityHashMap(); }//from w w w .ja v a2 s . c om ManifestPermissions manifestPermissions = myManifestPermissionsMap.get(manifest); if (manifestPermissions == null) { manifestPermissions = new ManifestVirtualFilePermissions(myProject, manifest); myManifestPermissionsMap.put(manifest, manifestPermissions); } return manifestPermissions; }