/// <summary> /// Sole constructor. </summary> public FacetResult(string dim, string[] path, float value, LabelAndValue[] labelValues, int childCount) { this.Dim = dim; this.Path = path; this.Value = value; this.LabelValues = labelValues; this.ChildCount = childCount; }
public override bool Equals(object other) { if ((other is LabelAndValue) == false) { return false; } LabelAndValue _other = (LabelAndValue)other; return Label.Equals(_other.Label, StringComparison.Ordinal) && Value.Equals(_other.Value); }
public override bool Equals(object _other) { if ((_other is LabelAndValue) == false) { return(false); } LabelAndValue other = (LabelAndValue)_other; return(label.Equals(other.label) && value.Equals(other.value)); }
public override bool Equals(object other) { if ((other is LabelAndValue) == false) { return(false); } LabelAndValue _other = (LabelAndValue)other; return(Label.Equals(_other.Label) && Value.Equals(_other.Value)); }
/// <summary> /// Note: if you use a counting <see cref="Facets"/> implementation, you can amortize the /// sampled counts by calling this method. Uses the <see cref="FacetsConfig"/> and /// the <see cref="IndexSearcher"/> to determine the upper bound for each facet value. /// </summary> public virtual FacetResult AmortizeFacetCounts(FacetResult res, FacetsConfig config, IndexSearcher searcher) { if (res == null || totalHits <= sampleSize) { return(res); } LabelAndValue[] fixedLabelValues = new LabelAndValue[res.LabelValues.Length]; IndexReader reader = searcher.IndexReader; DimConfig dimConfig = config.GetDimConfig(res.Dim); // +2 to prepend dimension, append child label string[] childPath = new string[res.Path.Length + 2]; childPath[0] = res.Dim; Array.Copy(res.Path, 0, childPath, 1, res.Path.Length); // reuse for (int i = 0; i < res.LabelValues.Length; i++) { childPath[res.Path.Length + 1] = res.LabelValues[i].Label; string fullPath = FacetsConfig.PathToString(childPath, childPath.Length); int max = reader.DocFreq(new Term(dimConfig.IndexFieldName, fullPath)); int correctedCount = (int)((double)res.LabelValues[i].Value / samplingRate); correctedCount = Math.Min(max, correctedCount); fixedLabelValues[i] = new LabelAndValue(res.LabelValues[i].Label, correctedCount); } // cap the total count on the total number of non-deleted documents in the reader int correctedTotalCount = (int)res.Value; if (correctedTotalCount > 0) { correctedTotalCount = Math.Min(reader.NumDocs, (int)((double)res.Value / samplingRate)); } return(new FacetResult(res.Dim, res.Path, correctedTotalCount, fixedLabelValues, res.ChildCount)); }
public override FacetResult GetTopChildren(int topN, string dim, params string[] path) { if (dim.Equals(Field) == false) { throw new System.ArgumentException("invalid dim \"" + dim + "\"; should be \"" + Field + "\""); } if (path.Length != 0) { throw new System.ArgumentException("path.length should be 0"); } LabelAndValue[] labelValues = new LabelAndValue[Counts.Length]; for (int i = 0; i < Counts.Length; i++) { labelValues[i] = new LabelAndValue(Ranges[i].Label, Counts[i]); } return new FacetResult(dim, path, TotCount, labelValues, labelValues.Length); }
/// <summary> /// Note: if you use a counting <seealso cref="Facets"/> implementation, you can amortize the /// sampled counts by calling this method. Uses the <seealso cref="FacetsConfig"/> and /// the <seealso cref="IndexSearcher"/> to determine the upper bound for each facet value. /// </summary> public virtual FacetResult AmortizeFacetCounts(FacetResult res, FacetsConfig config, IndexSearcher searcher) { if (res == null || totalHits <= sampleSize) { return res; } LabelAndValue[] fixedLabelValues = new LabelAndValue[res.LabelValues.Length]; IndexReader reader = searcher.IndexReader; DimConfig dimConfig = config.GetDimConfig(res.Dim); // +2 to prepend dimension, append child label string[] childPath = new string[res.Path.Length + 2]; childPath[0] = res.Dim; Array.Copy(res.Path, 0, childPath, 1, res.Path.Length); // reuse for (int i = 0; i < res.LabelValues.Length; i++) { childPath[res.Path.Length + 1] = res.LabelValues[i].label; string fullPath = FacetsConfig.PathToString(childPath, childPath.Length); int max = reader.DocFreq(new Term(dimConfig.IndexFieldName, fullPath)); int correctedCount = (int)((double)res.LabelValues[i].value / samplingRate); correctedCount = Math.Min(max, correctedCount); fixedLabelValues[i] = new LabelAndValue(res.LabelValues[i].label, correctedCount); } // cap the total count on the total number of non-deleted documents in the reader int correctedTotalCount = (int)res.Value; if (correctedTotalCount > 0) { correctedTotalCount = Math.Min(reader.NumDocs, (int)((double)res.Value / samplingRate)); } return new FacetResult(res.Dim, res.Path, correctedTotalCount, fixedLabelValues, res.ChildCount); }
/// <summary> /// Private constructor for shared parameters to be called by public constructors. /// </summary> private FacetResult(string dim, string[] path, LabelAndValue[] labelValues, int childCount) { this.Dim = dim; this.Path = path; this.LabelValues = labelValues; this.ChildCount = childCount; }
/// <summary> /// Constructor for <see cref="int"/> <paramref name="value"/>. Makes the <see cref="ToString()"/> method /// print the <paramref name="value"/> as an <see cref="int"/> with no decimal. /// </summary> public FacetResult(string dim, string[] path, int value, LabelAndValue[] labelValues, int childCount) : this(dim, path, labelValues, childCount) { this.Value = value; this.TypeOfValue = typeof(int); }