2020
2121#include " gtest/gtest.h"
2222#include " paimon/defs.h"
23+ #include " paimon/executor.h"
24+ #include " paimon/memory/memory_pool.h"
2325#include " paimon/predicate/predicate_builder.h"
2426#include " paimon/status.h"
2527#include " paimon/testing/mock/mock_file_system.h"
2628#include " paimon/testing/utils/testharness.h"
2729
2830namespace paimon ::test {
29- TEST (ReadContextTest, TestSimple ) {
31+ TEST (ReadContextTest, TestDefaultValue ) {
3032 ReadContextBuilder builder (" table_root_path" );
3133 ASSERT_OK_AND_ASSIGN (auto ctx, builder.Finish ());
3234 ASSERT_EQ (ctx->GetPath (), " table_root_path" );
@@ -50,6 +52,11 @@ TEST(ReadContextTest, TestSimple) {
5052
5153TEST (ReadContextTest, TestSetContent) {
5254 ReadContextBuilder builder (" table_root_path" );
55+ std::shared_ptr<MemoryPool> memory_pool = GetDefaultPool ();
56+ std::shared_ptr<Executor> executor = CreateDefaultExecutor ();
57+ CacheConfig cache_config (/* buffer_size_limit=*/ 1024 , /* range_size_limit=*/ 512 ,
58+ /* hole_size_limit=*/ 128 , /* pre_buffer_limit=*/ 2048 );
59+
5360 builder.AddOption (" key" , " value" );
5461 builder.SetReadSchema ({" f1" , " f2" });
5562 builder.SetReadFieldIds ({0 , 1 });
@@ -63,7 +70,11 @@ TEST(ReadContextTest, TestSetContent) {
6370 builder.SetPrefetchMaxParallelNum (6 );
6471 builder.EnableMultiThreadRowToBatch (true );
6572 builder.SetRowToBatchThreadNumber (9 );
73+ builder.WithMemoryPool (memory_pool);
74+ builder.WithExecutor (executor);
75+ builder.SetTableSchema (" table-schema-json" );
6676 builder.WithBranch (" rt" );
77+ builder.WithCacheConfig (cache_config);
6778 builder.WithFileSystemSchemeToIdentifierMap ({{" file" , " local" }});
6879 auto fs = std::make_shared<MockFileSystem>();
6980 builder.WithFileSystem (fs);
@@ -83,12 +94,31 @@ TEST(ReadContextTest, TestSetContent) {
8394 ASSERT_EQ (6 , ctx->GetPrefetchMaxParallelNum ());
8495 ASSERT_TRUE (ctx->EnableMultiThreadRowToBatch ());
8596 ASSERT_EQ (9 , ctx->GetRowToBatchThreadNumber ());
97+ ASSERT_EQ (memory_pool, ctx->GetMemoryPool ());
98+ ASSERT_EQ (executor, ctx->GetExecutor ());
99+ ASSERT_TRUE (ctx->GetSpecificTableSchema ().has_value ());
100+ ASSERT_EQ (" table-schema-json" , ctx->GetSpecificTableSchema ().value ());
86101 ASSERT_EQ (" rt" , ctx->GetBranch ());
102+ ASSERT_EQ (1024U , ctx->GetCacheConfig ().GetBufferSizeLimit ());
103+ ASSERT_EQ (512U , ctx->GetCacheConfig ().GetRangeSizeLimit ());
104+ ASSERT_EQ (128U , ctx->GetCacheConfig ().GetHoleSizeLimit ());
105+ ASSERT_EQ (2048U , ctx->GetCacheConfig ().GetPreBufferLimit ());
87106 std::map<std::string, std::string> expected_fs_map = {{" file" , " local" }};
88107 ASSERT_EQ (expected_fs_map, ctx->GetFileSystemSchemeToIdentifierMap ());
89108 std::map<std::string, std::string> expected_options = {{" key" , " value" }};
90109 ASSERT_EQ (expected_options, ctx->GetOptions ());
91110 ASSERT_EQ (ctx->GetSpecificFileSystem (), fs);
92111}
93112
113+ TEST (ReadContextTest, TestSetOptionsOverridesAddedOptions) {
114+ ReadContextBuilder builder (" table_root_path" );
115+ builder.AddOption (" old" , " value" );
116+ builder.SetOptions ({{" key1" , " value1" }, {" key2" , " value2" }});
117+
118+ ASSERT_OK_AND_ASSIGN (auto ctx, builder.Finish ());
119+
120+ std::map<std::string, std::string> expected_options = {{" key1" , " value1" }, {" key2" , " value2" }};
121+ ASSERT_EQ (expected_options, ctx->GetOptions ());
122+ }
123+
94124} // namespace paimon::test
0 commit comments