chaoyli commented on a change in pull request #454: Refactor Tablet and 
TabletMeta
URL: https://github.com/apache/incubator-doris/pull/454#discussion_r243510254
 
 

 ##########
 File path: be/src/olap/tablet_meta.cpp
 ##########
 @@ -17,968 +17,197 @@
 
 #include "olap/tablet_meta.h"
 
-#include <algorithm>
-#include <fstream>
-#include <queue>
-#include <sstream>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "olap/field.h"
-#include "olap/wrapper_field.h"
-#include "olap/file_helper.h"
-#include "olap/utils.h"
-
-using google::protobuf::RepeatedPtrField;
-using std::ifstream;
-using std::ios;
-using std::list;
-using std::make_pair;
-using std::ofstream;
-using std::queue;
-using std::sort;
-using std::string;
-using std::stringstream;
-using std::unordered_map;
-using std::vector;
-
 namespace doris {
-// related static functions of version graph
-
-// Construct version graph(using adjacency list) from header's information.
-static OLAPStatus construct_version_graph(
-        const RepeatedPtrField<PDelta>& versions_in_header,
-        vector<Vertex>* version_graph,
-        unordered_map<int, int>* vertex_helper_map);
-
-// Clear version graph and vertex_helper_map, release memory hold by 
version_graph.
-static OLAPStatus clear_version_graph(vector<Vertex>* version_graph,
-                                  unordered_map<int, int>* vertex_helper_map);
-
-// Add version to graph, it is called near the end of add_version
-static OLAPStatus add_version_to_graph(const Version& version,
-                                   vector<Vertex>* version_graph,
-                                   unordered_map<int, int>* vertex_helper_map);
-
-// Delete version from graph, it is called near the end of delete_version
-static OLAPStatus delete_version_from_graph(
-        const RepeatedPtrField<PDelta>& versions_in_header,
-        const Version& version,
-        vector<Vertex>* version_graph,
-        unordered_map<int, int>* vertex_helper_map);
 
-// Add vertex to graph, if vertex already exists, still return SUCCESS.
-static OLAPStatus add_vertex_to_graph(int vertex_value,
-                                  vector<Vertex>* version_graph,
-                                  unordered_map<int, int>* vertex_helper_map);
-
-TabletMeta::~TabletMeta() {
-    // Release memory of version graph.
-    clear_version_graph(&_version_graph, &_vertex_helper_map);
-    Clear();
+TabletMeta::TabletMeta(DataDir* data_dir) {
+    _data_dir = data_dir;
 }
 
-OLAPStatus TabletMeta::init() {
-    clear_version_graph(&_version_graph, &_vertex_helper_map);
-    if (construct_version_graph(delta(),
-                                &_version_graph,
-                                &_vertex_helper_map) != OLAP_SUCCESS) {
-        OLAP_LOG_WARNING("fail to construct version graph.");
-        return OLAP_ERR_OTHER_ERROR;
-    }
-    if (_file_name == "") {
-        stringstream file_stream;
-        file_stream << tablet_id() << ".hdr";
-        _file_name = file_stream.str();
-    }
-    return OLAP_SUCCESS;
-}
+NewStatus TabletMeta::serialize(string* meta_binary) {
+    std::lock_guard<std::mutex> lock(_mutex);
+    return serialize_unlock(meta_binary);
+};
 
-OLAPStatus TabletMeta::load_and_init() {
-    // check the tablet_path is not empty
-    if (_file_name == "") {
-        LOG(WARNING) << "file_path is empty for header";
-        return OLAP_ERR_DIR_NOT_EXIST;
-    }
-
-    FileHeader<OLAPHeaderMessage> file_header;
-    FileHandler file_handler;
+NewStatus TabletMeta::serialize_unlock(string* meta_binary) {
 
 Review comment:
   Rocksdb and kudu all use unlock, so I adopt this name.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@doris.apache.org
For additional commands, e-mail: dev-h...@doris.apache.org

Reply via email to