Exemple #1
0
        public async Task <IList <long> > ExecuteWrite(string collectionName, IEnumerable <IDictionary> documents)
        {
            _timer.Restart();

            IList <long> docIds;

            using (var write = _sessionFactory.CreateWriteSession(collectionName, collectionName.ToHash()))
            {
                docIds = await write.Write(documents);
            }

            if (docIds.Count > 0)
            {
                var skip = (int)docIds[0] - 1;
                var take = docIds.Count;

                using (var docs = _sessionFactory.CreateDocumentStreamSession(collectionName, collectionName.ToHash()))
                    using (var index = _sessionFactory.CreateIndexSession(collectionName, collectionName.ToHash()))
                    {
                        foreach (var doc in docs.ReadDocs(skip, take))
                        {
                            index.EmbedTerms(doc);
                        }
                    }
            }

            this.Log("executed {0} write+index job in {1}", collectionName, _timer.Elapsed);

            return(docIds);
        }
Exemple #2
0
 private void Commit(WriteTransaction tx)
 {
     using (var session = _sessionFactory.CreateWriteSession(tx.CollectionId))
     {
         session.Write(tx.Data, _tokenizer);
     }
     tx.Committed = true;
 }
Exemple #3
0
        private async Task <IList <ulong> > ExecuteWrite(WriteJob job)
        {
            try
            {
                _timer.Restart();

                IList <ulong> docIds;

                using (var session = _sessionFactory.CreateWriteSession(job.CollectionId))
                {
                    docIds = await session.Write(job);
                }

                _log.Log(string.Format("executed write job {0} in {1}", job.Id, _timer.Elapsed));

                return(docIds);
            }
            catch (Exception ex)
            {
                _log.Log(string.Format("failed to write job {0}: {1}", job.Id, ex));

                throw;
            }
        }