Apache GraphAr C++ Library
The C++ Library for Apache GraphAr
chunk_info_writer.h
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 #pragma once
21 
22 #include <memory>
23 #include <string>
24 #include <vector>
25 
26 #include "graphar/fwd.h"
27 #include "graphar/writer_util.h"
28 
29 namespace graphar {
30 
32  public:
50  explicit VertexChunkInfoWriter(
51  const std::shared_ptr<VertexInfo>& vertex_info, const std::string& prefix,
52  const ValidateLevel& validate_level = ValidateLevel::no_validate);
53 
54  Status WriteChunk(
55  const std::string& file_name,
56  const std::shared_ptr<PropertyGroup>& property_group, IdType chunk_index,
57  ValidateLevel validate_level = ValidateLevel::no_validate) const;
58 
59  private:
68  Status validate(const std::shared_ptr<PropertyGroup>& property_group,
69  IdType chunk_index, ValidateLevel validate_level) const;
70 
71  private:
72  std::shared_ptr<VertexInfo> vertex_info_;
73  std::string prefix_;
74  std::shared_ptr<FileSystem> fs_;
75  ValidateLevel validate_level_;
76 };
77 
90  explicit EdgeChunkInfoWriter(
91  const std::shared_ptr<EdgeInfo>& edge_info, const std::string& prefix,
92  AdjListType adj_list_type,
93  const ValidateLevel& validate_level = ValidateLevel::no_validate);
94 
105  Status WriteAdjListChunk(
106  const std::string& file_name, IdType vertex_chunk_index,
107  IdType chunk_index,
108  ValidateLevel validate_level = ValidateLevel::default_validate) const;
109 
119  Status WriteOffsetChunk(
120  const std::string& file_name, IdType vertex_chunk_index,
121  ValidateLevel validate_level = ValidateLevel::default_validate) const;
122 
134  Status WritePropertyChunk(
135  const std::string& file_name,
136  const std::shared_ptr<PropertyGroup>& property_group,
137  IdType vertex_chunk_index, IdType chunk_index,
138  ValidateLevel validate_level = ValidateLevel::default_validate) const;
139 
140  private:
150  Status validate(IdType count_or_index1, IdType count_or_index2,
151  ValidateLevel validate_level) const;
152 
163  Status validate(const std::shared_ptr<PropertyGroup>& property_group,
164  IdType vertex_chunk_index, IdType chunk_index,
165  ValidateLevel validate_level) const;
166 
167  private:
168  std::shared_ptr<EdgeInfo> edge_info_;
169  IdType vertex_chunk_size_;
170  IdType chunk_size_;
171  AdjListType adj_list_type_;
172  std::string prefix_;
173  std::shared_ptr<FileSystem> fs_;
174  ValidateLevel validate_level_;
175 };
176 } // namespace graphar
Status outcome object (success or error)
Definition: status.h:123
VertexChunkInfoWriter(const std::shared_ptr< VertexInfo > &vertex_info, const std::string &prefix, const ValidateLevel &validate_level=ValidateLevel::no_validate)
Copy a file as a vertex property group chunk.