1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

feat(fdb): MCOL-5802 Add support for blob insertion into FDB. (#3351)

This commit is contained in:
Denis Khalikov
2024-12-11 00:07:46 +03:00
committed by GitHub
parent eb6b370287
commit 87e2bb4cef
4 changed files with 474 additions and 1 deletions

View File

@ -20,6 +20,12 @@
using namespace std;
using namespace FDBCS;
using std::chrono::duration;
using std::chrono::duration_cast;
using std::chrono::high_resolution_clock;
using std::chrono::milliseconds;
// #define TEST_PERF 1
template <typename T>
static void assert_internal(const T& value, const std::string& errMessage)
@ -31,6 +37,68 @@ static void assert_internal(const T& value, const std::string& errMessage)
}
}
static std::string generateBlob(const uint32_t len)
{
std::string blob;
blob.reserve(len);
for (uint32_t i = 0; i < len; ++i)
{
blob.push_back('a' + (i % 26));
}
return blob;
}
static void testBlobHandler(std::shared_ptr<FDBCS::FDBDataBase> db)
{
#ifdef TEST_PERF
std::vector<uint32_t> blobSizes{0, 1, 11, 101, 1001, 10001, 100001, 1000001, 10000001, 100000001};
std::vector<uint32_t> blockSizes{10000, 100000};
#else
std::vector<uint32_t> blobSizes{0, 1, 10001, 100001, 10000001, 100000001};
std::vector<uint32_t> blockSizes{100000};
#endif
for (auto blobSize : blobSizes)
{
for (auto blockSize : blockSizes)
{
std::string rootKey = "root";
auto blobA = generateBlob(blobSize);
std::shared_ptr<BoostUIDKeyGenerator> gen = std::make_shared<BoostUIDKeyGenerator>();
BlobHandler handler(gen, blockSize);
#ifdef TEST_PERF
auto t1 = high_resolution_clock::now();
#endif
handler.writeBlob(db, rootKey, blobA);
#ifdef TEST_PERF
auto t2 = high_resolution_clock::now();
auto ms_int = duration_cast<milliseconds>(t2 - t1);
std::cout << "Write blob time: " << ms_int.count() << std::endl;
t1 = high_resolution_clock::now();
#endif
auto p = handler.readBlob(db, rootKey);
#ifdef TEST_PERF
t2 = high_resolution_clock::now();
cout << "size readed " << p.second.size() << endl;
#endif
assert_internal(p.second == blobA, "Blobs not equal");
#ifdef TEST_PERF
ms_int = duration_cast<milliseconds>(t2 - t1);
std::cout << "Read blob time: " << ms_int.count() << std::endl;
t1 = high_resolution_clock::now();
#endif
assert_internal(handler.removeBlob(db, rootKey), "Remove blob error");
#ifdef TEST_PERF
t2 = high_resolution_clock::now();
ms_int = duration_cast<milliseconds>(t2 - t1);
std::cout << "Remove blob time: " << ms_int.count() << std::endl;
#endif
p = handler.readBlob(db, rootKey);
assert_internal(!p.first, "Blob present after remove");
}
}
}
int main()
{
std::string path = "/etc/foundationdb/fdb.cluster";
@ -98,5 +166,6 @@ int main()
}
}
testBlobHandler(db);
return 0;
}