You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2022/08/23 10:32:16 UTC

[commons-collections] branch master updated (fe783da49 -> 6ba199c69)

This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git


    from fe783da49 Bump actions/cache from 3.0.7 to 3.0.8
     new 5a31023ea COLLECTIONS-831: Add BloomFilter clear() method
     new bf836c8df Test code cleanup
     new 6ba199c69 Removed obsolete file

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../bloomfilter/ArrayCountingBloomFilter.java      |  6 ++
 .../collections4/bloomfilter/BloomFilter.java      |  5 ++
 .../bloomfilter/SimpleBloomFilter.java             |  6 ++
 .../bloomfilter/SparseBloomFilter.java             |  5 ++
 .../bloomfilter/AbstractBitCountProducerTest.java  |  2 +-
 .../bloomfilter/AbstractBloomFilterTest.java       | 15 +++--
 .../bloomfilter/DefaultBloomFilterTest.java        |  5 ++
 .../collections4/bloomfilter/checkstyle.xml        | 67 ----------------------
 8 files changed, 38 insertions(+), 73 deletions(-)
 delete mode 100644 src/test/java/org/apache/commons/collections4/bloomfilter/checkstyle.xml


[commons-collections] 01/03: COLLECTIONS-831: Add BloomFilter clear() method

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git

commit 5a31023eae4bf2bd621fa8613699f54842109402
Author: Claude Warren, Jr <cl...@aiven.io>
AuthorDate: Tue Aug 23 11:27:24 2022 +0100

    COLLECTIONS-831: Add BloomFilter clear() method
---
 .../collections4/bloomfilter/ArrayCountingBloomFilter.java       | 6 ++++++
 .../org/apache/commons/collections4/bloomfilter/BloomFilter.java | 5 +++++
 .../commons/collections4/bloomfilter/SimpleBloomFilter.java      | 6 ++++++
 .../commons/collections4/bloomfilter/SparseBloomFilter.java      | 5 +++++
 .../collections4/bloomfilter/AbstractBloomFilterTest.java        | 9 +++++++++
 .../commons/collections4/bloomfilter/DefaultBloomFilterTest.java | 5 +++++
 6 files changed, 36 insertions(+)

diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/ArrayCountingBloomFilter.java b/src/main/java/org/apache/commons/collections4/bloomfilter/ArrayCountingBloomFilter.java
index 4202f6d86..ba13e6645 100644
--- a/src/main/java/org/apache/commons/collections4/bloomfilter/ArrayCountingBloomFilter.java
+++ b/src/main/java/org/apache/commons/collections4/bloomfilter/ArrayCountingBloomFilter.java
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.collections4.bloomfilter;
 
+import java.util.Arrays;
 import java.util.Objects;
 import java.util.function.IntPredicate;
 import java.util.function.LongPredicate;
@@ -104,6 +105,11 @@ public final class ArrayCountingBloomFilter implements CountingBloomFilter {
         this.counts = source.counts.clone();
     }
 
