/** * Hash a long and long seed. * * @param datum the input long * @param seed A long valued seed. * @return The 128-bit hash as a long[2]. */ public static long[] hashToLongs(final long datum, final long seed) { final long[] data = { datum }; return hash(data, seed); }
/** * Hash a int[] and long seed. * * @param data the input int array. * @param seed A long valued seed. * @return The 128-bit hash as a long[2]. */ public static long[] hashToLongs(final int[] data, final long seed) { if ((data == null) || (data.length == 0)) { return null; } return hash(data, seed); }
/** * Hash a char[] and long seed. * * @param data the input char array. * @param seed A long valued seed. * @return The 128-bit hash as a long[2]. */ public static long[] hashToLongs(final char[] data, final long seed) { if ((data == null) || (data.length == 0)) { return null; } return hash(data, seed); }
/** * Hash a byte[] and long seed. * * @param data the input byte array. * @param seed A long valued seed. * @return The 128-bit hash as a long[2]. */ public static long[] hashToLongs(final byte[] data, final long seed) { if ((data == null) || (data.length == 0)) { return null; } return hash(data, seed); }
/** * Hash a long[] and long seed. * * @param data the input long array. * @param seed A long valued seed. * @return The 128-bit hash as a long[2]. */ public static long[] hashToLongs(final long[] data, final long seed) { if ((data == null) || (data.length == 0)) { return null; } return hash(data, seed); }
/** * Hash a double and long seed. * * @param datum the input double. * @param seed A long valued seed. * @return The 128-bit hash as a long[2]. */ public static long[] hashToLongs(final double datum, final long seed) { final double d = (datum == 0.0) ? 0.0 : datum; //canonicalize -0.0, 0.0 final long[] data = { Double.doubleToLongBits(d) };//canonicalize all NaN forms return hash(data, seed); }
/** * Returns the HLL array index and value as a 16-bit coupon given the identifier to be hashed * and k. * @param identifier the given identifier * @return the HLL array index and value */ static final int coupon16(final byte[] identifier) { final long[] hash = MurmurHash3.hash(identifier, SEED); final int hllIdx = (int) (((hash[0] >>> 1) % 1024) & TEN_BIT_MASK); //hash[0] for 10-bit address final int lz = Long.numberOfLeadingZeros(hash[1]); final int value = (lz > 62 ? 62 : lz) + 1; return (value << 10) | hllIdx; }
/** * Hash a String and long seed. * * @param datum the input String. * @param seed A long valued seed. * @return The 128-bit hash as a long[2]. */ public static long[] hashToLongs(final String datum, final long seed) { if ((datum == null) || datum.isEmpty()) { return null; } final byte[] data = datum.getBytes(UTF_8); return hash(data, seed); }
/** * Create this sketch with the given byte array. * If the byte array is null or empty no create attempt is made and the method returns null. * * @param data The given byte array. * @return a SingleItemSketch or null */ public static SingleItemSketch create(final byte[] data) { if ((data == null) || (data.length == 0)) { return null; } return new SingleItemSketch(hash(data, DEFAULT_UPDATE_SEED)[0] >>> 1); }
/** * Create this sketch with the given integer array. * If the integer array is null or empty no create attempt is made and the method returns null. * * @param data The given int array. * @return a SingleItemSketch or null */ public static SingleItemSketch create(final int[] data) { if ((data == null) || (data.length == 0)) { return null; } return new SingleItemSketch(hash(data, DEFAULT_UPDATE_SEED)[0] >>> 1); }
private static long murmur(long key) { long[] keyArr = { key }; return MurmurHash3.hash(keyArr, 0)[0]; } }
/** * Create this sketch with a long. * * @param datum The given long datum. * @return a SingleItemSketch */ public static SingleItemSketch create(final long datum) { final long[] data = { datum }; return new SingleItemSketch(hash(data, DEFAULT_UPDATE_SEED)[0] >>> 1); }
/** * Create this sketch with the given byte array and a seed. * If the byte array is null or empty no create attempt is made and the method returns null. * * @param data The given byte array. * @param seed used to hash the given value. * @return a SingleItemSketch or null */ public static SingleItemSketch create(final byte[] data, final long seed) { if ((data == null) || (data.length == 0)) { return null; } return new SingleItemSketch(hash(data, seed)[0] >>> 1, seed); }
/** * Updates this sketch with a long[] key and double values. * The values will be stored or added to the ones associated with the key * * @param key The given long[] key * @param values The given values */ public void update(final long[] key, final double[] values) { if (key == null || key.length == 0) { return; } insertOrIgnore(MurmurHash3.hash(key, seed_)[0] >>> 1, values); }
/** * Updates this sketch with a byte[] key and U value. * The value is passed to update() method of the Summary object associated with the key * * @param key The given byte[] key * @param value The given U value */ public void update(final byte[] key, final U value) { if ((key == null) || (key.length == 0)) { return; } insertOrIgnore(MurmurHash3.hash(key, DEFAULT_UPDATE_SEED)[0] >>> 1, value); }
/** * Present the given long as a potential unique item. * * @param datum The given long datum. */ public void update(final long datum) { final long[] data = { datum }; final long[] arr = hash(data, seed); hashUpdate(arr[0], arr[1]); }
/** * Present the given byte array as a potential unique item. * If the byte array is null or empty no update attempt is made and the method returns. * * @param data The given byte array. */ public void update(final byte[] data) { if ((data == null) || (data.length == 0)) { return; } final long[] arr = hash(data, seed); hashUpdate(arr[0], arr[1]); }
/** * Updates this sketch with a byte[] key and double values. * The values will be stored or added to the ones associated with the key * * @param key The given byte[] key * @param values The given values */ public void update(final byte[] key, final double[] values) { if (key == null || key.length == 0) { return; } insertOrIgnore(MurmurHash3.hash(key, seed_)[0] >>> 1, values); }
/** * Updates this sketch with a long[] key and U value. * The value is passed to update() method of the Summary object associated with the key * * @param key The given long[] key * @param value The given U value */ public void update(final long[] key, final U value) { if ((key == null) || (key.length == 0)) { return; } insertOrIgnore(MurmurHash3.hash(key, DEFAULT_UPDATE_SEED)[0] >>> 1, value); }
/** * Present the given integer array as a potential unique item. * If the integer array is null or empty no update attempt is made and the method returns. * * @param data The given int array. */ public void update(final int[] data) { if ((data == null) || (data.length == 0)) { return; } final long[] arr = hash(data, seed); hashUpdate(arr[0], arr[1]); }