levy5307 commented on a change in pull request #757:
URL: https://github.com/apache/incubator-pegasus/pull/757#discussion_r654117325
##########
File path: src/server/rocksdb_wrapper.cpp
##########
@@ -119,8 +121,8 @@ int rocksdb_wrapper::write_batch_put_ctx(const
db_write_context &ctx,
rocksdb::Slice skey = utils::to_rocksdb_slice(raw_key);
rocksdb::SliceParts skey_parts(&skey, 1);
- rocksdb::SliceParts svalue = _value_generator->generate_value(
- _pegasus_data_version, value, db_expire_ts(expire_sec), new_timetag);
+ rocksdb::SliceParts svalue =
+ _value_generator->generate_value(value, db_expire_ts(expire_sec),
new_timetag);
Review comment:
I don't want to change the interface in value_generator in this pull
request
##########
File path: src/base/value_generator.cpp
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+#include "value_generator.h"
+#include "value_schema_manager.h"
+#include <dsn/utility/smart_pointers.h>
+
+namespace pegasus {
+/// A higher level utility for generating value with given version.
+rocksdb::SliceParts
+value_generator::generate_value(dsn::string_view user_data, uint32_t
expire_ts, uint64_t timetag)
+{
+ value_params params(_write_buf, _write_slices);
Review comment:
It is used by value_schema::generate_value
##########
File path: src/base/value_generator.cpp
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+#include "value_generator.h"
+#include "value_schema_manager.h"
+#include <dsn/utility/smart_pointers.h>
+
+namespace pegasus {
+/// A higher level utility for generating value with given version.
+rocksdb::SliceParts
+value_generator::generate_value(dsn::string_view user_data, uint32_t
expire_ts, uint64_t timetag)
+{
+ value_params params(_write_buf, _write_slices);
+ params.fields[value_field_type::EXPIRE_TIMESTAMP] =
+ dsn::make_unique<expire_timestamp_field>(expire_ts);
+ params.fields[value_field_type::TIME_TAG] =
dsn::make_unique<time_tag_field>(timetag);
+ params.fields[value_field_type::USER_DATA] =
dsn::make_unique<user_data_field>(user_data);
+
+ auto schema = value_schema_manager::instance().get_latest_value_schema();
Review comment:
We don't want to generate old value if a new version is developped
##########
File path: src/base/value_generator.h
##########
@@ -0,0 +1,51 @@
+/*
+ * 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 <rocksdb/slice.h>
+#include <dsn/utility/string_view.h>
+
+namespace pegasus {
+/**
+ * Helper class for generating value.
+ *
+ * NOTES:
+ * 1. The instance of value_generator must be alive while the returned
SliceParts is.
+ * The data of user_data must be alive while the returned SliceParts is,
because
+ * we do not copy it. And the returned SliceParts is only valid before the
next invoking of
+ * generate_value().
+ * 2. Only the latest version of data is generated in this function, because
we want to make
+ * data with older version disappear gradually.
Review comment:
yes
##########
File path: src/server/rocksdb_wrapper.cpp
##########
@@ -119,8 +121,8 @@ int rocksdb_wrapper::write_batch_put_ctx(const
db_write_context &ctx,
rocksdb::Slice skey = utils::to_rocksdb_slice(raw_key);
rocksdb::SliceParts skey_parts(&skey, 1);
- rocksdb::SliceParts svalue = _value_generator->generate_value(
- _pegasus_data_version, value, db_expire_ts(expire_sec), new_timetag);
+ rocksdb::SliceParts svalue =
+ _value_generator->generate_value(value, db_expire_ts(expire_sec),
new_timetag);
Review comment:
I don't want to change the interface in value_generator in this pull
request. The only thing I want to do is Rewrite the implementation of
value_generator.
--
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]