Ejemplo n.º 1
0
        private BOCHit Scan(long keyId, SortedList <long, byte> query)
        {
            BOCHit hit = null;

            var indexReader = CreateDocumentIndexReader(keyId);

            if (indexReader != null)
            {
                return(indexReader.ClosestMatch(query));
            }

            return(hit);
        }
Ejemplo n.º 2
0
        private void Map(Query query)
        {
            this.Log("before map: " + query.ToDiagram());

            var clauses = query.ToList();

            foreach (var q in clauses)
            {
                var cursor = q;

                while (cursor != null)
                {
                    BOCHit hit = null;

                    var indexReader = cursor.Term.KeyId.HasValue ?
                                      CreateIndexReader(cursor.Term.KeyId.Value) :
                                      CreateIndexReader(cursor.Term.KeyHash);

                    if (indexReader != null)
                    {
                        var termVector = cursor.Term.ToCharVector();

                        hit = indexReader.ClosestMatch(termVector);
                    }

                    if (hit != null)
                    {
                        cursor.Score = hit.Score;

                        foreach (var offs in hit.PostingsOffsets)
                        {
                            if (offs < 0)
                            {
                                throw new DataMisalignedException();
                            }

                            cursor.PostingsOffsets.Add(offs);
                        }
                    }

                    cursor = cursor.Then;
                }
            }

            this.Log("after map: " + query.ToDiagram());
        }