Пример #1
0
            public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs)
            {
                SortedDocValues fcsi       = FieldCache.DEFAULT.GetTermsIndex(context.AtomicReader, field);
                int             lowerPoint = lowerVal == null ? -1 : fcsi.LookupTerm(new BytesRef(lowerVal));
                int             upperPoint = upperVal == null ? -1 : fcsi.LookupTerm(new BytesRef(upperVal));

                int inclusiveLowerPoint, inclusiveUpperPoint;

                // Hints:
                // * binarySearchLookup returns 0, if value was null.
                // * the value is <0 if no exact hit was found, the returned value
                //   is (-(insertion point) - 1)
                if (lowerPoint == -1 && lowerVal == null)
                {
                    inclusiveLowerPoint = 0;
                }
                else if (includeLower && lowerPoint >= 0)
                {
                    inclusiveLowerPoint = lowerPoint;
                }
                else if (lowerPoint >= 0)
                {
                    inclusiveLowerPoint = lowerPoint + 1;
                }
                else
                {
                    inclusiveLowerPoint = Math.Max(0, -lowerPoint - 1);
                }

                if (upperPoint == -1 && upperVal == null)
                {
                    inclusiveUpperPoint = int.MaxValue;
                }
                else if (includeUpper && upperPoint >= 0)
                {
                    inclusiveUpperPoint = upperPoint;
                }
                else if (upperPoint >= 0)
                {
                    inclusiveUpperPoint = upperPoint - 1;
                }
                else
                {
                    inclusiveUpperPoint = -upperPoint - 2;
                }

                if (inclusiveUpperPoint < 0 || inclusiveLowerPoint > inclusiveUpperPoint)
                {
                    return(null);
                }

                // TODO: LUCENENET This should be throwing an exception during
                // a test run on the original solution, but does not.
                // ie. inclusiveLowerPoint > 0 && inclusiveUpperPoint > 0
                // evaluates to false, but a DebugAssertionException is not
                // thrown on the original test runs.
                Debug.Assert(inclusiveLowerPoint > 0 && inclusiveUpperPoint > 0);

                return(new AnonymousClassFieldCacheDocIdSet(fcsi, inclusiveLowerPoint, inclusiveUpperPoint, context.Reader.MaxDoc, acceptDocs));
            }
