Ejemplo n.º 1
0
 /// <summary>
 /// Determine the similarity between this estimator and the provided estimator data,
 /// </summary>
 /// <param name="estimatorData">The estimator data to compare against.</param>
 /// <returns></returns>
 public double?Similarity(IBitMinwiseHashEstimatorData estimatorData)
 {
     if (estimatorData == null)
     {
         return(0.0D);
     }
     return(Extract()
            .Similarity(estimatorData));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a bit array for the given estimator,
        /// </summary>
        /// <param name="estimator"></param>
        /// <returns></returns>
        private static FastBitArray CreateBitArray(IBitMinwiseHashEstimatorData estimator)
        {
            if (estimator == null)
            {
                throw new ArgumentNullException(nameof(estimator));
            }
            var estimatorBitArray = estimator.Values == null
                ? new FastBitArray((int)estimator.GetBitSize())
                : new FastBitArray(estimator.Values)
            {
                Length = (int)estimator.GetBitSize()
            };

            if (estimator.Values == null)
            {
                estimatorBitArray.SetAll(true);
            }
            return(estimatorBitArray);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Determine the similarity between two estimators.
 /// </summary>
 /// <param name="estimator"></param>
 /// <param name="otherEstimatorData"></param>
 /// <returns>Similarity (percentage similar, zero is completely different, one is completely the same)</returns>
 /// <remarks>Zero is no similarity, one is completely similar.</remarks>
 internal static double?Similarity(
     this IBitMinwiseHashEstimatorData estimator,
     IBitMinwiseHashEstimatorData otherEstimatorData)
 {
     if (estimator == null ||
         otherEstimatorData == null ||
         estimator.BitSize != otherEstimatorData.BitSize ||
         estimator.HashCount != otherEstimatorData.HashCount)
     {
         return(null);
     }
     if (estimator.Values == null && otherEstimatorData.Values == null)
     {
         return(1.0D);
     }
     return(ComputeSimilarityFromSignatures(
                CreateBitArray(estimator),
                CreateBitArray(otherEstimatorData),
                estimator.HashCount,
                estimator.BitSize));
 }
Ejemplo n.º 4
0
 internal static long GetBitSize(this IBitMinwiseHashEstimatorData data)
 {
     return(data == null ? 0L : data.GetBlockSize() *data.BitSize);
 }
Ejemplo n.º 5
0
 internal static long GetBlockSize(this IBitMinwiseHashEstimatorData data)
 {
     return(data == null ? 0L : data.HashCount *data.Capacity);
 }