aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/deprecated/datafile
diff options
context:
space:
mode:
authorvvvv <vvvv@ydb.tech>2023-07-31 20:07:26 +0300
committervvvv <vvvv@ydb.tech>2023-07-31 20:07:26 +0300
commitf9e4743508b7930e884714cc99985ac45f84ed98 (patch)
treea1290261a4915a6f607e110e2cc27aee4c205f85 /library/cpp/deprecated/datafile
parent5cf9beeab3ea847da0b6c414fcb5faa9cb041317 (diff)
downloadydb-f9e4743508b7930e884714cc99985ac45f84ed98.tar.gz
Use UDFs from YDB
Diffstat (limited to 'library/cpp/deprecated/datafile')
-rw-r--r--library/cpp/deprecated/datafile/CMakeLists.darwin-x86_64.txt19
-rw-r--r--library/cpp/deprecated/datafile/CMakeLists.linux-aarch64.txt20
-rw-r--r--library/cpp/deprecated/datafile/CMakeLists.linux-x86_64.txt20
-rw-r--r--library/cpp/deprecated/datafile/CMakeLists.txt17
-rw-r--r--library/cpp/deprecated/datafile/CMakeLists.windows-x86_64.txt19
-rw-r--r--library/cpp/deprecated/datafile/README.md3
-rw-r--r--library/cpp/deprecated/datafile/datafile.cpp42
-rw-r--r--library/cpp/deprecated/datafile/datafile.h88
-rw-r--r--library/cpp/deprecated/datafile/loadmode.cpp1
-rw-r--r--library/cpp/deprecated/datafile/loadmode.h20
-rw-r--r--library/cpp/deprecated/datafile/ya.make12
11 files changed, 0 insertions, 261 deletions
diff --git a/library/cpp/deprecated/datafile/CMakeLists.darwin-x86_64.txt b/library/cpp/deprecated/datafile/CMakeLists.darwin-x86_64.txt
deleted file mode 100644
index 3f88f788da7..00000000000
--- a/library/cpp/deprecated/datafile/CMakeLists.darwin-x86_64.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-
-# This file was generated by the build system used internally in the Yandex monorepo.
-# Only simple modifications are allowed (adding source-files to targets, adding simple properties
-# like target_include_directories). These modifications will be ported to original
-# ya.make files by maintainers. Any complex modifications which can't be ported back to the
-# original buildsystem will not be accepted.
-
-
-
-add_library(cpp-deprecated-datafile)
-target_link_libraries(cpp-deprecated-datafile PUBLIC
- contrib-libs-cxxsupp
- yutil
- cpp-deprecated-mapped_file
-)
-target_sources(cpp-deprecated-datafile PRIVATE
- ${CMAKE_SOURCE_DIR}/library/cpp/deprecated/datafile/datafile.cpp
- ${CMAKE_SOURCE_DIR}/library/cpp/deprecated/datafile/loadmode.cpp
-)
diff --git a/library/cpp/deprecated/datafile/CMakeLists.linux-aarch64.txt b/library/cpp/deprecated/datafile/CMakeLists.linux-aarch64.txt
deleted file mode 100644
index 43da9ae45a1..00000000000
--- a/library/cpp/deprecated/datafile/CMakeLists.linux-aarch64.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-
-# This file was generated by the build system used internally in the Yandex monorepo.
-# Only simple modifications are allowed (adding source-files to targets, adding simple properties
-# like target_include_directories). These modifications will be ported to original
-# ya.make files by maintainers. Any complex modifications which can't be ported back to the
-# original buildsystem will not be accepted.
-
-
-
-add_library(cpp-deprecated-datafile)
-target_link_libraries(cpp-deprecated-datafile PUBLIC
- contrib-libs-linux-headers
- contrib-libs-cxxsupp
- yutil
- cpp-deprecated-mapped_file
-)
-target_sources(cpp-deprecated-datafile PRIVATE
- ${CMAKE_SOURCE_DIR}/library/cpp/deprecated/datafile/datafile.cpp
- ${CMAKE_SOURCE_DIR}/library/cpp/deprecated/datafile/loadmode.cpp
-)
diff --git a/library/cpp/deprecated/datafile/CMakeLists.linux-x86_64.txt b/library/cpp/deprecated/datafile/CMakeLists.linux-x86_64.txt
deleted file mode 100644
index 43da9ae45a1..00000000000
--- a/library/cpp/deprecated/datafile/CMakeLists.linux-x86_64.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-
-# This file was generated by the build system used internally in the Yandex monorepo.
-# Only simple modifications are allowed (adding source-files to targets, adding simple properties
-# like target_include_directories). These modifications will be ported to original
-# ya.make files by maintainers. Any complex modifications which can't be ported back to the
-# original buildsystem will not be accepted.
-
-
-
-add_library(cpp-deprecated-datafile)
-target_link_libraries(cpp-deprecated-datafile PUBLIC
- contrib-libs-linux-headers
- contrib-libs-cxxsupp
- yutil
- cpp-deprecated-mapped_file
-)
-target_sources(cpp-deprecated-datafile PRIVATE
- ${CMAKE_SOURCE_DIR}/library/cpp/deprecated/datafile/datafile.cpp
- ${CMAKE_SOURCE_DIR}/library/cpp/deprecated/datafile/loadmode.cpp
-)
diff --git a/library/cpp/deprecated/datafile/CMakeLists.txt b/library/cpp/deprecated/datafile/CMakeLists.txt
deleted file mode 100644
index f8b31df0c11..00000000000
--- a/library/cpp/deprecated/datafile/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-
-# This file was generated by the build system used internally in the Yandex monorepo.
-# Only simple modifications are allowed (adding source-files to targets, adding simple properties
-# like target_include_directories). These modifications will be ported to original
-# ya.make files by maintainers. Any complex modifications which can't be ported back to the
-# original buildsystem will not be accepted.
-
-
-if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA)
- include(CMakeLists.linux-aarch64.txt)
-elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
- include(CMakeLists.darwin-x86_64.txt)
-elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA)
- include(CMakeLists.windows-x86_64.txt)
-elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA)
- include(CMakeLists.linux-x86_64.txt)
-endif()
diff --git a/library/cpp/deprecated/datafile/CMakeLists.windows-x86_64.txt b/library/cpp/deprecated/datafile/CMakeLists.windows-x86_64.txt
deleted file mode 100644
index 3f88f788da7..00000000000
--- a/library/cpp/deprecated/datafile/CMakeLists.windows-x86_64.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-
-# This file was generated by the build system used internally in the Yandex monorepo.
-# Only simple modifications are allowed (adding source-files to targets, adding simple properties
-# like target_include_directories). These modifications will be ported to original
-# ya.make files by maintainers. Any complex modifications which can't be ported back to the
-# original buildsystem will not be accepted.
-
-
-
-add_library(cpp-deprecated-datafile)
-target_link_libraries(cpp-deprecated-datafile PUBLIC
- contrib-libs-cxxsupp
- yutil
- cpp-deprecated-mapped_file
-)
-target_sources(cpp-deprecated-datafile PRIVATE
- ${CMAKE_SOURCE_DIR}/library/cpp/deprecated/datafile/datafile.cpp
- ${CMAKE_SOURCE_DIR}/library/cpp/deprecated/datafile/loadmode.cpp
-)
diff --git a/library/cpp/deprecated/datafile/README.md b/library/cpp/deprecated/datafile/README.md
deleted file mode 100644
index 7f8547108e8..00000000000
--- a/library/cpp/deprecated/datafile/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-A wrapper on top of some user-defined custom file format.
-
-Just write your own if you need it. It's going to be way easier than figuring out how to use this one.
diff --git a/library/cpp/deprecated/datafile/datafile.cpp b/library/cpp/deprecated/datafile/datafile.cpp
deleted file mode 100644
index ff93f11c6b7..00000000000
--- a/library/cpp/deprecated/datafile/datafile.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-#include "datafile.h"
-
-void TDataFileBase::DoLoad(const char* fname, int loadMode) {
- Destroy();
- TFile f(fname, RdOnly);
- DoLoad(f, loadMode, nullptr, 0);
-}
-
-void TDataFileBase::DoLoad(TFile& f, int loadMode, void* hdrPtr, size_t hdrSize) {
- if (hdrPtr) {
- if (loadMode & DLM_EXACT_SIZE && f.GetLength() != (i64)Length)
- throw yexception() << f.GetName() << " size does not match its header value";
- } else {
- Length = f.GetLength();
- hdrSize = 0;
- }
- if ((loadMode & DLM_LD_TYPE_MASK) == DLM_READ) {
- MemData = TVector<char>(Length);
- memcpy(MemData.begin(), hdrPtr, hdrSize);
- f.Load(MemData.begin() + hdrSize, Length - hdrSize);
- Start = MemData.begin();
- } else {
- FileData.init(f);
- if (FileData.getSize() < Length)
- throw yexception() << f.GetName() << " is smaller than what its header value says";
- if ((loadMode & DLM_LD_TYPE_MASK) == DLM_MMAP_PRC)
- FileData.precharge();
- Start = (const char*)FileData.getData();
- }
-}
-
-void TDataFileBase::Destroy() {
- TVector<char>().swap(MemData);
- FileData.term();
- Start = nullptr;
- Length = 0;
-}
-
-void TDataFileBase::Precharge() const {
- if (Length && Start == (char*)FileData.getData())
- FileData.precharge();
-}
diff --git a/library/cpp/deprecated/datafile/datafile.h b/library/cpp/deprecated/datafile/datafile.h
deleted file mode 100644
index a438baceca3..00000000000
--- a/library/cpp/deprecated/datafile/datafile.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#pragma once
-
-#include "loadmode.h"
-
-#include <library/cpp/deprecated/mapped_file/mapped_file.h>
-
-#include <util/generic/vector.h>
-#include <util/system/file.h>
-#include <util/system/filemap.h>
-
-/** Simple helper that allows a file to be either mapped or read into malloc'ed memory.
- This behaviour is controlled by EDataLoadMode enum defined in loadmode.h.
- Unlike TBlob it provides Precharge() function and simple file size - based integrity check.
-
- To use this code, inherit your class from TDataFile<TFileHeader>.
- TFileHeader must be a pod-type structure with byte layout of the file header.
- File must start with that header.
- TFileHeader must have FileSize() member function that determines expected file size or
- length of data that need to be read from the beginning of file.
- */
-
-class TDataFileBase {
-protected:
- TVector<char> MemData;
- TMappedFile FileData;
-
- const char* Start;
- size_t Length;
-
- TDataFileBase()
- : Start(nullptr)
- , Length(0)
- {
- }
-
- void DoLoad(TFile& f, int loadMode, void* hdrPtr, size_t hdrSize);
- void DoLoad(const char* fname, int loadMode); // just whole file
- void Destroy();
- void swap(TDataFileBase& with) {
- MemData.swap(with.MemData);
- FileData.swap(with.FileData);
- DoSwap(Start, with.Start);
- DoSwap(Length, with.Length);
- }
-
-public:
- void Precharge() const;
-};
-
-template <class TFileHeader>
-class TDataFile: public TDataFileBase {
-protected:
- void Load(const char* fname, EDataLoadMode loadMode) {
- Destroy();
- TFile f(fname, RdOnly | Seq);
- TFileHeader hdr;
- f.Load(&hdr, sizeof(hdr));
- Length = hdr.FileSize();
- DoLoad(f, (int)loadMode, &hdr, sizeof(hdr));
- }
- const TFileHeader& Hdr() const {
- return *(TFileHeader*)Start;
- }
-};
-
-// Use: class TFoo: public TDataFileEx<Foo> {...};
-// Additional requrement: TFileHeader must have Validate(fname) function that throws exception.
-// Class TUser itself must have Init(fname) function
-// Adds Load() function to your class (TUser)
-template <class TUser, class TFileHeader>
-class TDataFileEx: public TDataFile<TFileHeader> {
-private:
- using TBase = TDataFile<TFileHeader>;
- TUser& User() const {
- return *(TUser*)this;
- }
-
-public:
- TDataFileEx(const char* fname, EDataLoadMode loadMode = DLM_DEFAULT) {
- if (fname)
- Load(fname, loadMode);
- }
- void Load(const char* fname, EDataLoadMode loadMode = DLM_DEFAULT) {
- TBase::Load(fname, loadMode);
- TBase::Hdr().Validate(fname);
- User().Init(fname);
- }
-};
diff --git a/library/cpp/deprecated/datafile/loadmode.cpp b/library/cpp/deprecated/datafile/loadmode.cpp
deleted file mode 100644
index a857830326e..00000000000
--- a/library/cpp/deprecated/datafile/loadmode.cpp
+++ /dev/null
@@ -1 +0,0 @@
-#include "loadmode.h"
diff --git a/library/cpp/deprecated/datafile/loadmode.h b/library/cpp/deprecated/datafile/loadmode.h
deleted file mode 100644
index f04054dd645..00000000000
--- a/library/cpp/deprecated/datafile/loadmode.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#pragma once
-
-// It is recommended to support all reasonal value combinations via this enum,
-// to let Load() function argument be of EDataLoadMode type, not just int type
-
-enum EDataLoadMode {
- DLM_READ = 0,
- DLM_MMAP_PRC = 1, // precharge
- DLM_MMAP = 2, // w/o precharge
- DLM_MMAP_AUTO_PRC = 3, // precharge automatically (same as DLM_MMAP unless specifically supported)
- DLM_LD_TYPE_MASK = 15,
- DLM_EXACT_SIZE = 16, // fail if input file is larger than what header says
-
- DLM_READ_ESZ = DLM_READ | DLM_EXACT_SIZE,
- DLM_MMAP_PRC_ESZ = DLM_MMAP_PRC | DLM_EXACT_SIZE,
- DLM_MMAP_ESZ = DLM_MMAP | DLM_EXACT_SIZE,
- DLM_MMAP_APRC_ESZ = DLM_MMAP_AUTO_PRC | DLM_EXACT_SIZE,
-
- DLM_DEFAULT = DLM_MMAP_PRC_ESZ,
-};
diff --git a/library/cpp/deprecated/datafile/ya.make b/library/cpp/deprecated/datafile/ya.make
deleted file mode 100644
index 1ad4fe9bc74..00000000000
--- a/library/cpp/deprecated/datafile/ya.make
+++ /dev/null
@@ -1,12 +0,0 @@
-LIBRARY()
-
-SRCS(
- datafile.cpp
- loadmode.cpp
-)
-
-PEERDIR(
- library/cpp/deprecated/mapped_file
-)
-
-END()