Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
Lchangliang committed Jan 10, 2024
1 parent 80442c5 commit 217fe6e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
27 changes: 19 additions & 8 deletions be/src/olap/rowset/rowset_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include "olap/rowset/rowset_meta.h"

#include <type_traits>

#include "common/logging.h"
#include "google/protobuf/util/message_differencer.h"
#include "io/fs/local_file_system.h"
Expand All @@ -25,6 +27,7 @@
#include "olap/lru_cache.h"
#include "olap/olap_common.h"
#include "olap/storage_policy.h"
#include "olap/tablet_fwd.h"
#include "olap/tablet_schema.h"
#include "olap/tablet_schema_cache.h"

Expand Down Expand Up @@ -53,7 +56,9 @@ bool RowsetMeta::init(const RowsetMeta* rowset_meta) {

bool RowsetMeta::init_from_pb(const RowsetMetaPB& rowset_meta_pb) {
if (rowset_meta_pb.has_tablet_schema()) {
DCHECK(_handle == nullptr);
if (_handle) {
TabletSchemaCache::instance()->release(_handle);
}
auto pair = TabletSchemaCache::instance()->insert(
rowset_meta_pb.tablet_schema().SerializeAsString());
_handle = pair.first;
Expand Down Expand Up @@ -121,24 +126,30 @@ RowsetMetaPB RowsetMeta::get_rowset_pb() {
}

void RowsetMeta::set_tablet_schema(const TabletSchemaSPtr& tablet_schema) {
DCHECK(_handle == nullptr);
if (_handle) {
TabletSchemaCache::instance()->release(_handle);
}
auto pair = TabletSchemaCache::instance()->insert(tablet_schema->to_key());
_handle = pair.first;
_schema = pair.second;
}

void RowsetMeta::set_tablet_schema(const TabletSchemaPB& tablet_schema) {
if (_handle) {
TabletSchemaCache::instance()->release(_handle);
}
auto pair = TabletSchemaCache::instance()->insert(tablet_schema.SerializeAsString());
_handle = pair.first;
_schema = pair.second;
}

bool RowsetMeta::_deserialize_from_pb(const std::string& value) {
RowsetMetaPB rowset_meta_pb;
if (!rowset_meta_pb.ParseFromString(value)) {
return false;
}
if (rowset_meta_pb.has_tablet_schema()) {
DCHECK(_handle == nullptr);
auto pair = TabletSchemaCache::instance()->insert(
rowset_meta_pb.tablet_schema().SerializeAsString());
_handle = pair.first;
_schema = pair.second;
rowset_meta_pb.clear_tablet_schema();
set_tablet_schema(rowset_meta_pb.tablet_schema());
}
_rowset_meta_pb = rowset_meta_pb;
return true;
Expand Down
1 change: 1 addition & 0 deletions be/src/olap/rowset/rowset_meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ class RowsetMeta {
int64_t newest_write_timestamp() const { return _rowset_meta_pb.newest_write_timestamp(); }

void set_tablet_schema(const TabletSchemaSPtr& tablet_schema);
void set_tablet_schema(const TabletSchemaPB& tablet_schema);

const TabletSchemaSPtr& tablet_schema() { return _schema; }

Expand Down

0 comments on commit 217fe6e

Please sign in to comment.