Пример #1
0
        public override void WriteEndVersion(Process process, AbstractConnection input, Entity entity, bool force = false)
        {
            if (entity.Updates + entity.Inserts <= 0 && !force)
            {
                return;
            }

            var versionType = entity.Version == null ? "string" : entity.Version.SimpleType;
            var end         = entity.End ?? new DefaultFactory(Logger).Convert(entity.End, versionType);

            using (var dir = LuceneDirectoryFactory.Create(this, TflBatchEntity(entity.ProcessName))) {
                using (var writer = new IndexWriter(dir, new KeywordAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED)) {
                    var doc = new Document();
                    doc.fields.Add(new NumericField("id", Libs.Lucene.Net.Document.Field.Store.YES, true).SetIntValue(entity.TflBatchId));
                    doc.fields.Add(new Libs.Lucene.Net.Document.Field("process", entity.ProcessName, Libs.Lucene.Net.Document.Field.Store.YES, Libs.Lucene.Net.Document.Field.Index.NOT_ANALYZED_NO_NORMS));
                    doc.fields.Add(new Libs.Lucene.Net.Document.Field("connection", input.Name, Libs.Lucene.Net.Document.Field.Store.YES, Libs.Lucene.Net.Document.Field.Index.NOT_ANALYZED_NO_NORMS));
                    doc.fields.Add(new Libs.Lucene.Net.Document.Field("entity", entity.Alias, Libs.Lucene.Net.Document.Field.Store.YES, Libs.Lucene.Net.Document.Field.Index.NOT_ANALYZED_NO_NORMS));
                    doc.fields.Add(new NumericField("updates", Libs.Lucene.Net.Document.Field.Store.YES, true).SetLongValue(entity.Updates));
                    doc.fields.Add(new NumericField("inserts", Libs.Lucene.Net.Document.Field.Store.YES, true).SetLongValue(entity.Inserts));
                    doc.fields.Add(new NumericField("deletes", Libs.Lucene.Net.Document.Field.Store.YES, true).SetLongValue(entity.Deletes));
                    doc.fields.Add(LuceneWriter.CreateField("version", versionType, new SearchType {
                        Analyzer = "keyword"
                    }, end));
                    doc.fields.Add(new Libs.Lucene.Net.Document.Field("version_type", versionType, Libs.Lucene.Net.Document.Field.Store.YES, Libs.Lucene.Net.Document.Field.Index.NOT_ANALYZED_NO_NORMS));
                    doc.fields.Add(new NumericField("tflupdate", Libs.Lucene.Net.Document.Field.Store.YES, true).SetLongValue(DateTime.UtcNow.Ticks));
                    writer.AddDocument(doc);
                    writer.Commit();
                    writer.Optimize();
                }
            }
        }
Пример #2
0
 public LuceneLoadOperation(LuceneConnection luceneConnection, Entity entity, bool deleteFirst = false)
 {
     _luceneConnection = luceneConnection;
     _entity           = entity;
     _primaryKey       = entity.PrimaryKey.ToArray();
     _deleteFirst      = deleteFirst;
     _map = LuceneWriter.CreateFieldMap(entity);
 }
Пример #3
0
 public override IEnumerable <Row> Execute(IEnumerable <Row> rows)
 {
     using (var writer = LuceneWriter.Create(_luceneConnection, _entity)) {
         foreach (var row in rows)
         {
             writer.DeleteDocuments(LuceneWriter.CreateQuery(_primaryKey, row));
         }
         writer.Commit();
         writer.Optimize();
     }
     yield break;
 }