You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2020/03/01 02:39:23 UTC

[GitHub] [incubator-doris] morningman commented on a change in pull request #2983: Add block layer to storage-engine

morningman commented on a change in pull request #2983: Add block layer to storage-engine
URL: https://github.com/apache/incubator-doris/pull/2983#discussion_r386032512
 
 

 ##########
 File path: be/src/olap/fs/file_block_manager.h
 ##########
 @@ -0,0 +1,119 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <cstdint>
+#include <memory>
+#include <string>
+#include <unordered_set>
+#include <vector>
+
+#include "common/status.h"
+#include "olap/fs/block_manager.h"
+
+namespace doris {
+
+class BlockId;
+class Env;
+class MemTracker;
+class RandomAccessFile;
+
+namespace fs {
+namespace internal {
+
+class FileReadableBlock;
+class FileWritableBlock;
+struct BlockManagerMetrics;
+
+} // namespace internal
+
+// TODO(lingbin): When we create a batch of blocks(blocks are created one by one),
+// eg, when we do a compaction,  multiple files will be generated in sequence.
+// For this scenario, we should have a mechanism that can give the Operating System
+// more opportunities to perform IO merge.
+
+// A file-backed block storage implementation.
+//
+// This is a naive block implementation which maps each block to its own
+// file on disk.
+//
+// The block manager can take advantage of multiple filesystem paths.
+//
+// When creating blocks, the block manager will place blocks based on the
+// provided CreateBlockOptions.
+
+// The file-backed block manager.
+class FileBlockManager : public BlockManager {
+public:
+    // Note: all objects passed as pointers should remain alive for the lifetime
+    // of the block manager.
+    FileBlockManager(Env* env, BlockManagerOptions opts);
+    virtual ~FileBlockManager();
+
+    Status open() override;
+
+    Status create_block(const CreateBlockOptions& opts,
+                        std::unique_ptr<WritableBlock>* block) override;
+    Status open_block(const std::string& path, std::unique_ptr<ReadableBlock>* block) override;
+
+    Status get_all_block_ids(std::vector<BlockId>* block_ids) override {
+        // TODO(lingbin): to be implemented after we assign each block an id
+        return Status::OK();
+    };
+
+private:
+    friend class internal::FileReadableBlock;
+    friend class internal::FileWritableBlock;
+
+    // Deletes an existing block, allowing its space to be reclaimed by the
+    // filesystem. The change is immediately made durable.
+    //
+    // Blocks may be deleted while they are open for reading or writing;
+    // the actual deletion will take place after the last open reader or
+    // writer is closed.
+    Status _delete_block(const std::string& path);
+
+    // Synchronizes the metadata for a block with the given location.
+    Status _sync_metadata(const std::string& path);
+
+    Env* env() const { return _env; }
 
 Review comment:
   Why there is a private env() method?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org