src/AwkHandler.h
branchv_0
changeset 26 cf57e8c78492
parent 25 13a1e1134797
child 27 86d8bbc99e7b
equal deleted inserted replaced
25:13a1e1134797 26:cf57e8c78492
   224 		}
   224 		}
   225 
   225 
   226 		closeOrThrow(awkOutputReaderFD);
   226 		closeOrThrow(awkOutputReaderFD);
   227 	}
   227 	}
   228 
   228 
       
   229 	void debugVariableMapping(const string_t& relationName) {
       
   230 		relationalWriter->startRelation(relationName + L".variableMapping",{
       
   231 			{L"attribute", writer::TypeId::STRING},
       
   232 			{L"variable", writer::TypeId::STRING},
       
   233 		}, true);
       
   234 
       
   235 		for (std::pair<string_t, string_t> m : currenVariablesMapping) {
       
   236 			relationalWriter->writeAttribute(m.first);
       
   237 			relationalWriter->writeAttribute(m.second);
       
   238 		}
       
   239 	}
       
   240 
   229 public:
   241 public:
   230 
   242 
   231 	/**
   243 	/**
   232 	 * @param relationalWriter
   244 	 * @param relationalWriter
   233 	 * @param relationalWriterFlush the writer must be flushed before fork() in order to 
   245 	 * @param relationalWriterFlush the writer must be flushed before fork() in order to 
   368 					throw cli::RelpipeCLIException(L"Unable to fork Writer process.", cli::CLI::EXIT_CODE_UNEXPECTED_ERROR); // TODO: better exceptions?
   380 					throw cli::RelpipeCLIException(L"Unable to fork Writer process.", cli::CLI::EXIT_CODE_UNEXPECTED_ERROR); // TODO: better exceptions?
   369 				} else if (writerPid == 0) {
   381 				} else if (writerPid == 0) {
   370 					// Writer child process
   382 					// Writer child process
   371 					closeOrThrow(awkInputWriterFD);
   383 					closeOrThrow(awkInputWriterFD);
   372 
   384 
       
   385 					if (currentRelationConfiguration->debugVariableMapping) debugVariableMapping(name);
       
   386 
   373 					if (currentRelationConfiguration->drop) {
   387 					if (currentRelationConfiguration->drop) {
   374 						// TODO: omit whole this process and pipe AWK output to /dev/null?
   388 						// TODO: omit whole this process and pipe AWK output to /dev/null?
   375 					} else {
   389 					} else {
   376 						relationalWriter->startRelation(name, currentWriterMetadata, true);
   390 						relationalWriter->startRelation(name, currentWriterMetadata, true);
   377 					}
   391 					}