Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions be/src/olap/fs/fs_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ namespace fs {
namespace fs_util {

BlockManager* block_manager() {
#ifdef BE_TEST
return block_mgr_for_ut();
#else
return ExecEnv::GetInstance()->storage_engine()->block_manager();
#endif
}

BlockManager* block_mgr_for_ut() {
fs::BlockManagerOptions bm_opts;
bm_opts.read_only = false;
static FileBlockManager block_mgr(Env::Default(), std::move(bm_opts));
Expand Down
3 changes: 0 additions & 3 deletions be/src/olap/fs/fs_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ namespace fs_util {
// method for each type(instead of a factory method which require same params)
BlockManager* block_manager();

// For UnitTest.
BlockManager* block_mgr_for_ut();

} // namespace fs_util
} // namespace fs
} // namespace doris
11 changes: 4 additions & 7 deletions be/src/olap/page_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@

namespace doris {

// This should only be used in unit test. 1GB
static StoragePageCache s_ut_cache(1073741824);

StoragePageCache* StoragePageCache::_s_instance = &s_ut_cache;
StoragePageCache* StoragePageCache::_s_instance = nullptr;

void StoragePageCache::create_global_cache(size_t capacity) {
if (_s_instance == &s_ut_cache) {
_s_instance = new StoragePageCache(capacity);
}
DCHECK(_s_instance == nullptr);
static StoragePageCache instance(capacity);
_s_instance = &instance;
}

StoragePageCache::StoragePageCache(size_t capacity) : _cache(new_lru_cache(capacity)) {
Expand Down
5 changes: 0 additions & 5 deletions be/src/olap/storage_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ StorageEngine::StorageEngine(const EngineOptions& options)
_txn_manager(new TxnManager(config::txn_map_shard_size, config::txn_shard_size)),
_rowset_id_generator(new UniqueRowsetIdGenerator(options.backend_uid)),
_memtable_flush_executor(nullptr),
_block_manager(nullptr),
_default_rowset_type(ALPHA_ROWSET),
_heartbeat_flags(nullptr) {
if (_s_instance == nullptr) {
Expand Down Expand Up @@ -181,10 +180,6 @@ Status StorageEngine::_open() {
_memtable_flush_executor.reset(new MemTableFlushExecutor());
_memtable_flush_executor->init(dirs);

fs::BlockManagerOptions bm_opts;
bm_opts.read_only = false;
_block_manager.reset(new fs::FileBlockManager(Env::Default(), std::move(bm_opts)));

_parse_default_rowset_type();

return Status::OK();
Expand Down
3 changes: 0 additions & 3 deletions be/src/olap/storage_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ class StorageEngine {
TabletManager* tablet_manager() { return _tablet_manager.get(); }
TxnManager* txn_manager() { return _txn_manager.get(); }
MemTableFlushExecutor* memtable_flush_executor() { return _memtable_flush_executor.get(); }
fs::BlockManager* block_manager() { return _block_manager.get(); }

bool check_rowset_id_in_unused_rowsets(const RowsetId& rowset_id);

Expand Down Expand Up @@ -336,8 +335,6 @@ class StorageEngine {

std::unique_ptr<MemTableFlushExecutor> _memtable_flush_executor;

std::unique_ptr<fs::BlockManager> _block_manager;

// Used to control the migration from segment_v1 to segment_v2, can be deleted in futrue.
// Type of new loaded data
RowsetTypePB _default_rowset_type;
Expand Down
2 changes: 1 addition & 1 deletion be/test/agent/cgroups_mgr_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CgroupsMgrTest : public testing::Test {
public:
// create a mock cgroup folder
static void SetUpTestCase() {
ASSERT_FALSE(boost::filesystem::exists(_s_cgroup_path));
ASSERT_TRUE(boost::filesystem::remove_all(_s_cgroup_path));
// create a mock cgroup path
ASSERT_TRUE(boost::filesystem::create_directory(_s_cgroup_path));

Expand Down
1 change: 1 addition & 0 deletions be/test/olap/rowset/beta_rowset_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ TEST_F(BetaRowsetTest, BasicFunctionTest) {
} // namespace doris

int main(int argc, char **argv) {
doris::StoragePageCache::create_global_cache(1<<30);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Expand Down
1 change: 1 addition & 0 deletions be/test/olap/rowset/rowset_converter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ TEST_F(RowsetConverterTest, TestConvertBetaRowsetToAlpha) {
} // namespace doris

int main(int argc, char **argv) {
doris::StoragePageCache::create_global_cache(1<<30);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
3 changes: 2 additions & 1 deletion be/test/olap/rowset/segment_v2/bitmap_index_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void write_index_file(std::string& filename, const void* values,
{
std::unique_ptr<fs::WritableBlock> wblock;
fs::CreateBlockOptions opts({ filename });
ASSERT_TRUE(fs::fs_util::block_mgr_for_ut()->create_block(opts, &wblock).ok());
ASSERT_TRUE(fs::fs_util::block_manager()->create_block(opts, &wblock).ok());

std::unique_ptr<BitmapIndexWriter> writer;
BitmapIndexWriter::create(type_info, &writer);
Expand Down Expand Up @@ -238,6 +238,7 @@ TEST_F(BitmapIndexTest, test_null) {
}

int main(int argc, char** argv) {
doris::StoragePageCache::create_global_cache(1<<30);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void write_bloom_filter_index_file(const std::string& file_name, const void* val
{
std::unique_ptr<fs::WritableBlock> wblock;
fs::CreateBlockOptions opts({ fname });
Status st = fs::fs_util::block_mgr_for_ut()->create_block(opts, &wblock);
Status st = fs::fs_util::block_manager()->create_block(opts, &wblock);
ASSERT_TRUE(st.ok()) << st.to_string();

std::unique_ptr<BloomFilterIndexWriter> bloom_filter_index_writer;
Expand Down Expand Up @@ -285,6 +285,7 @@ TEST_F(BloomFilterIndexReaderWriterTest, test_decimal) {
}

int main(int argc, char** argv) {
doris::StoragePageCache::create_global_cache(1<<30);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Expand Down
5 changes: 3 additions & 2 deletions be/test/olap/rowset/segment_v2/column_reader_writer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void test_nullable_data(uint8_t* src_data, uint8_t* src_is_null, int num_rows, s
{
std::unique_ptr<fs::WritableBlock> wblock;
fs::CreateBlockOptions opts({ fname });
Status st = fs::fs_util::block_mgr_for_ut()->create_block(opts, &wblock);
Status st = fs::fs_util::block_manager()->create_block(opts, &wblock);
ASSERT_TRUE(st.ok()) << st.get_error_msg();

ColumnWriterOptions writer_opts;
Expand Down Expand Up @@ -131,7 +131,7 @@ void test_nullable_data(uint8_t* src_data, uint8_t* src_is_null, int num_rows, s
st = reader->new_iterator(&iter);
ASSERT_TRUE(st.ok());
std::unique_ptr<fs::ReadableBlock> rblock;
fs::BlockManager* block_manager = fs::fs_util::block_mgr_for_ut();
fs::BlockManager* block_manager = fs::fs_util::block_manager();
block_manager->open_block(fname, &rblock);

ASSERT_TRUE(st.ok());
Expand Down Expand Up @@ -445,6 +445,7 @@ TEST_F(ColumnReaderWriterTest, test_default_value) {
} // namespace doris

int main(int argc, char** argv) {
doris::StoragePageCache::create_global_cache(1<<30);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Expand Down
4 changes: 3 additions & 1 deletion be/test/olap/rowset/segment_v2/ordinal_page_index_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "common/logging.h"
#include "env/env.h"
#include "olap/fs/fs_util.h"
#include "olap/page_cache.h"
#include "util/file_utils.h"

namespace doris {
Expand Down Expand Up @@ -61,7 +62,7 @@ TEST_F(OrdinalPageIndexTest, normal) {
{
std::unique_ptr<fs::WritableBlock> wblock;
fs::CreateBlockOptions opts({ filename });
ASSERT_TRUE(fs::fs_util::block_mgr_for_ut()->create_block(opts, &wblock).ok());
ASSERT_TRUE(fs::fs_util::block_manager()->create_block(opts, &wblock).ok());

ASSERT_TRUE(builder.finish(wblock.get(), &index_meta).ok());
ASSERT_EQ(ORDINAL_INDEX, index_meta.type());
Expand Down Expand Up @@ -157,6 +158,7 @@ TEST_F(OrdinalPageIndexTest, one_data_page) {
}

int main(int argc, char** argv) {
doris::StoragePageCache::create_global_cache(1<<30);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Expand Down
7 changes: 4 additions & 3 deletions be/test/olap/rowset/segment_v2/segment_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class SegmentReaderWriterTest : public ::testing::Test {
string filename = strings::Substitute("$0/seg_$1.dat", kSegmentDir, seg_id++);
std::unique_ptr<fs::WritableBlock> wblock;
fs::CreateBlockOptions block_opts({ filename });
Status st = fs::fs_util::block_mgr_for_ut()->create_block(block_opts, &wblock);
Status st = fs::fs_util::block_manager()->create_block(block_opts, &wblock);
ASSERT_TRUE(st.ok());
SegmentWriter writer(wblock.get(), 0, &build_schema, opts);
st = writer.init(10);
Expand Down Expand Up @@ -609,7 +609,7 @@ TEST_F(SegmentReaderWriterTest, estimate_segment_size) {
std::string fname = dname + "/int_case";
std::unique_ptr<fs::WritableBlock> wblock;
fs::CreateBlockOptions wblock_opts({ fname });
Status st = fs::fs_util::block_mgr_for_ut()->create_block(wblock_opts, &wblock);
Status st = fs::fs_util::block_manager()->create_block(wblock_opts, &wblock);
ASSERT_TRUE(st.ok());
SegmentWriter writer(wblock.get(), 0, tablet_schema.get(), opts);
st = writer.init(10);
Expand Down Expand Up @@ -775,7 +775,7 @@ TEST_F(SegmentReaderWriterTest, TestStringDict) {
std::string fname = dname + "/string_case";
std::unique_ptr<fs::WritableBlock> wblock;
fs::CreateBlockOptions wblock_opts({ fname });
Status st = fs::fs_util::block_mgr_for_ut()->create_block(wblock_opts, &wblock);
Status st = fs::fs_util::block_manager()->create_block(wblock_opts, &wblock);
ASSERT_TRUE(st.ok());
SegmentWriter writer(wblock.get(), 0, tablet_schema.get(), opts);
st = writer.init(10);
Expand Down Expand Up @@ -1139,6 +1139,7 @@ TEST_F(SegmentReaderWriterTest, TestBloomFilterIndexUniqueModel) {
}

int main(int argc, char** argv) {
doris::StoragePageCache::create_global_cache(1<<30);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
6 changes: 4 additions & 2 deletions be/test/olap/rowset/segment_v2/zone_map_index_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "env/env.h"
#include "olap/fs/block_manager.h"
#include "olap/fs/fs_util.h"
#include "olap/page_cache.h"
#include "olap/rowset/segment_v2/zone_map_index.h"
#include "olap/tablet_schema_helper.h"
#include "util/file_utils.h"
Expand Down Expand Up @@ -72,7 +73,7 @@ class ColumnZoneMapTest : public testing::Test {
{
std::unique_ptr<fs::WritableBlock> wblock;
fs::CreateBlockOptions opts({ filename });
ASSERT_TRUE(fs::fs_util::block_mgr_for_ut()->create_block(opts, &wblock).ok());
ASSERT_TRUE(fs::fs_util::block_manager()->create_block(opts, &wblock).ok());
ASSERT_TRUE(builder.finish(wblock.get(), &index_meta).ok());
ASSERT_EQ(ZONE_MAP_INDEX, index_meta.type());
ASSERT_TRUE(wblock->close().ok());
Expand Down Expand Up @@ -125,7 +126,7 @@ TEST_F(ColumnZoneMapTest, NormalTestIntPage) {
{
std::unique_ptr<fs::WritableBlock> wblock;
fs::CreateBlockOptions opts({ filename });
ASSERT_TRUE(fs::fs_util::block_mgr_for_ut()->create_block(opts, &wblock).ok());
ASSERT_TRUE(fs::fs_util::block_manager()->create_block(opts, &wblock).ok());
ASSERT_TRUE(builder.finish(wblock.get(), &index_meta).ok());
ASSERT_EQ(ZONE_MAP_INDEX, index_meta.type());
ASSERT_TRUE(wblock->close().ok());
Expand Down Expand Up @@ -173,6 +174,7 @@ TEST_F(ColumnZoneMapTest, NormalTestCharPage) {
}

int main(int argc, char** argv) {
doris::StoragePageCache::create_global_cache(1<<30);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}