diff -r 25c1ff79297c -r 4fce579bed22 include/relpipe/writer/BufferingMode.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/relpipe/writer/BufferingMode.h Sat Apr 23 23:23:29 2022 +0200 @@ -0,0 +1,62 @@ +/** + * Relational pipes (library) + * Copyright © 2022 František Kučera (Frantovo.cz, GlobalCode.info) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the: + * - GNU Lesser General Public License as published by the Free Software Foundation; + * version 3 of the License or (at your option) + * - GNU General Public License as published by the Free Software Foundation; + * version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +namespace relpipe { +namespace writer { + +/** + * Relational output might be – and usually is – buffered + * i.e. relational data are written to a buffer and flushed later and sent to the actual output stream. + * + * Through these modes we can control when the flush is done. + * + * Recommendation: + * - batch processing: AUTO + * - interactive processing: RECORD + * - tools should not set the mode explicitly unless asked by the user or unles specific mode is obvious for given task; + * then ENVIRONMENT mode is the initial one and it defaults to AUTO when user has not set the environmental variable + */ +enum class BufferingMode { + /** + * Output buffer is not explicitly flushed, it is written when full. + */ + AUTO, + /** + * Mode is determined by the environmental variable RELPIPE_WRITER_BUFFERING_MODE. + * If value is missing or has invalid value, AUTO is used as default. + */ + ENVIRONMENT, + /** + * Output buffer is flushed at least at the end of each relation. + */ + RELATION, + /** + * Output buffer is flushed at least at the end of each record. + */ + RECORD, + /** + * Output buffer is flushed at least at the end of each attribute. + */ + ATTRIBUTE +}; + +} +}