src/AwkHandler.h
branchv_0
changeset 19 e4558df9ba2d
parent 18 2ac59242d0cb
child 20 f937ad57351f
--- a/src/AwkHandler.h	Tue May 07 21:25:45 2019 +0200
+++ b/src/AwkHandler.h	Tue May 07 21:33:59 2019 +0200
@@ -141,6 +141,7 @@
 		currentAttributeIndex = 0;
 		currentReaderMetadata.clear();
 		currentWriterMetadata.clear();
+		currentRelationConfiguration = nullptr;
 	}
 
 	string_t a2v(const string_t& attributeName) {
@@ -174,7 +175,6 @@
 
 		currentReaderMetadata = attributes;
 
-		currentRelationConfiguration = nullptr;
 		for (int i = 0; i < configuration.relationConfigurations.size(); i++) {
 			if (regex_match(name, wregex(configuration.relationConfigurations[i].relation))) {
 				currentRelationConfiguration = &configuration.relationConfigurations[i];
@@ -262,13 +262,21 @@
 					__gnu_cxx::stdio_filebuf<wchar_t> awkOutputReaderBuffer(awkOutputReaderFD, std::ios::in);
 					std::wistream awkOutputReader(&awkOutputReaderBuffer);
 
-					// FIXME: currentWriterMetadata
-					relationalWriter->startRelation(name,{
-						{L"message", writer::TypeId::STRING},
-					}, true);
+					if (currentRelationConfiguration->drop) {
+						// TODO: omit whole this process and pipe AWK output to /dev/null?
+					} else {
+						// FIXME: currentWriterMetadata
+						relationalWriter->startRelation(name,{
+							{L"message", writer::TypeId::STRING},
+						}, true);
+					}
 
 					for (string_t line; getline(awkOutputReader, line).good();) {
-						relationalWriter->writeAttribute(line);
+						if (currentRelationConfiguration->drop) {
+							// just eat the lines from the AWK
+						} else {
+							relationalWriter->writeAttribute(line);
+						}
 					}
 
 					closeOrThrow(awkOutputReaderFD);