16 #ifndef STORAGES_RT_MUTABLE_GRAPH_CSR_NBR_H_
17 #define STORAGES_RT_MUTABLE_GRAPH_CSR_NBR_H_
19 #include "grape/types.h"
28 template <
typename EDATA_T>
47 bool exists()
const {
return neighbor != std::numeric_limits<vid_t>::max(); }
58 ~ImmutableNbr() =
default;
60 ImmutableNbr& operator=(
const ImmutableNbr& rhs) {
61 neighbor = rhs.neighbor;
66 const Date& get_data()
const {
return data; }
67 vid_t get_neighbor()
const {
return neighbor; }
69 void set_data(
const Date& val) { data = val; }
70 void set_neighbor(
vid_t neighbor) { this->neighbor = neighbor; }
72 bool exists()
const {
return neighbor != std::numeric_limits<vid_t>::max(); }
99 template <
typename EDATA_T>
137 :
ptr_(ptr), column_(column) {}
143 const ColumnNbr&
operator=(
const ColumnNbr& nbr)
const {
171 : slice_(slice), column_(column) {}
173 : slice_(rhs.slice_), column_(rhs.column_) {}
176 int size()
const {
return slice_.size(); }
180 const ColumnNbr
begin()
const {
return ColumnNbr(slice_.begin(), column_); }
181 const ColumnNbr
end()
const {
return ColumnNbr(slice_.end(), column_); }
203 :
ptr_(ptr), table_(table) {}
235 : slice_(slice), table_(table) {}
237 : slice_(rhs.slice_), table_(rhs.table_) {}
240 int size()
const {
return slice_.size(); }
244 const TableNbr
begin()
const {
return TableNbr(slice_.begin(), table_); }
245 const TableNbr
end()
const {
return TableNbr(slice_.end(), table_); }
257 template <
typename EDATA_T>
317 template <
typename EDATA_T>
350 struct MutableTableNbr {
355 :
ptr_(ptr), table_(table) {}
360 const MutableTableNbr&
operator*()
const {
return *
this; }
362 const MutableTableNbr&
operator=(
const MutableTableNbr& nbr)
const {
367 return ptr_ == nbr.ptr_;
370 return ptr_ != nbr.ptr_;
383 return ptr_ - nbr.ptr_;
386 bool operator<(
const MutableTableNbr& nbr)
const {
return ptr_ < nbr.ptr_; }
394 : slice_(slice), table_(table) {}
396 : slice_(rhs.slice_), table_(rhs.table_) {}
400 int size()
const {
return slice_.size(); }
405 const MutableTableNbr
begin()
const {
406 return MutableTableNbr(slice_.begin(), table_);
409 const MutableTableNbr
end()
const {
410 return MutableTableNbr(slice_.end(), table_);
423 struct MutableColumnNbr {
428 :
ptr_(ptr), column_(column) {}
433 const MutableColumnNbr&
operator*()
const {
return *
this; }
435 const MutableColumnNbr&
operator=(
const MutableColumnNbr& nbr)
const {
440 return ptr_ == nbr.ptr_;
443 return ptr_ != nbr.ptr_;
456 return ptr_ - nbr.ptr_;
460 return ptr_ < nbr.ptr_;
469 : slice_(slice), column_(column) {}
471 : slice_(rhs.slice_), column_(rhs.column_) {}
474 int size()
const {
return slice_.size(); }
478 const MutableColumnNbr
begin()
const {
479 return MutableColumnNbr(slice_.begin(), column_);
481 const MutableColumnNbr
end()
const {
482 return MutableColumnNbr(slice_.end(), column_);
495 template <
typename EDATA_T>
526 struct MutableColumnNbr {
530 :
ptr_(ptr), column_(column) {}
535 return column_.get_view(
ptr_->
data);
547 const MutableColumnNbr&
operator*()
const {
return *
this; }
549 MutableColumnNbr&
operator=(
const MutableColumnNbr& nbr) {
554 return ptr_ == nbr.ptr_;
557 return ptr_ != nbr.ptr_;
577 : slice_(slice), column_(column) {}
580 int size()
const {
return slice_.size(); }
584 MutableColumnNbr
begin() {
return MutableColumnNbr(slice_.begin(), column_); }
585 MutableColumnNbr
end() {
return MutableColumnNbr(slice_.end(), column_); }
600 struct MutableTableNbr {
612 for (
size_t i = 0; i < r.
len; ++i) {
615 grape::OutArchive out;
616 out.SetSlice(in.GetBuffer(), in.GetSize());
624 const MutableTableNbr&
operator*()
const {
return *
this; }
628 MutableTableNbr&
operator=(
const MutableTableNbr& nbr) {
633 return ptr_ == nbr.ptr_;
636 return ptr_ != nbr.ptr_;
648 return ptr_ - nbr.ptr_;
659 : slice_(slice), table_(table) {}
662 int size()
const {
return slice_.size(); }
const Table & table_
Definition: nbr.h:254
ImmutableNbrSlice(const ImmutableNbrSlice< size_t > &slice, const Table &table)
Definition: nbr.h:234
static ImmutableNbrSlice empty(const Table &table)
Definition: nbr.h:247
int size() const
Definition: nbr.h:240
const TableNbr begin() const
Definition: nbr.h:244
void set_begin(const ImmutableNbr< size_t > *ptr)
Definition: nbr.h:242
ImmutableNbrSlice(const ImmutableNbrSlice &rhs)
Definition: nbr.h:236
const TableNbr end() const
Definition: nbr.h:245
~ImmutableNbrSlice()=default
void set_size(int size)
Definition: nbr.h:239
ImmutableNbrSlice< size_t > slice_
Definition: nbr.h:253
const TableNbr const_nbr_ptr_t
Definition: nbr.h:233
const TableNbr const_nbr_t
Definition: nbr.h:232
void set_begin(const ImmutableNbr< size_t > *ptr)
Definition: nbr.h:178
ImmutableNbrSlice(const ImmutableNbrSlice &rhs)
Definition: nbr.h:172
ImmutableNbrSlice< size_t > slice_
Definition: nbr.h:191
static ImmutableNbrSlice empty(const StringColumn &column)
Definition: nbr.h:183
void set_size(int size)
Definition: nbr.h:175
int size() const
Definition: nbr.h:176
const StringColumn & column_
Definition: nbr.h:192
ImmutableNbrSlice(const StringColumn &column)
Definition: nbr.h:168
~ImmutableNbrSlice()=default
const ColumnNbr const_nbr_ptr_t
Definition: nbr.h:167
const ColumnNbr begin() const
Definition: nbr.h:180
ImmutableNbrSlice(const ImmutableNbrSlice< size_t > &slice, const StringColumn &column)
Definition: nbr.h:169
const ColumnNbr const_nbr_t
Definition: nbr.h:166
const ColumnNbr end() const
Definition: nbr.h:181
~ImmutableNbrSlice()=default
const_nbr_ptr_t ptr_
Definition: nbr.h:125
int size() const
Definition: nbr.h:110
static ImmutableNbrSlice empty()
Definition: nbr.h:117
void set_size(int size)
Definition: nbr.h:109
void set_begin(const_nbr_ptr_t ptr)
Definition: nbr.h:112
const_nbr_ptr_t end() const
Definition: nbr.h:115
const_nbr_ptr_t begin() const
Definition: nbr.h:114
ImmutableNbrSlice(const ImmutableNbrSlice &rhs)
Definition: nbr.h:105
int size_
Definition: nbr.h:126
ImmutableNbrSlice()=default
~MutableNbrSliceMut()=default
MutableTableNbr nbr_ptr_t
Definition: nbr.h:656
MutableNbrSliceMut< size_t > slice_
Definition: nbr.h:675
int field_num() const
Definition: nbr.h:663
nbr_ptr_t begin()
Definition: nbr.h:667
int size() const
Definition: nbr.h:662
void set_begin(MutableNbr< size_t > *ptr)
Definition: nbr.h:665
MutableNbrSliceMut(MutableNbrSliceMut< size_t > slice, Table &table)
Definition: nbr.h:658
void set_size(int size)
Definition: nbr.h:661
Table & table_
Definition: nbr.h:676
static MutableNbrSliceMut empty(Table &table)
Definition: nbr.h:670
nbr_ptr_t end()
Definition: nbr.h:668
void set_begin(MutableNbr< size_t > *ptr)
Definition: nbr.h:582
MutableNbrSliceMut< size_t > slice_
Definition: nbr.h:593
~MutableNbrSliceMut()=default
int size() const
Definition: nbr.h:580
void set_size(int size)
Definition: nbr.h:579
MutableColumnNbr end()
Definition: nbr.h:585
StringColumn & column_
Definition: nbr.h:594
MutableColumnNbr begin()
Definition: nbr.h:584
MutableNbrSliceMut(MutableNbrSliceMut< size_t > slice, StringColumn &column)
Definition: nbr.h:576
MutableColumnNbr nbr_ptr_t
Definition: nbr.h:574
static MutableNbrSliceMut empty(StringColumn &column)
Definition: nbr.h:587
nbr_t * begin()
Definition: nbr.h:508
void set_begin(nbr_t *ptr)
Definition: nbr.h:506
nbr_t * end()
Definition: nbr.h:509
nbr_t * ptr_
Definition: nbr.h:519
static MutableNbrSliceMut empty()
Definition: nbr.h:511
MutableNbrSliceMut()
Definition: nbr.h:500
~MutableNbrSliceMut()=default
int size_
Definition: nbr.h:520
void set_size(int size)
Definition: nbr.h:503
int size() const
Definition: nbr.h:504
const MutableTableNbr begin() const
Definition: nbr.h:405
~MutableNbrSlice()=default
int size() const
Definition: nbr.h:400
MutableNbrSlice< size_t > slice_
Definition: nbr.h:416
void set_size(int size)
Definition: nbr.h:399
const MutableTableNbr end() const
Definition: nbr.h:409
static MutableNbrSlice empty(const Table &table)
Definition: nbr.h:412
MutableNbrSlice(MutableNbrSlice< size_t > slice, const Table &table)
Definition: nbr.h:393
MutableNbrSlice(const MutableNbrSlice &rhs)
Definition: nbr.h:395
const Table & table_
Definition: nbr.h:417
int field_num() const
Definition: nbr.h:401
const MutableTableNbr const_nbr_ptr_t
Definition: nbr.h:392
void set_begin(const MutableNbr< size_t > *ptr)
Definition: nbr.h:403
const MutableTableNbr const_nbr_t
Definition: nbr.h:391
const MutableColumnNbr end() const
Definition: nbr.h:481
static MutableNbrSlice empty(const StringColumn &column)
Definition: nbr.h:485
void set_begin(const MutableNbr< size_t > *ptr)
Definition: nbr.h:476
MutableNbrSlice(MutableNbrSlice< size_t > slice, const StringColumn &column)
Definition: nbr.h:468
const MutableColumnNbr const_nbr_t
Definition: nbr.h:466
MutableNbrSlice< size_t > slice_
Definition: nbr.h:491
void set_size(int size)
Definition: nbr.h:473
MutableNbrSlice(const MutableNbrSlice &rhs)
Definition: nbr.h:470
~MutableNbrSlice()=default
const MutableColumnNbr begin() const
Definition: nbr.h:478
int size() const
Definition: nbr.h:474
const StringColumn & column_
Definition: nbr.h:492
const MutableColumnNbr const_nbr_ptr_t
Definition: nbr.h:467
void set_size(int size)
Definition: nbr.h:327
int size_
Definition: nbr.h:344
void set_begin(const_nbr_ptr_t ptr)
Definition: nbr.h:330
const_nbr_ptr_t ptr_
Definition: nbr.h:343
const_nbr_ptr_t end() const
Definition: nbr.h:333
static MutableNbrSlice empty()
Definition: nbr.h:335
~MutableNbrSlice()=default
int size() const
Definition: nbr.h:328
MutableNbrSlice()
Definition: nbr.h:322
MutableNbrSlice(const MutableNbrSlice &rhs)
Definition: nbr.h:323
const_nbr_ptr_t begin() const
Definition: nbr.h:332
Definition: adj_list.h:23
uint32_t timestamp_t
Definition: types.h:30
struct __attribute__((packed)) ImmutableNbr< Date >
Definition: nbr.h:54
uint32_t vid_t
Definition: types.h:31
Definition: loading_config.h:232
const TableNbr & operator++() const
Definition: nbr.h:215
const TableNbr * operator->() const
Definition: nbr.h:208
vid_t get_neighbor() const
Definition: nbr.h:204
const_nbr_ptr_t ptr_
Definition: nbr.h:229
const Table & table_
Definition: nbr.h:230
const TableNbr & operator*() const
Definition: nbr.h:207
bool operator!=(const TableNbr &nbr) const
Definition: nbr.h:214
TableNbr(const_nbr_ptr_t ptr, const Table &table)
Definition: nbr.h:202
const TableNbr & operator=(const TableNbr &nbr) const
Definition: nbr.h:209
const TableNbr & operator+=(size_t n) const
Definition: nbr.h:220
bool operator==(const TableNbr &nbr) const
Definition: nbr.h:213
RecordView get_data() const
Definition: nbr.h:205
size_t operator-(const TableNbr &nbr) const
Definition: nbr.h:225
bool operator<(const TableNbr &nbr) const
Definition: nbr.h:227
const ColumnNbr & operator+=(size_t n) const
Definition: nbr.h:154
const_nbr_ptr_t ptr_
Definition: nbr.h:163
const StringColumn & column_
Definition: nbr.h:164
const ColumnNbr * operator->() const
Definition: nbr.h:142
std::string_view get_data() const
Definition: nbr.h:139
ColumnNbr(const_nbr_ptr_t ptr, const StringColumn &column)
Definition: nbr.h:136
const ColumnNbr & operator=(const ColumnNbr &nbr) const
Definition: nbr.h:143
const ColumnNbr & operator++() const
Definition: nbr.h:149
size_t operator-(const ColumnNbr &nbr) const
Definition: nbr.h:159
bool operator<(const ColumnNbr &nbr) const
Definition: nbr.h:161
vid_t get_neighbor() const
Definition: nbr.h:138
const ColumnNbr & operator*() const
Definition: nbr.h:141
bool operator==(const ColumnNbr &nbr) const
Definition: nbr.h:147
bool operator!=(const ColumnNbr &nbr) const
Definition: nbr.h:148
ImmutableNbr(const ImmutableNbr &rhs)
Definition: nbr.h:81
void set_neighbor(vid_t neighbor)
Definition: nbr.h:90
ImmutableNbr & operator=(const ImmutableNbr &rhs)
Definition: nbr.h:84
vid_t neighbor
Definition: nbr.h:94
void set_data(const grape::EmptyType &)
Definition: nbr.h:89
const grape::EmptyType & get_data() const
Definition: nbr.h:91
grape::EmptyType data
Definition: nbr.h:95
vid_t get_neighbor() const
Definition: nbr.h:92
bool exists() const
Definition: nbr.h:47
const EDATA_T & get_data() const
Definition: nbr.h:41
EDATA_T data
Definition: nbr.h:50
ImmutableNbr(const ImmutableNbr &rhs)
Definition: nbr.h:31
ImmutableNbr & operator=(const ImmutableNbr &rhs)
Definition: nbr.h:35
void set_data(const EDATA_T &val)
Definition: nbr.h:44
void set_neighbor(vid_t neighbor)
Definition: nbr.h:45
vid_t get_neighbor() const
Definition: nbr.h:42
vid_t neighbor
Definition: nbr.h:49
vid_t neighbor() const
Definition: nbr.h:604
MutableTableNbr & operator*()
Definition: nbr.h:625
void set_data(const Record &r, timestamp_t ts)
Definition: nbr.h:610
Table & table_
Definition: nbr.h:654
void set_timestamp(timestamp_t ts)
Definition: nbr.h:622
RecordView get_data() const
Definition: nbr.h:608
vid_t get_neighbor() const
Definition: nbr.h:605
nbr_t * ptr_
Definition: nbr.h:653
MutableTableNbr(nbr_t *ptr, Table &table)
Definition: nbr.h:603
const MutableTableNbr * operator->() const
Definition: nbr.h:626
size_t operator-(const MutableTableNbr &nbr) const
Definition: nbr.h:647
bool operator==(const MutableTableNbr &nbr) const
Definition: nbr.h:632
timestamp_t get_timestamp() const
Definition: nbr.h:606
const MutableTableNbr & operator*() const
Definition: nbr.h:624
MutableTableNbr & operator=(const MutableTableNbr &nbr)
Definition: nbr.h:628
bool operator!=(const MutableTableNbr &nbr) const
Definition: nbr.h:635
bool operator<(const MutableTableNbr &nbr)
Definition: nbr.h:651
MutableTableNbr * operator->()
Definition: nbr.h:627
const MutableTableNbr & operator++() const
Definition: nbr.h:639
size_t get_index() const
Definition: nbr.h:607
void set_neighbor(vid_t neighbor)
Definition: nbr.h:620
const MutableTableNbr & operator+=(size_t n) const
Definition: nbr.h:643
bool operator!=(const MutableColumnNbr &nbr) const
Definition: nbr.h:556
std::string_view data()
Definition: nbr.h:532
StringColumn & column_
Definition: nbr.h:572
bool operator==(const MutableColumnNbr &nbr) const
Definition: nbr.h:553
vid_t get_neighbor() const
Definition: nbr.h:533
void set_neighbor(vid_t neighbor)
Definition: nbr.h:543
MutableColumnNbr & operator++()
Definition: nbr.h:560
nbr_t * ptr_
Definition: nbr.h:571
bool operator<(const MutableColumnNbr &nbr)
Definition: nbr.h:569
MutableColumnNbr & operator+=(size_t n)
Definition: nbr.h:564
const MutableColumnNbr & operator*() const
Definition: nbr.h:547
vid_t neighbor() const
Definition: nbr.h:531
void set_timestamp(timestamp_t ts)
Definition: nbr.h:545
const std::string_view get_data() const
Definition: nbr.h:534
MutableColumnNbr & operator=(const MutableColumnNbr &nbr)
Definition: nbr.h:549
MutableColumnNbr(nbr_t *ptr, StringColumn &column)
Definition: nbr.h:529
void set_data(const std::string_view &sw, timestamp_t ts)
Definition: nbr.h:539
timestamp_t get_timestamp() const
Definition: nbr.h:537
size_t get_index() const
Definition: nbr.h:538
MutableColumnNbr & operator*()
Definition: nbr.h:548
const MutableTableNbr & operator=(const MutableTableNbr &nbr) const
Definition: nbr.h:362
vid_t get_neighbor() const
Definition: nbr.h:356
const MutableTableNbr & operator++() const
Definition: nbr.h:372
timestamp_t get_timestamp() const
Definition: nbr.h:357
bool operator==(const MutableTableNbr &nbr) const
Definition: nbr.h:366
bool operator<(const MutableTableNbr &nbr) const
Definition: nbr.h:386
MutableTableNbr(const_nbr_ptr_t ptr, const Table &table)
Definition: nbr.h:354
RecordView get_data() const
Definition: nbr.h:358
bool operator!=(const MutableTableNbr &nbr) const
Definition: nbr.h:369
const Table & table_
Definition: nbr.h:389
const MutableTableNbr * operator->() const
Definition: nbr.h:361
const_nbr_ptr_t ptr_
Definition: nbr.h:388
size_t operator-(const MutableTableNbr &nbr) const
Definition: nbr.h:382
const MutableTableNbr & operator*() const
Definition: nbr.h:360
const MutableTableNbr & operator+=(size_t n) const
Definition: nbr.h:377
MutableColumnNbr(const_nbr_ptr_t ptr, const StringColumn &column)
Definition: nbr.h:427
size_t operator-(const MutableColumnNbr &nbr) const
Definition: nbr.h:455
const MutableColumnNbr & operator+=(size_t n) const
Definition: nbr.h:450
vid_t get_neighbor() const
Definition: nbr.h:429
const MutableColumnNbr & operator=(const MutableColumnNbr &nbr) const
Definition: nbr.h:435
const MutableColumnNbr * operator->() const
Definition: nbr.h:434
std::string_view get_data() const
Definition: nbr.h:430
const StringColumn & column_
Definition: nbr.h:464
const MutableColumnNbr & operator*() const
Definition: nbr.h:433
bool operator==(const MutableColumnNbr &nbr) const
Definition: nbr.h:439
const_nbr_ptr_t ptr_
Definition: nbr.h:463
timestamp_t get_timestamp() const
Definition: nbr.h:431
bool operator!=(const MutableColumnNbr &nbr) const
Definition: nbr.h:442
bool operator<(const MutableColumnNbr &nbr) const
Definition: nbr.h:459
const MutableColumnNbr & operator++() const
Definition: nbr.h:445
vid_t neighbor
Definition: nbr.h:310
void set_timestamp(timestamp_t ts)
Definition: nbr.h:306
void set_data(const grape::EmptyType &, timestamp_t ts)
Definition: nbr.h:302
MutableNbr(const MutableNbr &rhs)
Definition: nbr.h:292
grape::EmptyType data
Definition: nbr.h:313
const grape::EmptyType & get_data() const
Definition: nbr.h:307
void set_neighbor(vid_t neighbor)
Definition: nbr.h:305
std::atomic< timestamp_t > timestamp
Definition: nbr.h:312
vid_t get_neighbor() const
Definition: nbr.h:308
timestamp_t get_timestamp() const
Definition: nbr.h:309
MutableNbr & operator=(const MutableNbr &rhs)
Definition: nbr.h:296
vid_t neighbor
Definition: nbr.h:284
void set_data(const EDATA_T &val, timestamp_t ts)
Definition: nbr.h:277
std::atomic< timestamp_t > timestamp
Definition: nbr.h:285
timestamp_t get_timestamp() const
Definition: nbr.h:275
void set_neighbor(vid_t neighbor)
Definition: nbr.h:281
MutableNbr & operator=(const MutableNbr &rhs)
Definition: nbr.h:266
const EDATA_T & get_data() const
Definition: nbr.h:273
MutableNbr(const MutableNbr &rhs)
Definition: nbr.h:260
vid_t get_neighbor() const
Definition: nbr.h:274
void set_timestamp(timestamp_t ts)
Definition: nbr.h:282
EDATA_T data
Definition: nbr.h:286
Any * props
Definition: types.h:331
size_t len
Definition: types.h:330