本文整理汇总了Java中com.google.common.hash.Hasher.putDouble方法的典型用法代码示例。如果您正苦于以下问题:Java Hasher.putDouble方法的具体用法?Java Hasher.putDouble怎么用?Java Hasher.putDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.hash.Hasher
的用法示例。
在下文中一共展示了Hasher.putDouble方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
示例3: hash
import com.google.common.hash.Hasher; //导入方法依赖的package包/类
@Override
public void hash(final Hasher hasher) {
hasher.putInt(MetricType.SPREAD.ordinal());
hasher.putLong(timestamp);
hasher.putLong(count);
hasher.putDouble(sum);
hasher.putDouble(sum2);
hasher.putDouble(min);
hasher.putDouble(max);
}
示例4: putDouble
import com.google.common.hash.Hasher; //导入方法依赖的package包/类
@Override
public Hasher putDouble(double d) {
for (Hasher hasher : hashers) {
hasher.putDouble(d);
}
return this;
}
示例5: hash
import com.google.common.hash.Hasher; //导入方法依赖的package包/类
/**
* Utility method to compute an hash string from a vararg list of objects. The returned string
* is 16 characters long, starts with {@code A-Za-z} and contains only characters
* {@code A-Za-z0-9}.
*
* @param objects
* the objects to compute the hash from
* @return the computed hash string
*/
public static String hash(final Object... objects) {
final Hasher hasher = Hashing.md5().newHasher();
for (final Object object : objects) {
if (object instanceof CharSequence) {
hasher.putString((CharSequence) object, Charsets.UTF_16LE);
} else if (object instanceof byte[]) {
hasher.putBytes((byte[]) object);
} else if (object instanceof Character) {
hasher.putChar((Character) object);
} else if (object instanceof Boolean) {
hasher.putBoolean((Boolean) object);
} else if (object instanceof Integer) {
hasher.putInt(((Integer) object).intValue());
} else if (object instanceof Long) {
hasher.putLong(((Long) object).longValue());
} else if (object instanceof Double) {
hasher.putDouble(((Double) object).doubleValue());
} else if (object instanceof Float) {
hasher.putFloat(((Float) object).floatValue());
} else if (object instanceof Byte) {
hasher.putByte(((Byte) object).byteValue());
} else {
hasher.putString(object.toString(), Charsets.UTF_16LE);
}
}
final byte[] bytes = hasher.hash().asBytes();
final StringBuilder builder = new StringBuilder(16);
int max = 52;
for (int i = 0; i < bytes.length; ++i) {
final int n = (bytes[i] & 0x7F) % max;
if (n < 26) {
builder.append((char) (65 + n));
} else if (n < 52) {
builder.append((char) (71 + n));
} else {
builder.append((char) (n - 4));
}
max = 62;
}
return builder.toString();
}
示例6: hash
import com.google.common.hash.Hasher; //导入方法依赖的package包/类
@Override
public void hash(final Hasher hasher) {
hasher.putInt(MetricType.POINT.ordinal());
hasher.putDouble(value);
}