OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FileRegions.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2021 OmniSci, Inc.
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 "FileRegions.h"
18 
20 
21 namespace foreign_storage {
22 // Serialization functions for FileRegion
23 void set_value(rapidjson::Value& json_val,
24  const FileRegion& file_region,
25  rapidjson::Document::AllocatorType& allocator) {
26  json_val.SetObject();
28  json_val, file_region.first_row_file_offset, "first_row_file_offset", allocator);
30  json_val, file_region.first_row_index, "first_row_index", allocator);
32  json_val, file_region.region_size, "region_size", allocator);
34  json_val, file_region.row_count, "row_count", allocator);
35  if (file_region.filename.size()) {
37  json_val, file_region.filename, "filename", allocator);
38  }
39 }
40 
41 void get_value(const rapidjson::Value& json_val, FileRegion& file_region) {
42  CHECK(json_val.IsObject());
44  json_val, file_region.first_row_file_offset, "first_row_file_offset");
46  json_val, file_region.first_row_index, "first_row_index");
47  json_utils::get_value_from_object(json_val, file_region.region_size, "region_size");
48  json_utils::get_value_from_object(json_val, file_region.row_count, "row_count");
49  if (json_val.HasMember("filename")) {
50  json_utils::get_value_from_object(json_val, file_region.filename, "filename");
51  }
52 }
53 } // namespace foreign_storage
void get_value(const rapidjson::Value &json_val, FileRegion &file_region)
Definition: CsvShared.cpp:44
void get_value_from_object(const rapidjson::Value &object, T &value, const std::string &name)
Definition: FsiJsonUtils.h:164
void add_value_to_object(rapidjson::Value &object, const T &value, const std::string &name, rapidjson::Document::AllocatorType &allocator)
Definition: FsiJsonUtils.h:149
#define CHECK(condition)
Definition: Logger.h:209
void set_value(rapidjson::Value &json_val, const FileRegion &file_region, rapidjson::Document::AllocatorType &allocator)
Definition: CsvShared.cpp:26