/** * Removes a specified key from <i>this</i> counting Bloom filter. * <p> * <b>Invariant</b>: nothing happens if the specified key does not belong to <i>this</i> counter Bloom filter. * @param key The key to remove. */ public void delete(Key key) { if(key == null) { throw new NullPointerException("Key may not be null"); } if(!membershipTest(key)) { throw new IllegalArgumentException("Key is not a member"); } int[] h = hash.hash(key); hash.clear(); for(int i = 0; i < nbHash; i++) { // find the bucket int wordNum = h[i] >> 4; // div 16 int bucketShift = (h[i] & 0x0f) << 2; // (mod 16) * 4 long bucketMask = 15L << bucketShift; long bucketValue = (buckets[wordNum] & bucketMask) >>> bucketShift; // only decrement if the count in the bucket is between 0 and BUCKET_MAX_VALUE if(bucketValue >= 1 && bucketValue < BUCKET_MAX_VALUE) { // decrement by 1 buckets[wordNum] = (buckets[wordNum] & ~bucketMask) | ((bucketValue - 1) << bucketShift); } } }
/** * Removes a specified key from <i>this</i> counting Bloom filter. * <p> * <b>Invariant</b>: nothing happens if the specified key does not belong to <i>this</i> counter Bloom filter. * @param key The key to remove. */ public void delete(Key key) { if(key == null) { throw new NullPointerException("Key may not be null"); } if(!membershipTest(key)) { throw new IllegalArgumentException("Key is not a member"); } int[] h = hash.hash(key); hash.clear(); for(int i = 0; i < nbHash; i++) { // find the bucket int wordNum = h[i] >> 4; // div 16 int bucketShift = (h[i] & 0x0f) << 2; // (mod 16) * 4 long bucketMask = 15L << bucketShift; long bucketValue = (buckets[wordNum] & bucketMask) >>> bucketShift; // only decrement if the count in the bucket is between 0 and BUCKET_MAX_VALUE if(bucketValue >= 1 && bucketValue < BUCKET_MAX_VALUE) { // decrement by 1 buckets[wordNum] = (buckets[wordNum] & ~bucketMask) | ((bucketValue - 1) << bucketShift); } } }
/** * Removes a specified key from <i>this</i> counting Bloom filter. * <p> * <b>Invariant</b>: nothing happens if the specified key does not belong to <i>this</i> counter Bloom filter. * @param key The key to remove. */ public void delete(Key key) { if(key == null) { throw new NullPointerException("Key may not be null"); } if(!membershipTest(key)) { throw new IllegalArgumentException("Key is not a member"); } int[] h = hash.hash(key); hash.clear(); for(int i = 0; i < nbHash; i++) { // find the bucket int wordNum = h[i] >> 4; // div 16 int bucketShift = (h[i] & 0x0f) << 2; // (mod 16) * 4 long bucketMask = 15L << bucketShift; long bucketValue = (buckets[wordNum] & bucketMask) >>> bucketShift; // only decrement if the count in the bucket is between 0 and BUCKET_MAX_VALUE if(bucketValue >= 1 && bucketValue < BUCKET_MAX_VALUE) { // decrement by 1 buckets[wordNum] = (buckets[wordNum] & ~bucketMask) | ((bucketValue - 1) << bucketShift); } } }
/** * Removes a specified key from <i>this</i> counting Bloom filter. * <p> * <b>Invariant</b>: nothing happens if the specified key does not belong to <i>this</i> counter Bloom filter. * @param key The key to remove. */ public void delete(Key key) { if(key == null) { throw new NullPointerException("Key may not be null"); } if(!membershipTest(key)) { throw new IllegalArgumentException("Key is not a member"); } int[] h = hash.hash(key); hash.clear(); for(int i = 0; i < nbHash; i++) { // find the bucket int wordNum = h[i] >> 4; // div 16 int bucketShift = (h[i] & 0x0f) << 2; // (mod 16) * 4 long bucketMask = 15L << bucketShift; long bucketValue = (buckets[wordNum] & bucketMask) >>> bucketShift; // only decrement if the count in the bucket is between 0 and BUCKET_MAX_VALUE if(bucketValue >= 1 && bucketValue < BUCKET_MAX_VALUE) { // decrement by 1 buckets[wordNum] = (buckets[wordNum] & ~bucketMask) | ((bucketValue - 1) << bucketShift); } } }
/** * Removes a specified key from <i>this</i> counting Bloom filter. * <p> * <b>Invariant</b>: nothing happens if the specified key does not belong to <i>this</i> counter Bloom filter. * @param key The key to remove. */ public void delete(Key key) { if(key == null) { throw new NullPointerException("Key may not be null"); } if(!membershipTest(key)) { throw new IllegalArgumentException("Key is not a member"); } int[] h = hash.hash(key); hash.clear(); for(int i = 0; i < nbHash; i++) { // find the bucket int wordNum = h[i] >> 4; // div 16 int bucketShift = (h[i] & 0x0f) << 2; // (mod 16) * 4 long bucketMask = 15L << bucketShift; long bucketValue = (buckets[wordNum] & bucketMask) >>> bucketShift; // only decrement if the count in the bucket is between 0 and BUCKET_MAX_VALUE if(bucketValue >= 1 && bucketValue < BUCKET_MAX_VALUE) { // decrement by 1 buckets[wordNum] = (buckets[wordNum] & ~bucketMask) | ((bucketValue - 1) << bucketShift); } } }
/** * Removes a specified key from <i>this</i> counting Bloom filter. * <p> * <b>Invariant</b>: nothing happens if the specified key does not belong to <i>this</i> counter Bloom filter. * @param key The key to remove. */ public void delete(Key key) { if(key == null) { throw new NullPointerException("Key may not be null"); } if(!membershipTest(key)) { throw new IllegalArgumentException("Key is not a member"); } int[] h = hash.hash(key); hash.clear(); for(int i = 0; i < nbHash; i++) { // find the bucket int wordNum = h[i] >> 4; // div 16 int bucketShift = (h[i] & 0x0f) << 2; // (mod 16) * 4 long bucketMask = 15L << bucketShift; long bucketValue = (buckets[wordNum] & bucketMask) >>> bucketShift; // only decrement if the count in the bucket is between 0 and BUCKET_MAX_VALUE if(bucketValue >= 1 && bucketValue < BUCKET_MAX_VALUE) { // decrement by 1 buckets[wordNum] = (buckets[wordNum] & ~bucketMask) | ((bucketValue - 1) << bucketShift); } } }
@Override public boolean contains(StateEvent matchingEvent, Object candidateEvents) { Object[] obj; if (expressionExecutorList != null) { obj = new Object[expressionExecutorList.size()]; int count = 0; for (ExpressionExecutor expressionExecutor : expressionExecutorList) { Object value = expressionExecutor.execute(matchingEvent); obj[count] = value; if (isBloomEnabled) { boolean mightContain = dbHandler.getBloomFilters()[attributeIndexArray[count]].membershipTest(new Key(value.toString().getBytes())); if (!mightContain) { return false; } } count++; } } else { obj = new Object[]{}; } return dbHandler.checkExistence(obj, executionInfo); }
@Override public StreamEvent find(StateEvent matchingEvent, Object candidateEvents, StreamEventCloner candidateEventCloner) { Object[] obj; if (expressionExecutorList != null) { obj = new Object[expressionExecutorList.size()]; int count = 0; for (ExpressionExecutor expressionExecutor : expressionExecutorList) { Object value = expressionExecutor.execute(matchingEvent); obj[count] = value; if (isBloomEnabled) { boolean mightContain = dbHandler.getBloomFilters()[attributeIndexArray[count]].membershipTest(new Key(value.toString().getBytes())); if (!mightContain) { return null; } } count++; } } else { obj = new Object[]{}; } return dbHandler.selectEvent(obj, executionInfo); }
filter.membershipTest(key)); assertTrue("CountingBloomFilter.approximateCount error", filter.approximateCount(key) == 1); filter.membershipTest(key)); filter.membershipTest(key)); assertTrue("CountingBloomFilter.approximateCount error", filter.approximateCount(key) == 0);
filter.membershipTest(key)); assertTrue("CountingBloomFilter.approximateCount error", filter.approximateCount(key) == 1); filter.membershipTest(key)); filter.membershipTest(key)); assertTrue("CountingBloomFilter.approximateCount error", filter.approximateCount(key) == 0);