Пример #2
0
            public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs)
            {
                SortedDocValues fcsi       = FieldCache.DEFAULT.GetTermsIndex(context.AtomicReader, field);
                int             lowerPoint = lowerVal == null ? -1 : fcsi.LookupTerm(new BytesRef(lowerVal));
                int             upperPoint = upperVal == null ? -1 : fcsi.LookupTerm(new BytesRef(upperVal));

                int inclusiveLowerPoint, inclusiveUpperPoint;

                // Hints:
                // * binarySearchLookup returns 0, if value was null.
                // * the value is <0 if no exact hit was found, the returned value
                //   is (-(insertion point) - 1)
                if (lowerPoint == -1 && lowerVal == null)
                {
                    inclusiveLowerPoint = 0;
                }
                else if (includeLower && lowerPoint >= 0)
                {
                    inclusiveLowerPoint = lowerPoint;
                }
                else if (lowerPoint >= 0)
                {
                    inclusiveLowerPoint = lowerPoint + 1;
                }
                else
                {
                    inclusiveLowerPoint = Math.Max(0, -lowerPoint - 1);
                }

                if (upperPoint == -1 && upperVal == null)
                {
                    inclusiveUpperPoint = int.MaxValue;
                }
                else if (includeUpper && upperPoint >= 0)
                {
                    inclusiveUpperPoint = upperPoint;
                }
                else if (upperPoint >= 0)
                {
                    inclusiveUpperPoint = upperPoint - 1;
                }
                else
                {
                    inclusiveUpperPoint = -upperPoint - 2;
                }

                if (inclusiveUpperPoint < 0 || inclusiveLowerPoint > inclusiveUpperPoint)
                {
                    return(null);
                }

                if (Debugging.AssertsEnabled)
                {
                    Debugging.Assert(inclusiveLowerPoint >= 0 && inclusiveUpperPoint >= 0);
                }

                return(new AnonymousClassFieldCacheDocIdSet(fcsi, inclusiveLowerPoint, inclusiveUpperPoint, context.Reader.MaxDoc, acceptDocs));
            }
            public override void SetNextReader(AtomicReaderContext context)
            {
                if (m_segmentFacetCounts != null)
                {
                    m_segmentResults.Add(CreateSegmentResult());
                }

                groupFieldTermsIndex = FieldCache.DEFAULT.GetTermsIndex(context.AtomicReader, m_groupField);
                facetFieldTermsIndex = FieldCache.DEFAULT.GetTermsIndex(context.AtomicReader, m_facetField);

                // 1+ to allow for the -1 "not set":
                m_segmentFacetCounts = new int[facetFieldTermsIndex.ValueCount + 1];
                m_segmentTotalCount  = 0;

                segmentGroupedFacetHits.Clear();
                foreach (GroupedFacetHit groupedFacetHit in groupedFacetHits)
                {
                    int facetOrd = groupedFacetHit.facetValue == null ? -1 : facetFieldTermsIndex.LookupTerm(groupedFacetHit.facetValue);
                    if (groupedFacetHit.facetValue != null && facetOrd < 0)
                    {
                        continue;
                    }

                    int groupOrd = groupedFacetHit.groupValue == null ? -1 : groupFieldTermsIndex.LookupTerm(groupedFacetHit.groupValue);
                    if (groupedFacetHit.groupValue != null && groupOrd < 0)
                    {
                        continue;
                    }

                    int segmentGroupedFacetsIndex = groupOrd * (facetFieldTermsIndex.ValueCount + 1) + facetOrd;
                    segmentGroupedFacetHits.Put(segmentGroupedFacetsIndex);
                }

                if (m_facetPrefix != null)
                {
                    m_startFacetOrd = facetFieldTermsIndex.LookupTerm(m_facetPrefix);
                    if (m_startFacetOrd < 0)
                    {
                        // Points to the ord one higher than facetPrefix
                        m_startFacetOrd = -m_startFacetOrd - 1;
                    }
                    BytesRef facetEndPrefix = BytesRef.DeepCopyOf(m_facetPrefix);
                    facetEndPrefix.Append(UnicodeUtil.BIG_TERM);
                    m_endFacetOrd = facetFieldTermsIndex.LookupTerm(facetEndPrefix);
                    if (Debugging.AssertsEnabled)
                    {
                        Debugging.Assert(m_endFacetOrd < 0);
                    }
                    m_endFacetOrd = -m_endFacetOrd - 1; // Points to the ord one higher than facetEndPrefix
                }
                else
                {
                    m_startFacetOrd = -1;
                    m_endFacetOrd   = facetFieldTermsIndex.ValueCount;
                }
            }
Пример #4
0
        public override void SetNextReader(AtomicReaderContext context)
        {
            groupFieldTermIndex = FieldCache.DEFAULT.GetTermsIndex(context.AtomicReader, groupField);
            countFieldTermIndex = FieldCache.DEFAULT.GetTermsIndex(context.AtomicReader, countField);
            ordSet.Clear();
            foreach (GroupCount group in groups)
            {
                int groupOrd = group.GroupValue == null ? -1 : groupFieldTermIndex.LookupTerm(group.GroupValue);
                if (group.GroupValue != null && groupOrd < 0)
                {
                    continue;
                }

                groupCounts[ordSet.Put(groupOrd)] = group;
                group.ords = new int[group.UniqueValues.Count()];
                Arrays.Fill(group.ords, -2);
                int i = 0;
                foreach (BytesRef value2 in group.UniqueValues)
                {
                    int countOrd = value2 == null ? -1 : countFieldTermIndex.LookupTerm(value2);
                    if (value2 == null || countOrd >= 0)
                    {
                        group.ords[i++] = countOrd;
                    }
                }
            }
        }
Пример #5
0
        public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs)
        {
            SortedDocValues fcsi = FieldCache.GetTermsIndex((context.AtomicReader), field);
            FixedBitSet     bits = new FixedBitSet(fcsi.ValueCount);

            for (int i = 0; i < terms.Length; i++)
            {
                int ord = fcsi.LookupTerm(terms[i]);
                if (ord >= 0)
                {
                    bits.Set(ord);
                }
            }
            return(new FieldCacheDocIdSetAnonymousInnerClassHelper(this, context.Reader.MaxDoc, acceptDocs, fcsi, bits));
        }
