static FacetDataCache MakeFacetDataCache()
        {
            FacetDataCache cache = new FacetDataCache();
            cache.Freqs = new int[numVals];
            Random r = new Random();
            for (int i = 0; i < cache.Freqs.Length; ++i)
            {
                int p = r.Next(100);
                int v;
                if (p % 100 < percent_zero)
                {
                    v = 0;
                }
                else
                {
                    v = Math.Abs(rand.Next(numDocs - 1)) + 1;
                }

                cache.Freqs[i] = v;
            }
            //Arrays.Fill(cache.Freqs, 1);
            cache.MaxIDs = new int[numVals];
            cache.MinIDs = new int[numVals];
            cache.ValArray = new TermIntList(numVals, "0000000000");

            for (int i = 0; i < numVals; ++i)
            {
                cache.ValArray.Add((i + 1).ToString("0000000000"));
            }
            cache.ValArray.Seal();
            cache.OrderArray = new BigIntArray(numDocsPerSeg);
            return cache;
        }
Example #2
0
 public FacetDocIdSetIterator(FacetDataCache dataCache, int index)
 {
     _index = index;
     _doc = Math.Max(-1, dataCache.MinIDs[_index] - 1);
     _maxID = dataCache.MaxIDs[_index];
     _orderArray = dataCache.OrderArray;
 }
 public FacetDocIdSetIterator(FacetDataCache dataCache, int index)
 {
     this.index = index;
     doc = Math.Max(-1, dataCache.minIDs[this.index] - 1);
     maxID = dataCache.maxIDs[this.index];
     orderArray = dataCache.orderArray;
 }
 public BitSetRandomAccessDocIdSet(bool multi, MultiValueFacetDataCache multiCache, OpenBitSet openBitSet, FacetDataCache dataCache)
 {
     _multi = multi;
     _multiCache = multiCache;
     _openBitSet = openBitSet;
     _dataCache = dataCache;
 }
        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);
                }
            }
        }
Example #6
0
        /// <summary>
        /// Same as ConvertString(FacetDataCache dataCache,string[] vals) except that the
        /// values are supplied in raw form so that we can take advantage of the type
        /// information to find index faster.
        /// </summary>
        /// <param name="dataCache"></param>
        /// <param name="vals"></param>
        /// <returns>the array of order indices of the values.</returns>
        public static int[] Convert <T>(FacetDataCache dataCache, T[] vals)
        {
            if (vals != null && (typeof(T) == typeof(string)))
            {
                var valsString = vals.Cast <string>().ToArray();
                return(ConvertString(dataCache, valsString));
            }
            var list = new List <int>(vals.Length);

            for (int i = 0; i < vals.Length; ++i)
            {
                int index         = -1;
                var valArrayTyped = dataCache.ValArray as TermValueList <T>;
                if (valArrayTyped != null)
                {
                    index = valArrayTyped.IndexOfWithType(vals[i]);
                }
                else
                {
                    index = dataCache.ValArray.IndexOf(vals[i]);
                }
                if (index >= 0)
                {
                    list.Add(index);
                }
            }
            return(list.ToArray());
        }
 public PathFacetHandler(string name)
     : base(name)
 {
     dataCache = null;
     termListFactory = TermListFactory.StringListFactory;
     separator = DEFAULT_SEP;
 }
 public SimpleFacetHandler(string name, string indexFieldName, TermListFactory termListFactory)
     : base(name)
 {
     _indexFieldName = indexFieldName;
     _dataCache = null;
     _termListFactory = termListFactory;
 }
        //private int _totalGroups; // NOT USED

        public GroupByFacetCountCollector(string name,
                                    FacetDataCache dataCache,
                                    int docBase,
                                    BrowseSelection sel,
                                    FacetSpec ospec)
            : base(name, dataCache, docBase, sel, ospec)
        {
        }
 public DefaultFacetCountCollector(BrowseSelection sel, FacetDataCache dataCache, string name, FacetSpec ospec)
 {
     _sel = sel;
     _ospec = ospec;
     _name = name;
     _dataCache = dataCache;
     _count = new int[_dataCache.freqs.Length];
     _array = _dataCache.orderArray;
 }
 public RangeFacetHandler(string name, string indexFieldName, TermListFactory termListFactory, bool autoRange)
     : base(name)
 {
     this.dataCache = null;
     this.indexFieldName = indexFieldName;
     this.termListFactory = termListFactory;
     this.predefinedRanges = null;
     this.autoRange = autoRange;
 }
 public RangeFacetHandler(string name, string indexFieldName, TermListFactory termListFactory, IEnumerable<string> predefinedRanges)
     : base(name)
 {
     this.indexFieldName = indexFieldName;
     this.dataCache = null;
     this.termListFactory = termListFactory;
     this.predefinedRanges = predefinedRanges;
     this.autoRange = false;
 }
 public virtual OpenBitSet GetBitSet(FacetDataCache dataCache)
 {
     if (lastCache == dataCache)
     {
         return bitSet;
     }
     bitSet = bitSetBuilder.BitSet(dataCache);
     lastCache = dataCache;
     return bitSet;
 }
 public CompactMultiValueFacetFilter(FacetDataCache dataCache, int[] index)
 {
     this.dataCache = dataCache;
     orderArray = this.dataCache.orderArray;
     this.index = index;
     bits = 0x0;
     foreach (int i in index)
     {
         bits |= 0x00000001 << (i - 1);
     }
 }
