• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "minddata/mindrecord/include/shard_page.h"
18 #include "pybind11/pybind11.h"
19 
20 namespace mindspore {
21 namespace mindrecord {
GetPage() const22 json Page::GetPage() const {
23   json str_page;
24   str_page["page_id"] = page_id_;
25   str_page["shard_id"] = shard_id_;
26   str_page["page_type"] = page_type_;
27   str_page["page_type_id"] = page_type_id_;
28   str_page["start_row_id"] = start_row_id_;
29   str_page["end_row_id"] = end_row_id_;
30   if (row_group_ids_.size() == 0) {
31     json row_groups = json({});
32     row_groups["id"] = 0;
33     row_groups["offset"] = 0;
34     str_page["row_group_ids"].push_back(row_groups);
35   } else {
36     for (const auto &rg : row_group_ids_) {
37       json row_groups = json({});
38       row_groups["id"] = rg.first;
39       row_groups["offset"] = rg.second;
40       str_page["row_group_ids"].push_back(row_groups);
41     }
42   }
43   str_page["page_size"] = page_size_;
44   return str_page;
45 }
46 
DeleteLastGroupId()47 void Page::DeleteLastGroupId() {
48   if (!row_group_ids_.empty()) {
49     page_size_ = row_group_ids_.back().second;
50     row_group_ids_.pop_back();
51   }
52 }
53 }  // namespace mindrecord
54 }  // namespace mindspore
55