aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/microbdb/utility.h
diff options
context:
space:
mode:
authorqrort <qrort@yandex-team.com>2022-12-02 11:31:25 +0300
committerqrort <qrort@yandex-team.com>2022-12-02 11:31:25 +0300
commitb1f4ffc9c8abff3ba58dc1ec9a9f92d2f0de6806 (patch)
tree2a23209faf0fea5586a6d4b9cee60d1b318d29fe /library/cpp/microbdb/utility.h
parent559174a9144de40d6bb3997ea4073c82289b4974 (diff)
downloadydb-b1f4ffc9c8abff3ba58dc1ec9a9f92d2f0de6806.tar.gz
remove kikimr/driver DEPENDS
Diffstat (limited to 'library/cpp/microbdb/utility.h')
-rw-r--r--library/cpp/microbdb/utility.h75
1 files changed, 0 insertions, 75 deletions
diff --git a/library/cpp/microbdb/utility.h b/library/cpp/microbdb/utility.h
deleted file mode 100644
index 5c86061bca0..00000000000
--- a/library/cpp/microbdb/utility.h
+++ /dev/null
@@ -1,75 +0,0 @@
-#pragma once
-
-#include "microbdb.h"
-
-template <class TRecord, template <class T> class TCompare>
-int SortData(const TFile& ifile, const TFile& ofile, const TDatMetaPage* meta, size_t memory, const char* tmpDir = nullptr) {
- char templ[FILENAME_MAX];
- TInDatFileImpl<TRecord> datin;
- TOutDatFileImpl<TRecord> datout;
- TDatSorterImpl<TRecord, TCompare<TRecord>, TFakeCompression, TFakeSieve<TRecord>> sorter;
- const TRecord* u;
- int ret;
-
- const size_t minMemory = (2u << 20);
- memory = Max(memory, minMemory + minMemory / 2);
- if (datin.Open(ifile, meta, memory - minMemory, 0))
- err(1, "can't read input file");
-
- size_t outpages = Max((size_t)2u, minMemory / datin.GetPageSize());
- memory -= outpages * datin.GetPageSize();
-
- if (ret = MakeSorterTempl(templ, tmpDir))
- err(1, "can't create tempdir in \"%s\"; error: %d\n", templ, ret);
-
- if (sorter.Open(templ, datin.GetPageSize(), outpages)) {
- *strrchr(templ, LOCSLASH_C) = 0;
- RemoveDirWithContents(templ);
- err(1, "can't open sorter");
- }
-
- while (1) {
- datin.Freeze();
- while ((u = datin.Next()))
- sorter.PushWithExtInfo(u);
- sorter.NextPortion();
- if (datin.GetError() || datin.IsEof())
- break;
- }
-
- if (datin.GetError()) {
- *strrchr(templ, LOCSLASH_C) = 0;
- RemoveDirWithContents(templ);
- err(1, "in data file error %d", datin.GetError());
- }
- if (datin.Close()) {
- *strrchr(templ, LOCSLASH_C) = 0;
- RemoveDirWithContents(templ);
- err(1, "can't close in data file");
- }
-
- sorter.Sort(memory);
-
- if (datout.Open(ofile, datin.GetPageSize(), outpages)) {
- *strrchr(templ, LOCSLASH_C) = 0;
- RemoveDirWithContents(templ);
- err(1, "can't write out file");
- }
-
- while ((u = sorter.Next()))
- datout.PushWithExtInfo(u);
-
- if (sorter.GetError())
- err(1, "sorter error %d", sorter.GetError());
- if (sorter.Close())
- err(1, "can't close sorter");
-
- *strrchr(templ, LOCSLASH_C) = 0;
- RemoveDirWithContents(templ);
-
- if (datout.GetError())
- err(1, "out data file error %d", datout.GetError());
- if (datout.Close())
- err(1, "can't close out data file");
- return 0;
-}