Exemplo n.º 1
0
        public RangeFacetCountCollector(string name, FacetDataCache dataCache, int docBase, FacetSpec ospec, IList <string> predefinedRanges)
        {
            m_name        = name;
            m_dataCache   = dataCache;
            m_countLength = m_dataCache.Freqs.Length;
            m_count       = new LazyBigInt32Array(m_countLength);
            m_array       = m_dataCache.OrderArray;
            m_ospec       = ospec;
            if (predefinedRanges != null)
            {
                m_predefinedRanges = new TermStringList();
                predefinedRanges.Sort();
                m_predefinedRanges.AddAll(predefinedRanges);
            }
            else
            {
                m_predefinedRanges = null;
            }

            if (m_predefinedRanges != null)
            {
                m_predefinedRangeIndexes = new int[m_predefinedRanges.Count][];
                int i = 0;
                foreach (string range in this.m_predefinedRanges)
                {
                    m_predefinedRangeIndexes[i++] = FacetRangeFilter.Parse(this.m_dataCache, range);
                }
            }
        }
        public RangeFacetCountCollector(string name, FacetDataCache dataCache, int docBase, FacetSpec ospec, IEnumerable<string> predefinedRanges)
        {
            _name = name;
            _dataCache = dataCache;
            _countLength = _dataCache.Freqs.Length;
            _count = new LazyBigIntArray(_countLength);
            _array = _dataCache.OrderArray;
            _docBase = docBase;
            _ospec = ospec;
            if (predefinedRanges != null)
            {
                _predefinedRanges = new TermStringList();
                var tempList = new List<string>(predefinedRanges);
                tempList.Sort();
                _predefinedRanges.AddAll(tempList);
            }
            else
            {
                _predefinedRanges = null;
            }

            if (_predefinedRanges != null)
            {
                _predefinedRangeIndexes = new int[_predefinedRanges.Count()][];
                int i = 0;
                foreach (string range in this._predefinedRanges)
                {
                    _predefinedRangeIndexes[i++] = FacetRangeFilter.Parse(this._dataCache, range);
                }
            }
        }
        public RangeFacetCountCollector(string name, FacetDataCache dataCache, int docBase, FacetSpec ospec, IEnumerable <string> predefinedRanges)
        {
            _name        = name;
            _dataCache   = dataCache;
            _countLength = _dataCache.Freqs.Length;
            _count       = new LazyBigIntArray(_countLength);
            _array       = _dataCache.OrderArray;
            _docBase     = docBase;
            _ospec       = ospec;
            if (predefinedRanges != null)
            {
                _predefinedRanges = new TermStringList();
                var tempList = new List <string>(predefinedRanges);
                tempList.Sort();
                _predefinedRanges.AddAll(tempList);
            }
            else
            {
                _predefinedRanges = null;
            }

            if (_predefinedRanges != null)
            {
                _predefinedRangeIndexes = new int[_predefinedRanges.Count()][];
                int i = 0;
                foreach (string range in this._predefinedRanges)
                {
                    _predefinedRangeIndexes[i++] = FacetRangeFilter.Parse(this._dataCache, range);
                }
            }
        }
 public void TestTermStringListAddWrongOrder()
 {
     TermStringList tsl1 = new TermStringList();
     tsl1.Add(null);
     tsl1.Add("m");
     try
     {
         tsl1.Add("a");
     }
     catch (Exception e)
     {
         Assert.True(e.Message.Contains("ascending order"), "There should be an exception and the message contains ascending order");
         return;
     }
     Assert.Fail("There should be an exception and the message contains ascending order");
 }
        public void TestTermStringListAddWrongOrder()
        {
            TermStringList tsl1 = new TermStringList();

            tsl1.Add(null);
            tsl1.Add("m");
            try
            {
                tsl1.Add("a");
            }
            catch (Exception e)
            {
                Assert.True(e.Message.Contains("ascending order"), "There should be an exception and the message contains ascending order");
                return;
            }
            Assert.Fail("There should be an exception and the message contains ascending order");
        }
 public void TestTermStringListAddCorrectOrder()
 {
     TermStringList tsl1 = new TermStringList();
     tsl1.Add(null);
     tsl1.Add("");
     try
     {
         tsl1.Add("m");
         tsl1.Add("s");
         tsl1.Add("t");
     }
     catch (Exception e)
     {
         Assert.False(e.Message.Contains("ascending order"), "There should NOT be an exception and the message contains ascending order");
         return;
     }
     tsl1.Seal();
     Assert.AreEqual(1, tsl1.IndexOf(""), "Should skip index 0 which is used for dummy null");
 }
        public GeoSimpleFacetCountCollector(string name, FacetDataCache latDataCache, FacetDataCache longDataCache, int docBase, FacetSpec spec, IEnumerable <string> predefinedRanges)
        {
            _name          = name;
            _latDataCache  = latDataCache;
            _longDataCache = longDataCache;
            _latCount      = new int[_latDataCache.Freqs.Length];
            _longCount     = new int[_longDataCache.Freqs.Length];
            log.Info("latCount: " + _latDataCache.Freqs.Length + " longCount: " + _longDataCache.Freqs.Length);
            _latOrderArray    = _latDataCache.OrderArray;
            _longOrderArray   = _longDataCache.OrderArray;
            _docBase          = docBase;
            _spec             = spec;
            _predefinedRanges = new TermStringList();
            var predefinedRangesTemp = new List <string>(predefinedRanges);

            predefinedRangesTemp.Sort();
            _predefinedRanges.AddAll(predefinedRangesTemp);

            if (predefinedRanges != null)
            {
                _latPredefinedRangeIndexes = new int[_predefinedRanges.Count][];
                for (int j = 0; j < _latPredefinedRangeIndexes.Length; j++)
                {
                    _latPredefinedRangeIndexes[j] = new int[2];
                }
                _longPredefinedRangeIndexes = new int[_predefinedRanges.Count][];
                for (int j = 0; j < _longPredefinedRangeIndexes.Length; j++)
                {
                    _longPredefinedRangeIndexes[j] = new int[2];
                }
                int i = 0;
                foreach (string range in _predefinedRanges)
                {
                    int[] ranges = GeoSimpleFacetFilter.Parse(_latDataCache, _longDataCache, range);
                    _latPredefinedRangeIndexes[i][0]  = ranges[0];  // latStart
                    _latPredefinedRangeIndexes[i][1]  = ranges[1];  // latEnd
                    _longPredefinedRangeIndexes[i][0] = ranges[2];  // longStart
                    _longPredefinedRangeIndexes[i][1] = ranges[3];  // longEnd
                    i++;
                }
            }
        }
        public void TestTermStringListAddCorrectOrder()
        {
            TermStringList tsl1 = new TermStringList();

            tsl1.Add(null);
            tsl1.Add("");
            try
            {
                tsl1.Add("m");
                tsl1.Add("s");
                tsl1.Add("t");
            }
            catch (Exception e)
            {
                Assert.False(e.Message.Contains("ascending order"), "There should NOT be an exception and the message contains ascending order");
                return;
            }
            tsl1.Seal();
            Assert.AreEqual(1, tsl1.IndexOf(""), "Should skip index 0 which is used for dummy null");
        }
        public GeoSimpleFacetCountCollector(string name, FacetDataCache latDataCache, FacetDataCache longDataCache, int docBase, FacetSpec spec, IEnumerable<string> predefinedRanges)
        {
            _name = name;
            _latDataCache = latDataCache;
            _longDataCache = longDataCache;
            _latCount = new int[_latDataCache.Freqs.Length];
            _longCount = new int[_longDataCache.Freqs.Length];
            log.Info("latCount: " + _latDataCache.Freqs.Length + " longCount: " + _longDataCache.Freqs.Length);
            _latOrderArray = _latDataCache.OrderArray;
            _longOrderArray = _longDataCache.OrderArray;
            _docBase = docBase;
            _spec = spec;
            _predefinedRanges = new TermStringList();
            var predefinedRangesTemp = new List<string>(predefinedRanges);
            predefinedRangesTemp.Sort();
            _predefinedRanges.AddAll(predefinedRangesTemp);

            if (predefinedRanges != null)
            {
                _latPredefinedRangeIndexes = new int[_predefinedRanges.Count][];
                for (int j = 0; j < _latPredefinedRangeIndexes.Length; j++)
                {
                    _latPredefinedRangeIndexes[j] = new int[2];
                }
                _longPredefinedRangeIndexes = new int[_predefinedRanges.Count][];
                for (int j = 0; j < _longPredefinedRangeIndexes.Length; j++)
                {
                    _longPredefinedRangeIndexes[j] = new int[2];
                }
                int i = 0;
                foreach (string range in _predefinedRanges)
                {
                    int[] ranges = GeoSimpleFacetFilter.Parse(_latDataCache, _longDataCache, range);
                    _latPredefinedRangeIndexes[i][0] = ranges[0];   // latStart 
                    _latPredefinedRangeIndexes[i][1] = ranges[1];   // latEnd
                    _longPredefinedRangeIndexes[i][0] = ranges[2];  // longStart
                    _longPredefinedRangeIndexes[i][1] = ranges[3];  // longEnd
                    i++;
                }
            }
        }
        public BucketFacetCountCollector(string name, DefaultFacetCountCollector subCollector, FacetSpec ospec, IDictionary<string, string[]> predefinedBuckets, int numdocs)
        {
            _name = name;
            _subCollector = subCollector;
            _ospec = ospec;
            _numdocs = numdocs;

            _predefinedBuckets = predefinedBuckets;
            _collapsedCounts = null;

            _bucketValues = new TermStringList();
            _bucketValues.Add("");

            List<string> bucketArray = _predefinedBuckets.Keys.ToList();
            bucketArray.Sort();
            foreach (string bucket in bucketArray)
            {
                _bucketValues.Add(bucket);
            }
            _bucketValues.Seal();
        }
