Apache GraphAr C++ Library
The C++ Library for Apache GraphAr
chunk_info_reader.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 
28 namespace graphar {
29 
32  public:
34 
43  const std::shared_ptr<VertexInfo>& vertex_info,
44  const std::shared_ptr<PropertyGroup>& property_group,
45  const std::string& prefix);
46 
55  Status seek(IdType id);
56 
60  Result<std::string> GetChunk() const;
61 
69 
71  IdType GetChunkNum() const noexcept { return chunk_num_; }
72 
80  static Result<std::shared_ptr<VertexPropertyChunkInfoReader>> Make(
81  const std::shared_ptr<VertexInfo>& vertex_info,
82  const std::shared_ptr<PropertyGroup>& property_group,
83  const std::string& prefix);
84 
93  static Result<std::shared_ptr<VertexPropertyChunkInfoReader>> Make(
94  const std::shared_ptr<GraphInfo>& graph_info, const std::string& label,
95  const std::shared_ptr<PropertyGroup>& property_group);
96 
106  static Result<std::shared_ptr<VertexPropertyChunkInfoReader>> Make(
107  const std::shared_ptr<GraphInfo>& graph_info, const std::string& label,
108  const std::string& property_name);
109 
110  private:
111  std::shared_ptr<VertexInfo> vertex_info_;
112  std::shared_ptr<PropertyGroup> property_group_;
113  std::string prefix_;
114  IdType chunk_index_;
115  IdType chunk_num_;
116 };
117 
120  public:
122 
130  explicit AdjListChunkInfoReader(const std::shared_ptr<EdgeInfo>& edge_info,
131  AdjListType adj_list_type,
132  const std::string& prefix);
133 
140  Status seek_src(IdType id);
141 
148  Status seek_dst(IdType id);
149 
157  Status seek(IdType index);
158 
160  Result<std::string> GetChunk();
161 
168  Status next_chunk();
169 
177  static Result<std::shared_ptr<AdjListChunkInfoReader>> Make(
178  const std::shared_ptr<EdgeInfo>& edge_info, AdjListType adj_list_type,
179  const std::string& prefix);
180 
190  static Result<std::shared_ptr<AdjListChunkInfoReader>> Make(
191  const std::shared_ptr<GraphInfo>& graph_info,
192  const std::string& src_label, const std::string& edge_label,
193  const std::string& dst_label, AdjListType adj_list_type);
194 
195  private:
196  std::shared_ptr<EdgeInfo> edge_info_;
197  AdjListType adj_list_type_;
198  std::string prefix_;
199  IdType vertex_chunk_index_, chunk_index_;
200  IdType vertex_chunk_num_, chunk_num_;
201  std::string base_dir_; // the chunk files base dir
202  std::shared_ptr<FileSystem> fs_;
203 };
204 
206  public:
208 
219  const std::shared_ptr<EdgeInfo>& edge_info, AdjListType adj_list_type,
220  const std::string& prefix);
221 
228  Status seek(IdType id);
229 
233  Result<std::string> GetChunk() const;
234 
241  Status next_chunk();
242 
250  static Result<std::shared_ptr<AdjListOffsetChunkInfoReader>> Make(
251  const std::shared_ptr<EdgeInfo>& edge_info, AdjListType adj_list_type,
252  const std::string& prefix);
253 
263  static Result<std::shared_ptr<AdjListOffsetChunkInfoReader>> Make(
264  const std::shared_ptr<GraphInfo>& graph_info,
265  const std::string& src_label, const std::string& edge_label,
266  const std::string& dst_label, AdjListType adj_list_type);
267 
268  private:
269  std::shared_ptr<EdgeInfo> edge_info_;
270  AdjListType adj_list_type_;
271  std::string prefix_;
272  IdType chunk_index_;
273  IdType vertex_chunk_size_;
274  IdType vertex_chunk_num_;
275 };
276 
281  public:
291  const std::shared_ptr<EdgeInfo>& edge_info,
292  const std::shared_ptr<PropertyGroup>& property_group,
293  AdjListType adj_list_type, const std::string prefix);
294 
300  Status seek_src(IdType id);
301 
307  Status seek_dst(IdType id);
308 
316  Status seek(IdType offset);
317 
319  Result<std::string> GetChunk() const;
320 
327  Status next_chunk();
328 
337  static Result<std::shared_ptr<AdjListPropertyChunkInfoReader>> Make(
338  const std::shared_ptr<EdgeInfo>& edge_info,
339  const std::shared_ptr<PropertyGroup>& property_group,
340  AdjListType adj_list_type, const std::string& prefix);
341 
353  static Result<std::shared_ptr<AdjListPropertyChunkInfoReader>> Make(
354  const std::shared_ptr<GraphInfo>& graph_info,
355  const std::string& src_label, const std::string& edge_label,
356  const std::string& dst_label,
357  const std::shared_ptr<PropertyGroup>& property_group,
358  AdjListType adj_list_type);
359 
372  static Result<std::shared_ptr<AdjListPropertyChunkInfoReader>> Make(
373  const std::shared_ptr<GraphInfo>& graph_info,
374  const std::string& src_label, const std::string& edge_label,
375  const std::string& dst_label, const std::string& property_name,
376  AdjListType adj_list_type);
377 
378  private:
379  std::shared_ptr<EdgeInfo> edge_info_;
380  std::shared_ptr<PropertyGroup> property_group_;
381  AdjListType adj_list_type_;
382  std::string prefix_;
383  IdType vertex_chunk_index_, chunk_index_;
384  IdType vertex_chunk_num_, chunk_num_;
385  std::string base_dir_; // the chunk files base dir
386  std::shared_ptr<FileSystem> fs_;
387 };
388 } // namespace graphar
Status seek_dst(IdType id)
Sets chunk position indicator for reader by destination internal vertex id.
Status seek(IdType index)
Sets chunk position indicator for reader by edge index.
Status seek_src(IdType id)
Sets chunk position indicator for reader by source internal vertex id.
Result< std::string > GetChunk()
static Result< std::shared_ptr< AdjListChunkInfoReader > > Make(const std::shared_ptr< EdgeInfo > &edge_info, AdjListType adj_list_type, const std::string &prefix)
Create an AdjListChunkInfoReader instance from edge info.
AdjListChunkInfoReader(const std::shared_ptr< EdgeInfo > &edge_info, AdjListType adj_list_type, const std::string &prefix)
Initialize the AdjListChunkInfoReader.
Status seek(IdType id)
Sets chunk position indicator for reader by source internal vertex id.
AdjListOffsetChunkInfoReader(const std::shared_ptr< EdgeInfo > &edge_info, AdjListType adj_list_type, const std::string &prefix)
Initialize the AdjListOffsetChunkInfoReader.
Result< std::string > GetChunk() const
Return the current chunk file path of chunk position indicator.
static Result< std::shared_ptr< AdjListOffsetChunkInfoReader > > Make(const std::shared_ptr< EdgeInfo > &edge_info, AdjListType adj_list_type, const std::string &prefix)
Create an AdjListOffsetChunkInfoReader instance from edge info.
Status seek(IdType offset)
Sets chunk position indicator for reader by edge index.
Status seek_src(IdType id)
Sets chunk position indicator for reader by source vertex id.
static Result< std::shared_ptr< AdjListPropertyChunkInfoReader > > Make(const std::shared_ptr< EdgeInfo > &edge_info, const std::shared_ptr< PropertyGroup > &property_group, AdjListType adj_list_type, const std::string &prefix)
Create an AdjListPropertyChunkInfoReader instance from edge info.
AdjListPropertyChunkInfoReader(const std::shared_ptr< EdgeInfo > &edge_info, const std::shared_ptr< PropertyGroup > &property_group, AdjListType adj_list_type, const std::string prefix)
Initialize the AdjListPropertyChunkInfoReader.
Result< std::string > GetChunk() const
Status seek_dst(IdType id)
Sets chunk position indicator for reader by destination vertex id.
Status outcome object (success or error)
Definition: status.h:123
static Result< std::shared_ptr< VertexPropertyChunkInfoReader > > Make(const std::shared_ptr< VertexInfo > &vertex_info, const std::shared_ptr< PropertyGroup > &property_group, const std::string &prefix)
Create a VertexPropertyChunkInfoReader instance from vertex info.
Status seek(IdType id)
Sets chunk position indicator for reader by internal vertex id. If internal vertex id is not found,...
VertexPropertyChunkInfoReader(const std::shared_ptr< VertexInfo > &vertex_info, const std::shared_ptr< PropertyGroup > &property_group, const std::string &prefix)
Initialize the VertexPropertyChunkInfoReader.
Result< std::string > GetChunk() const
Return the current chunk file path of chunk position indicator.