<commit_before>﻿// Version compatibility level: 3.1.0
namespace BoboBrowse.Net.Facets.Range
{
    using BoboBrowse.Net.Facets.Data;
    using BoboBrowse.Net.Facets.Filter;
    using BoboBrowse.Net.Facets.Impl;
    using BoboBrowse.Net.Query.Scoring;
    using BoboBrowse.Net.Sort;
    using BoboBrowse.Net.Support;
    using BoboBrowse.Net.Util;
    using Lucene.Net.Index;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class MultiRangeFacetHandler : RangeFacetHandler
    {
        private readonly Term sizePayloadTerm;
        private int maxItems = BigNestedIntArray.MAX_ITEMS;

        public MultiRangeFacetHandler(string name, string indexFieldName, Term sizePayloadTerm,
            TermListFactory termListFactory, IEnumerable<string> predefinedRanges)
            : base(name, indexFieldName, termListFactory, predefinedRanges)
        {
            this.sizePayloadTerm = sizePayloadTerm;
        }

        public override DocComparatorSource GetDocComparatorSource()
        {
            return new MultiFacetDocComparatorSource(new MultiDataCacheBuilder(Name, _indexFieldName));
        }

        public override string[] GetFieldValues(BoboIndexReader reader, int id)
        {
            MultiValueFacetDataCache dataCache = GetFacetData(reader);
            if (dataCache != null)
            {
                return dataCache.NestedArray.GetTranslatedData(id, dataCache.ValArray);
            }
            return new string[0];
        }

        public override object[] GetRawFieldValues(BoboIndexReader reader, int id)
        {
 	        MultiValueFacetDataCache dataCache = GetFacetData(reader);
            if (dataCache != null) {
                return dataCache.NestedArray.GetRawData(id, dataCache.ValArray);
            }
            return new string[0];
        }

        public MultiValueFacetDataCache GetFacetData(BoboIndexReader reader)
        {
            return (MultiValueFacetDataCache)reader.GetFacetData(_name);
        }

        public override RandomAccessFilter BuildRandomAccessFilter(string value, Properties prop)
        {
 	         return new FacetRangeFilter(this, value);
        }

        public override FacetCountCollectorSource GetFacetCountCollectorSource(BrowseSelection sel, FacetSpec ospec)
        {
 	         return new MultiRangeFacetCountCollectorSource(this, ospec);
        }

        private class MultiRangeFacetCountCollectorSource : FacetCountCollectorSource
        {
            private readonly MultiRangeFacetHandler parent;
            private readonly FacetSpec ospec;

            public MultiRangeFacetCountCollectorSource(MultiRangeFacetHandler parent, FacetSpec ospec)
            {
                this.parent = parent;
                this.ospec = ospec;
            }

            public override IFacetCountCollector GetFacetCountCollector(BoboIndexReader reader, int docBase)
            {
                MultiValueFacetDataCache dataCache = parent.GetFacetData(reader);
                BigNestedIntArray _nestedArray = dataCache.NestedArray;
                return new MultiRangeFacetCountCollector(parent.Name, dataCache, docBase, this.ospec, parent._predefinedRanges, _nestedArray);
            }

            public class MultiRangeFacetCountCollector : RangeFacetCountCollector
            {
                private readonly BigNestedIntArray _nestedArray;

                public MultiRangeFacetCountCollector(string name, MultiValueFacetDataCache dataCache, 
                    int docBase, FacetSpec ospec, IEnumerable<string> predefinedRanges, BigNestedIntArray nestedArray)
                    : base(name, dataCache, docBase, ospec, predefinedRanges)
                {
                    _nestedArray = nestedArray;
                }

                public override void Collect(int docid)
                {
                    _nestedArray.CountNoReturn(docid, _count);
                }
            }
        }

        public override BoboDocScorer GetDocScorer(BoboIndexReader reader, IFacetTermScoringFunctionFactory scoringFunctionFactory,
            IDictionary<string, float> boostMap)
        {
            MultiValueFacetDataCache dataCache = GetFacetData(reader);
            float[] boostList = BoboDocScorer.BuildBoostList(dataCache.ValArray, boostMap);
            return new MultiValueFacetHandler.MultiValueDocScorer(dataCache, scoringFunctionFactory, boostList);
        }

        public override FacetDataCache Load(BoboIndexReader reader)
        {
 	         return Load(reader, new BoboIndexReader.WorkArea());
        }

        public override FacetDataCache Load(BoboIndexReader reader, BoboIndexReader.WorkArea workArea)
        {
            MultiValueFacetDataCache dataCache = new MultiValueFacetDataCache();
            dataCache.MaxItems = maxItems;
            if (sizePayloadTerm == null)
            {
                dataCache.Load(_indexFieldName, reader, _termListFactory, workArea);
            }
            else
            {
                dataCache.Load(_indexFieldName, reader, _termListFactory, sizePayloadTerm);
            }
            return dataCache;
        }

        public void SetMaxItems(int maxItems)
        {<commit_msg>Updated MultiRangeFacetHandler.GetFacetData to be an override instead of a new method declaration.<commit_after>﻿// Version compatibility level: 3.1.0
namespace BoboBrowse.Net.Facets.Range
{
    using BoboBrowse.Net.Facets.Data;
    using BoboBrowse.Net.Facets.Filter;
    using BoboBrowse.Net.Facets.Impl;
    using BoboBrowse.Net.Query.Scoring;
    using BoboBrowse.Net.Sort;
    using BoboBrowse.Net.Support;
    using BoboBrowse.Net.Util;
    using Lucene.Net.Index;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class MultiRangeFacetHandler : RangeFacetHandler
    {
        private readonly Term sizePayloadTerm;
        private int maxItems = BigNestedIntArray.MAX_ITEMS;

        public MultiRangeFacetHandler(string name, string indexFieldName, Term sizePayloadTerm,
            TermListFactory termListFactory, IEnumerable<string> predefinedRanges)
            : base(name, indexFieldName, termListFactory, predefinedRanges)
        {
            this.sizePayloadTerm = sizePayloadTerm;
        }

        public override DocComparatorSource GetDocComparatorSource()
        {
            return new MultiFacetDocComparatorSource(new MultiDataCacheBuilder(Name, _indexFieldName));
        }

        public override string[] GetFieldValues(BoboIndexReader reader, int id)
        {
            MultiValueFacetDataCache dataCache = GetFacetData<MultiValueFacetDataCache>(reader);
            if (dataCache != null)
            {
                return dataCache.NestedArray.GetTranslatedData(id, dataCache.ValArray);
            }
            return new string[0];
        }

        public override object[] GetRawFieldValues(BoboIndexReader reader, int id)
        {
            MultiValueFacetDataCache dataCache = GetFacetData<MultiValueFacetDataCache>(reader);
            if (dataCache != null) {
                return dataCache.NestedArray.GetRawData(id, dataCache.ValArray);
            }
            return new string[0];
        }

        public override T GetFacetData<T>(BoboIndexReader reader)
        {
            return (T)reader.GetFacetData(_name);
        }

        public override RandomAccessFilter BuildRandomAccessFilter(string value, Properties prop)
        {
 	         return new FacetRangeFilter(this, value);
        }

        public override FacetCountCollectorSource GetFacetCountCollectorSource(BrowseSelection sel, FacetSpec ospec)
        {
 	         return new MultiRangeFacetCountCollectorSource(this, ospec);
        }

        private class MultiRangeFacetCountCollectorSource : FacetCountCollectorSource
        {
            private readonly MultiRangeFacetHandler parent;
            private readonly FacetSpec ospec;

            public MultiRangeFacetCountCollectorSource(MultiRangeFacetHandler parent, FacetSpec ospec)
            {
                this.parent = parent;
                this.ospec = ospec;
            }

            public override IFacetCountCollector GetFacetCountCollector(BoboIndexReader reader, int docBase)
            {
                MultiValueFacetDataCache dataCache = parent.GetFacetData<MultiValueFacetDataCache>(reader);
                BigNestedIntArray _nestedArray = dataCache.NestedArray;
                return new MultiRangeFacetCountCollector(parent.Name, dataCache, docBase, this.ospec, parent._predefinedRanges, _nestedArray);
            }

            public class MultiRangeFacetCountCollector : RangeFacetCountCollector
            {
                private readonly BigNestedIntArray _nestedArray;

                public MultiRangeFacetCountCollector(string name, MultiValueFacetDataCache dataCache, 
                    int docBase, FacetSpec ospec, IEnumerable<string> predefinedRanges, BigNestedIntArray nestedArray)
                    : base(name, dataCache, docBase, ospec, predefinedRanges)
                {
                    _nestedArray = nestedArray;
                }

                public override void Collect(int docid)
                {
                    _nestedArray.CountNoReturn(docid, _count);
                }
            }
        }

        public override BoboDocScorer GetDocScorer(BoboIndexReader reader, IFacetTermScoringFunctionFactory scoringFunctionFactory,
            IDictionary<string, float> boostMap)
        {
            MultiValueFacetDataCache dataCache = GetFacetData<MultiValueFacetDataCache>(reader);
            float[] boostList = BoboDocScorer.BuildBoostList(dataCache.ValArray, boostMap);
            return new MultiValueFacetHandler.MultiValueDocScorer(dataCache, scoringFunctionFactory, boostList);
        }

        public override FacetDataCache Load(BoboIndexReader reader)
        {
 	         return Load(reader, new BoboIndexReader.WorkArea());
        }

        public override FacetDataCache Load(BoboIndexReader reader, BoboIndexReader.WorkArea workArea)
        {
            MultiValueFacetDataCache dataCache = new MultiValueFacetDataCache();
            dataCache.MaxItems = maxItems;
            if (sizePayloadTerm == null)
            {
                dataCache.Load(_indexFieldName, reader, _termListFactory, workArea);
            }
            else
            {
                dataCache.Load(_indexFieldName, reader, _termListFactory, sizePayloadTerm);
            }
            return dataCache;
        }

        public void SetMaxItems(int maxItems)
        {
{'fraction_non_alphanumeric': 0.060503886859604755, 'fraction_numerical': 0.0009365926758452749, 'mean_word_length': 2.3462864305860234, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1374941', 'n_tokens_mistral': 2806, 'n_tokens_neox': 2698, 'n_words': 560}