Exemplo n.º 1
0
        public Collector(string directory, IxInfo ix, IScoringScheme scorerFactory = null, int documentCount = -1)
        {
            _directory     = directory;
            _ix            = ix;
            _scorerFactory = scorerFactory;
            _documentCount = documentCount == -1 ? ix.DocumentCount : documentCount;
            _scoreCache    = new Dictionary <Query, IList <DocumentScore> >();

            var docHashesFileName = Path.Combine(_directory, string.Format("{0}.{1}", _ix.VersionId, "pk"));

            _posFileName = Path.Combine(directory, string.Format("{0}.{1}", ix.VersionId, "pos"));

            _docHashReader = new DocHashReader(docHashesFileName);
        }
Exemplo n.º 2
0
        private IEnumerable <DocumentScore> DoScore(IList <DocumentPosting> postings)
        {
            var docHashesFileName = Path.Combine(_directory, string.Format("{0}.{1}", _ix.VersionId, "pk"));

            using (var docHashReader = new DocHashReader(docHashesFileName))
            {
                if (_scorerFactory == null)
                {
                    foreach (var posting in postings)
                    {
                        var docHash = docHashReader.Read(posting.DocumentId);

                        if (!docHash.IsObsolete)
                        {
                            yield return(new DocumentScore(posting.DocumentId, docHash.Hash, 0, _ix));
                        }
                    }
                }
                else
                {
                    if (postings.Any())
                    {
                        var docsWithTerm = postings.Count;

                        var scorer = _scorerFactory.CreateScorer(_documentCount, docsWithTerm);

                        foreach (var posting in postings)
                        {
                            var docHash = docHashReader.Read(posting.DocumentId);

                            if (!docHash.IsObsolete)
                            {
                                var score = scorer.Score(posting);

                                yield return(new DocumentScore(posting.DocumentId, docHash.Hash, score, _ix));
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public RDocStream(string fileName, string primaryKeyFieldName = null, int skip = 0, int take = int.MaxValue)
            : base(primaryKeyFieldName)
        {
            var versionId         = Path.GetFileNameWithoutExtension(fileName);
            var directory         = Path.GetDirectoryName(fileName);
            var docFileName       = Path.Combine(directory, versionId + ".rdoc");
            var docAddressFn      = Path.Combine(directory, versionId + ".da");
            var docHashesFileName = Path.Combine(directory, string.Format("{0}.{1}", versionId, "pk"));
            var keyIndexFileName  = Path.Combine(directory, versionId + ".kix");
            var keyIndex          = Util.GetKeyIndex(keyIndexFileName);

            _ix             = IxInfo.Load(Path.Combine(directory, versionId + ".ix"));
            _hashReader     = new DocHashReader(docHashesFileName);
            _addressReader  = new DocumentAddressReader(new FileStream(docAddressFn, FileMode.Open, FileAccess.Read));
            _documentReader = new DocumentReader(
                new FileStream(docFileName, FileMode.Open, FileAccess.Read),
                _ix.Compression,
                keyIndex);

            _skip      = skip;
            _take      = take;
            _directory = directory;
        }
Exemplo n.º 4
0
 public FullTextReadSession(SegmentInfo version, DocHashReader docHashReader, BlockInfoReader addressReader, Stream stream) : base(version, docHashReader, addressReader, stream)
 {
 }
Exemplo n.º 5
0
 public NetworkFullTextReadSession(
     IPEndPoint postingsEndpoint, IPEndPoint documentsEndpoint, SegmentInfo version, DocHashReader docHashReader, BlockInfoReader addressReader, Stream stream)
     : base(version, docHashReader, addressReader, stream)
 {
     _postingsReader  = new NetworkPostingsReader(postingsEndpoint);
     _documentsReader = new NetworkBlockReader(documentsEndpoint);
 }