From baa146f17613e1df7089396ee4c1ee93f33b5335 Mon Sep 17 00:00:00 2001 From: Michalis Toutoudakis Date: Wed, 28 Aug 2024 13:59:55 +0300 Subject: [PATCH] Add write once option to toc store to avoid creating very large datasets --- src/fdb5/toc/TocStore.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/fdb5/toc/TocStore.cc b/src/fdb5/toc/TocStore.cc index e61a981cc..a198bd99c 100644 --- a/src/fdb5/toc/TocStore.cc +++ b/src/fdb5/toc/TocStore.cc @@ -105,7 +105,10 @@ bool TocStore::exists() const { eckit::DataHandle* TocStore::retrieve(Field& field) const { return field.dataHandle(); } - +#define write_once +bool written_once = false; +long len = 0; +eckit::Offset position = 0; std::unique_ptr TocStore::archive(const Key &key, const void *data, eckit::Length length) { dirty_ = true; @@ -113,9 +116,19 @@ std::unique_ptr TocStore::archive(const Key &key, const void *dat eckit::DataHandle &dh = getDataHandle(dataPath); - eckit::Offset position = dh.position(); + - long len = dh.write( data, length ); +#ifdef write_once + // michalis hack + if (written_once == false){ + position = dh.position(); + len = dh.write( data, length ); + written_once = true; + } +#else + + eckit::Offset position = dh.position(); +#endif ASSERT(len == length);