Пример #6
0
        public override void SetNextReader(AtomicReaderContext context)
        {
            base.SetNextReader(context);
            index = FieldCache.DEFAULT.GetTermsIndex(context.AtomicReader, groupField);

            // Rebuild ordSet
            ordSet.Clear();
            foreach (AbstractSecondPassGroupingCollector.SearchGroupDocs <BytesRef> group in m_groupMap.Values)
            {
                //      System.out.println("  group=" + (group.groupValue == null ? "null" : group.groupValue.utf8ToString()));
                int ord = group.GroupValue == null ? -1 : index.LookupTerm(group.GroupValue);
                if (group.GroupValue == null || ord >= 0)
                {
                    m_groupDocs[ordSet.Put(ord)] = group;
                }
            }
        }
Пример #7
0
        public override void SetNextReader(AtomicReaderContext context)
        {
            index = FieldCache.DEFAULT.GetTermsIndex(context.AtomicReader, groupField);

            // Clear ordSet and fill it with previous encountered groups that can occur in the current segment.
            ordSet.Clear();
            foreach (BytesRef countedGroup in groups)
            {
                if (countedGroup is null)
                {
                    ordSet.Put(-1);
                }
                else
                {
                    int ord = index.LookupTerm(countedGroup);
                    if (ord >= 0)
                    {
                        ordSet.Put(ord);
                    }
                }
            }
        }
Пример #8
0
 public override int LookupTerm(BytesRef key)
 {
     return(@in.LookupTerm(key));
 }
Пример #9
0
			/// <exception cref="System.IO.IOException"></exception>
			public override void SetNextReader(AtomicReaderContext context)
			{
				if (segmentFacetCounts != null)
				{
					segmentResults.AddItem(((TermGroupFacetCollector.SV.SegmentResult)CreateSegmentResult
						()));
				}
				groupFieldTermsIndex = FieldCache.DEFAULT.GetTermsIndex(((AtomicReader)context.Reader
					()), groupField);
				facetFieldTermsIndex = FieldCache.DEFAULT.GetTermsIndex(((AtomicReader)context.Reader
					()), facetField);
				// 1+ to allow for the -1 "not set":
				segmentFacetCounts = new int[facetFieldTermsIndex.GetValueCount() + 1];
				segmentTotalCount = 0;
				segmentGroupedFacetHits.Clear();
				foreach (GroupedFacetHit groupedFacetHit in groupedFacetHits)
				{
					int facetOrd = groupedFacetHit.facetValue == null ? -1 : facetFieldTermsIndex.LookupTerm
						(groupedFacetHit.facetValue);
					if (groupedFacetHit.facetValue != null && facetOrd < 0)
					{
						continue;
					}
					int groupOrd = groupedFacetHit.groupValue == null ? -1 : groupFieldTermsIndex.LookupTerm
						(groupedFacetHit.groupValue);
					if (groupedFacetHit.groupValue != null && groupOrd < 0)
					{
						continue;
					}
					int segmentGroupedFacetsIndex = groupOrd * (facetFieldTermsIndex.GetValueCount() 
						+ 1) + facetOrd;
					segmentGroupedFacetHits.Put(segmentGroupedFacetsIndex);
				}
				if (facetPrefix != null)
				{
					startFacetOrd = facetFieldTermsIndex.LookupTerm(facetPrefix);
					if (startFacetOrd < 0)
					{
						// Points to the ord one higher than facetPrefix
						startFacetOrd = -startFacetOrd - 1;
					}
					BytesRef facetEndPrefix = BytesRef.DeepCopyOf(facetPrefix);
					facetEndPrefix.Append(UnicodeUtil.BIG_TERM);
					endFacetOrd = facetFieldTermsIndex.LookupTerm(facetEndPrefix);
					endFacetOrd < 0 = -endFacetOrd - 1;
				}
				else
				{
					// Points to the ord one higher than facetEndPrefix
					startFacetOrd = -1;
					endFacetOrd = facetFieldTermsIndex.GetValueCount();
				}
			}