+    @Override
+    public void clear() {
+        Arrays.fill(counts, 0);
+    }
+
     @Override
     public ArrayCountingBloomFilter copy() {
         return new ArrayCountingBloomFilter(this);
diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/BloomFilter.java b/src/main/java/org/apache/commons/collections4/bloomfilter/BloomFilter.java
index 58ed6bcb5..9471e5dcd 100644
--- a/src/main/java/org/apache/commons/collections4/bloomfilter/BloomFilter.java
+++ b/src/main/java/org/apache/commons/collections4/bloomfilter/BloomFilter.java
@@ -60,6 +60,11 @@ public interface BloomFilter extends IndexProducer, BitMapProducer {
      */
     Shape getShape();
 
+    /**
+     * Resets the filter to its initial, unpopulated state.
+     */
+    void clear();
+
     /**
      * Returns {@code true} if this filter contains the specified filter.
      *
diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/SimpleBloomFilter.java b/src/main/java/org/apache/commons/collections4/bloomfilter/SimpleBloomFilter.java
index c351f40c1..eb777f726 100644
--- a/src/main/java/org/apache/commons/collections4/bloomfilter/SimpleBloomFilter.java
+++ b/src/main/java/org/apache/commons/collections4/bloomfilter/SimpleBloomFilter.java
@@ -117,6 +117,12 @@ public final class SimpleBloomFilter implements BloomFilter {
         this.cardinality = source.cardinality;
     }
 
+    @Override
+    public void clear() {
+        Arrays.fill(bitMap, 0L);
+        cardinality = 0;
+    }
+
     @Override
     public long[] asBitMapArray() {
         return Arrays.copyOf(bitMap, bitMap.length);
diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/SparseBloomFilter.java b/src/main/java/org/apache/commons/collections4/bloomfilter/SparseBloomFilter.java
index 9cfa034eb..f5670ce1c 100644
--- a/src/main/java/org/apache/commons/collections4/bloomfilter/SparseBloomFilter.java
+++ b/src/main/java/org/apache/commons/collections4/bloomfilter/SparseBloomFilter.java
@@ -174,6 +174,11 @@ public final class SparseBloomFilter implements BloomFilter {
         return true;
     }
 
+    @Override
+    public void clear() {
+        indices.clear();
+    }
+
     @Override
     public Shape getShape() {
         return shape;
diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractBloomFilterTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractBloomFilterTest.java
index d8ceea079..a61885491 100644
--- a/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractBloomFilterTest.java
+++ b/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractBloomFilterTest.java
@@ -18,6 +18,7 @@ package org.apache.commons.collections4.bloomfilter;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
@@ -178,6 +179,14 @@ public abstract class AbstractBloomFilterTest<T extends BloomFilter> {
         assertTrue(bf4.contains(bf1));
     }
 
+    @Test
+    public void testClear() {
+        BloomFilter bf1 = createFilter(getTestShape(), from1);
+        assertNotEquals(0, bf1.cardinality());
+        bf1.clear();
+        assertEquals(0, bf1.cardinality());
+    }
+
     /**
      * Tests that the andCardinality calculations are correct.
      *
diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/DefaultBloomFilterTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/DefaultBloomFilterTest.java
index ff258ae80..ea7bd25f6 100644
--- a/src/test/java/org/apache/commons/collections4/bloomfilter/DefaultBloomFilterTest.java
+++ b/src/test/java/org/apache/commons/collections4/bloomfilter/DefaultBloomFilterTest.java
@@ -112,6 +112,11 @@ public class DefaultBloomFilterTest extends AbstractBloomFilterTest<DefaultBloom
             }
         }
 
+        @Override
+        public void clear() {
+            indices.clear();
+        }
+
         @Override
         public boolean forEachIndex(IntPredicate consumer) {
             for (Integer i : indices) {


[commons-collections] 03/03: Removed obsolete file

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git

commit 6ba199c691d1789c60c449c35cb07ed9a89f63e6
Author: aherbert <a....@sussex.ac.uk>
AuthorDate: Tue Aug 23 11:31:25 2022 +0100

    Removed obsolete file
---
 .../collections4/bloomfilter/checkstyle.xml        | 67 ----------------------
 1 file changed, 67 deletions(-)

diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/checkstyle.xml b/src/test/java/org/apache/commons/collections4/bloomfilter/checkstyle.xml
deleted file mode 100644
index 0b79c22dc..000000000
--- a/src/test/java/org/apache/commons/collections4/bloomfilter/checkstyle.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-
-<!DOCTYPE module PUBLIC
-      "-//Checkstyle//DTD Checkstyle Configuration 1.2//EN"
-      "https://checkstyle.org/dtds/configuration_1_2.dtd">
-
-<!-- Apache Commons Collections customization of default Checkstyle behavior -->
-<module name="Checker">
-  <property name="localeLanguage" value="en"/>
-  <module name="JavadocPackage"/>
-  <module name="NewlineAtEndOfFile">
-    <property name="lineSeparator" value="lf" />
-  </module>
-  <module name="FileTabCharacter">
-    <property name="fileExtensions" value="java,xml"/>
-  </module>
-  <module name="RegexpSingleline">
-    <!-- \s matches whitespace character, $ matches end of line. -->
-    <property name="format" value="\s+$"/>
-    <property name="message" value="Line has trailing spaces."/>
-  </module>
-  <module name="SuppressionFilter">
-    <property name="file" value="${checkstyle.suppressions.file}"/>
-  </module>
-  <module name="Header">
-    <property name="headerFile" value="${checkstyle.header.file}"/>
-  </module>
-  <module name="TreeWalker">
-    <module name="AvoidStarImport"/>
-    <module name="IllegalImport"/>
-    <module name="RedundantImport"/>
-    <module name="UnusedImports"/>
-    <module name="NeedBraces"/>
-    <module name="JavadocMethod">
-      <property name="accessModifiers" value="protected" />
-    </module>
-    <module name="ModifierOrder"/>
-    <module name="RedundantModifier"/>
-    <module name="UpperEll" />
-    <module name="LeftCurly"/>
-    <module name="NeedBraces"/>
-    <module name="RightCurly"/>
-    <module name="GenericWhitespace"/>
-    <module name="WhitespaceAfter"/>
-    <module name="NoWhitespaceBefore"/>
-    <module name="Indentation">
-      <!-- Indentation style recommended by Oracle -->
-      <property name="caseIndent" value="0"/>
-    </module>
- </module>
-</module>


[commons-collections] 02/03: Test code cleanup

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git

commit bf836c8df0648eda397e0df8114e35b2e7bc8938
Author: aherbert <a....@sussex.ac.uk>
AuthorDate: Tue Aug 23 11:30:17 2022 +0100

    Test code cleanup
    
    Use static
    
    Remove incorrect javadoc tags
    
    Add javadoc to return tag
---
 .../collections4/bloomfilter/AbstractBitCountProducerTest.java      | 2 +-
 .../commons/collections4/bloomfilter/AbstractBloomFilterTest.java   | 6 +-----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractBitCountProducerTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractBitCountProducerTest.java
index 5894b7c37..e51f90105 100644
--- a/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractBitCountProducerTest.java
+++ b/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractBitCountProducerTest.java
@@ -63,7 +63,7 @@ public abstract class AbstractBitCountProducerTest extends AbstractIndexProducer
     /**
      * Determines if empty tests should be run.  Some producers do not implement an empty
      * version.  Tests for those classes should return false.
-     * @return
+     * @return true if the empty tests are supported
      */
     protected boolean supportsEmpty() {
         return true;
diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractBloomFilterTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractBloomFilterTest.java
index a61885491..da2aa897c 100644
--- a/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractBloomFilterTest.java
+++ b/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractBloomFilterTest.java
@@ -189,8 +189,6 @@ public abstract class AbstractBloomFilterTest<T extends BloomFilter> {
 
     /**
      * Tests that the andCardinality calculations are correct.
-     *
-     * @param filterFactory the factory function to create the filter
      */
     @Test
     public final void testEstimateIntersection() {
@@ -209,8 +207,6 @@ public abstract class AbstractBloomFilterTest<T extends BloomFilter> {
 
     /**
      * Tests that the andCardinality calculations are correct.
-     *
-     * @param filterFactory the factory function to create the filter
      */
     @Test
     public final void testEstimateUnion() {
@@ -331,7 +327,7 @@ public abstract class AbstractBloomFilterTest<T extends BloomFilter> {
         assertThrows(IllegalArgumentException.class, () -> bf1.merge(bf6));
     }
 
-    private void assertIndexProducerConstructor(Shape shape, int[] values, int[] expected) {
+    private static void assertIndexProducerConstructor(Shape shape, int[] values, int[] expected) {
         IndexProducer indices = IndexProducer.fromIndexArray(values);
         SparseBloomFilter filter = new SparseBloomFilter(shape, indices);
         List<Integer> lst = new ArrayList<>();