Shuo-Jia commented on a change in pull request #757: URL: https://github.com/apache/incubator-pegasus/pull/757#discussion_r654107713
########## 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: so the later, all will use lastest version? https://github.com/apache/incubator-pegasus/pull/757/files#diff-5151d39412bc1d3867a16ceea604fba73fc7019f2291628689157eded0098383R124 ########## 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: why use `latest` version defaulty ########## 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: function `generate_value` just name `generate` ########## 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: I can't find where use `params` ########## 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: Oh,I see, here...https://github.com/apache/incubator-pegasus/pull/757/files/e5b729d628b97e7f9243497e2e5b550548b598fe#diff-df7505b9cb2a2157665b192c6f05acd243fc32926cdb5e7727c457a0da1b3f0bR36 -- 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]