Exemplo n.º 11
0
        public BucketFacetCountCollector(string name, DefaultFacetCountCollector subCollector, FacetSpec ospec, IDictionary <string, string[]> predefinedBuckets, int numdocs)
        {
            m_name         = name;
            m_subCollector = subCollector;
            m_ospec        = ospec;
            m_numdocs      = numdocs;

            m_predefinedBuckets = predefinedBuckets;
            m_collapsedCounts   = null;

            m_bucketValues = new TermStringList();
            m_bucketValues.Add("");

            List <string> bucketArray = m_predefinedBuckets.Keys.ToList();

            bucketArray.Sort();
            foreach (string bucket in bucketArray)
            {
                m_bucketValues.Add(bucket);
            }
            m_bucketValues.Seal();
        }
Exemplo n.º 12
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">name of the Geo Facet</param>
        /// <param name="dataCache">The data cache for the Geo Facet</param>
        /// <param name="docBase">the base doc id</param>
        /// <param name="fspec">the facet spec for this facet</param>
        /// <param name="predefinedRanges">List of ranges, where each range looks like &lt;lat, lon: rad&gt;</param>
        /// <param name="miles">variable to specify if the geo distance calculations are in miles. False indicates distance calculation is in kilometers</param>
        public GeoFacetCountCollector(string name, GeoFacetHandler.GeoFacetData dataCache, int docBase,
                                      FacetSpec fspec, IList <string> predefinedRanges, bool miles)
        {
            m_name             = name;
            m_xvals            = dataCache.xValArray;
            m_yvals            = dataCache.yValArray;
            m_zvals            = dataCache.zValArray;
            m_spec             = fspec;
            m_predefinedRanges = new TermStringList();
            predefinedRanges.Sort();
            m_predefinedRanges.AddAll(predefinedRanges);
            m_countlength = predefinedRanges.Count;
            m_count       = new LazyBigInt32Array(m_countlength);
            m_ranges      = new GeoRange[predefinedRanges.Count];
            int index = 0;

            foreach (string range in predefinedRanges)
            {
                m_ranges[index++] = Parse(range);
            }
            m_miles = miles;
        }
        public GeoSimpleFacetCountCollector(string name, FacetDataCache latDataCache, FacetDataCache longDataCache, int docBase, FacetSpec spec, IList <string> predefinedRanges)
        {
            m_name          = name;
            m_latDataCache  = latDataCache;
            m_longDataCache = longDataCache;
            m_latCount      = new int[m_latDataCache.Freqs.Length];
            m_longCount     = new int[m_longDataCache.Freqs.Length];
            log.Info("latCount: " + m_latDataCache.Freqs.Length + " longCount: " + m_longDataCache.Freqs.Length);
            m_latOrderArray    = m_latDataCache.OrderArray;
            m_longOrderArray   = m_longDataCache.OrderArray;
            m_spec             = spec;
            m_predefinedRanges = new TermStringList();
            predefinedRanges.Sort();
            m_predefinedRanges.AddAll(predefinedRanges);

            if (predefinedRanges != null)
            {
                m_latPredefinedRangeIndexes = new int[m_predefinedRanges.Count][];
                for (int j = 0; j < m_latPredefinedRangeIndexes.Length; j++)
                {
                    m_latPredefinedRangeIndexes[j] = new int[2];
                }
                m_longPredefinedRangeIndexes = new int[m_predefinedRanges.Count][];
                for (int j = 0; j < m_longPredefinedRangeIndexes.Length; j++)
                {
                    m_longPredefinedRangeIndexes[j] = new int[2];
                }
                int i = 0;
                foreach (string range in m_predefinedRanges)
                {
                    int[] ranges = GeoSimpleFacetFilter.Parse(m_latDataCache, m_longDataCache, range);
                    m_latPredefinedRangeIndexes[i][0]  = ranges[0];  // latStart
                    m_latPredefinedRangeIndexes[i][1]  = ranges[1];  // latEnd
                    m_longPredefinedRangeIndexes[i][0] = ranges[2];  // longStart
                    m_longPredefinedRangeIndexes[i][1] = ranges[3];  // longEnd
                    i++;
                }
            }
        }
        public void TestDefaultFacetIterator()
        {
            TermStringList tsl1 = new TermStringList();

            tsl1.Add("i");
            tsl1.Add("m");
            tsl1.Seal();
            BigInt32Array count = new BigInt32Array(2);

            count.Add(0, 1);
            count.Add(1, 2);
            DefaultFacetIterator itr1 = new DefaultFacetIterator(tsl1, count, 2, false);
            TermStringList       tsl2 = new TermStringList();

            tsl2.Add("i");
            tsl2.Add("m");
            tsl2.Seal();
            BigInt32Array count2 = new BigInt32Array(2);

            count2.Add(0, 1);
            count2.Add(1, 5);
            DefaultFacetIterator itr2 = new DefaultFacetIterator(tsl2, count2, 2, true);
            List <FacetIterator> list = new List <FacetIterator>();

            list.Add(itr1);
            list.Add(itr2);
            CombinedFacetIterator ctr = new CombinedFacetIterator(list);
            string result             = "";

            while (ctr.HasNext())
            {
                ctr.Next();
                result += ctr.Facet;
                result += ctr.Count;
            }
            Assert.AreEqual("i1m7", result, "result should be i1m7");
        }
