public override IEnumerable <Row> Execute(IEnumerable <Row> rows) { PrepareSchema(); using (var writer = new LuceneWriter(_folder)) { foreach (var row in rows) { if (row["action"] == null) { throw new InvalidOperationException("There is no action column. A valid action is None, Create, or Update!"); } var action = row["action"].ToString(); row.Remove("action"); _counters[action] += 1; switch (action) { case "None": break; case "Create": writer.Add(RowToDoc(row)); break; case "Delete": writer.Delete(row["id"].ToString()); break; case "Update": writer.Update(row["id"].ToString(), RowToDoc(row)); break; } } writer.Commit(); writer.Optimize(); } Info("Lucene Create: {0}, Update: {1}, and None: {2}.", _counters["Create"], _counters["Update"], _counters["None"]); yield break; }
public override IEnumerable <Row> Execute(IEnumerable <Row> rows) { PrepareSchema(); foreach (var row in rows) { if (row["action"] == null) { throw new InvalidOperationException("There is no action column. A valid action is None, Create, or Update!"); } var action = row["action"].ToString(); row.Remove("action"); _counters[action] += 1; switch (action) { case "None": break; case "Create": _luceneWriter.Add(RowToDoc(row)); break; case "Delete": _luceneWriter.Delete(row["id"].ToString()); break; case "Update": _luceneWriter.Update(row["id"].ToString(), RowToDoc(row)); break; } } yield break; }