include/relpipe/writer/BufferingMode.h
author František Kučera <franta-hg@frantovo.cz>
Sat, 23 Apr 2022 23:23:29 +0200
branchv_0
changeset 59 4fce579bed22
parent 41 include/relpipe/writer/RelationalWriter.h@744b61559eb2
permissions -rw-r--r--
BufferingMode: configurable modes that control when flush() is called set through the environmental variable RELPIPE_WRITER_BUFFERING_MODE or through the API method setBufferingMode()

/**
 * 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 <http://www.gnu.org/licenses/>.
 */
#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
};

}
}