Ejemplo n.º 1
0
        public override Terms Terms(string field)
        {
            Terms result;

            Terms_Renamed.TryGetValue(field, out result);
            if (result != null)
            {
                return(result);
            }

            // Lazy init: first time this field is requested, we
            // create & add to terms:
            IList <Terms>       subs2   = new List <Terms>();
            IList <ReaderSlice> slices2 = new List <ReaderSlice>();

            // Gather all sub-readers that share this field
            for (int i = 0; i < Subs.Length; i++)
            {
                Terms terms = Subs[i].Terms(field);
                if (terms != null)
                {
                    subs2.Add(terms);
                    slices2.Add(SubSlices[i]);
                }
            }
            if (subs2.Count == 0)
            {
                result = null;
                // don't cache this case with an unbounded cache, since the number of fields that don't exist
                // is unbounded.
            }
            else
            {
                result = new MultiTerms(subs2.ToArray(/*Terms.EMPTY_ARRAY*/), slices2.ToArray(/*ReaderSlice.EMPTY_ARRAY*/));
                Terms_Renamed[field] = result;
            }

            return(result);
        }
Ejemplo n.º 2
0
        public override Terms Terms(string field)
        {
            Terms result;
            Terms_Renamed.TryGetValue(field, out result);
            if (result != null)
            {
                return result;
            }

            // Lazy init: first time this field is requested, we
            // create & add to terms:
            IList<Terms> subs2 = new List<Terms>();
            IList<ReaderSlice> slices2 = new List<ReaderSlice>();

            // Gather all sub-readers that share this field
            for (int i = 0; i < Subs.Length; i++)
            {
                Terms terms = Subs[i].Terms(field);
                if (terms != null)
                {
                    subs2.Add(terms);
                    slices2.Add(SubSlices[i]);
                }
            }
            if (subs2.Count == 0)
            {
                result = null;
                // don't cache this case with an unbounded cache, since the number of fields that don't exist
                // is unbounded.
            }
            else
            {
                result = new MultiTerms(subs2.ToArray(/*Terms.EMPTY_ARRAY*/), slices2.ToArray(/*ReaderSlice.EMPTY_ARRAY*/));
                Terms_Renamed[field] = result;
            }

            return result;
        }