Class SetOperations
java.lang.Object
org.apache.commons.collections4.bloomfilter.SetOperations
Implementations of set operations on BitMapProducers.
- Since:
- 4.5
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
andCardinality
(BitMapProducer first, BitMapProducer second) Calculates the cardinality of the logicalAND
of the bit maps for the two filters.static int
cardinality
(BitMapProducer producer) Calculates the cardinality of a BitMapProducer.static double
cosineDistance
(BitMapProducer first, BitMapProducer second) Calculates the Cosine distance between two BitMapProducer.static double
cosineSimilarity
(BitMapProducer first, BitMapProducer second) Calculates the Cosine similarity between two BitMapProducers.static double
cosineSimilarity
(BloomFilter first, BloomFilter second) Calculates the Cosine similarity between two Bloom filters.static int
hammingDistance
(BitMapProducer first, BitMapProducer second) Calculates the Hamming distance between two BitMapProducers.static double
jaccardDistance
(BitMapProducer first, BitMapProducer second) Calculates the Jaccard distance between two BitMapProducer.static double
jaccardSimilarity
(BitMapProducer first, BitMapProducer second) Calculates the Jaccard similarity between two BitMapProducer.static int
orCardinality
(BitMapProducer first, BitMapProducer second) Calculates the cardinality of the logicalOR
of the bit maps for the two filters.static int
xorCardinality
(BitMapProducer first, BitMapProducer second) Calculates the cardinality of the logicalXOR
of the bit maps for the two filters.
-
Method Details
-
andCardinality
Calculates the cardinality of the logicalAND
of the bit maps for the two filters.- Parameters:
first
- the first BitMapProducer.second
- the second BitMapProducer- Returns:
- the cardinality of the
AND
of the filters.
-
cardinality
Calculates the cardinality of a BitMapProducer. By necessity this method will visit each bit map created by the producer.- Parameters:
producer
- the Producer to calculate the cardinality for.- Returns:
- the cardinality of the bit maps produced by the producer.
-
cosineDistance
Calculates the Cosine distance between two BitMapProducer.Cosine distance is defined as
1 - Cosine similarity
- Parameters:
first
- the first BitMapProducer.second
- the second BitMapProducer.- Returns:
- the jaccard distance.
-
cosineSimilarity
Calculates the Cosine similarity between two BitMapProducers.Also known as Orchini similarity and the Tucker coefficient of congruence or Ochiai similarity.
If either producer is empty the result is 0 (zero)
- Parameters:
first
- the first BitMapProducer.second
- the second BitMapProducer.- Returns:
- the Cosine similarity.
-
cosineSimilarity
Calculates the Cosine similarity between two Bloom filters.Also known as Orchini similarity and the Tucker coefficient of congruence or Ochiai similarity.
If either filter is empty (no enabled bits) the result is 0 (zero)
This is a version of cosineSimilarity optimized for Bloom filters.
- Parameters:
first
- the first Bloom filter.second
- the second Bloom filter.- Returns:
- the Cosine similarity.
-
hammingDistance
Calculates the Hamming distance between two BitMapProducers.- Parameters:
first
- the first BitMapProducer.second
- the second BitMapProducer.- Returns:
- the Hamming distance.
-
jaccardDistance
Calculates the Jaccard distance between two BitMapProducer.Jaccard distance is defined as
1 - Jaccard similarity
- Parameters:
first
- the first BitMapProducer.second
- the second BitMapProducer.- Returns:
- the Jaccard distance.
-
jaccardSimilarity
Calculates the Jaccard similarity between two BitMapProducer.Also known as Jaccard index, Intersection over Union, and Jaccard similarity coefficient
- Parameters:
first
- the first BitMapProducer.second
- the second BitMapProducer.- Returns:
- the Jaccard similarity.
-
orCardinality
Calculates the cardinality of the logicalOR
of the bit maps for the two filters.- Parameters:
first
- the first BitMapProducer.second
- the second BitMapProducer- Returns:
- the cardinality of the
OR
of the filters.
-
xorCardinality
Calculates the cardinality of the logicalXOR
of the bit maps for the two filters.- Parameters:
first
- the first BitMapProducer.second
- the second BitMapProducer- Returns:
- the cardinality of the
XOR
of the filters.
-