30 #include "graphar/arrow/chunk_reader.h"
31 #include "graphar/filesystem.h"
32 #include "graphar/graph_info.h"
33 #include "graphar/reader_util.h"
34 #include "graphar/types.h"
35 #include "graphar/util.h"
58 std::vector<VertexPropertyArrowChunkReader>& readers);
65 inline IdType
id() const noexcept {
return id_; }
90 if (properties_.find(
property) != properties_.end()) {
91 return properties_.at(
property).has_value();
93 if (list_properties_.find(
property) != list_properties_.end()) {
96 throw std::invalid_argument(
"Property with name " +
property +
97 " does not exist in the vertex.");
102 std::map<std::string, std::any> properties_;
103 std::map<std::string, std::shared_ptr<arrow::Array>> list_properties_;
118 std::vector<AdjListPropertyArrowChunkReader>&
126 inline IdType
source() const noexcept {
return src_id_; }
141 template <
typename T>
151 if (properties_.find(
property) != properties_.end()) {
152 return properties_.at(
property).has_value();
154 if (list_properties_.find(
property) != list_properties_.end()) {
157 throw std::invalid_argument(
"Property with name " +
property +
158 " does not exist in the edge.");
162 IdType src_id_, dst_id_;
163 std::map<std::string, std::any> properties_;
164 std::map<std::string, std::shared_ptr<arrow::Array>> list_properties_;
180 explicit VertexIter(
const std::shared_ptr<VertexInfo>& vertex_info,
181 const std::string& prefix, IdType offset,
182 const std::vector<std::string>& labels,
183 const bool& is_filtered =
false,
184 const std::vector<IdType>& filtered_ids = {}) noexcept {
185 if (!labels.empty()) {
190 for (
const auto& pg : vertex_info->GetPropertyGroups()) {
191 readers_.emplace_back(vertex_info, pg, prefix);
193 is_filtered_ = is_filtered;
194 filtered_ids_ = filtered_ids;
195 cur_offset_ = offset;
200 : readers_(other.readers_),
201 cur_offset_(other.cur_offset_),
202 labels_(other.labels_),
203 label_reader_(other.label_reader_),
204 is_filtered_(other.is_filtered_),
205 filtered_ids_(other.filtered_ids_) {}
210 for (
auto& reader : readers_) {
211 reader.seek(filtered_ids_[cur_offset_]);
214 for (
auto& reader : readers_) {
215 reader.seek(cur_offset_);
219 return Vertex(cur_offset_, readers_);
225 return filtered_ids_[cur_offset_];
232 template <
typename T>
234 std::shared_ptr<arrow::ChunkedArray> column(
nullptr);
236 for (
auto& reader : readers_) {
237 reader.seek(filtered_ids_[cur_offset_]);
238 GAR_ASSIGN_OR_RAISE(
auto chunk_table,
239 reader.GetChunk(graphar::GetChunkVersion::V1));
240 column = util::GetArrowColumnByName(chunk_table,
property);
241 if (column !=
nullptr) {
246 for (
auto& reader : readers_) {
247 reader.seek(cur_offset_);
248 GAR_ASSIGN_OR_RAISE(
auto chunk_table,
249 reader.GetChunk(graphar::GetChunkVersion::V1));
250 column = util::GetArrowColumnByName(chunk_table,
property);
251 if (column !=
nullptr) {
257 if (column !=
nullptr) {
258 auto array = util::GetArrowArrayByChunkIndex(column, 0);
259 GAR_ASSIGN_OR_RAISE(
auto data, util::GetArrowArrayData(array));
263 " does not exist in the vertex.");
270 Result<std::vector<std::string>>
label() noexcept;
288 ret.cur_offset_ += offset;
294 cur_offset_ += offset;
300 return cur_offset_ == rhs.cur_offset_;
305 return cur_offset_ != rhs.cur_offset_;
309 std::vector<VertexPropertyArrowChunkReader> readers_;
311 std::vector<std::string> labels_;
314 std::vector<IdType> filtered_ids_;
331 const std::string& prefix,
332 const bool is_filtered =
false,
333 std::vector<IdType> filtered_ids = {})
334 : vertex_info_(vertex_info),
336 labels_(vertex_info->GetLabels()),
337 is_filtered_(is_filtered),
338 filtered_ids_(std::move(filtered_ids)) {
340 std::string base_dir;
341 GAR_ASSIGN_OR_RAISE_ERROR(
auto fs,
342 FileSystemFromUriOrPath(prefix, &base_dir));
343 GAR_ASSIGN_OR_RAISE_ERROR(
auto file_path,
344 vertex_info->GetVerticesNumFilePath());
345 std::string vertex_num_path = base_dir + file_path;
346 GAR_ASSIGN_OR_RAISE_ERROR(vertex_num_,
347 fs->ReadFileToValue<IdType>(vertex_num_path));
352 return VertexIter(vertex_info_, prefix_, 0, labels_, is_filtered_,
359 return VertexIter(vertex_info_, prefix_, filtered_ids_.size(), labels_,
360 is_filtered_, filtered_ids_);
361 return VertexIter(vertex_info_, prefix_, vertex_num_, labels_, is_filtered_,
367 return VertexIter(vertex_info_, prefix_,
id, labels_);
373 return filtered_ids_.size();
379 Result<std::vector<IdType>>
filter(
380 const std::vector<std::string>& filter_labels,
381 std::vector<IdType>* new_valid_chunk =
nullptr);
383 Result<std::vector<IdType>> filter_by_acero(
384 const std::vector<std::string>& filter_labels)
const;
386 Result<std::vector<IdType>>
filter(
387 const std::string& property_name,
388 std::shared_ptr<Expression> filter_expression,
389 std::vector<IdType>* new_valid_chunk =
nullptr);
402 const std::string& filter_label,
403 const std::shared_ptr<GraphInfo>& graph_info,
const std::string& type);
405 static Result<std::shared_ptr<VerticesCollection>> verticesWithLabelbyAcero(
406 const std::string& filter_label,
407 const std::shared_ptr<GraphInfo>& graph_info,
const std::string& type);
418 const std::string& filter_label,
419 const std::shared_ptr<VerticesCollection>& vertices_collection);
432 const std::vector<std::string>& filter_labels,
433 const std::shared_ptr<GraphInfo>& graph_info,
const std::string& type);
435 static Result<std::shared_ptr<VerticesCollection>>
436 verticesWithMultipleLabelsbyAcero(
437 const std::vector<std::string>& filter_labels,
438 const std::shared_ptr<GraphInfo>& graph_info,
const std::string& type);
440 static Result<std::shared_ptr<VerticesCollection>> verticesWithProperty(
441 const std::string property_name,
const graphar::util::Filter
filter,
442 const std::shared_ptr<GraphInfo>& graph_info,
const std::string& type);
444 static Result<std::shared_ptr<VerticesCollection>> verticesWithProperty(
445 const std::string property_name,
const graphar::util::Filter
filter,
446 const std::shared_ptr<VerticesCollection>& vertices_collection);
457 const std::vector<std::string>& filter_labels,
458 const std::shared_ptr<VerticesCollection>& vertices_collection);
466 static Result<std::shared_ptr<VerticesCollection>>
Make(
467 const std::shared_ptr<GraphInfo>& graph_info,
const std::string& type) {
468 auto vertex_info = graph_info->GetVertexInfo(type);
469 auto labels = vertex_info->GetLabels();
473 return std::make_shared<VerticesCollection>(vertex_info,
474 graph_info->GetPrefix());
478 std::shared_ptr<VertexInfo> vertex_info_;
480 std::vector<std::string> labels_;
482 std::vector<IdType> filtered_ids_;
483 std::vector<IdType> valid_chunk_;
506 explicit EdgeIter(
const std::shared_ptr<EdgeInfo>& edge_info,
507 const std::string& prefix, AdjListType adj_list_type,
509 IdType chunk_begin, IdType chunk_end,
510 std::shared_ptr<util::IndexConverter> index_converter)
511 : adj_list_reader_(edge_info, adj_list_type, prefix),
514 chunk_size_(edge_info->GetChunkSize()),
515 src_chunk_size_(edge_info->GetSrcChunkSize()),
516 dst_chunk_size_(edge_info->GetDstChunkSize()),
517 num_row_of_chunk_(0),
518 chunk_begin_(chunk_begin),
519 chunk_end_(chunk_end),
520 adj_list_type_(adj_list_type),
521 index_converter_(index_converter) {
522 vertex_chunk_index_ =
525 const auto& property_groups = edge_info->GetPropertyGroups();
526 for (
const auto& pg : property_groups) {
527 property_readers_.emplace_back(edge_info, pg, adj_list_type, prefix),
528 property_readers_.back().seek_chunk_index(vertex_chunk_index_);
530 if (adj_list_type == AdjListType::ordered_by_source ||
531 adj_list_type == AdjListType::ordered_by_dest) {
532 offset_reader_ = std::make_shared<AdjListOffsetArrowChunkReader>(
533 edge_info, adj_list_type, prefix);
539 : adj_list_reader_(other.adj_list_reader_),
540 offset_reader_(other.offset_reader_),
541 property_readers_(other.property_readers_),
542 global_chunk_index_(other.global_chunk_index_),
543 vertex_chunk_index_(other.vertex_chunk_index_),
544 cur_offset_(other.cur_offset_),
545 chunk_size_(other.chunk_size_),
546 src_chunk_size_(other.src_chunk_size_),
547 dst_chunk_size_(other.dst_chunk_size_),
548 num_row_of_chunk_(other.num_row_of_chunk_),
549 chunk_begin_(other.chunk_begin_),
550 chunk_end_(other.chunk_end_),
551 adj_list_type_(other.adj_list_type_),
552 index_converter_(other.index_converter_) {}
556 adj_list_reader_.
seek(cur_offset_);
557 for (
auto& reader : property_readers_) {
558 reader.seek(cur_offset_);
560 return Edge(adj_list_reader_, property_readers_);
570 template <
typename T>
572 std::shared_ptr<arrow::ChunkedArray> column(
nullptr);
573 for (
auto& reader : property_readers_) {
574 reader.seek(cur_offset_);
575 GAR_ASSIGN_OR_RAISE(
auto chunk_table, reader.GetChunk());
576 column = util::GetArrowColumnByName(chunk_table,
property);
577 if (column !=
nullptr) {
581 if (column !=
nullptr) {
582 auto array = util::GetArrowArrayByChunkIndex(column, 0);
583 GAR_ASSIGN_OR_RAISE(
auto data, util::GetArrowArrayData(array));
587 " does not exist in the edge.");
592 if (num_row_of_chunk_ == 0) {
593 adj_list_reader_.
seek(cur_offset_);
594 GAR_ASSIGN_OR_RAISE_ERROR(num_row_of_chunk_,
597 auto st = adj_list_reader_.
seek(++cur_offset_);
598 if (st.ok() && num_row_of_chunk_ != chunk_size_) {
600 auto row_offset = cur_offset_ % chunk_size_;
601 if (row_offset >= num_row_of_chunk_) {
602 cur_offset_ = (cur_offset_ / chunk_size_ + 1) * chunk_size_;
603 adj_list_reader_.
seek(cur_offset_);
608 if (st.ok() && num_row_of_chunk_ == chunk_size_ &&
609 cur_offset_ % chunk_size_ == 0) {
610 GAR_ASSIGN_OR_RAISE_ERROR(num_row_of_chunk_,
612 ++global_chunk_index_;
615 for (
auto& reader : property_readers_) {
619 if (st.IsKeyError()) {
621 ++global_chunk_index_;
622 ++vertex_chunk_index_;
623 if (!st.IsIndexError()) {
624 GAR_ASSIGN_OR_RAISE_ERROR(num_row_of_chunk_,
626 for (
auto& reader : property_readers_) {
631 adj_list_reader_.
seek(cur_offset_);
645 adj_list_reader_ = other.adj_list_reader_;
646 offset_reader_ = other.offset_reader_;
647 property_readers_ = other.property_readers_;
648 global_chunk_index_ = other.global_chunk_index_;
649 vertex_chunk_index_ = other.vertex_chunk_index_;
650 cur_offset_ = other.cur_offset_;
651 chunk_size_ = other.chunk_size_;
652 src_chunk_size_ = other.src_chunk_size_;
653 dst_chunk_size_ = other.dst_chunk_size_;
654 num_row_of_chunk_ = other.num_row_of_chunk_;
655 chunk_begin_ = other.chunk_begin_;
656 chunk_end_ = other.chunk_end_;
657 adj_list_type_ = other.adj_list_type_;
658 index_converter_ = other.index_converter_;
664 return global_chunk_index_ == rhs.global_chunk_index_ &&
665 cur_offset_ == rhs.cur_offset_ &&
666 adj_list_type_ == rhs.adj_list_type_;
671 return global_chunk_index_ != rhs.global_chunk_index_ ||
672 cur_offset_ != rhs.cur_offset_ ||
673 adj_list_type_ != rhs.adj_list_type_;
704 global_chunk_index_ = chunk_begin_;
706 vertex_chunk_index_ =
707 index_converter_->GlobalChunkIndexToIndexPair(global_chunk_index_)
713 bool is_end()
const {
return global_chunk_index_ >= chunk_end_; }
719 IdType
id = this->
source();
720 IdType pre_vertex_chunk_index = vertex_chunk_index_;
721 if (adj_list_type_ == AdjListType::ordered_by_source) {
730 if (this->
source() ==
id) {
733 if (adj_list_type_ == AdjListType::unordered_by_source) {
734 if (vertex_chunk_index_ > pre_vertex_chunk_index)
750 IdType pre_vertex_chunk_index = vertex_chunk_index_;
751 if (adj_list_type_ == AdjListType::ordered_by_dest) {
763 if (adj_list_type_ == AdjListType::unordered_by_dest) {
764 if (vertex_chunk_index_ > pre_vertex_chunk_index)
798 adj_list_reader_.
seek(cur_offset_);
799 for (
auto& reader : property_readers_) {
800 reader.seek_chunk_index(vertex_chunk_index_);
802 GAR_ASSIGN_OR_RAISE_ERROR(num_row_of_chunk_,
807 AdjListArrowChunkReader adj_list_reader_;
808 std::shared_ptr<AdjListOffsetArrowChunkReader> offset_reader_;
809 std::vector<AdjListPropertyArrowChunkReader> property_readers_;
810 IdType global_chunk_index_;
811 IdType vertex_chunk_index_;
814 IdType src_chunk_size_;
815 IdType dst_chunk_size_;
816 IdType num_row_of_chunk_;
817 IdType chunk_begin_, chunk_end_;
818 AdjListType adj_list_type_;
819 std::shared_ptr<util::IndexConverter> index_converter_;
821 friend class OBSEdgeCollection;
822 friend class OBDEdgesCollection;
823 friend class UBSEdgesCollection;
824 friend class UBDEdgesCollection;
836 if (begin_ ==
nullptr) {
837 EdgeIter iter(edge_info_, prefix_, adj_list_type_, chunk_begin_, 0,
838 chunk_begin_, chunk_end_, index_converter_);
839 begin_ = std::make_shared<EdgeIter>(iter);
846 if (end_ ==
nullptr) {
847 EdgeIter iter(edge_info_, prefix_, adj_list_type_, chunk_end_, 0,
848 chunk_begin_, chunk_end_, index_converter_);
849 end_ = std::make_shared<EdgeIter>(iter);
855 virtual size_t size() const noexcept {
return edge_num_; }
889 static Result<std::shared_ptr<EdgesCollection>>
Make(
890 const std::shared_ptr<GraphInfo>& graph_info,
const std::string& src_type,
891 const std::string& edge_type,
const std::string& dst_type,
892 AdjListType adj_list_type,
const IdType vertex_chunk_begin = 0,
893 const IdType vertex_chunk_end =
894 std::numeric_limits<int64_t>::max()) noexcept;
907 const std::
string& prefix, IdType vertex_chunk_begin,
908 IdType vertex_chunk_end, AdjListType adj_list_type)
909 : edge_info_(edge_info), prefix_(prefix), adj_list_type_(adj_list_type) {
910 GAR_ASSIGN_OR_RAISE_ERROR(
911 auto vertex_chunk_num,
912 util::GetVertexChunkNum(prefix_, edge_info_, adj_list_type_));
913 std::vector<IdType> edge_chunk_nums(vertex_chunk_num, 0);
914 if (vertex_chunk_end == std::numeric_limits<int64_t>::max()) {
915 vertex_chunk_end = vertex_chunk_num;
920 for (IdType i = 0; i < vertex_chunk_num; ++i) {
921 GAR_ASSIGN_OR_RAISE_ERROR(
923 util::GetEdgeChunkNum(prefix, edge_info, adj_list_type_, i));
924 if (i < vertex_chunk_begin) {
925 chunk_begin_ += edge_chunk_nums[i];
926 chunk_end_ += edge_chunk_nums[i];
928 if (i >= vertex_chunk_begin && i < vertex_chunk_end) {
929 chunk_end_ += edge_chunk_nums[i];
930 GAR_ASSIGN_OR_RAISE_ERROR(
931 auto chunk_edge_num_,
932 util::GetEdgeNum(prefix, edge_info, adj_list_type_, i));
933 edge_num_ += chunk_edge_num_;
937 std::make_shared<util::IndexConverter>(std::move(edge_chunk_nums));
940 std::shared_ptr<EdgeInfo> edge_info_;
942 AdjListType adj_list_type_;
943 IdType chunk_begin_, chunk_end_;
944 std::shared_ptr<util::IndexConverter> index_converter_;
945 std::shared_ptr<EdgeIter> begin_, end_;
966 const std::shared_ptr<EdgeInfo>& edge_info,
const std::string& prefix,
967 IdType vertex_chunk_begin = 0,
968 IdType vertex_chunk_end = std::numeric_limits<int64_t>::max())
969 :
Base(edge_info, prefix, vertex_chunk_begin, vertex_chunk_end,
970 AdjListType::ordered_by_source) {}
982 util::GetAdjListOffsetOfVertex(edge_info_, prefix_, adj_list_type_,
id);
983 if (!result.status().ok()) {
986 auto begin_offset = result.value().first;
987 auto end_offset = result.value().second;
988 if (begin_offset >= end_offset) {
991 auto begin_global_chunk_index =
992 index_converter_->IndexPairToGlobalChunkIndex(
993 id / edge_info_->GetSrcChunkSize(),
994 begin_offset / edge_info_->GetChunkSize());
995 auto end_global_chunk_index = index_converter_->IndexPairToGlobalChunkIndex(
996 id / edge_info_->GetSrcChunkSize(),
997 end_offset / edge_info_->GetChunkSize());
998 if (begin_global_chunk_index > from.global_chunk_index_) {
999 return EdgeIter(edge_info_, prefix_, adj_list_type_,
1000 begin_global_chunk_index, begin_offset, chunk_begin_,
1001 chunk_end_, index_converter_);
1002 }
else if (end_global_chunk_index < from.global_chunk_index_) {
1005 if (begin_offset > from.cur_offset_) {
1006 return EdgeIter(edge_info_, prefix_, adj_list_type_,
1007 begin_global_chunk_index, begin_offset, chunk_begin_,
1008 chunk_end_, index_converter_);
1009 }
else if (end_offset <= from.cur_offset_) {
1012 return EdgeIter(edge_info_, prefix_, adj_list_type_,
1013 from.global_chunk_index_, from.cur_offset_,
1014 chunk_begin_, chunk_end_, index_converter_);
1031 while (iter !=
end) {
1033 if (edge.destination() ==
id) {
1058 const std::shared_ptr<EdgeInfo>& edge_info,
const std::string& prefix,
1059 IdType vertex_chunk_begin = 0,
1060 IdType vertex_chunk_end = std::numeric_limits<int64_t>::max())
1061 :
Base(edge_info, prefix, vertex_chunk_begin, vertex_chunk_end,
1062 AdjListType::ordered_by_dest) {}
1075 while (iter !=
end) {
1077 if (edge.source() ==
id) {
1095 util::GetAdjListOffsetOfVertex(edge_info_, prefix_, adj_list_type_,
id);
1096 if (!result.status().ok()) {
1099 auto begin_offset = result.value().first;
1100 auto end_offset = result.value().second;
1101 if (begin_offset >= end_offset) {
1104 auto begin_global_chunk_index =
1105 index_converter_->IndexPairToGlobalChunkIndex(
1106 id / edge_info_->GetDstChunkSize(),
1107 begin_offset / edge_info_->GetChunkSize());
1108 auto end_global_chunk_index = index_converter_->IndexPairToGlobalChunkIndex(
1109 id / edge_info_->GetDstChunkSize(),
1110 end_offset / edge_info_->GetChunkSize());
1111 if (begin_global_chunk_index > from.global_chunk_index_) {
1112 return EdgeIter(edge_info_, prefix_, adj_list_type_,
1113 begin_global_chunk_index, begin_offset, chunk_begin_,
1114 chunk_end_, index_converter_);
1115 }
else if (end_global_chunk_index < from.global_chunk_index_) {
1118 if (begin_offset >= from.cur_offset_) {
1119 return EdgeIter(edge_info_, prefix_, adj_list_type_,
1120 begin_global_chunk_index, begin_offset, chunk_begin_,
1121 chunk_end_, index_converter_);
1122 }
else if (end_offset <= from.cur_offset_) {
1125 return EdgeIter(edge_info_, prefix_, adj_list_type_,
1126 from.global_chunk_index_, from.cur_offset_,
1127 chunk_begin_, chunk_end_, index_converter_);
1150 const std::shared_ptr<EdgeInfo>& edge_info,
const std::string& prefix,
1151 IdType vertex_chunk_begin = 0,
1152 IdType vertex_chunk_end = std::numeric_limits<int64_t>::max())
1153 :
Base(edge_info, prefix, vertex_chunk_begin, vertex_chunk_end,
1154 AdjListType::unordered_by_source) {}
1167 while (iter !=
end) {
1169 if (edge.source() ==
id) {
1188 while (iter !=
end) {
1190 if (edge.destination() ==
id) {
1215 const std::shared_ptr<EdgeInfo>& edge_info,
const std::string& prefix,
1216 IdType vertex_chunk_begin = 0,
1217 IdType vertex_chunk_end = std::numeric_limits<int64_t>::max())
1218 :
Base(edge_info, prefix, vertex_chunk_begin, vertex_chunk_end,
1219 AdjListType::unordered_by_dest) {}
1232 while (iter !=
end) {
1234 if (edge.source() ==
id) {
1253 while (iter !=
end) {
1255 if (edge.destination() ==
id) {
The arrow chunk reader for adj list topology chunk.
Status seek(IdType offset)
Sets chunk position indicator for reader by edge index.
Result< IdType > GetRowNumOfChunk()
Get the number of rows of the current chunk table.
Status seek_chunk_index(IdType vertex_chunk_index, IdType chunk_index=0)
Sets chunk position to the specific vertex chunk and edge chunk.
Status next_chunk()
Sets chunk position indicator to next chunk.
Edge contains information of certain edge.
IdType source() const noexcept
Get source id of the edge.
Edge(AdjListArrowChunkReader &adj_list_reader, std::vector< AdjListPropertyArrowChunkReader > &property_readers)
IdType destination() const noexcept
Get destination id of the edge.
bool IsValid(const std::string &property) const
Return true if value at the property is valid (not null).
Result< T > property(const std::string &property) const
Get the property value of the edge.
EdgeInfo is a class to describe the edge information, including the source vertex type,...
The iterator for traversing a type of edges.
IdType cur_offset() const
bool operator!=(const EdgeIter &rhs) const noexcept
EdgeIter(const EdgeIter &other)
bool first_dst(const EdgeIter &from, IdType id)
bool first_src(const EdgeIter &from, IdType id)
EdgeIter operator=(const EdgeIter &other)
IdType global_chunk_index() const
bool operator==(const EdgeIter &rhs) const noexcept
Result< T > property(const std::string &property) noexcept
EdgeIter(const std::shared_ptr< EdgeInfo > &edge_info, const std::string &prefix, AdjListType adj_list_type, IdType global_chunk_index, IdType offset, IdType chunk_begin, IdType chunk_end, std::shared_ptr< util::IndexConverter > index_converter)
EdgesCollection is designed for reading a collection of edges.
virtual EdgeIter find_dst(IdType id, const EdgeIter &from)=0
static Result< std::shared_ptr< EdgesCollection > > Make(const std::shared_ptr< GraphInfo > &graph_info, const std::string &src_type, const std::string &edge_type, const std::string &dst_type, AdjListType adj_list_type, const IdType vertex_chunk_begin=0, const IdType vertex_chunk_end=std::numeric_limits< int64_t >::max()) noexcept
Construct an EdgesCollection from graph info and edge type.
virtual EdgeIter find_src(IdType id, const EdgeIter &from)=0
virtual size_t size() const noexcept
EdgesCollection(const std::shared_ptr< EdgeInfo > &edge_info, const std::string &prefix, IdType vertex_chunk_begin, IdType vertex_chunk_end, AdjListType adj_list_type)
Initialize the EdgesCollection with a range of chunks.
Ordered By Destination EdgesCollection implementation.
EdgeIter find_src(IdType id, const EdgeIter &from) override
EdgeIter find_dst(IdType id, const EdgeIter &from) override
OBDEdgesCollection(const std::shared_ptr< EdgeInfo > &edge_info, const std::string &prefix, IdType vertex_chunk_begin=0, IdType vertex_chunk_end=std::numeric_limits< int64_t >::max())
Initialize the OBDEdgesCollection with a range of chunks.
Ordered By Source EdgesCollection implementation.
OBSEdgeCollection(const std::shared_ptr< EdgeInfo > &edge_info, const std::string &prefix, IdType vertex_chunk_begin=0, IdType vertex_chunk_end=std::numeric_limits< int64_t >::max())
Initialize the OBSEdgeCollection with a range of chunks.
EdgeIter find_src(IdType id, const EdgeIter &from) override
EdgeIter find_dst(IdType id, const EdgeIter &from) override
static Status KeyError(Args &&... args)
Unordered By Destination EdgesCollection implementation.
EdgeIter find_src(IdType id, const EdgeIter &from) override
EdgeIter find_dst(IdType id, const EdgeIter &from) override
UBDEdgesCollection(const std::shared_ptr< EdgeInfo > &edge_info, const std::string &prefix, IdType vertex_chunk_begin=0, IdType vertex_chunk_end=std::numeric_limits< int64_t >::max())
Initialize the EdgesCollection with a range of chunks.
Unordered By Source EdgesCollection implementation.
EdgeIter find_dst(IdType id, const EdgeIter &from) override
UBSEdgesCollection(const std::shared_ptr< EdgeInfo > &edge_info, const std::string &prefix, IdType vertex_chunk_begin=0, IdType vertex_chunk_end=std::numeric_limits< int64_t >::max())
Initialize the EdgesCollection with a range of chunks.
EdgeIter find_src(IdType id, const EdgeIter &from) override
Vertex contains information of certain vertex.
bool IsValid(const std::string &property) const
Return true if value at the property is valid (not null).
IdType id() const noexcept
Get the id of the vertex.
Result< T > property(const std::string &property) const
Get the property value of the vertex.
Result< T > label() const
Get the label of the vertex.
Vertex(IdType id, std::vector< VertexPropertyArrowChunkReader > &readers)
The iterator for traversing a type of vertices.
Result< std::vector< std::string > > label() noexcept
Result< bool > hasLabel(const std::string &label) noexcept
VertexIter(const std::shared_ptr< VertexInfo > &vertex_info, const std::string &prefix, IdType offset, const std::vector< std::string > &labels, const bool &is_filtered=false, const std::vector< IdType > &filtered_ids={}) noexcept
bool operator==(const VertexIter &rhs) const noexcept
Result< T > property(const std::string &property) noexcept
Vertex operator*() noexcept
VertexIter operator++(int)
VertexIter operator+(IdType offset)
VertexIter(const VertexIter &other)
bool operator!=(const VertexIter &rhs) const noexcept
VertexIter & operator+=(IdType offset)
The arrow chunk reader for vertex property group.
VerticesCollection is designed for reading a collection of vertices.
static Result< std::shared_ptr< VerticesCollection > > Make(const std::shared_ptr< GraphInfo > &graph_info, const std::string &type)
Construct a VerticesCollection from graph info and vertex label.
VertexIter find(IdType id)
static Result< std::shared_ptr< VerticesCollection > > verticesWithMultipleLabels(const std::vector< std::string > &filter_labels, const std::shared_ptr< GraphInfo > &graph_info, const std::string &type)
Query vertices with multiple labels.
static Result< std::shared_ptr< VerticesCollection > > verticesWithLabel(const std::string &filter_label, const std::shared_ptr< GraphInfo > &graph_info, const std::string &type)
Query vertices with a specific label.
size_t size() const noexcept
VertexIter begin() noexcept
VertexIter end() noexcept
Result< std::vector< IdType > > filter(const std::vector< std::string > &filter_labels, std::vector< IdType > *new_valid_chunk=nullptr)
VerticesCollection(const std::shared_ptr< VertexInfo > &vertex_info, const std::string &prefix, const bool is_filtered=false, std::vector< IdType > filtered_ids={})
Initialize the VerticesCollection.