Exemplo n.º 15
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">name of the Geo Facet</param>
 /// <param name="dataCache">The data cache for the Geo Facet</param>
 /// <param name="docBase">the base doc id</param>
 /// <param name="fspec">the facet spec for this facet</param>
 /// <param name="predefinedRanges">List of ranges, where each range looks like &lt;lat, lon: rad&gt;</param>
 /// <param name="miles">variable to specify if the geo distance calculations are in miles. False indicates distance calculation is in kilometers</param>
 public GeoFacetCountCollector(string name, GeoFacetHandler.GeoFacetData dataCache,
     int docBase, FacetSpec fspec, IEnumerable<string> predefinedRanges, bool miles)
 {
     _name = name;
     _dataCache = dataCache;
     _xvals = dataCache.xValArray;
     _yvals = dataCache.yValArray;
     _zvals = dataCache.zValArray;
     _spec = fspec;
     _predefinedRanges = new TermStringList();
     var predefinedTemp = new List<string>(predefinedRanges);
     predefinedTemp.Sort();
     _predefinedRanges.AddAll(predefinedTemp);
     _docBase = docBase;
     _countlength = predefinedTemp.Count;
     _count = new LazyBigIntArray(_countlength);
     _ranges = new GeoRange[predefinedTemp.Count];
     int index = 0;
     foreach (string range in predefinedTemp)
     {
         _ranges[index++] = Parse(range);
     }
     _miles = miles;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">name of the Geo Facet</param>
 /// <param name="dataCache">The data cache for the Geo Facet</param>
 /// <param name="docBase">the base doc id</param>
 /// <param name="fspec">the facet spec for this facet</param>
 /// <param name="predefinedRanges">List of ranges, where each range looks like &lt;lat, lon: rad&gt;</param>
 /// <param name="miles">variable to specify if the geo distance calculations are in miles. False indicates distance calculation is in kilometers</param>
 public GeoFacetCountCollector(string name, GeoFacetHandler.GeoFacetData dataCache,
     int docBase, FacetSpec fspec, IEnumerable<string> predefinedRanges, bool miles)
 {
     _name = name;
     _dataCache = dataCache;
     _xvals = dataCache.xValArray;
     _yvals = dataCache.yValArray;
     _zvals = dataCache.zValArray;
     _spec = fspec;
     _predefinedRanges = new TermStringList();
     var predefinedTemp = new List<string>(predefinedRanges);
     predefinedTemp.Sort();
     _predefinedRanges.AddAll(predefinedTemp);
     _docBase = docBase;
     _countlength = predefinedTemp.Count;
     _count = new LazyBigIntArray(_countlength);
     _ranges = new GeoRange[predefinedTemp.Count];
     int index = 0;
     foreach (string range in predefinedTemp)
     {
         _ranges[index++] = Parse(range);
     }
     _miles = miles;
 }
 public RangeFacetCountCollectorFieldAccessor(TermStringList predefinedRanges)
 {
     this._predefinedRanges = predefinedRanges;
 }
 public RangeFacetCountCollectorFieldAccessor(TermStringList predefinedRanges)
 {
     this._predefinedRanges = predefinedRanges;
 }
 public void TestDefaultFacetIterator()
 {
     TermStringList tsl1 = new TermStringList();
     tsl1.Add("i");
     tsl1.Add("m");
     tsl1.Seal();
     BigIntArray count = new BigIntArray(2);
     count.Add(0, 1);
     count.Add(1, 2);
     DefaultFacetIterator itr1 = new DefaultFacetIterator(tsl1, count, 2, false);
     TermStringList tsl2 = new TermStringList();
     tsl2.Add("i");
     tsl2.Add("m");
     tsl2.Seal();
     BigIntArray count2 = new BigIntArray(2);
     count2.Add(0, 1);
     count2.Add(1, 5);
     DefaultFacetIterator itr2 = new DefaultFacetIterator(tsl2, count2, 2, true);
     List<FacetIterator> list = new List<FacetIterator>();
     list.Add(itr1);
     list.Add(itr2);
     CombinedFacetIterator ctr = new CombinedFacetIterator(list);
     string result = "";
     while (ctr.HasNext())
     {
         ctr.Next();
         result += ctr.Facet;
         result += ctr.Count;
     }
     Assert.AreEqual("i1m7", result, "result should be i1m7");
 }