Пример #1
0
        public NearSpansOrdered(SpanNearQuery spanNearQuery, AtomicReaderContext context, IBits acceptDocs, IDictionary <Term, TermContext> termContexts, bool collectPayloads)
        {
            // LUCENENET: Added guard clauses for null
            if (spanNearQuery is null)
            {
                throw new ArgumentNullException(nameof(spanNearQuery));
            }

            sorter = new InPlaceMergeSorterAnonymousClass(this);
            if (spanNearQuery.GetClauses().Length < 2)
            {
                throw new ArgumentException("Less than 2 clauses: " + spanNearQuery);
            }
            this.collectPayloads = collectPayloads;
            allowedSlop          = spanNearQuery.Slop;
            SpanQuery[] clauses = spanNearQuery.GetClauses();
            subSpans      = new Spans[clauses.Length];
            matchPayload  = new JCG.List <byte[]>();
            subSpansByDoc = new Spans[clauses.Length];
            for (int i = 0; i < clauses.Length; i++)
            {
                subSpans[i]      = clauses[i].GetSpans(context, acceptDocs, termContexts);
                subSpansByDoc[i] = subSpans[i]; // used in toSameDoc()
            }
            query = spanNearQuery;              // kept for toString() only.
        }
Пример #2
0
        public NearSpansUnordered(SpanNearQuery query, AtomicReaderContext context, IBits acceptDocs, IDictionary <Term, TermContext> termContexts)
        {
            this.query = query;
            this.slop  = query.Slop;

            SpanQuery[] clauses = query.GetClauses();
            queue    = new CellQueue(this, clauses.Length);
            subSpans = new Spans[clauses.Length];
            for (int i = 0; i < clauses.Length; i++)
            {
                SpansCell cell = new SpansCell(this, clauses[i].GetSpans(context, acceptDocs, termContexts), i);
                ordered.Add(cell);
                subSpans[i] = cell.spans;
            }
        }