src/GuileHandler.h
branchv_0
changeset 15 051e58022783
parent 14 82bd0f57a889
child 16 2dcc22b7a424
equal deleted inserted replaced
14:82bd0f57a889 15:051e58022783
    60 	vector<AttributeMetadata> currentReaderMetadata;
    60 	vector<AttributeMetadata> currentReaderMetadata;
    61 	vector<writer::AttributeMetadata> currentWriterMetadata;
    61 	vector<writer::AttributeMetadata> currentWriterMetadata;
    62 	integer_t currentAttributeIndex = 0;
    62 	integer_t currentAttributeIndex = 0;
    63 	boolean_t includeCurrentRecord = false;
    63 	boolean_t includeCurrentRecord = false;
    64 
    64 
       
    65 	void add(vector<AttributeMetadata>& readerAttributes, vector<writer::AttributeMetadata>& writerAttributes) {
       
    66 		for (AttributeMetadata readerAttributes : readerAttributes)
       
    67 			writerAttributes.push_back({
       
    68 				readerAttributes.getAttributeName(),
       
    69 				relationalWriter->toTypeId(readerAttributes.getTypeName())
       
    70 			});
       
    71 	}
       
    72 
    65 	/**
    73 	/**
    66 	 * @param attributeName name from relational pipe
    74 	 * @param attributeName name from relational pipe
    67 	 * @return variable name in Guile
    75 	 * @return variable name in Guile
    68 	 */
    76 	 */
    69 	string_t a2v(const string_t& attributeName) {
    77 	string_t a2v(const string_t& attributeName) {
   204 
   212 
   205 		currentReaderMetadata = attributes;
   213 		currentReaderMetadata = attributes;
   206 		// TODO: move to a reusable method (or use same metadata on both reader and writer side?)
   214 		// TODO: move to a reusable method (or use same metadata on both reader and writer side?)
   207 		currentWriterMetadata.clear();
   215 		currentWriterMetadata.clear();
   208 		if (currentRelationConfiguration && currentRelationConfiguration->writerMetadata.size()) {
   216 		if (currentRelationConfiguration && currentRelationConfiguration->writerMetadata.size()) {
   209 			currentWriterMetadata = currentRelationConfiguration->writerMetadata;
   217 			if (currentRelationConfiguration->inputAttributesPrepend) add(currentReaderMetadata, currentWriterMetadata);
       
   218 			currentWriterMetadata.insert(currentWriterMetadata.end(), currentRelationConfiguration->writerMetadata.begin(), currentRelationConfiguration->writerMetadata.end());
       
   219 			if (currentRelationConfiguration->inputAttributesAppend) add(currentReaderMetadata, currentWriterMetadata);
   210 		} else {
   220 		} else {
   211 			for (AttributeMetadata readerMetadata : attributes) currentWriterMetadata.push_back({readerMetadata.getAttributeName(), relationalWriter->toTypeId(readerMetadata.getTypeName())});
   221 			add(currentReaderMetadata, currentWriterMetadata);
   212 		}
   222 		}
   213 
   223 
   214 		if (!currentRelationConfiguration || !currentRelationConfiguration->drop) relationalWriter->startRelation(name, currentWriterMetadata, true);
   224 		if (!currentRelationConfiguration || !currentRelationConfiguration->drop) relationalWriter->startRelation(name, currentWriterMetadata, true);
   215 
   225 
   216 		if (currentRelationConfiguration) {
   226 		if (currentRelationConfiguration) {