flush the output after each attribute; TODO: configurable BufferingMode v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sat, 23 Apr 2022 21:09:24 +0200
branchv_0
changeset 58 25c1ff79297c
parent 57 08c392fc66e4
child 59 4fce579bed22
flush the output after each attribute; TODO: configurable BufferingMode
src/StreamRelationalWriter.h
--- a/src/StreamRelationalWriter.h	Fri Apr 22 23:47:08 2022 +0200
+++ b/src/StreamRelationalWriter.h	Sat Apr 23 21:09:24 2022 +0200
@@ -62,11 +62,13 @@
 	std::vector<TypeId> columnTypes;
 
 	void writeString(const string_t &stringValue, const TypeId typeId) {
+		// TODO: cache writers at given positions
 		for (DataTypeWriterBase* writer : writers) if (writer->supports(typeId)) return writer->writeString(output, stringValue);
 		throw RelpipeWriterException(L"Unsupported data type: " + static_cast<integer_t> (typeId));
 	}
 
 	void writeRaw(const void* value, const type_info& typeInfo, const TypeId typeId) {
+		// TODO: cache writers at given positions
 		for (DataTypeWriterBase* writer : writers) if (writer->supports(typeId)) return writer->writeRaw(output, value, typeInfo);
 		throw RelpipeWriterException(L"Unsupported data type: " + static_cast<integer_t> (typeId));
 	}
@@ -112,6 +114,8 @@
 			columnTypes[c] = typeId;
 		}
 
+		// TODO: configurable buffer control
+		output.flush();
 	}
 
 	void writeAttribute(const string_t& value) override {
@@ -119,6 +123,8 @@
 		// TODO: select writer for each attribute just once in startRelation() instead of looking it each time here
 		writeString(value, columnTypes[currentColumn]);
 		if (++currentColumn == columnCount) currentColumn = 0;
+		// TODO: configurable buffer control
+		output.flush();
 	}
 
 	void writeAttribute(const void* value, const std::type_info& type) override {
@@ -126,6 +132,8 @@
 		// TODO: select writer for each attribute just once in startRelation() instead of looking it each time here
 		writeRaw(value, type, columnTypes[currentColumn]);
 		if (++currentColumn == columnCount) currentColumn = 0;
+		// TODO: configurable buffer control
+		output.flush();
 	}
 
 };