Example #15
0
        public override DocComparator GetComparator(IndexReader reader, int docbase)
        {
            if (!(reader.GetType().Equals(typeof(BoboIndexReader))))
            {
                throw new ArgumentException("reader not instance of BoboIndexReader");
            }
            BoboIndexReader   boboReader = (BoboIndexReader)reader;
            FacetDataCache    dataCache  = _facetHandler.GetFacetData <FacetDataCache>(boboReader);
            BigSegmentedArray orderArray = dataCache.OrderArray;

            return(new FacetDocComparator(dataCache, orderArray));
        }
Example #16
0
        public override DocComparer GetComparer(AtomicReader reader, int docbase)
        {
            if (!(reader is BoboSegmentReader))
            {
                throw new ArgumentException("reader not instance of BoboSegmentReader");
            }
            BoboSegmentReader boboReader = (BoboSegmentReader)reader;
            FacetDataCache    dataCache  = m_facetHandler.GetFacetData <FacetDataCache>(boboReader);
            BigSegmentedArray orderArray = dataCache.OrderArray;

            return(new FacetDocComparer(dataCache, orderArray));
        }
Example #17
0
 internal FacetRangeDocIdSetIterator(int start, int end, FacetDataCache dataCache)
 {
     _start = start;
     _end = end;
     for (int i = start; i <= end; ++i)
     {
         _minID = Math.Min(_minID, dataCache.MinIDs[i]);
         _maxID = Math.Max(_maxID, dataCache.MaxIDs[i]);
     }
     _doc = Math.Max(-1, _minID - 1);
     _orderArray = dataCache.OrderArray;
 }
