1 /* 2 * Copyright (C) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_MEDIA_CLOUD_MEDIA_DATA_CLIENT_HANDLER_PROCESSOR_H 17 #define OHOS_MEDIA_CLOUD_MEDIA_DATA_CLIENT_HANDLER_PROCESSOR_H 18 19 #include <string> 20 #include <vector> 21 22 #include "cloud_meta_data.h" 23 #include "photos_vo.h" 24 #include "medialibrary_errno.h" 25 26 namespace OHOS::Media::CloudSync { 27 class CloudMediaDataClientHandlerProcessor { 28 public: 29 std::vector<CloudMetaData> GetCloudNewData(const std::vector<PhotosVo> &newDatas); 30 std::vector<CloudMetaData> GetCloudFdirtyData(const std::vector<PhotosVo> &fdirtyDatas); 31 32 public: 33 template <class T> SplitVector(const std::vector<T> & input,size_t maxSize,std::vector<std::vector<T>> & result)34 int32_t SplitVector(const std::vector<T> &input, size_t maxSize, std::vector<std::vector<T>> &result) 35 { 36 maxSize = maxSize > 0 ? maxSize : 1; 37 size_t numSubVectors = (input.size() + maxSize - 1) / maxSize; 38 size_t maxSubVectors = 1000; 39 numSubVectors = numSubVectors > 0 ? numSubVectors : 0; 40 numSubVectors = numSubVectors > maxSubVectors ? maxSubVectors : numSubVectors; 41 for (size_t i = 0; i < numSubVectors; ++i) { 42 size_t start = i * maxSize; 43 size_t end = std::min(start + maxSize, input.size()); 44 std::vector<T> subVector(input.begin() + start, input.begin() + end); 45 result.emplace_back(subVector); 46 } 47 return E_OK; 48 } 49 }; 50 } // namespace OHOS::Media::CloudSync 51 #endif // OHOS_MEDIA_CLOUD_MEDIA_DATA_CLIENT_HANDLER_PROCESSOR_H