From 85f0c04b1decee5313868ff4ec5605441c4966c1 Mon Sep 17 00:00:00 2001 From: yangliu Date: Sat, 7 May 2022 19:05:20 +0800 Subject: [PATCH 1/8] add kv datashare code Signed-off-by: yangliu --- bundle.json | 3 +- .../include/kvstore_datashare_result_set.h | 53 ++ .../include/kvstore_predicates.h | 78 +++ .../src/kvstore_datashare_native.cpp | 59 ++ .../src/kvstore_datashare_result_set.cpp | 128 +++++ .../src/kvstore_predicates.cpp | 507 ++++++++++++++++++ interfaces/innerkits/distributeddata/BUILD.gn | 7 + .../include/kvstore_datashare_native.h | 43 ++ 8 files changed, 877 insertions(+), 1 deletion(-) create mode 100644 frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_datashare_result_set.h create mode 100644 frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h create mode 100644 frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_datashare_native.cpp create mode 100644 frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_datashare_result_set.cpp create mode 100644 frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_predicates.cpp create mode 100644 interfaces/innerkits/distributeddata/include/kvstore_datashare_native.h diff --git a/bundle.json b/bundle.json index 9ed5012f5..8a9cf50d6 100644 --- a/bundle.json +++ b/bundle.json @@ -109,7 +109,8 @@ "visibility.h", "data_query.h", "device_status_change_listener.h", - "store_errno.h" + "store_errno.h", + "kvstore_datashare_native.h" ], "header_base": "//foundation/distributeddatamgr/distributeddatamgr/interfaces/innerkits/distributeddata/include" } diff --git a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_datashare_result_set.h b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_datashare_result_set.h new file mode 100644 index 000000000..24e373e54 --- /dev/null +++ b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_datashare_result_set.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed 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. + */ + +#ifndef KVSTORE_DATASHARE_RESULT_SET_H +#define KVSTORE_DATASHARE_RESULT_SET_H + +#include "datashare_abstract_result_set.h" +#include "kvstore_result_set.h" +#include "single_kvstore.h" +#include "datashare_errno.h" + +namespace OHOS { +namespace DistributedKv { +using namespace DataShare; +class KvStoreDataShareResultSet : public DataShareAbstractResultSet +{ +public: + KvStoreDataShareResultSet(std::shared_ptr kvResultSet); + + ~KvStoreDataShareResultSet() = default; + + int GetRowCount(int &count) override; + + int GetAllColumnOrKeyName(std::vector &columnOrKeyNames) override; + + bool OnGo(int oldRowIndex, int newRowIndex, DataShareBlockWriter &writer) override; + +private: + int Count(); + + bool FillBlock(int startRowIndex, DataShareBlockWriter &writer); + + static constexpr int32_t INVALID_COUNT = -1; + + int32_t resultRowCount {INVALID_COUNT}; + + std::shared_ptr kvResultSet_; +}; +} // namespace DistributedKv +} // namespace OHOS +#endif // KVSTORE_DATASHARE_RESULT_SET_H \ No newline at end of file diff --git a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h new file mode 100644 index 000000000..5aaec1d5c --- /dev/null +++ b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed 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. + */ + + +#ifndef KVSTORE_PREDICATE_H +#define KVSTORE_PREDICATE_H + +#include +#include "data_query.h" +#include "types.h" +#include "datashare_predicates.h" + +namespace OHOS { +namespace DistributedKv { +using namespace DataShare; + +class KvStorePredicate +{ +public: + struct Context { + int intValue; + int64_t longValue; + double doubleValue; + bool boolValue; + std::string field; + std::string stringValue; + std::vector intList; + std::vector longList; + std::vector doubleList; + std::vector stringList; + DataSharePredicatesObjectType innerType; + }; + KvStorePredicate() = default; + ~KvStorePredicate() = default; + Status ToQuery(DataQuery &query, DataSharePredicates predicates); +private: + Status EqualTo(const OperationItem &oper, DataQuery &query); + Status NotEqualTo(const OperationItem &oper, DataQuery &query); + Status GreaterThan(const OperationItem &oper, DataQuery &query); + Status LessThan(const OperationItem &oper, DataQuery &query); + Status GreaterThanOrEqualTo(const OperationItem &oper, DataQuery &query); + Status LessThanOrEqualTo(const OperationItem &oper, DataQuery &query); + Status And(const OperationItem &oper, DataQuery &query); + Status Or(const OperationItem &oper, DataQuery &query); + Status IsNull(const OperationItem &oper, DataQuery &query); + Status IsNotNull(const OperationItem &oper, DataQuery &query); + Status In(const OperationItem &oper, DataQuery &query); + Status NotIn(const OperationItem &oper, DataQuery &query); + Status Like(const OperationItem &oper, DataQuery &query); + Status Unlike(const OperationItem &oper, DataQuery &query); + Status OrderByAsc(const OperationItem &oper, DataQuery &query); + Status OrderByDesc(const OperationItem &oper, DataQuery &query); + Status Limit(const OperationItem &oper, DataQuery &query); + Status InKeys(const OperationItem &oper, DataQuery &query); + Status SetSuggestIndex(const OperationItem &oper, DataQuery &query); + Status KeyPrefix(const OperationItem &oper, DataQuery &query); + Status GetContext(const OperationItem &oper,Context &context); + using QueryHandler = Status (KvStorePredicate::*)(const OperationItem &, DataQuery &); + static const std::map HANDLERS; + //DataSharePredicates predicates_; +}; +} // namespace DistributedKv +} // namespace OHOS +#endif // KVSTORE_PREDICATE_H + + diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_datashare_native.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_datashare_native.cpp new file mode 100644 index 000000000..c54f13d5c --- /dev/null +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_datashare_native.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed 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. + */ + +#define LOG_TAG "KvStoreDataShareNative" + + +#include "kvstore_datashare_result_set.h" +#include "kvstore_predicates.h" +#include "kvstore_datashare_native.h" +#include "log_print.h" +#include "data_query.h" + +namespace OHOS { +namespace DistributedKv { + +KvStoreDataShareNative::KvStoreDataShareNative(std::shared_ptr kvStoreClient) + :kvStoreClient_(kvStoreClient) {}; + +std::shared_ptr KvStoreDataShareNative::GetDataShareResult(const DataSharePredicates &predicate) +{ + if(kvStoreClient_ == nullptr) + { + ZLOGE("kvStoreClient_ nullptr"); + return nullptr; + } + + DataQuery query; + auto kvPredicates = std::make_shared(); + Status status = kvPredicates->ToQuery(query, predicate); + if(status != Status::SUCCESS) + { + ZLOGE("ToQuery failed: %{public}d", status); + return nullptr; + } + + std::shared_ptr resultSet; + status = kvStoreClient_->GetResultSetWithQuery(query, resultSet); + if (status != Status::SUCCESS) + { + ZLOGE("GetResultSetWithQuery failed: %{public}d", status); + return nullptr; + } + + return std::make_shared(resultSet); +} +} // namespace DistributedKv +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_datashare_result_set.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_datashare_result_set.cpp new file mode 100644 index 000000000..f3c85eace --- /dev/null +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_datashare_result_set.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed 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. + */ + +#define LOG_TAG "KvStoreDataShareResultSet" + +#include "constant.h" +#include "log_print.h" +#include "kvstore_datashare_result_set.h" + +namespace OHOS { +namespace DistributedKv { +KvStoreDataShareResultSet::KvStoreDataShareResultSet(std::shared_ptr kvResultSet) + :kvResultSet_(kvResultSet) {}; + +int KvStoreDataShareResultSet::GetRowCount(int &count) +{ + count = Count(); + return count == INVALID_COUNT ? E_ERROR : E_OK; +} + +int KvStoreDataShareResultSet::GetAllColumnOrKeyName(std::vector &columnOrKeyNames) +{ + columnOrKeyNames.clear(); + columnOrKeyNames.emplace_back("key"); + columnOrKeyNames.emplace_back("value"); + return E_OK; +} + +bool KvStoreDataShareResultSet::FillBlock(int startRowIndex, DataShareBlockWriter &writer) +{ + if (kvResultSet_ == nullptr) + { + ZLOGE("kvResultSet_ nullptr"); + return false; + } + + bool isMoved = kvResultSet_->MoveToPosition(startRowIndex); + if (!isMoved) + { + ZLOGE("MoveToPosition failed"); + return false; + } + + Entry entry; + Status status = kvResultSet_->GetEntry(entry); + if (status != Status::SUCCESS) + { + ZLOGE("GetEntry failed %{public}d", status); + return false; + } + + int clearStatus = writer.Clear(); + if(clearStatus != E_OK){ + ZLOGE("clear writer failed: %{public}d", clearStatus); + return false; + } + + if ((entry.key.Size() + entry.value.Size()) > (writer.Size() - writer.GetUsedBytes())) + { + ZLOGE("not enought memory; entry size: %{public}d, writer size: %{public}d", + entry.key.Size() + entry.value.Size(), writer.Size() - writer.GetUsedBytes()); + return false; + } + + int keyStatus = writer.WriteBlob((uint32_t)startRowIndex, 0, &entry.key.Data(), entry.key.Size()); + if(keyStatus != E_OK) + { + ZLOGE("WriteBlob key error: %{public}d", keyStatus); + return false; + } + + int valueStatus = writer.WriteBlob((uint32_t)startRowIndex, 1, &entry.value.Data(), entry.value.Size()); + if(valueStatus != E_OK) + { + ZLOGE("WriteBlob value error: %{public}d", valueStatus); + return false; + } + return true; +} + +int KvStoreDataShareResultSet::Count() +{ + if (kvResultSet_ == nullptr) + { + ZLOGE("kvResultSet_ nullptr"); + return INVALID_COUNT; + } + if (resultRowCount != INVALID_COUNT) + { + return resultRowCount; + } + int count = kvResultSet_->GetCount(); + if (count < 0) + { + ZLOGE("kvResultSet count invalid: %{public}d", count); + return INVALID_COUNT; + } + resultRowCount = count; + return count; +} + +bool KvStoreDataShareResultSet::OnGo(int oldRowIndex, int newRowIndex, DataShareBlockWriter &writer) +{ + if (writer == nullptr) + { + ZLOGE("pointer writer is nullptr"); + return false; + } + if (newRowIndex >= Count()) { + ZLOGE("newRowIndex out of line: %{public}d", newRowIndex); + return false; + } + return FillBlock(newRowIndex, writer); +} +} // namespace DistributedKv +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_predicates.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_predicates.cpp new file mode 100644 index 000000000..8cb87f0c7 --- /dev/null +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_predicates.cpp @@ -0,0 +1,507 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed 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. + */ + +#define LOG_TAG "KvStorePredicate" + +#include "kvstore_predicates.h" +#include "log_print.h" +#include "datashare_errno.h" + +namespace OHOS { +namespace DistributedKv { + +const std::map KvStorePredicate::HANDLERS = { + {EQUAL_TO, &KvStorePredicate::EqualTo}, + {NOT_EQUAL_TO, &KvStorePredicate::NotEqualTo}, + {GREATER_THAN, &KvStorePredicate::GreaterThan}, + {LESS_THAN, &KvStorePredicate::LessThan}, + {GREATER_THAN_OR_EQUAL_TO, &KvStorePredicate::GreaterThanOrEqualTo}, + {LESS_THAN_OR_EQUAL_TO, &KvStorePredicate::LessThanOrEqualTo}, + {AND, &KvStorePredicate::And}, + {OR, &KvStorePredicate::Or}, + {IS_NULL, &KvStorePredicate::IsNull}, + {IS_NOT_NULL, &KvStorePredicate::IsNotNull}, + {IN, &KvStorePredicate::In}, + {NOT_IN, &KvStorePredicate::NotIn}, + {LIKE, &KvStorePredicate::Like}, + {UNLIKE, &KvStorePredicate::Unlike}, + {ORDER_BY_ASC, &KvStorePredicate::OrderByAsc}, + {ORDER_BY_DESC, &KvStorePredicate::OrderByDesc}, + {LIMIT, &KvStorePredicate::Limit}, + {IN_KEY, &KvStorePredicate::InKeys}, + {SET_SUGGEST_INDEX, &KvStorePredicate::SetSuggestIndex}, + {KEY_PREFIX, &KvStorePredicate::KeyPrefix} +}; + +Status KvStorePredicate::GetContext(const OperationItem &oper,Context &context) +{ + int status = oper.para1.GetString(context.field); + if(status != E_OK){ + ZLOGE("Get context.field failed: %{public}d", status); + return Status::ERROR; + } + + auto innerType = oper.para2.GetType(); + switch(innerType) + { + case DataSharePredicatesObjectType::TYPE_INT: { + int status = oper.para2.GetInt(context.intValue); + return status != E_OK ? Status::ERROR : Status::SUCCESS; + } + case DataSharePredicatesObjectType::TYPE_LONG: { + int status = oper.para2.GetLong(context.longValue); + return status != E_OK ? Status::ERROR : Status::SUCCESS; + } + case DataSharePredicatesObjectType::TYPE_DOUBLE: { + int status = oper.para2.GetDouble(context.doubleValue); + return status != E_OK ? Status::ERROR : Status::SUCCESS; + } + case DataSharePredicatesObjectType::TYPE_BOOL: { + int status = oper.para2.GetBool(context.boolValue); + return status != E_OK ? Status::ERROR : Status::SUCCESS; + } + case DataSharePredicatesObjectType::TYPE_STRING: { + int status = oper.para2.GetString(context.stringValue); + return status != E_OK ? Status::ERROR : Status::SUCCESS; + } + case DataSharePredicatesObjectType::TYPE_INT_VECTOR: { + int status = oper.para2.GetIntVector(context.intList); + return status != E_OK ? Status::ERROR : Status::SUCCESS; + } + case DataSharePredicatesObjectType::TYPE_LONG_VECTOR: { + int status = oper.para2.GetLongVector(context.longList); + return status != E_OK ? Status::ERROR : Status::SUCCESS; + } + case DataSharePredicatesObjectType::TYPE_DOUBLE_VECTOR: { + int status = oper.para2.GetDoubleVector(context.doubleList); + return status != E_OK ? Status::ERROR : Status::SUCCESS; + } + case DataSharePredicatesObjectType::TYPE_STRING_VECTOR: { + int status = oper.para2.GetStringVector(context.stringList); + return status != E_OK ? Status::ERROR : Status::SUCCESS; + } + default: + return Status::ERROR; + } +} + +Status KvStorePredicate::ToQuery(DataQuery &query, DataSharePredicates predicates) +{ + std::list operationList = predicates.GetOperationList(); + for(const auto &oper : operationList) + { + auto it = HANDLERS.find(oper.operation); + if(it == HANDLERS.end()) + { + ZLOGE("This feature is not supported"); + return Status::NOT_SUPPORT; + } + Status status = (this->*(it->second))(oper, query); + if(status != Status::SUCCESS){ + ZLOGE("ToQuery called failed"); + return status; + } + } + return Status::SUCCESS; +} + +Status KvStorePredicate::InKeys(const OperationItem &oper, DataQuery &query) +{ + std::vector keys; + int status = oper.para1.GetStringVector(keys); + if(status != E_OK){ + ZLOGE("GetStringVector failed: %{public}d", status); + return Status::ERROR; + } + query.InKeys(keys); + return Status::SUCCESS; +} + +Status KvStorePredicate::KeyPrefix(const OperationItem &oper, DataQuery &query) +{ + std::string prefix; + int status = oper.para1.GetString(prefix); + if(status != E_OK){ + ZLOGE("KeyPrefix failed: %{public}d", status); + return Status::ERROR; + } + query.KeyPrefix(prefix); + return Status::SUCCESS; +} + +Status KvStorePredicate::EqualTo(const OperationItem &oper, DataQuery &query) +{ + Context context; + Status status = GetContext(oper,context); + if(status != Status::SUCCESS){ + ZLOGE("EqualTo GetContext called failed"); + return status; + } + + if(context.innerType == DataSharePredicatesObjectType::TYPE_INT) + { + query.EqualTo(context.field,context.intValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_LONG) + { + query.EqualTo(context.field,context.longValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_DOUBLE) + { + query.EqualTo(context.field,context.doubleValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_BOOL) + { + query.EqualTo(context.field,context.boolValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_STRING) + { + query.EqualTo(context.field,context.stringValue); + } + return Status::SUCCESS; +} + +Status KvStorePredicate::NotEqualTo(const OperationItem &oper, DataQuery &query) +{ + Context context; + Status status = GetContext(oper,context); + if(status != Status::SUCCESS){ + ZLOGE("NotEqualTo GetContext called failed"); + return status; + } + + if(context.innerType == DataSharePredicatesObjectType::TYPE_INT) + { + query.NotEqualTo(context.field,context.intValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_LONG) + { + query.NotEqualTo(context.field,context.longValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_DOUBLE) + { + query.NotEqualTo(context.field,context.doubleValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_BOOL) + { + query.NotEqualTo(context.field,context.boolValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_STRING) + { + query.NotEqualTo(context.field,context.stringValue); + } + return Status::SUCCESS; +} + +Status KvStorePredicate::GreaterThan(const OperationItem &oper, DataQuery &query) +{ + Context context; + Status status = GetContext(oper,context); + if(status != Status::SUCCESS){ + ZLOGE("GreaterThan GetContext called failed"); + return status; + } + + if(context.innerType == DataSharePredicatesObjectType::TYPE_INT) + { + query.GreaterThan(context.field,context.intValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_LONG) + { + query.GreaterThan(context.field,context.longValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_DOUBLE) + { + query.GreaterThan(context.field,context.doubleValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_STRING) + { + query.GreaterThan(context.field,context.stringValue); + } + return Status::SUCCESS; +} + +Status KvStorePredicate::LessThan(const OperationItem &oper, DataQuery &query) +{ + Context context; + Status status = GetContext(oper,context); + if(status != Status::SUCCESS){ + ZLOGE("LessThan GetContext called failed"); + return status; + } + + if(context.innerType == DataSharePredicatesObjectType::TYPE_INT) + { + query.LessThan(context.field,context.intValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_LONG) + { + query.LessThan(context.field,context.longValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_DOUBLE) + { + query.LessThan(context.field,context.doubleValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_STRING) + { + query.LessThan(context.field,context.stringValue); + } + return Status::SUCCESS; +} + +Status KvStorePredicate::GreaterThanOrEqualTo(const OperationItem &oper, DataQuery &query) +{ + Context context; + Status status = GetContext(oper,context); + if(status != Status::SUCCESS){ + ZLOGE("GreaterThanOrEqualTo GetContext called failed"); + return status; + } + + if(context.innerType == DataSharePredicatesObjectType::TYPE_INT) + { + query.GreaterThanOrEqualTo(context.field,context.intValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_LONG) + { + query.GreaterThanOrEqualTo(context.field,context.longValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_DOUBLE) + { + query.GreaterThanOrEqualTo(context.field,context.doubleValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_STRING) + { + query.GreaterThanOrEqualTo(context.field,context.stringValue); + } + return Status::SUCCESS; +} + +Status KvStorePredicate::LessThanOrEqualTo(const OperationItem &oper, DataQuery &query) +{ + Context context; + Status status = GetContext(oper,context); + if(status != Status::SUCCESS){ + ZLOGE("LessThanOrEqualTo GetContext called failed"); + return status; + } + + if(context.innerType == DataSharePredicatesObjectType::TYPE_INT) + { + query.LessThanOrEqualTo(context.field,context.intValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_LONG) + { + query.LessThanOrEqualTo(context.field,context.longValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_DOUBLE) + { + query.LessThanOrEqualTo(context.field,context.doubleValue); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_STRING) + { + query.LessThanOrEqualTo(context.field,context.stringValue); + } + return Status::SUCCESS; +} + +Status KvStorePredicate::And(const OperationItem &oper, DataQuery &query) +{ + query.And(); + return Status::SUCCESS; +} + +Status KvStorePredicate::Or(const OperationItem &oper, DataQuery &query) +{ + query.Or(); + return Status::SUCCESS; +} + +Status KvStorePredicate::IsNull(const OperationItem &oper, DataQuery &query) +{ + std::string field; + int status = oper.para1.GetString(field); + if(status != E_OK){ + ZLOGE("IsNull failed: %{public}d", status); + return Status::ERROR; + } + query.IsNull(field); + return Status::SUCCESS; +} + +Status KvStorePredicate::IsNotNull(const OperationItem &oper, DataQuery &query) +{ + std::string field; + int status = oper.para1.GetString(field); + if(status != E_OK){ + ZLOGE("IsNotNull failed: %{public}d", status); + return Status::ERROR; + } + query.IsNotNull(field); + return Status::SUCCESS; +} + +Status KvStorePredicate::In(const OperationItem &oper, DataQuery &query) +{ + Context context; + Status status = GetContext(oper,context); + if(status != Status::SUCCESS){ + ZLOGE("In GetContext called failed"); + return status; + } + + if(context.innerType == DataSharePredicatesObjectType::TYPE_INT_VECTOR) + { + query.In(context.field,context.intList); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_LONG_VECTOR) + { + query.In(context.field,context.longList); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_DOUBLE_VECTOR) + { + query.In(context.field,context.doubleList); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_STRING_VECTOR) + { + query.In(context.field,context.stringList); + } + return Status::SUCCESS; + +} + +Status KvStorePredicate::NotIn(const OperationItem &oper, DataQuery &query) +{ + Context context; + Status status = GetContext(oper,context); + if(status != Status::SUCCESS){ + ZLOGE("NotIn GetContext called failed"); + return status; + } + + if(context.innerType == DataSharePredicatesObjectType::TYPE_INT_VECTOR) + { + query.NotIn(context.field,context.intList); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_LONG_VECTOR) + { + query.NotIn(context.field,context.longList); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_DOUBLE_VECTOR) + { + query.NotIn(context.field,context.doubleList); + } + else if(context.innerType == DataSharePredicatesObjectType::TYPE_STRING_VECTOR) + { + query.NotIn(context.field,context.stringList); + } + return Status::SUCCESS; +} + +Status KvStorePredicate::Like(const OperationItem &oper, DataQuery &query) +{ + std::string field; + int status = oper.para1.GetString(field); + if(status != E_OK){ + ZLOGE("Like field failed: %{public}d", status); + return Status::ERROR; + } + + std::string value; + status = oper.para2.GetString(value); + if(status != E_OK){ + ZLOGE("Like value failed: %{public}d", status); + return Status::ERROR; + } + query.Like(field,value); + return Status::SUCCESS; +} + +Status KvStorePredicate::Unlike(const OperationItem &oper, DataQuery &query) +{ + std::string field; + int status = oper.para1.GetString(field); + if(status != E_OK){ + ZLOGE("Unlike failed: %{public}d", status); + return Status::ERROR; + } + + std::string value; + status = oper.para2.GetString(value); + if(status != E_OK){ + ZLOGE("Unlike value failed: %{public}d", status); + return Status::ERROR; + } + query.Unlike(field,value); + return Status::SUCCESS; +} + +Status KvStorePredicate::OrderByAsc(const OperationItem &oper, DataQuery &query) +{ + std::string field; + int status = oper.para1.GetString(field); + if(status != E_OK){ + ZLOGE("OrderByAsc failed: %{public}d", status); + return Status::ERROR; + } + query.OrderByAsc(field); + return Status::SUCCESS; +} + +Status KvStorePredicate::OrderByDesc(const OperationItem &oper, DataQuery &query) +{ + std::string field; + int status = oper.para1.GetString(field); + if(status != E_OK){ + ZLOGE("OrderByDesc failed: %{public}d", status); + return Status::ERROR; + } + query.OrderByDesc(field); + return Status::SUCCESS; +} + +Status KvStorePredicate::Limit(const OperationItem &oper, DataQuery &query) +{ + int number; + int status = oper.para1.GetInt(number); + if(status != E_OK){ + ZLOGE("Limit number failed: %{public}d", status); + return Status::ERROR; + } + + int offset; + status = oper.para2.GetInt(offset); + if(status != E_OK){ + ZLOGE("Limit offset failed: %{public}d", offset); + return Status::ERROR; + } + query.Limit(number,offset); + return Status::SUCCESS; +} + +Status KvStorePredicate::SetSuggestIndex(const OperationItem &oper, DataQuery &query) +{ + std::string field; + int status = oper.para1.GetString(field); + if(status != E_OK){ + ZLOGE("SetSuggestIndex failed: %{public}d", status); + return Status::ERROR; + } + query.SetSuggestIndex(field); + return Status::SUCCESS; +} + +} // namespace DistributedKv +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/innerkits/distributeddata/BUILD.gn b/interfaces/innerkits/distributeddata/BUILD.gn index 712faae1f..4d2f64591 100755 --- a/interfaces/innerkits/distributeddata/BUILD.gn +++ b/interfaces/innerkits/distributeddata/BUILD.gn @@ -31,6 +31,9 @@ config("distributeddatafwk_config") { "//utils/system/safwk/native/include", "//utils/native/base/include", "//foundation/distributeddatamgr/distributeddatamgr/interfaces/innerkits/app_distributeddata/include", + "//foundation/distributeddatamgr/appdatamgr/interfaces/inner_api/native/data_share/provider/include", + "//foundation/distributeddatamgr/appdatamgr/interfaces/inner_api/native/data_share/common/include", + "//foundation/distributeddatamgr/appdatamgr/frameworks/native/data_share/common/include" ] } @@ -71,6 +74,9 @@ ohos_shared_library("distributeddata_inner") { "../../../frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_sync_callback_client.cpp", "../../../frameworks/innerkitsimpl/distributeddatafwk/src/single_kvstore_client.cpp", "../../../frameworks/innerkitsimpl/distributeddatafwk/src/sync_observer.cpp", + "../../../frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_datashare_native.cpp", + "../../../frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_datashare_result_set.cpp", + "../../../frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_predicates.cpp", "include/types.h", ] @@ -89,6 +95,7 @@ ohos_shared_library("distributeddata_inner") { "//foundation/distributeddatamgr/distributeddatamgr/services/distributeddataservice/adapter:distributeddata_adapter", "//foundation/distributeddatamgr/distributeddatamgr/services/distributeddataservice/adapter/utils:distributeddata_utils_static", "//utils/native/base:utils", + "//foundation/distributeddatamgr/appdatamgr/frameworks/native/data_share/common:datashare_common" ] external_deps = [ "hiviewdfx_hilog_native:libhilog", diff --git a/interfaces/innerkits/distributeddata/include/kvstore_datashare_native.h b/interfaces/innerkits/distributeddata/include/kvstore_datashare_native.h new file mode 100644 index 000000000..89a1fa2b6 --- /dev/null +++ b/interfaces/innerkits/distributeddata/include/kvstore_datashare_native.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed 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. + */ + +#ifndef KVSTORE_DATASHARE_NATIVE_H +#define KVSTORE_DATASHARE_NATIVE_H + +#include "types.h" +#include "single_kvstore.h" +#include "datashare_predicates.h" +#include "data_query.h" +#include "datashare_abstract_result_set.h" + +namespace OHOS { +namespace DistributedKv { +using namespace DataShare; +class KvStoreDataShareNative { + +public: + KvStoreDataShareNative(std::shared_ptr kvStoreClient); + + ~KvStoreDataShareNative() = default; + + std::shared_ptr GetDataShareResult(const DataSharePredicates &predicate); + +private: + std::shared_ptr kvStoreClient_ = nullptr; + +}; +} // namespace DistributedKv +} // namespace OHOS +#endif // KVSTORE_DATASHARE_NATIVE_H \ No newline at end of file -- Gitee From 4f768483ea985074665b8e17ac4734d464caeb2b Mon Sep 17 00:00:00 2001 From: yangliu Date: Sat, 7 May 2022 19:13:53 +0800 Subject: [PATCH 2/8] update kv datashare Signed-off-by: yangliu --- .../distributeddatafwk/include/kvstore_predicates.h | 1 - .../distributeddatafwk/src/kvstore_datashare_native.cpp | 1 + .../distributeddatafwk/src/kvstore_predicates.cpp | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h index 5aaec1d5c..467385216 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h +++ b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h @@ -24,7 +24,6 @@ namespace OHOS { namespace DistributedKv { -using namespace DataShare; class KvStorePredicate { diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_datashare_native.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_datashare_native.cpp index c54f13d5c..e5b4f9ea6 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_datashare_native.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_datashare_native.cpp @@ -24,6 +24,7 @@ namespace OHOS { namespace DistributedKv { +using namespace DataShare; KvStoreDataShareNative::KvStoreDataShareNative(std::shared_ptr kvStoreClient) :kvStoreClient_(kvStoreClient) {}; diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_predicates.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_predicates.cpp index 8cb87f0c7..ca642df7e 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_predicates.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_predicates.cpp @@ -21,7 +21,8 @@ namespace OHOS { namespace DistributedKv { - +using namespace DataShare; + const std::map KvStorePredicate::HANDLERS = { {EQUAL_TO, &KvStorePredicate::EqualTo}, {NOT_EQUAL_TO, &KvStorePredicate::NotEqualTo}, @@ -105,7 +106,6 @@ Status KvStorePredicate::ToQuery(DataQuery &query, DataSharePredicates predicate auto it = HANDLERS.find(oper.operation); if(it == HANDLERS.end()) { - ZLOGE("This feature is not supported"); return Status::NOT_SUPPORT; } Status status = (this->*(it->second))(oper, query); -- Gitee From 427ffceb2d30de5da0b708c9dbeb55d19776b941 Mon Sep 17 00:00:00 2001 From: yangliu Date: Mon, 9 May 2022 10:34:23 +0800 Subject: [PATCH 3/8] code review fixed Signed-off-by: yangliu --- .../include/kvstore_datashare_result_set.h | 6 +++--- .../distributeddatafwk/include/kvstore_predicates.h | 2 +- .../distributeddatafwk/src/kvstore_predicates.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_datashare_result_set.h b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_datashare_result_set.h index 24e373e54..f075eeb65 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_datashare_result_set.h +++ b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_datashare_result_set.h @@ -35,12 +35,12 @@ public: int GetAllColumnOrKeyName(std::vector &columnOrKeyNames) override; - bool OnGo(int oldRowIndex, int newRowIndex, DataShareBlockWriter &writer) override; + bool OnGo(int oldRowIndex, int newRowIndex, const std::shared_ptr &writer) override; private: int Count(); - bool FillBlock(int startRowIndex, DataShareBlockWriter &writer); + bool FillBlock(int startRowIndex, const std::shared_ptr &writer); static constexpr int32_t INVALID_COUNT = -1; @@ -50,4 +50,4 @@ private: }; } // namespace DistributedKv } // namespace OHOS -#endif // KVSTORE_DATASHARE_RESULT_SET_H \ No newline at end of file +#endif // KVSTORE_DATASHARE_RESULT_SET_H diff --git a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h index 467385216..58364cf58 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h +++ b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h @@ -43,7 +43,7 @@ public: }; KvStorePredicate() = default; ~KvStorePredicate() = default; - Status ToQuery(DataQuery &query, DataSharePredicates predicates); + Status ToQuery(DataQuery &query, const DataSharePredicates predicates); private: Status EqualTo(const OperationItem &oper, DataQuery &query); Status NotEqualTo(const OperationItem &oper, DataQuery &query); diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_predicates.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_predicates.cpp index ca642df7e..af4b38fa6 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_predicates.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_predicates.cpp @@ -98,7 +98,7 @@ Status KvStorePredicate::GetContext(const OperationItem &oper,Context &context) } } -Status KvStorePredicate::ToQuery(DataQuery &query, DataSharePredicates predicates) +Status KvStorePredicate::ToQuery(DataQuery &query, const DataSharePredicates predicates) { std::list operationList = predicates.GetOperationList(); for(const auto &oper : operationList) -- Gitee From 42c00b40b25c0821abedcb496be006bdbd533ed2 Mon Sep 17 00:00:00 2001 From: yangliu Date: Mon, 9 May 2022 11:21:19 +0800 Subject: [PATCH 4/8] code reivew fixed Signed-off-by: yangliu --- .../include/kvstore_datashare_result_set.h | 3 +- .../include/kvstore_predicates.h | 31 +++++++++---------- .../include/kvstore_datashare_native.h | 1 - 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_datashare_result_set.h b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_datashare_result_set.h index f075eeb65..08b3eb1b0 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_datashare_result_set.h +++ b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_datashare_result_set.h @@ -24,8 +24,7 @@ namespace OHOS { namespace DistributedKv { using namespace DataShare; -class KvStoreDataShareResultSet : public DataShareAbstractResultSet -{ +class KvStoreDataShareResultSet : public DataShareAbstractResultSet { public: KvStoreDataShareResultSet(std::shared_ptr kvResultSet); diff --git a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h index 58364cf58..ce7b040c7 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h +++ b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h @@ -13,7 +13,6 @@ * limitations under the License. */ - #ifndef KVSTORE_PREDICATE_H #define KVSTORE_PREDICATE_H @@ -24,23 +23,21 @@ namespace OHOS { namespace DistributedKv { - -class KvStorePredicate -{ +class KvStorePredicate { public: - struct Context { - int intValue; - int64_t longValue; - double doubleValue; - bool boolValue; - std::string field; - std::string stringValue; - std::vector intList; - std::vector longList; - std::vector doubleList; - std::vector stringList; - DataSharePredicatesObjectType innerType; - }; + struct Context { + int intValue; + int64_t longValue; + double doubleValue; + bool boolValue; + std::string field; + std::string stringValue; + std::vector intList; + std::vector longList; + std::vector doubleList; + std::vector stringList; + DataSharePredicatesObjectType innerType; + }; KvStorePredicate() = default; ~KvStorePredicate() = default; Status ToQuery(DataQuery &query, const DataSharePredicates predicates); diff --git a/interfaces/innerkits/distributeddata/include/kvstore_datashare_native.h b/interfaces/innerkits/distributeddata/include/kvstore_datashare_native.h index 89a1fa2b6..4e394b0b4 100644 --- a/interfaces/innerkits/distributeddata/include/kvstore_datashare_native.h +++ b/interfaces/innerkits/distributeddata/include/kvstore_datashare_native.h @@ -26,7 +26,6 @@ namespace OHOS { namespace DistributedKv { using namespace DataShare; class KvStoreDataShareNative { - public: KvStoreDataShareNative(std::shared_ptr kvStoreClient); -- Gitee From f86a6d2fabf2bb3f313e10c4aa46cf3ff5f817b5 Mon Sep 17 00:00:00 2001 From: yangliu Date: Mon, 9 May 2022 11:24:23 +0800 Subject: [PATCH 5/8] code review fixed Signed-off-by: yangliu --- .../include/kvstore_predicates.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h index ce7b040c7..9166d8e80 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h +++ b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h @@ -26,16 +26,16 @@ namespace DistributedKv { class KvStorePredicate { public: struct Context { - int intValue; - int64_t longValue; - double doubleValue; - bool boolValue; - std::string field; + int intValue; + int64_t longValue; + double doubleValue; + bool boolValue; + std::string field; std::string stringValue; std::vector intList; std::vector longList; - std::vector doubleList; - std::vector stringList; + std::vector doubleList; + std::vector stringList; DataSharePredicatesObjectType innerType; }; KvStorePredicate() = default; -- Gitee From 99b160ded208010696a9bf54106ea2b373dc3641 Mon Sep 17 00:00:00 2001 From: yangliu Date: Mon, 9 May 2022 11:26:44 +0800 Subject: [PATCH 6/8] code review fixed Signed-off-by: yangliu --- .../include/kvstore_predicates.h | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h index 9166d8e80..9748bbb2b 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h +++ b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h @@ -25,19 +25,19 @@ namespace OHOS { namespace DistributedKv { class KvStorePredicate { public: - struct Context { - int intValue; - int64_t longValue; - double doubleValue; - bool boolValue; - std::string field; - std::string stringValue; - std::vector intList; - std::vector longList; - std::vector doubleList; - std::vector stringList; - DataSharePredicatesObjectType innerType; - }; + struct Context { + int intValue; + int64_t longValue; + double doubleValue; + bool boolValue; + std::string field; + std::string stringValue; + std::vector intList; + std::vector longList; + std::vector doubleList; + std::vector stringList; + DataSharePredicatesObjectType innerType; + }; KvStorePredicate() = default; ~KvStorePredicate() = default; Status ToQuery(DataQuery &query, const DataSharePredicates predicates); -- Gitee From 2bb43975247e9e5fb8b5fd0ff4413593b8aa2a07 Mon Sep 17 00:00:00 2001 From: yangliu Date: Mon, 9 May 2022 11:28:53 +0800 Subject: [PATCH 7/8] code review fixed Signed-off-by: yangliu --- .../include/kvstore_predicates.h | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h index 9748bbb2b..5932de740 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h +++ b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h @@ -26,17 +26,17 @@ namespace DistributedKv { class KvStorePredicate { public: struct Context { - int intValue; - int64_t longValue; - double doubleValue; - bool boolValue; - std::string field; - std::string stringValue; - std::vector intList; - std::vector longList; - std::vector doubleList; - std::vector stringList; - DataSharePredicatesObjectType innerType; + int intValue; + int64_t longValue; + double doubleValue; + bool boolValue; + std::string field; + std::string stringValue; + std::vector intList; + std::vector longList; + std::vector doubleList; + std::vector stringList; + DataSharePredicatesObjectType innerType; }; KvStorePredicate() = default; ~KvStorePredicate() = default; -- Gitee From ffb3ff86ace279f6d592c071e0038a9e5d11d162 Mon Sep 17 00:00:00 2001 From: yangliu Date: Mon, 9 May 2022 11:29:36 +0800 Subject: [PATCH 8/8] code review fixed Signed-off-by: yangliu --- .../distributeddatafwk/include/kvstore_predicates.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h index 5932de740..5bdad52b9 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h +++ b/frameworks/innerkitsimpl/distributeddatafwk/include/kvstore_predicates.h @@ -27,7 +27,7 @@ class KvStorePredicate { public: struct Context { int intValue; - int64_t longValue; + int64_t longValue; double doubleValue; bool boolValue; std::string field; -- Gitee