Example #18
0
        private static int[] ConvertString(FacetDataCache dataCache, string[] vals)
        {
            var list = new List <int>(vals.Length);

            for (int i = 0; i < vals.Length; ++i)
            {
                int index = dataCache.ValArray.IndexOf(vals[i]);
                if (index >= 0)
                {
                    list.Add(index);
                }
            }
            return(list.ToArray());
        }
 public FacetOrFilter(FacetDataCache dataCache, int[] index, bool takeCompliment)
 {
     this.dataCache = dataCache;
     orderArray = dataCache.orderArray;
     this.index = index;
     bitset = new OpenBitSet(this.dataCache.valArray.Count);
     foreach (int i in this.index)
     {
         bitset.FastSet(i);
     }
     if (takeCompliment)
     {
         bitset.Flip(0, this.dataCache.valArray.Count);
     }
 }
        public virtual OpenBitSet BitSet(FacetDataCache dataCache)
        {
            int[] index = facetValueConverter.Convert(dataCache, vals);

            OpenBitSet bitset = new OpenBitSet(dataCache.ValArray.Count);
            foreach (int i in index)
            {
                bitset.FastSet(i);
            }
            if (takeCompliment)
            {
                // flip the bits
                for (int i = 0; i < index.Length; ++i)
                {
                    bitset.FastFlip(i);
                }
            }
            return bitset;
        }
        protected internal RangeFacetCountCollector(string name, FacetDataCache dataCache, FacetSpec ospec, IEnumerable<string> predefinedRanges, bool autoRange)
        {
            this.name = name;
            this.dataCache = dataCache;
            this.ospec = ospec;
            count = new int[this.dataCache.freqs.Length];
            orderArray = this.dataCache.orderArray;
            this.predefinedRanges = predefinedRanges;
            this.autoRange = autoRange;

            if (this.predefinedRanges != null)
            {
                predefinedRangeIndexes = new int[this.predefinedRanges.Count()][];
                int i = 0;
                foreach (string range in this.predefinedRanges)
                {
                    predefinedRangeIndexes[i++] = RangeFacetHandler.Parse(this.dataCache, range);
                }
            }
        }
        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++;
                }
            }
        }
 internal GeoSimpleDocIdSetIterator(int latStart, int latEnd, int longStart, int longEnd, FacetDataCache latDataCache, FacetDataCache longDataCache)
 {
     //_totalFreq = 0; // NOT USED
     _latStart = latStart;
     _longStart = longStart;
     _latEnd = latEnd;
     _longEnd = longEnd;
     for (int i = latStart; i <= latEnd; ++i)
     {
         _minID = Math.Min(_minID, latDataCache.MinIDs[i]);
         _maxID = Math.Max(_maxID, latDataCache.MaxIDs[i]);
     }
     for (int i = longStart; i <= longEnd; ++i)
     {
         _minID = Math.Min(_minID, longDataCache.MinIDs[i]);
         _maxID = Math.Max(_maxID, longDataCache.MaxIDs[i]);
     }
     _doc = Math.Max(-1, _minID - 1);
     _latOrderArray = latDataCache.OrderArray;
     _longOrderArray = longDataCache.OrderArray;
 }
 public CompactMultiValueFacetDocIdSetIterator(FacetDataCache dataCache, int[] index, int bits)
 {
     this.bits = bits;
     doc = int.MaxValue;
     maxID = -1;
     orderArray = dataCache.orderArray;
     foreach (int i in index)
     {
         if (doc > dataCache.minIDs[i])
         {
             doc = dataCache.minIDs[i];
         }
         if (maxID < dataCache.maxIDs[i])
         {
             maxID = dataCache.maxIDs[i];
         }
     }
     doc--;
     if (doc < 0)
     {
         doc = -1;
     }
 }            
 public CompactMultiValueFacetDocIdSetIterator(FacetDataCache dataCache, int[] index, int bits)
 {
     _bits = bits;
     _doc = int.MaxValue;
     _maxID = -1;
     _orderArray = dataCache.OrderArray;
     foreach (int i in index)
     {
         if (_doc > dataCache.MinIDs[i])
         {
             _doc = dataCache.MinIDs[i];
         }
         if (_maxID < dataCache.MaxIDs[i])
         {
             _maxID = dataCache.MaxIDs[i];
         }
     }
     _doc--;
     if (_doc < 0)
     {
         _doc = -1;
     }
 }
        public DefaultFacetCountCollector(string name, FacetDataCache dataCache, int docBase, BrowseSelection sel, FacetSpec ospec)
        {
            _sel = sel;
            _ospec = ospec;
            _name = name;
            _dataCache = dataCache;
            _countlength = _dataCache.Freqs.Length;

            if (_dataCache.Freqs.Length <= 3096)
            {
                _count = new LazyBigIntArray(_countlength);
            }
            else
            {
                _count = new LazyBigIntArray(_countlength);

                // NOTE: Removed memory manager implementation
                //_count = intarraymgr.Get(_countlength);
                //intarraylist.Add(_count);
            }

            _array = _dataCache.OrderArray;
            _docBase = docBase;
        }
 public SimpleBoboDocScorer(FacetDataCache dataCache, IFacetTermScoringFunctionFactory scoreFunctionFactory, float[] boostList)
     : base(scoreFunctionFactory.GetFacetTermScoringFunction(dataCache.valArray.Count, dataCache.orderArray.Size()), boostList)
 {
     _dataCache = dataCache;
 }
 public SimpleFacetCountCollector(BrowseSelection sel, FacetDataCache dataCache, string name, FacetSpec ospec)
     : base(sel, dataCache, name, ospec)
 {
 }
 public override void Load(BoboIndexReader reader)
 {
     if (_dataCache == null)
     {
         _dataCache = new FacetDataCache();
     }
     _dataCache.Load(_indexFieldName, reader, _termListFactory);
 }
		    public int[] Convert(FacetDataCache dataCache, string[] vals){
			    return FacetDataCache.Convert(dataCache, vals);
		    }
 public CompactMultiValueFacetFilterDocIdSet(FacetDataCache dataCache, int[] indexes, int finalBits, BigSegmentedArray orderArray)
 {
     this.dataCache = dataCache;
     this.indexes = indexes;
     this.finalBits = finalBits;
     this.orderArray = orderArray;
 }
 public FacetFieldComparator(int numHits,int type, FacetDataCache dataCache)
 {
     _docs = new int[numHits];
     _fieldType = type;
     _dataCache = dataCache;
     orderArray = _dataCache.orderArray;
 }
 public static int[] Convert(FacetDataCache dataCache, string[] vals)
 {
     List<int> list = new List<int>(vals.Length);
     for (int i = 0; i < vals.Length; ++i)
     {
         int index = dataCache.valArray.IndexOf(vals[i]);
         if (index >= 0)
         {
             list.Add(index);
         }
     }
     return list.ToArray();
 }
 public FacetOrFilter(FacetDataCache dataCache, int[] index)
     : this(dataCache, index, false)
 {
 }
Example #35
0
 public FacetDocComparator(FacetDataCache dataCache, BigSegmentedArray orderArray)
 {
     _dataCache  = dataCache;
     _orderArray = orderArray;
 }
Example #36
0
 public FacetDocComparer(FacetDataCache dataCache, BigSegmentedArray orderArray)
 {
     m_dataCache  = dataCache;
     m_orderArray = orderArray;
 }