public virtual void AddFacetCount(BytesRef facetValue, int count)
            {
                if (count < currentMin)
                {
                    return;
                }

                FacetEntry facetEntry = new FacetEntry(facetValue, count);

                if (facetEntries.Count == maxSize)
                {
                    FacetEntry temp;
                    if (!facetEntries.TrySuccessor(facetEntry, out temp))
                    {
                        return;
                    }
                    facetEntries.DeleteMax();
                }
                facetEntries.Add(facetEntry);

                if (facetEntries.Count == maxSize)
                {
                    currentMin = facetEntries.FindMax().Count;
                }
            }
Ejemplo n.º 2
0
            public virtual void AddFacetCount(BytesRef facetValue, int count)
            {
                if (count < currentMin)
                {
                    return;
                }

                FacetEntry facetEntry = new FacetEntry(facetValue, count);

                if (facetEntries.Count == maxSize)
                {
                    if (!facetEntries.TryGetSuccessor(facetEntry, out FacetEntry _))
                    {
                        return;
                    }
                    var max = facetEntries.Max;
                    if (max != null)
                    {
                        facetEntries.Remove(max);
                    }
                }
                facetEntries.Add(facetEntry);

                if (facetEntries.Count == maxSize)
                {
                    var max = facetEntries.Max;
                    currentMin = max != null ? max.Count : 0;
                }
            }
 public FilterMapFacetHandler(string name, Dictionary<string, RandomAccessFilter> filterMap)
     : base(name)
 {
     _facetEntries = new FacetEntry[filterMap.Count];
     _filterMap = new Dictionary<string, FacetEntry>();
     int i = 0;
     foreach (KeyValuePair<string, RandomAccessFilter> entry in filterMap)
     {
         FacetEntry f = new FacetEntry();
         f.filter = entry.Value;
         f.value = entry.Key;
         _facetEntries[i] = f;
         _filterMap.Add(f.value, f);
         i++;
     }
 }
Ejemplo n.º 4
0
        public override ID GenerateIdForFacet(string facetName, ID parentId, ID templateId)
        {
            var id    = GenerateIdForValue("facet", facetName);
            var value = new FacetEntry
            {
                Name       = facetName,
                ParentID   = parentId,
                TemplateID = templateId
            };

            if (facetDictionary.ContainsKey(id))
            {
                facetDictionary[id] = value;
            }
            else
            {
                facetDictionary.Add(id, value);
            }

            return(id);
        }
            public override bool Equals(object o)
            {
                if (this == o)
                {
                    return(true);
                }
                if (o == null || GetType() != o.GetType())
                {
                    return(false);
                }

                FacetEntry that = (FacetEntry)o;

                if (count != that.count)
                {
                    return(false);
                }
                if (!value.Equals(that.value))
                {
                    return(false);
                }

                return(true);
            }
 public void Init()
 {
     instance = new FacetEntry();
 }