public virtual Explanation Explain(AtomicReader reader, int doc, Explanation innerExplanation) { if (reader is BoboSegmentReader) { BoboSegmentReader boboReader = (BoboSegmentReader)reader; object dataObj = boboReader.GetFacetData(m_timeFacetName); if (dataObj is FacetDataCache) { FacetDataCache facetDataCache = (FacetDataCache)(boboReader.GetFacetData(m_timeFacetName)); BigSegmentedArray orderArray = facetDataCache.OrderArray; TermInt64List termList = (TermInt64List)facetDataCache.ValArray; Explanation finalExpl = new Explanation(); finalExpl.AddDetail(innerExplanation); float rawScore = innerExplanation.Value; long timeVal = termList.GetPrimitiveValue(orderArray.Get(doc)); float timeScore = ComputeTimeFactor(timeVal); float finalScore = CombineScores(timeScore, rawScore); finalExpl.Value = finalScore; finalExpl.Description = "final score = (time score: " + timeScore + ") * (raw score: " + rawScore + "), timeVal: " + timeVal; return(finalExpl); } else { throw new InvalidOperationException("underlying facet data must be of type FacetDataCache<long>"); } } else { throw new ArgumentException("reader not instance of " + typeof(BoboSegmentReader)); } }
public override IFacetCountCollector GetFacetCountCollector(BoboSegmentReader reader, int docBase) { FacetDataCache dataCache = (FacetDataCache)reader.GetFacetData(m_dataHandlerName); IFacetCountCollector baseCollector = m_baseCollectorSrc.GetFacetCountCollector(reader, docBase); return(new HistogramCollector(m_name, baseCollector, dataCache, m_ospec, m_start, m_end, m_unit)); }
public override IFacetCountCollector GetFacetCountCollector(BoboSegmentReader reader, int docBase) { int facetsPerKey = m_parent.GetFacetsPerKey(m_browseSelection); if (m_ospec.Properties != null && m_ospec.Properties.ContainsKey(MAX_FACETS_PER_KEY_PROP_NAME)) { facetsPerKey = int.Parse(m_ospec.Properties.Get(MAX_FACETS_PER_KEY_PROP_NAME)); } MultiValueFacetDataCache dataCache = (MultiValueFacetDataCache)reader.GetFacetData(m_parent.Name); return(new AttributesFacetCountCollector(m_parent, m_parent.Name, dataCache, docBase, m_browseSelection, m_ospec, facetsPerKey, m_parent.GetSeparator(m_browseSelection))); }
// NOTE: The Weight.Scorer method lost the scoreDocsInOrder and topScorer parameters between // Lucene 4.3.0 and 4.8.0. They are not used by BoboBrowse anyway, so the code here diverges // from the original Java source to remove these two parameters. // public virtual Scorer CreateScorer(Scorer innerScorer, AtomicReader reader, bool scoreDocsInOrder, bool topScorer) public virtual Scorer CreateScorer(Scorer innerScorer, AtomicReader reader) { if (reader is BoboSegmentReader) { BoboSegmentReader boboReader = (BoboSegmentReader)reader; object dataObj = boboReader.GetFacetData(m_timeFacetName); if (dataObj is FacetDataCache) { FacetDataCache facetDataCache = (FacetDataCache)(boboReader.GetFacetData(m_timeFacetName)); BigSegmentedArray orderArray = facetDataCache.OrderArray; TermInt64List termList = (TermInt64List)facetDataCache.ValArray; return(new RecencyBoostScorer(this, innerScorer, orderArray, termList)); } else { throw new InvalidOperationException("underlying facet data must be of type FacetDataCache<long>"); } } else { throw new ArgumentException("reader not instance of " + typeof(BoboSegmentReader)); } }
public virtual void Load(string latFieldName, string lonFieldName, BoboSegmentReader reader) { if (reader == null) { throw new ArgumentNullException("reader object is null"); } FacetDataCache latCache = (FacetDataCache)reader.GetFacetData(latFieldName); FacetDataCache lonCache = (FacetDataCache)reader.GetFacetData(lonFieldName); int maxDoc = reader.MaxDoc; BigSingleArray xVals = this.m_xValArray; BigSingleArray yVals = this.m_yValArray; BigSingleArray zVals = this.m_zValArray; if (xVals == null) { xVals = NewInstance(maxDoc); } else { xVals.EnsureCapacity(maxDoc); } if (yVals == null) { yVals = NewInstance(maxDoc); } else { yVals.EnsureCapacity(maxDoc); } if (zVals == null) { zVals = NewInstance(maxDoc); } else { zVals.EnsureCapacity(maxDoc); } this.m_xValArray = xVals; this.m_yValArray = yVals; this.m_zValArray = zVals; BigSegmentedArray latOrderArray = latCache.OrderArray; ITermValueList latValList = latCache.ValArray; BigSegmentedArray lonOrderArray = lonCache.OrderArray; ITermValueList lonValList = lonCache.ValArray; for (int i = 0; i < maxDoc; ++i) { string docLatString = latValList.Get(latOrderArray.Get(i)).Trim(); string docLonString = lonValList.Get(lonOrderArray.Get(i)).Trim(); float docLat = 0; if (docLatString.Length > 0) { docLat = float.Parse(docLatString); } float docLon = 0; if (docLonString.Length > 0) { docLon = float.Parse(docLonString); } float[] coords = GeoMatchUtil.GeoMatchCoordsFromDegrees(docLat, docLon); m_xValArray.Add(i, coords[0]); m_yValArray.Add(i, coords[1]); m_zValArray.Add(i, coords[2]); } }
public virtual T GetFacetData <T>(BoboSegmentReader reader) { return((T)reader.GetFacetData(m_name)); }
public override T GetFacetData <T>(BoboSegmentReader reader) { return((T)reader.GetFacetData(m_name)); }
public virtual FacetDataCache Build(BoboSegmentReader reader) { return((FacetDataCache)reader.GetFacetData(m_name)); }