Class SetOperations
- java.lang.Object
-
- org.apache.commons.collections4.bloomfilter.SetOperations
-
public final class SetOperations extends java.lang.Object
Implementations of set operations on BitMapExtractors.- Since:
- 4.5.0-M1
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intandCardinality(BitMapExtractor first, BitMapExtractor second)Calculates the cardinality of the logicalANDof the bit maps for the two filters.static intcardinality(BitMapExtractor bitMapExtractor)Calculates the cardinality of a BitMapExtractor.static doublecosineDistance(BitMapExtractor first, BitMapExtractor second)Calculates the Cosine distance between two BitMapExtractor.static doublecosineSimilarity(BitMapExtractor first, BitMapExtractor second)Calculates the Cosine similarity between two BitMapExtractors.static doublecosineSimilarity(BloomFilter<?> first, BloomFilter<?> second)Calculates the Cosine similarity between two Bloom filters.static inthammingDistance(BitMapExtractor first, BitMapExtractor second)Calculates the Hamming distance between two BitMapExtractors.static doublejaccardDistance(BitMapExtractor first, BitMapExtractor second)Calculates the Jaccard distance between two BitMapExtractor.static doublejaccardSimilarity(BitMapExtractor first, BitMapExtractor second)Calculates the Jaccard similarity between two BitMapExtractor.static intorCardinality(BitMapExtractor first, BitMapExtractor second)Calculates the cardinality of the logicalORof the bit maps for the two filters.static intxorCardinality(BitMapExtractor first, BitMapExtractor second)Calculates the cardinality of the logicalXORof the bit maps for the two filters.
-
-
-
Method Detail
-
andCardinality
public static int andCardinality(BitMapExtractor first, BitMapExtractor second)
Calculates the cardinality of the logicalANDof the bit maps for the two filters.- Parameters:
first- the first BitMapExtractor.second- the second BitMapExtractor- Returns:
- the cardinality of the
ANDof the filters.
-
cardinality
public static int cardinality(BitMapExtractor bitMapExtractor)
Calculates the cardinality of a BitMapExtractor. By necessity this method will visit each bit map created by the bitMapExtractor.- Parameters:
bitMapExtractor- the extractor to calculate the cardinality for.- Returns:
- the cardinality of the bit maps produced by the bitMapExtractor.
-
cosineDistance
public static double cosineDistance(BitMapExtractor first, BitMapExtractor second)
Calculates the Cosine distance between two BitMapExtractor.Cosine distance is defined as
1 - Cosine similarity- Parameters:
first- the first BitMapExtractor.second- the second BitMapExtractor.- Returns:
- the jaccard distance.
-
cosineSimilarity
public static double cosineSimilarity(BitMapExtractor first, BitMapExtractor second)
Calculates the Cosine similarity between two BitMapExtractors.Also known as Orchini similarity and the Tucker coefficient of congruence or Ochiai similarity.
If either extractor is empty the result is 0 (zero)
- Parameters:
first- the first BitMapExtractor.second- the second BitMapExtractor.- Returns:
- the Cosine similarity.
-
cosineSimilarity
public static double cosineSimilarity(BloomFilter<?> first, BloomFilter<?> second)
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
public static int hammingDistance(BitMapExtractor first, BitMapExtractor second)
Calculates the Hamming distance between two BitMapExtractors.- Parameters:
first- the first BitMapExtractor.second- the second BitMapExtractor.- Returns:
- the Hamming distance.
-
jaccardDistance
public static double jaccardDistance(BitMapExtractor first, BitMapExtractor second)
Calculates the Jaccard distance between two BitMapExtractor.Jaccard distance is defined as
1 - Jaccard similarity- Parameters:
first- the first BitMapExtractor.second- the second BitMapExtractor.- Returns:
- the Jaccard distance.
-
jaccardSimilarity
public static double jaccardSimilarity(BitMapExtractor first, BitMapExtractor second)
Calculates the Jaccard similarity between two BitMapExtractor.Also known as Jaccard index, Intersection over Union, and Jaccard similarity coefficient
- Parameters:
first- the first BitMapExtractor.second- the second BitMapExtractor.- Returns:
- the Jaccard similarity.
-
orCardinality
public static int orCardinality(BitMapExtractor first, BitMapExtractor second)
Calculates the cardinality of the logicalORof the bit maps for the two filters.- Parameters:
first- the first BitMapExtractor.second- the second BitMapExtractor- Returns:
- the cardinality of the
ORof the filters.
-
xorCardinality
public static int xorCardinality(BitMapExtractor first, BitMapExtractor second)
Calculates the cardinality of the logicalXORof the bit maps for the two filters.- Parameters:
first- the first BitMapExtractor.second- the second BitMapExtractor- Returns:
- the cardinality of the
XORof the filters.
-
-