List of usage examples for com.google.common.hash HashCode fromInt
@CheckReturnValue public static HashCode fromInt(int hash)
From source file:com.facebook.buck.rules.modern.SerializationTestHelper.java
/** * Serialize and deserialize an object./*from ww w . j av a 2 s . c o m*/ * * <p>The ruleFinder and cellResolver are used for serialization, the rest for deserialization. */ public static <T extends AddsToRuleKey> T serializeAndDeserialize(T instance, Class<T> tClass, SourcePathRuleFinder ruleFinder, CellPathResolver cellResolver, SourcePathResolver resolver, ToolchainProvider toolchainProvider, Function<Optional<String>, ProjectFilesystem> filesystemFunction) throws IOException { Map<HashCode, byte[]> dataMap = new HashMap<>(); Map<HashCode, List<HashCode>> childMap = new HashMap<>(); Delegate serializerDelegate = (value, data, children) -> { int id = dataMap.size(); HashCode hash = HashCode.fromInt(id); dataMap.put(hash, data); childMap.put(hash, children); return hash; }; Either<HashCode, byte[]> serialized = new Serializer(ruleFinder, cellResolver, serializerDelegate) .serialize(instance, DefaultClassInfoFactory.forInstance(instance)); return new Deserializer(filesystemFunction, Class::forName, () -> resolver, toolchainProvider) .deserialize(new DataProvider() { @Override public InputStream getData() { return new ByteArrayInputStream( serialized.transform(left -> dataMap.get(left), right -> right)); } @Override public DataProvider getChild(HashCode hash) { return getDataProvider(dataMap, childMap, hash); } }, tClass); }
From source file:com.google.idea.blaze.android.run.binary.instantrun.BlazeInstantRunContext.java
@NotNull @Override public HashCode getManifestResourcesHash() { // TODO b/28373160 return HashCode.fromInt(0); }
From source file:com.facebook.buck.rules.modern.builders.ReconstructingStrategy.java
ReconstructingStrategy(SourcePathRuleFinder ruleFinder, CellPathResolver cellResolver, Cell rootCell) { dataMap = new ConcurrentHashMap<>(); id = new AtomicInteger(); delegate = (instance, data, children) -> { HashCode hash = HashCode.fromInt(id.incrementAndGet()); dataMap.put(hash, data);// w w w . j a v a 2 s. c om return hash; }; serializer = new Serializer(ruleFinder, cellResolver, delegate); deserializer = new Deserializer( name -> rootCell.getCellProvider().getCellByPath(cellResolver.getCellPathOrThrow(name)) .getFilesystem(), Class::forName, () -> DefaultSourcePathResolver.from(ruleFinder), rootCell.getToolchainProvider()); }
From source file:com.android.tools.idea.gradle.run.GradleInstantRunContext.java
@VisibleForTesting static HashCode getManifestResourcesHash(@NotNull AndroidFacet facet) { Document manifest = MergedManifest.get(facet).getDocument(); if (manifest == null || manifest.getDocumentElement() == null) { return HashCode.fromInt(0); }//w w w.j ava2s . c o m final Hasher hasher = Hashing.goodFastHash(32).newHasher(); SortedSet<ResourceUrl> appResourceReferences = getAppResourceReferences(manifest.getDocumentElement()); AppResourceRepository appResources = AppResourceRepository.getAppResources(facet, true); // read action needed when reading the values for app resources ApplicationManager.getApplication().runReadAction(() -> { hashResources(appResourceReferences, appResources, hasher); }); return hasher.hash(); }
From source file:com.facebook.buck.distributed.DistBuildFileMaterializer.java
@Override public HashCode get(Path path) throws IOException { Queue<Path> remainingPaths = new LinkedList<>(); remainingPaths.add(path);/*from w ww . j a v a2 s . c o m*/ while (remainingPaths.size() > 0) { materializeIfNeeded(remainingPaths.remove(), remainingPaths); } return HashCode.fromInt(0); }
From source file:com.facebook.buck.distributed.DistBuildFileMaterializer.java
@Override public HashCode get(ArchiveMemberPath archiveMemberPath) throws IOException { materializeIfNeeded(archiveMemberPath.getArchivePath(), new LinkedList<>()); return HashCode.fromInt(0); }
From source file:com.facebook.buck.distributed.MaterializerDummyFileHashCache.java
@Override public HashCode get(Path relPath) throws IOException { materializeIfNeededAsync(relPath);/* w w w .j a v a2 s .c o m*/ if (getMaterializationFuturesAsList().isDone()) { return delegate.get(relPath); } else { // Return a fake. This class is not meant for actually computing HashCodes. return HashCode.fromInt(0); } }
From source file:com.facebook.buck.distributed.MaterializerDummyFileHashCache.java
@Override public HashCode get(ArchiveMemberPath archiveMemberRelPath) throws IOException { materializeIfNeededAsync(archiveMemberRelPath.getArchivePath()); if (getMaterializationFuturesAsList().isDone()) { return delegate.get(archiveMemberRelPath); } else {//w w w. j a v a 2s .c o m // Return a fake. This class is not meant for actually computing HashCodes. return HashCode.fromInt(0); } }