Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Introduce grin apis #1191

Open
wants to merge 85 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
baa166f
draft commit of grin apis
andydiwenzhu Feb 10, 2023
926b662
pre implement arrow fragment by grin apis
andydiwenzhu Feb 13, 2023
d789df9
fix nbr, adjlist, project & dests
andydiwenzhu Feb 13, 2023
22b938e
macro format
andydiwenzhu Feb 14, 2023
a526c0d
reorg iterator logic & partition logic & property row logic
andydiwenzhu Feb 15, 2023
88cc56a
grin api implementations
andydiwenzhu Feb 20, 2023
e90d1d8
some fixes
andydiwenzhu Feb 21, 2023
812bafa
add doxygen comments
andydiwenzhu Feb 24, 2023
f2bf332
refine grin *.cc
andydiwenzhu Feb 26, 2023
8ee63d8
compile ok
andydiwenzhu Feb 27, 2023
fd890eb
update docs
andydiwenzhu Mar 1, 2023
b6f3a1d
a mixed example and updated docs
andydiwenzhu Mar 2, 2023
ee9f86c
refactor macro/type/func names
andydiwenzhu Mar 3, 2023
9ab9bb3
format func parameters & add vertex ordering predicate
andydiwenzhu Mar 6, 2023
caf908c
update macros and docs
andydiwenzhu Mar 9, 2023
62d008a
update docs
andydiwenzhu Mar 10, 2023
5d58284
refactor array-style access & vertex ordering
andydiwenzhu Mar 15, 2023
faabc0c
quick fix
andydiwenzhu Mar 15, 2023
c022184
reorg
andydiwenzhu Mar 16, 2023
aa267a2
use grin headers as submodule
andydiwenzhu Mar 16, 2023
0c6d17a
update docs
andydiwenzhu Mar 17, 2023
5de8334
add iterators
andydiwenzhu Mar 17, 2023
0268287
remove pointers in _T structs
andydiwenzhu Mar 20, 2023
b16338a
refine partition impl
andydiwenzhu Mar 20, 2023
9ba798a
refine partition & update headers
andydiwenzhu Mar 21, 2023
b8f21e1
debug grin_test
andydiwenzhu Mar 21, 2023
3d848a7
hot fix grin header
andydiwenzhu Mar 21, 2023
d3082d6
fix list filter return new value
andydiwenzhu Mar 21, 2023
90cc495
build libvineyard_grin lib
andydiwenzhu Mar 21, 2023
161b5c7
fix get edge from adjacentlist
andydiwenzhu Mar 22, 2023
0c275e5
implement vertex/edge total num (by type) methods
andydiwenzhu Mar 24, 2023
722725b
implement iodests in grin fragment
andydiwenzhu Mar 24, 2023
5323302
update docs
andydiwenzhu Mar 24, 2023
b241677
implement destroys
andydiwenzhu Mar 28, 2023
165ffaa
rename & update impl
andydiwenzhu Mar 28, 2023
b0c0fef
fix get properties by name
andydiwenzhu Mar 28, 2023
799109d
fix for destroy value and name
andydiwenzhu Mar 29, 2023
b924bef
add destroy partitioned graph handler impl
andydiwenzhu Mar 29, 2023
5560acf
add get graph from storage
andydiwenzhu Mar 29, 2023
102ec98
refine get value from property table
andydiwenzhu Mar 29, 2023
a17798a
refine type cast
andydiwenzhu Mar 30, 2023
86d8b37
remove limits.h
andydiwenzhu Mar 31, 2023
1716bba
add rust gen and reorg predefine.h
andydiwenzhu Mar 31, 2023
6cff974
refine rust codegen
andydiwenzhu Apr 12, 2023
aa1d053
refine doc after removing local complete
andydiwenzhu Apr 12, 2023
7cc4086
update storage feature protobuf impl
andydiwenzhu Apr 13, 2023
305a1d8
impl vertex primary key & gie schema converter
andydiwenzhu Apr 17, 2023
4d8ff04
update gie schema proto in grin
andydiwenzhu Apr 18, 2023
9fba8d1
rename trait in storage feature proto to feature to distinguish trait…
andydiwenzhu Apr 18, 2023
11324ec
make sure grin.so has C interface
andydiwenzhu Apr 21, 2023
080d662
fix for c tests
andydiwenzhu Apr 24, 2023
e1b21be
revert submodule reorg
andydiwenzhu Apr 24, 2023
43068ed
fix for test
andydiwenzhu May 4, 2023
ddc9e0d
expand value APIs and remove datatype.h impls
andydiwenzhu May 7, 2023
6088c02
impl fast_vertex_ref trait
andydiwenzhu May 8, 2023
b8c41d7
imsync datatype with schema
andydiwenzhu May 8, 2023
05c270f
change some handlers into integers for better performance
andydiwenzhu May 8, 2023
6dfe5b9
add fast vertex ref to message
andydiwenzhu May 8, 2023
ac480ce
impl error code
andydiwenzhu May 8, 2023
29b6e7f
quick fix insert string to row
andydiwenzhu May 9, 2023
d964311
add error_code to rust codegen
andydiwenzhu May 9, 2023
6f80b2d
null value in rust codegen and errorcode update
andydiwenzhu May 9, 2023
bdee5bd
grin api rename
andydiwenzhu May 10, 2023
823689c
add protoc to cmake
andydiwenzhu May 10, 2023
d46d4d7
remove total num impls
andydiwenzhu May 10, 2023
c58e8c7
fix original id impl
andydiwenzhu May 12, 2023
86cba7c
fix shared ptr copy problem in Graph_T
andydiwenzhu May 12, 2023
18b4abd
impl for value/original_id update
andydiwenzhu May 14, 2023
9581461
fix grin include
andydiwenzhu May 15, 2023
97d7435
small fixes
andydiwenzhu May 15, 2023
e5d179b
fix some adjlist bug
andydiwenzhu May 16, 2023
3c6c180
fix adjacent list bug
andydiwenzhu May 16, 2023
3c0367c
fix adjacent bug
andydiwenzhu May 16, 2023
7dd3cf5
change vertex handler from void* to int64
andydiwenzhu May 17, 2023
da59a45
grin graph cache optimize
andydiwenzhu May 18, 2023
301a923
update codegen rs
andydiwenzhu May 19, 2023
9148ed7
is_simple in adjlist
andydiwenzhu May 19, 2023
d3a44f4
optimize vertexlist and adjlist impl
andydiwenzhu May 21, 2023
5582d1b
update v6d impl for removing table from property
andydiwenzhu May 22, 2023
6fd6086
fix for remove column macros
andydiwenzhu May 22, 2023
3c6b783
fix get string bug
andydiwenzhu May 23, 2023
cd3ce9f
remove used code in arrow fragment group
andydiwenzhu May 23, 2023
c5e5b3a
fix simple vertex/adj list init bugs
andydiwenzhu May 23, 2023
a04fc92
optimize if branch using likely
andydiwenzhu May 24, 2023
e35a263
remove const value ptr support in v6d for inefficiency
andydiwenzhu May 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change vertex handler from void* to int64
andydiwenzhu committed May 18, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 7dd3cf516662a492d5d5e110b17db5941597e302
4 changes: 2 additions & 2 deletions modules/graph/grin/predefine.h
Original file line number Diff line number Diff line change
@@ -825,7 +825,7 @@ typedef enum {
/** @brief Null graph (invalid return value) */
#define GRIN_NULL_GRAPH NULL
/** @brief Non-existing vertex (invalid return value) */
#define GRIN_NULL_VERTEX NULL
#define GRIN_NULL_VERTEX (unsigned long long int)~0
/** @brief Non-existing edge (invalid return value) */
#define GRIN_NULL_EDGE NULL
/** @brief Null list of any kind (invalid return value) */
@@ -859,7 +859,7 @@ typedef enum {

/* Define the handlers using typedef */
typedef void* GRIN_GRAPH;
typedef void* GRIN_VERTEX;
typedef unsigned long long int GRIN_VERTEX;
typedef void* GRIN_EDGE;

#ifdef GRIN_WITH_VERTEX_DATA
2 changes: 1 addition & 1 deletion modules/graph/grin/rust/v6d_all.h
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@

/// RUST_KEEP pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED;
/// RUST_KEEP pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut();
/// RUST_KEEP pub const GRIN_NULL_VERTEX: GrinVertex = std::ptr::null_mut();
/// RUST_KEEP pub const GRIN_NULL_VERTEX: GrinVertex = u64::MAX;
/// RUST_KEEP pub const GRIN_NULL_EDGE: GrinEdge = std::ptr::null_mut();
/// RUST_KEEP pub const GRIN_NULL_LIST: *mut ::std::os::raw::c_void = std::ptr::null_mut();
/// RUST_KEEP pub const GRIN_NULL_LIST_ITERATOR: *mut ::std::os::raw::c_void = std::ptr::null_mut();
21 changes: 8 additions & 13 deletions modules/graph/grin/src/index/order.cc
Original file line number Diff line number Diff line change
@@ -18,25 +18,20 @@ extern "C" {

#ifdef GRIN_ASSUME_ALL_VERTEX_LIST_SORTED
bool grin_smaller_vertex(GRIN_GRAPH g, GRIN_VERTEX v1, GRIN_VERTEX v2) {
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
auto _v1 = static_cast<GRIN_VERTEX_T*>(v1);
auto _v2 = static_cast<GRIN_VERTEX_T*>(v2);
return _g->Vertex2Gid(*_v1) < _g->Vertex2Gid(*_v2);
return v1 < v2;
}
#endif

#if defined(GRIN_ASSUME_ALL_VERTEX_LIST_SORTED) && defined(GRIN_ENABLE_VERTEX_LIST_ARRAY)
size_t grin_get_position_of_vertex_from_sorted_list(GRIN_GRAPH g, GRIN_VERTEX_LIST vl, GRIN_VERTEX v) {
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
auto _v = static_cast<GRIN_VERTEX_T*>(v);
auto _vl = static_cast<GRIN_VERTEX_LIST_T*>(vl);
return _v->GetValue() - _vl->vrs[0].begin_value();
// auto vtype = (unsigned)_g->vertex_label(*_v);
// if (vtype < _vl->type_begin || vtype >= _vl->type_end) return GRIN_NULL_SIZE;
// auto offset = _v->GetValue() - _vl->vrs[vtype - _vl->type_begin].begin_value();
// if (offset < _vl->vrs[vtype - _vl->type_begin].size()) {
// return _vl->offsets[vtype - _vl->type_begin] + offset;
// }
// return GRIN_NULL_SIZE;
auto vtype = (unsigned)_g->vertex_label(_GRIN_VERTEX_T(v)); // TODO: optimize after rebase
if (vtype < _vl->type_begin || vtype >= _vl->type_end) return GRIN_NULL_SIZE;
auto offset = v - _vl->vrs[vtype - _vl->type_begin].begin_value();
if (offset < _vl->vrs[vtype - _vl->type_begin].size()) {
return _vl->offsets[vtype - _vl->type_begin] + offset;
}
return GRIN_NULL_SIZE;
}
#endif
9 changes: 4 additions & 5 deletions modules/graph/grin/src/index/original_id.cc
Original file line number Diff line number Diff line change
@@ -23,18 +23,17 @@ GRIN_DATATYPE grin_get_vertex_original_id_datatype(GRIN_GRAPH g) {
#ifdef GRIN_ENABLE_VERTEX_ORIGINAL_ID_OF_INT64
long long int grin_get_vertex_original_id_of_int64(GRIN_GRAPH g, GRIN_VERTEX v) {
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
auto _v = static_cast<GRIN_VERTEX_T*>(v);
auto gid = _g->Vertex2Gid(*_v);
auto gid = _g->Vertex2Gid(_GRIN_VERTEX_T(v));
return _g->Gid2Oid(gid);
}

GRIN_VERTEX grin_get_vertex_by_original_id_of_int64(GRIN_GRAPH g, long long int oid) {
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
_GRIN_GRAPH_T::vid_t gid;
auto v = new GRIN_VERTEX_T();
_GRIN_VERTEX_T v;
if (_g->Oid2Gid(0, oid, gid)) {
if (_g->Gid2Vertex(gid, *v)) {
return v;
if (_g->Gid2Vertex(gid, v)) {
return v.GetValue();
}
}
return GRIN_NULL_VERTEX;
4 changes: 1 addition & 3 deletions modules/graph/grin/src/partition/partition.cc
Original file line number Diff line number Diff line change
@@ -35,12 +35,10 @@ GRIN_PARTITIONED_GRAPH grin_get_partitioned_graph_from_storage(int argc, char**
for (auto & [fid, location] : pg->pg->FragmentLocations()) {
if (location == pg->client.instance_id()) {
auto obj_id = pg->pg->Fragments().at(fid);
// std::cout << fid << ": " << obj_id << std::endl;
// auto frag = std::dynamic_pointer_cast<_GRIN_GRAPH_T>(pg->client.GetObject(obj_id));
pg->lgs[fid] = obj_id;
}
}
return pg;
return pg;
}

void grin_destroy_partitioned_graph(GRIN_PARTITIONED_GRAPH pg) {
17 changes: 7 additions & 10 deletions modules/graph/grin/src/partition/reference.cc
Original file line number Diff line number Diff line change
@@ -21,24 +21,23 @@ extern "C" {
#ifdef GRIN_ENABLE_VERTEX_REF
GRIN_VERTEX_REF grin_get_vertex_ref_by_vertex(GRIN_GRAPH g, GRIN_VERTEX v) {
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
auto _v = static_cast<GRIN_VERTEX_T*>(v);
return _g->Vertex2Gid(*_v);
return _g->Vertex2Gid(_GRIN_VERTEX_T(v));
}

void grin_destroy_vertex_ref(GRIN_GRAPH g, GRIN_VERTEX_REF vr) {}

GRIN_VERTEX grin_get_vertex_from_vertex_ref(GRIN_GRAPH g, GRIN_VERTEX_REF vr) {
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
auto v = new GRIN_VERTEX_T();
if (_g->Gid2Vertex(vr, *v)) {
return v;
_GRIN_VERTEX_T v;
if (_g->Gid2Vertex(vr, v)) {
return v.GetValue();
}
return GRIN_NULL_VERTEX;
}

GRIN_PARTITION grin_get_master_partition_from_vertex_ref(GRIN_GRAPH g, GRIN_VERTEX_REF vr) {
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
auto id_parser = vineyard::IdParser<GRIN_VERTEX_REF_T>();
auto id_parser = vineyard::IdParser<GRIN_VERTEX_REF_T>(); //TODO optimize after rebase
id_parser.Init(_g->fnum(), _g->vertex_label_num());
return id_parser.GetFid(vr);
}
@@ -75,14 +74,12 @@ GRIN_VERTEX_REF grin_deserialize_to_vertex_ref(GRIN_GRAPH g, const char* msg) {

bool grin_is_master_vertex(GRIN_GRAPH g, GRIN_VERTEX v) {
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
auto _v = static_cast<GRIN_VERTEX_T*>(v);
return _g->IsInnerVertex(*_v);
return _g->IsInnerVertex(_GRIN_VERTEX_T(v)); // TODO
}

bool grin_is_mirror_vertex(GRIN_GRAPH g, GRIN_VERTEX v) {
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
auto _v = static_cast<GRIN_VERTEX_T*>(v);
return _g->IsOuterVertex(*_v);
return _g->IsOuterVertex(_GRIN_VERTEX_T(v)); // TODO
}
#endif

13 changes: 6 additions & 7 deletions modules/graph/grin/src/predefine.cc
Original file line number Diff line number Diff line change
@@ -72,14 +72,13 @@ const void* _get_value_from_vertex_property_table(GRIN_GRAPH g, GRIN_VERTEX_PROP
grin_error_code = GRIN_ERROR_CODE::NO_ERROR;
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
auto _vpt = static_cast<GRIN_VERTEX_PROPERTY_TABLE_T*>(vpt);
auto _v = static_cast<GRIN_VERTEX_T*>(v);
unsigned vtype = _grin_get_type_from_property(vp);
unsigned vprop = _grin_get_prop_from_property(vp);
if (vtype != _vpt->vtype || !_vpt->vertices.Contain(*_v)) {
if (v < _vpt->vbegin || v >= _vpt->vend) {
grin_error_code = GRIN_ERROR_CODE::INVALID_VALUE;
return NULL;
}
auto offset = _v->GetValue() - _vpt->vertices.begin_value();
unsigned vtype = _grin_get_type_from_property(vp);
unsigned vprop = _grin_get_prop_from_property(vp);
auto offset = v - _vpt->vbegin;
auto array = _g->vertex_data_table(vtype)->column(vprop)->chunk(0);
return vineyard::get_arrow_array_data_element(array, offset);
}
@@ -107,7 +106,7 @@ void __grin_init_vertex_list(_GRIN_GRAPH_T* g, GRIN_VERTEX_LIST_T* vl) {
vl->vrs.clear();
_GRIN_GRAPH_T::vertices_t vr;
vl->offsets.push_back(0);
unsigned sum = 0;
size_t sum = 0;
for (auto vtype = vl->type_begin; vtype < vl->type_end; ++vtype) {
if (vl->all_master_mirror == 0) {
vr = g->Vertices(vtype);
@@ -129,7 +128,7 @@ void __grin_init_adjacent_list(_GRIN_GRAPH_T* g, GRIN_ADJACENT_LIST_T* al) {
al->data.clear();
_GRIN_GRAPH_T::raw_adj_list_t ral;
al->offsets.push_back(0);
unsigned sum = 0;
size_t sum = 0;
for (auto etype = al->etype_begin; etype < al->etype_end; ++etype) {
if (al->dir == GRIN_DIRECTION::IN) {
ral = g->GetIncomingRawAdjList(_GRIN_GRAPH_T::vertex_t(al->vid), etype);
9 changes: 5 additions & 4 deletions modules/graph/grin/src/predefine.h
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ struct GRIN_GRAPH_T {
std::shared_ptr<_GRIN_GRAPH_T> _g;
_GRIN_GRAPH_T* g;
};
typedef _GRIN_GRAPH_T::vertex_t GRIN_VERTEX_T;
typedef _GRIN_GRAPH_T::vertex_t _GRIN_VERTEX_T;
struct GRIN_EDGE_T {
_GRIN_GRAPH_T::vid_t src;
_GRIN_GRAPH_T::vid_t dst;
@@ -116,7 +116,7 @@ struct GRIN_VERTEX_LIST_T {
unsigned type_begin;
unsigned type_end;
unsigned all_master_mirror;
std::vector<unsigned> offsets;
std::vector<size_t> offsets;
std::vector<_GRIN_GRAPH_T::vertices_t> vrs;
};
void __grin_init_vertex_list(_GRIN_GRAPH_T* g, GRIN_VERTEX_LIST_T* vl);
@@ -139,7 +139,7 @@ struct GRIN_ADJACENT_LIST_T {
GRIN_DIRECTION dir;
unsigned etype_begin;
unsigned etype_end;
std::vector<unsigned> offsets;
std::vector<size_t> offsets;
std::vector<_GRIN_GRAPH_T::raw_adj_list_t> data;
};
void __grin_init_adjacent_list(_GRIN_GRAPH_T* g, GRIN_ADJACENT_LIST_T* al);
@@ -179,7 +179,8 @@ typedef unsigned long long int GRIN_VERTEX_PROPERTY_T;
typedef std::vector<GRIN_VERTEX_PROPERTY_T> GRIN_VERTEX_PROPERTY_LIST_T;
struct GRIN_VERTEX_PROPERTY_TABLE_T {
unsigned vtype;
_GRIN_GRAPH_T::vertices_t vertices;
_GRIN_GRAPH_T::vid_t vbegin;
_GRIN_GRAPH_T::vid_t vend;
};
#endif

29 changes: 10 additions & 19 deletions modules/graph/grin/src/property/primarykey.cc
Original file line number Diff line number Diff line change
@@ -56,35 +56,26 @@ GRIN_VERTEX grin_get_vertex_by_primary_keys(GRIN_GRAPH g, GRIN_VERTEX_TYPE vtype
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
auto _r = static_cast<GRIN_ROW_T*>(r);
auto value = (*_r)[0];
#if 0
for (auto p = 0; p < _g->vertex_property_num(vtype); ++p) {
if (_g->schema().GetVertexPropertyName(vtype, p) == "id") {
auto arrow_dt = _g->schema().GetVertexPropertyType(vtype, p);
auto dt = ArrowToDataType(arrow_dt);

if (dt == GRIN_DATATYPE::Int32) {
auto vid = static_cast<const int32_t*>(value);
auto _v = new GRIN_VERTEX_T();
if (!_g->GetVertex(vtype, *vid, *_v)) return GRIN_NULL_VERTEX;
return _v;
} else if (dt == GRIN_DATATYPE::UInt32) {
auto vid = static_cast<const uint32_t*>(value);
auto _v = new GRIN_VERTEX_T();
if (!_g->GetVertex(vtype, *vid, *_v)) return GRIN_NULL_VERTEX;
return _v;
} else if (dt == GRIN_DATATYPE::Int64) {
if (dt == GRIN_DATATYPE::Int64) {
#endif
_GRIN_VERTEX_T v;
auto vid = static_cast<const int64_t*>(value);
auto _v = new GRIN_VERTEX_T();
if (!_g->GetVertex(vtype, *vid, *_v)) return GRIN_NULL_VERTEX;
return _v;
} else if (dt == GRIN_DATATYPE::UInt64) {
auto vid = static_cast<const uint64_t*>(value);
auto _v = new GRIN_VERTEX_T();
if (!_g->GetVertex(vtype, *vid, *_v)) return GRIN_NULL_VERTEX;
return _v;
if (!_g->GetVertex(vtype, *vid, v)) return GRIN_NULL_VERTEX;
return v.GetValue();
#if 0
} else {
return GRIN_NULL_VERTEX;
}
}
}
return GRIN_NULL_VERTEX;
#endif
}
#endif

4 changes: 2 additions & 2 deletions modules/graph/grin/src/property/property.cc
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ const char* grin_get_vertex_property_name(GRIN_GRAPH g, GRIN_VERTEX_TYPE vtype,
int len = s.length() + 1;
char* out = new char[len];
snprintf(out, len, "%s", s.c_str());
return out;
return out; // TODO: optimize after rebase, put strings in g.
}

GRIN_VERTEX_PROPERTY grin_get_vertex_property_by_name(GRIN_GRAPH g, GRIN_VERTEX_TYPE vtype,
@@ -59,7 +59,7 @@ const char* grin_get_edge_property_name(GRIN_GRAPH g, GRIN_EDGE_TYPE etype, GRIN
int len = s.length() + 1;
char* out = new char[len];
snprintf(out, len, "%s", s.c_str());
return out;
return out; // TODO
}

GRIN_EDGE_PROPERTY grin_get_edge_property_by_name(GRIN_GRAPH g, GRIN_EDGE_TYPE etype,
9 changes: 5 additions & 4 deletions modules/graph/grin/src/property/propertytable.cc
Original file line number Diff line number Diff line change
@@ -186,7 +186,9 @@ GRIN_VERTEX_PROPERTY_TABLE grin_get_vertex_property_table_by_type(GRIN_GRAPH g,
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
auto vpt = new GRIN_VERTEX_PROPERTY_TABLE_T();
vpt->vtype = vtype;
vpt->vertices = _g->InnerVertices(vtype);
auto vr = _g->InnerVertices(vtype);
vpt->vbegin = vr.begin_value();
vpt->vend = vr.end_value();
return vpt;
}

@@ -295,10 +297,9 @@ GRIN_ROW grin_get_row_from_vertex_property_table(GRIN_GRAPH g, GRIN_VERTEX_PROPE
GRIN_VERTEX_PROPERTY_LIST vpl) {
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
auto _vpt = static_cast<GRIN_VERTEX_PROPERTY_TABLE_T*>(vpt);
auto _v = static_cast<GRIN_VERTEX_T*>(v);
auto _vpl = static_cast<GRIN_VERTEX_PROPERTY_LIST_T*>(vpl);
if (!_vpt->vertices.Contain(*_v)) return NULL;
auto offset = _v->GetValue() - _vpt->vertices.begin_value();
if (v < _vpt->vbegin || v >= _vpt->vend) return NULL;
auto offset = v - _vpt->vbegin;

auto r = new GRIN_ROW_T();
for (auto vp: *_vpl) {
13 changes: 6 additions & 7 deletions modules/graph/grin/src/property/type.cc
Original file line number Diff line number Diff line change
@@ -22,8 +22,7 @@ bool grin_equal_vertex_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt1, GRIN_VERTEX_TYPE

GRIN_VERTEX_TYPE grin_get_vertex_type(GRIN_GRAPH g, GRIN_VERTEX v) {
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
auto _v = static_cast<GRIN_VERTEX_T*>(v);
return _g->vertex_label(*_v);
return _g->vertex_label(_GRIN_VERTEX_T(v)); // TODO
}

void grin_destroy_vertex_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) {}
@@ -71,7 +70,7 @@ const char* grin_get_vertex_type_name(GRIN_GRAPH g, GRIN_VERTEX_TYPE vtype) {
int len = s.length() + 1;
char* out = new char[len];
snprintf(out, len, "%s", s.c_str());
return out;
return out; // TODO
}

GRIN_VERTEX_TYPE grin_get_vertex_type_by_name(GRIN_GRAPH g, const char* name) {
@@ -149,7 +148,7 @@ const char* grin_get_edge_type_name(GRIN_GRAPH g, GRIN_EDGE_TYPE etype) {
int len = s.length() + 1;
char* out = new char[len];
snprintf(out, len, "%s", s.c_str());
return out;
return out; // TODO
}

GRIN_EDGE_TYPE grin_get_edge_type_by_name(GRIN_GRAPH g, const char* name) {
@@ -181,7 +180,7 @@ GRIN_VERTEX_TYPE_LIST grin_get_src_types_by_edge_type(GRIN_GRAPH g, GRIN_EDGE_TY
for (auto& pair : entry.relations) {
vtl->push_back(GRIN_VERTEX_TYPE_T(_g->schema().GetVertexLabelId(pair.first)));
}
return vtl;
return vtl; // TODO
}

GRIN_VERTEX_TYPE_LIST grin_get_dst_types_by_edge_type(GRIN_GRAPH g, GRIN_EDGE_TYPE etype) {
@@ -191,7 +190,7 @@ GRIN_VERTEX_TYPE_LIST grin_get_dst_types_by_edge_type(GRIN_GRAPH g, GRIN_EDGE_TY
for (auto& pair : entry.relations) {
vtl->push_back(GRIN_VERTEX_TYPE_T(_g->schema().GetVertexLabelId(pair.second)));
}
return vtl;
return vtl; // TODO
}

GRIN_EDGE_TYPE_LIST grin_get_edge_types_by_vertex_type_pair(GRIN_GRAPH g, GRIN_VERTEX_TYPE src_vt,
@@ -209,6 +208,6 @@ GRIN_EDGE_TYPE_LIST grin_get_edge_types_by_vertex_type_pair(GRIN_GRAPH g, GRIN_V
}
}
}
return etl;
return etl; // TODO
}
#endif
9 changes: 3 additions & 6 deletions modules/graph/grin/src/topology/adjacentlist.cc
Original file line number Diff line number Diff line change
@@ -22,9 +22,8 @@ extern "C" {
GRIN_ADJACENT_LIST grin_get_adjacent_list(GRIN_GRAPH g, GRIN_DIRECTION d, GRIN_VERTEX v) {
if (d == GRIN_DIRECTION::BOTH) return GRIN_NULL_LIST;
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
auto _v = static_cast<GRIN_VERTEX_T*>(v);
auto al = new GRIN_ADJACENT_LIST_T();
al->vid = _v->GetValue();
al->vid = v;
al->dir = d;
al->etype_begin = 0;
al->etype_end = _g->edge_label_num();
@@ -48,8 +47,7 @@ GRIN_VERTEX grin_get_neighbor_from_adjacent_list(GRIN_GRAPH g, GRIN_ADJACENT_LIS
if (idx < _al->offsets[i+1]) {
auto _idx = idx - _al->offsets[i];
auto _nbr = _al->data[i].begin() + _idx;
auto v = new GRIN_VERTEX_T(_nbr->vid);
return v;
return _nbr->vid;
}
}
return GRIN_NULL_VERTEX;
@@ -136,8 +134,7 @@ bool grin_is_adjacent_list_end(GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR ali) {
GRIN_VERTEX grin_get_neighbor_from_adjacent_list_iter(GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR ali) {
auto _ali = static_cast<GRIN_ADJACENT_LIST_ITERATOR_T*>(ali);
auto _nbr = _ali->data.begin() + _ali->current;
auto v = new GRIN_VERTEX_T(_nbr->vid);
return v;
return _nbr->vid;
}

GRIN_EDGE grin_get_edge_from_adjacent_list_iter(GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR ali) {
Loading