private int add(byte[] source, int sourcePos, int sourceLen, int sourceMask, long[] bloom, int[] bloomSeeds, long bloomMask) { int i = bloomSeeds.length; int seen = 1; while (--i>=0) { seen = updateBloom(bloom, bloomMask, seen, MurmurHash.hash32(source, sourcePos, sourceLen, sourceMask, bloomSeeds[i])); } memberCount -= (seen-1); return seen; }
/** * Returns 0 if this was a new addition, and 1 if this may have been and old value * @return */ private int add(CharSequence value, long[] bloom, int[] bloomSeeds, long bloomMask) { int i = bloomSeeds.length; int seen = 1; while (--i>=0) { seen = updateBloom(bloom, bloomMask, seen, MurmurHash.hash32(value, bloomSeeds[i])); } memberCount -= (seen-1); return seen; }
@Override protected int updateBloom(long[] bloom, long bloomMask, int seen, int hash32) { // TODO Auto-generated method stub seen = super.updateBloom(bloom, bloomMask, seen, hash32); if (memberCount()>half) { //also record here since we are in the second half int secondSeen = super.updateBloom(bloom2, bloomMask, 1, hash32); if (memberCount()>=n) { //switch to the second now that we have reached the end. memberCount = n/2; System.arraycopy(bloom2, 0, bloom, 0, bloom2.length); Arrays.fill(bloom2, 0); } } return seen; }
/** * Returns 0 if this was a new addition, and 1 if this may have been and old value */ public int add(int[] slab, int slabPos, int slabMask, int slabLength, byte[] blob, int blobPos, int blobMask, int blobLength) { int i = bloomSeeds.length; int seen = 1; while (--i>=0) { int seed = bloomSeeds[i]; int slabHash = MurmurHash.hash32(slab, slabPos, slabLength, slabMask, seed); int blobHash = MurmurHash.hash32(blob, blobPos, blobLength, blobMask, seed); seen = updateBloom(bloom, bloomMask, seen, MurmurHash.hash32(slabHash, blobHash, seed)); } return seen; }