当前位置: 首页>>代码示例>>Java>>正文


Java Hasher.putUnencodedChars方法代码示例

本文整理汇总了Java中com.google.common.hash.Hasher.putUnencodedChars方法的典型用法代码示例。如果您正苦于以下问题:Java Hasher.putUnencodedChars方法的具体用法?Java Hasher.putUnencodedChars怎么用?Java Hasher.putUnencodedChars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.hash.Hasher的用法示例。


在下文中一共展示了Hasher.putUnencodedChars方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCacheKey

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
public String getCacheKey() {
	Hasher hasher = hf.newHasher();
	hasher.putUnencodedChars(queryKey);
	for (Number id : ids) {
		if (id instanceof Integer) {
			hasher.putInt(id.intValue());
		} else if (id instanceof Long) {
			hasher.putLong(id.longValue());
		} else if (id instanceof Short) {
			hasher.putLong(id.shortValue());
		} else if (id instanceof Double) {
			hasher.putDouble(id.doubleValue());
		} else if (id instanceof Float) {
			hasher.putFloat(id.floatValue());
		} else if (id instanceof Byte) {
			hasher.putFloat(id.byteValue());
		}
	}
	HashCode hashcode = hasher.hash();
	return hashcode.toString();
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:22,代码来源:CacheDescriptor.java

示例2: testBasics

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
@Test
public void testBasics() {
    Hasher hasher = NullHasher.INSTANCE;
    assertEquals(0, hasher.hash().asInt());
    hasher.putBoolean(false);
    hasher.putByte((byte) 3);
    hasher.putBytes(new byte[0]);
    hasher.putBytes(null, 3, 3);
    hasher.putChar('c');
    hasher.putDouble(3.3);
    hasher.putFloat(3.4f);
    hasher.putInt(7);
    hasher.putLong(3);
    hasher.putObject(null, null);
    hasher.putShort((short) 7);
    hasher.putString(null, null);
    hasher.putUnencodedChars(null);
}
 
开发者ID:aws,项目名称:elastic-load-balancing-tools,代码行数:19,代码来源:NullHasherTest.java

示例3: createEObjectDescriptions

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
@Override
public boolean createEObjectDescriptions(final EObject eObject, final IAcceptor<IEObjectDescription> acceptor) {
  if (getQualifiedNameProvider() == null || !(eObject instanceof ScopeModel)) {
    return false;
  }
  ScopeModel model = (ScopeModel) eObject;
  try {
    QualifiedName qualifiedName = getQualifiedNameProvider().getFullyQualifiedName(model);
    if (qualifiedName != null) {
      Hasher hasher = Hashing.murmur3_32().newHasher(HASHER_CAPACITY);
      hasher.putUnencodedChars(getSourceText(model));
      for (ScopeModel include : model.getIncludedScopes()) {
        hasher.putUnencodedChars(getSourceText(include));
      }
      acceptor.accept(EObjectDescription.create(qualifiedName, model, Collections.singletonMap("fingerprint", hasher.hash().toString())));
    }
    // CHECKSTYLE:CHECK-OFF IllegalCatch
  } catch (RuntimeException e) {
    // CHECKSTYLE:CHECK-ON
    LOG.error(e.getMessage(), e);
  }
  return false;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:24,代码来源:ScopeResourceDescriptionStrategy.java

示例4: fingerprintEObject

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
/**
 * Generate a fingerprint for the target object using its URI.
 *
 * @param target
 *          The target object
 * @param context
 *          The object containing the reference
 * @param hasher
 *          hasher to stream to
 */
private void fingerprintEObject(final EObject target, final EObject context, final Hasher hasher) {
  if (target == null) {
    hasher.putUnencodedChars(NULL_STRING);
  } else if (target.eIsProxy()) {
    if (context.eResource() instanceof LazyLinkingResource) {
      final URI proxyUri = ((InternalEObject) target).eProxyURI();
      if (!((LazyLinkingResource) context.eResource()).getEncoder().isCrossLinkFragment(context.eResource(), proxyUri.fragment())) {
        hasher.putUnencodedChars(proxyUri.toString());
        return;
      }
    }
    hasher.putUnencodedChars(UNRESOLVED_STRING);
  } else {
    hasher.putUnencodedChars(EcoreUtil.getURI(target).toString());
  }
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:27,代码来源:AbstractStreamingFingerprintComputer.java

示例5: generateSuffix

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
/**
 * Returns the {@code nameIdx}-th short name. This might be a reserved name.
 * A user-requested prefix is not included, but the first returned character
 * is supposed to go at position {@code position} in the final name
 */
private String generateSuffix(int position, int nameIdx) {
  StringBuilder name = new StringBuilder();
  int length = getNameLength(position, nameIdx);
  nameIdx++;
  do {
    nameIdx--;
    String alphabet;
    if (position == 0) {
      alphabet = shuffledFirst;
    } else {
      Hasher hasher = Hashing.murmur3_128().newHasher();
      hasher.putInt(length);
      hasher.putUnencodedChars(name);
      int alphabetIdx = (hasher.hash().asInt() & 0x7fffffff) % NUM_SHUFFLES;
      alphabet = shuffledNonFirst.get(alphabetIdx);
    }
    int alphabetSize = alphabet.length();
    char character = alphabet.charAt(nameIdx % alphabetSize);
    name.append(character);

    nameIdx /= alphabetSize;
    position++;
  } while (nameIdx > 0);
  return name.toString();
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:31,代码来源:RandomNameGenerator.java

示例6: computeHashes

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
public static long[] computeHashes(String item, int numWords, int seed)
{
	long[] hashes = new long[numWords];

	for (int word = 0; word < numWords; word += 2)
	{
		HashFunction hashFunc = Hashing.murmur3_128(seed + word);
		Hasher hasher = hashFunc.newHasher();
		hasher.putUnencodedChars(item);

		// get the two longs out
		HashCode hc = hasher.hash();
		ByteBuffer bb = ByteBuffer.wrap(hc.asBytes());
		hashes[word] = bb.getLong(0);
		if (word + 1 < numWords)
			hashes[word + 1] = bb.getLong(8);
	}

	return hashes;
}
 
开发者ID:marbl,项目名称:MHAP,代码行数:21,代码来源:HashUtils.java

示例7: createHasherWithAbiKeyForDeps

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
/**
 * Creates a Hasher containing the ABI keys of the dependencies.
 * @param rulesWithAbiToConsider a sorted set containing the dependencies whose ABI key will be
 *     added to the hasher.
 * @return a Hasher containing the ABI keys of the dependencies.
 */
private Hasher createHasherWithAbiKeyForDeps(SortedSet<HasBuildTarget> rulesWithAbiToConsider) {
  Hasher hasher = Hashing.sha1().newHasher();

  for (HasBuildTarget candidate : rulesWithAbiToConsider) {
    if (candidate == this) {
      continue;
    }

    if (candidate instanceof HasJavaAbi) {
      Sha1HashCode abiKey = ((HasJavaAbi) candidate).getAbiKey();
      hasher.putUnencodedChars(abiKey.getHash());
    } else if (candidate instanceof BuildRule) {
      HashCode hashCode = ((BuildRule) candidate).getRuleKey().getHashCode();
      hasher.putBytes(hashCode.asBytes());
    }
  }

  return hasher;
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:26,代码来源:DefaultJavaLibrary.java

示例8: init

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
public Hasher init(final URI url) {
	final Hasher hasher = hashFunction.newHasher();
	if (url != null) {
		// Note that we need to go directly to the hasher to encode explicit IP addresses
		hasher.putUnencodedChars(url.getHost());
		hasher.putByte((byte)0);
	}
	return hasher;
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:10,代码来源:BinaryParser.java

示例9: hashTo

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
public void hashTo(Hasher digest) {
    for (Map.Entry<String, Object> e : annotations.entrySet()) {
        digest.putUnencodedChars(e.getKey());
        // we're going to assume value is a String or Number because the creation code enforces that
        digest.putUnencodedChars(e.getValue().toString());
    }
}
 
开发者ID:yahoo,项目名称:yql-plus,代码行数:8,代码来源:Annotations.java

示例10: hashTo

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
@Override
public void hashTo(Hasher digest) {
    super.hashTo(digest);
    for (String sym : symbols) {
        digest.putUnencodedChars(sym);
    }
}
 
开发者ID:yahoo,项目名称:yql-plus,代码行数:8,代码来源:YQLEnumType.java

示例11: computeChecksum

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
/** Computes a 16-bit checksum of the contents of the specific ByteBuffer and channel name. */
private static int computeChecksum(byte[] buf, int offset, int length, String channel) {
    Hasher hasher = Hashing.murmur3_32().newHasher();
    hasher.putBytes(buf, offset, length);
    hasher.putUnencodedChars(channel);
    return hasher.hash().asInt() & 0xffff;
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:8,代码来源:AstyanaxEventId.java

示例12: hashFlags

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
/** Converts the given flag values into a string hash for use as an output directory fragment. */
private static String hashFlags(SortedMap<Label, String> flagValues) {
  // This hash function is relatively fast and stable between JVM invocations.
  Hasher hasher = Hashing.murmur3_128().newHasher();

  for (Map.Entry<Label, String> flag : flagValues.entrySet()) {
    hasher.putUnencodedChars(flag.getKey().toString());
    hasher.putByte((byte) 0);
    hasher.putUnencodedChars(flag.getValue());
    hasher.putByte((byte) 0);
  }
  return hasher.hash().toString();
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:14,代码来源:ConfigFeatureFlagConfiguration.java

示例13: createTotalAbiKey

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
/**
 * Creates the total ABI key for this rule. If export_deps is true, the total key is computed by
 * hashing the ABI keys of the dependencies together with the ABI key of this rule. If export_deps
 * is false, the standalone ABI key for this rule is used as the total key.
 * @param abiKey the standalone ABI key for this rule.
 * @return total ABI key containing also the ABI keys of the dependencies.
 */
protected Sha1HashCode createTotalAbiKey(Sha1HashCode abiKey) {
  if (getExportedDeps().isEmpty()) {
    return abiKey;
  }

  SortedSet<HasBuildTarget> depsForAbiKey = getDepsForAbiKey();

  // Hash the ABI keys of all dependencies together with ABI key for the current rule.
  Hasher hasher = createHasherWithAbiKeyForDeps(depsForAbiKey);
  hasher.putUnencodedChars(abiKey.getHash());
  return new Sha1HashCode(hasher.hash().toString());
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:20,代码来源:DefaultJavaLibrary.java

示例14: computeAbiKey

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
@VisibleForTesting
static Sha1HashCode computeAbiKey(ImmutableSortedMap<String, HashCode> classNames) {
  Hasher hasher = Hashing.sha1().newHasher();
  for (Map.Entry<String, HashCode> entry : classNames.entrySet()) {
    hasher.putUnencodedChars(entry.getKey());
    hasher.putByte((byte) 0);
    hasher.putUnencodedChars(entry.getValue().toString());
    hasher.putByte((byte) 0);
  }
  return new Sha1HashCode(hasher.hash().toString());
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:12,代码来源:DexProducedFromJavaLibrary.java

示例15: apply

import com.google.common.hash.Hasher; //导入方法依赖的package包/类
@Override
public Sha1HashCode apply(Iterable<HasAndroidResourceDeps> deps) {
  Hasher hasher = Hashing.sha1().newHasher();
  for (HasAndroidResourceDeps dep : deps) {
    hasher.putUnencodedChars(dep.getPathToTextSymbolsFile().toString());
    // Avoid collisions by marking end of path explicitly.
    hasher.putChar('\0');
    hasher.putUnencodedChars(dep.getTextSymbolsAbiKey().getHash());
    hasher.putUnencodedChars(dep.getRDotJavaPackage());
    hasher.putChar('\0');
  }
  return new Sha1HashCode(hasher.hash().toString());
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:14,代码来源:HasAndroidResourceDeps.java


注:本文中的com.google.common.hash.Hasher.putUnencodedChars方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。