Skip to content

Commit

Permalink
remove const value ptr support in v6d for inefficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
andydiwenzhu committed May 25, 2023
1 parent a04fc92 commit e35a263
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 79 deletions.
62 changes: 59 additions & 3 deletions modules/graph/grin/c/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,18 +668,18 @@ void test_property_edge_property_value(int argc, char** argv) {
#else
if (dt == Int64) {
long long int pv =
grin_get_edge_property_value_of_int64(g, ept, e, ep);
grin_get_edge_property_value_of_int64(g, e, ep);
long long int rv = grin_get_int64_from_row(g, row, k);
printf("ep_id %u e%zu %s value: %lld %lld\n", id, j, ep_name, pv, rv);
} else if (dt == String) {
const char* pv =
grin_get_edge_property_value_of_string(g, ept, e, ep);
grin_get_edge_property_value_of_string(g, e, ep);
const char* rv = grin_get_string_from_row(g, row, k);
printf("ep_id %u e%zu %s value: %s %s\n", id, j, ep_name, pv, rv);
grin_destroy_string_value(g, pv);
grin_destroy_string_value(g, rv);
} else if (dt == Double) {
double pv = grin_get_edge_property_value_of_double(g, ept, e, ep);
double pv = grin_get_edge_property_value_of_double(g, e, ep);
double rv = grin_get_double_from_row(g, row, k);
printf("ep_id %u e%zu %s value: %f %f\n", id, j, ep_name, pv, rv);
}
Expand Down Expand Up @@ -1069,6 +1069,61 @@ void test_topology_adjacent_list(int argc, char** argv, GRIN_DIRECTION dir) {
grin_destroy_graph(g);
}

Check notice on line 1071 in modules/graph/grin/c/test.c

View check run for this annotation

codefactor.io / CodeFactor

modules/graph/grin/c/test.c#L984-L1071

Complex Method
void test_index_order(int argc, char** argv) {
printf("+++++++++++++++++++++ Test index/order +++++++++++++++++++++\n");
GRIN_GRAPH g = get_graph(argc, argv);

GRIN_VERTEX_LIST vl = grin_get_vertex_list(g);
size_t vl_sz = grin_get_vertex_list_size(g, vl);
for (size_t i = 0; i < vl_sz; ++i) {
GRIN_VERTEX v = grin_get_vertex_from_list(g, vl, i);
size_t p = grin_get_position_of_vertex_from_sorted_list(g, vl, v);
if (p != i) {
printf("vertex position not match\n");
}
grin_destroy_vertex(g, v);
}
printf("%zu vertices checked\n", vl_sz);

#ifdef GRIN_ENABLE_GRAPH_PARTITION
GRIN_VERTEX_LIST mvl = grin_select_master_for_vertex_list(g, vl);
size_t mvl_sz = grin_get_vertex_list_size(g, mvl);
for (size_t i = 0; i < mvl_sz; ++i) {
GRIN_VERTEX v = grin_get_vertex_from_list(g, mvl, i);
size_t p = grin_get_position_of_vertex_from_sorted_list(g, mvl, v);
if (p != i) {
printf("vertex position not match\n");
}
grin_destroy_vertex(g, v);
}
printf("%zu vertices checked\n", mvl_sz);
grin_destroy_vertex_list(g, mvl);
#endif

GRIN_VERTEX_TYPE vtype = grin_get_vertex_type_by_name(g, "person");
GRIN_VERTEX_LIST svl = grin_select_type_for_vertex_list(g, vtype, vl);
size_t svl_sz = grin_get_vertex_list_size(g, svl);
for (size_t i = 0; i < svl_sz; ++i) {
GRIN_VERTEX v = grin_get_vertex_from_list(g, svl, i);
size_t p = grin_get_position_of_vertex_from_sorted_list(g, svl, v);
if (p != i) {
printf("vertex position not match\n");
}
grin_destroy_vertex(g, v);
}
printf("%zu vertices checked\n", svl_sz);
grin_destroy_vertex_list(g, svl);

grin_destroy_vertex_list(g, vl);
grin_destroy_graph(g);
}

void test_index(int argc, char** argv) {
#ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY
test_index_order(argc, argv);
#endif
}

void test_topology(int argc, char** argv) {
test_topology_vertex_list(argc, argv);
test_topology_adjacent_list(argc, argv, OUT);
Expand All @@ -1079,5 +1134,6 @@ int main(int argc, char** argv) {
test_property(argc, argv);
test_partition(argc, argv);
test_topology(argc, argv);
test_index(argc, argv);
return 0;
}
1 change: 0 additions & 1 deletion modules/graph/grin/predefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,6 @@ typedef enum {

// GRIN_STORAGE_ENABLE
#define GRIN_ENABLE_ROW
#define GRIN_TRAIT_CONST_VALUE_PTR
#define GRIN_WITH_VERTEX_PROPERTY
#define GRIN_WITH_VERTEX_PROPERTY_NAME
#define GRIN_WITH_VERTEX_TYPE_NAME
Expand Down
2 changes: 1 addition & 1 deletion modules/graph/grin/src/index/order.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ size_t grin_get_position_of_vertex_from_sorted_list(GRIN_GRAPH g, GRIN_VERTEX_LI
if (likely(_vl->is_simple)) return v - _vl->begin_;
auto _cache = static_cast<GRIN_GRAPH_T*>(g)->cache;
auto vtype = _cache->id_parser.GetLabelId(v);
return v - _vl->offsets[vtype].second;
return v - _vl->offsets[vtype].second + _vl->offsets[vtype].first;
}
#endif
2 changes: 2 additions & 0 deletions modules/graph/grin/src/partition/topology.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ GRIN_VERTEX_LIST grin_select_master_for_vertex_list(GRIN_GRAPH g, GRIN_VERTEX_LI
fvl->vtype = _vl->vtype;
fvl->is_simple = _vl->is_simple;
if (fvl->is_simple) __grin_init_simple_vertex_list(_g, fvl);
else __grin_init_complex_vertex_list(_g, fvl);
return fvl;
}

Expand All @@ -40,6 +41,7 @@ GRIN_VERTEX_LIST grin_select_mirror_for_vertex_list(GRIN_GRAPH g, GRIN_VERTEX_LI
fvl->vtype = _vl->vtype;
fvl->is_simple = _vl->is_simple;
if (fvl->is_simple) __grin_init_simple_vertex_list(_g, fvl);
else __grin_init_complex_vertex_list(_g, fvl);
return fvl;
}
#endif
Expand Down
74 changes: 0 additions & 74 deletions modules/graph/grin/src/property/property.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,43 +163,6 @@ GRIN_VERTEX_TYPE grin_get_vertex_type_from_property(GRIN_GRAPH g, GRIN_VERTEX_PR
}
#endif

#if defined(GRIN_WITH_VERTEX_PROPERTY) && defined(GRIN_TRAIT_CONST_VALUE_PTR)
const void* grin_get_vertex_property_value(GRIN_GRAPH g, GRIN_VERTEX v, GRIN_VERTEX_PROPERTY vp) {
auto result = _get_value_from_vertex_property_table(g, v, vp);
if (result == NULL) return NULL;
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
unsigned vtype = _grin_get_type_from_property(vp);
unsigned vprop = _grin_get_prop_from_property(vp);
auto _dt = _g->schema().GetVertexPropertyType(vtype, vprop);
auto dt = ArrowToDataType(_dt);
switch (dt) {
case GRIN_DATATYPE::Int32:
return static_cast<const int32_t*>(result);
case GRIN_DATATYPE::UInt32:
return static_cast<const uint32_t*>(result);
case GRIN_DATATYPE::Int64:
return static_cast<const int64_t*>(result);
case GRIN_DATATYPE::UInt64:
return static_cast<const uint64_t*>(result);
case GRIN_DATATYPE::Float:
return static_cast<const float*>(result);
case GRIN_DATATYPE::Double:
return static_cast<const double*>(result);
case GRIN_DATATYPE::String:
return static_cast<const std::string*>(result)->c_str();
case GRIN_DATATYPE::Date32:
return new int32_t(*static_cast<const int32_t*>(result));
case GRIN_DATATYPE::Time32:
return new int32_t(*static_cast<const int32_t*>(result));
case GRIN_DATATYPE::Timestamp64:
return new int64_t(*static_cast<const int64_t*>(result));
default:
grin_error_code = GRIN_ERROR_CODE::UNKNOWN_DATATYPE;
return NULL;
}
}
#endif


#ifdef GRIN_WITH_EDGE_PROPERTY
bool grin_equal_edge_property(GRIN_GRAPH g, GRIN_EDGE_PROPERTY ep1, GRIN_EDGE_PROPERTY ep2) {
Expand Down Expand Up @@ -278,40 +241,3 @@ GRIN_EDGE_TYPE grin_get_edge_type_from_property(GRIN_GRAPH g, GRIN_EDGE_PROPERTY
return _grin_get_type_from_property(ep);
}
#endif

#if defined(GRIN_WITH_EDGE_PROPERTY) && defined(GRIN_TRAIT_CONST_VALUE_PTR)
const void* grin_get_edge_property_value(GRIN_GRAPH g, GRIN_EDGE e, GRIN_EDGE_PROPERTY ep) {
const void* result = _get_value_from_edge_property_table(g, e, ep);
if (result == NULL) return NULL;
auto _g = static_cast<GRIN_GRAPH_T*>(g)->g;
unsigned etype = _grin_get_type_from_property(ep);
unsigned eprop = _grin_get_prop_from_property(ep);
auto _dt = _g->schema().GetEdgePropertyType(etype, eprop);
auto dt = ArrowToDataType(_dt);
switch (dt) {
case GRIN_DATATYPE::Int32:
return static_cast<const int32_t*>(result);
case GRIN_DATATYPE::UInt32:
return static_cast<const uint32_t*>(result);
case GRIN_DATATYPE::Int64:
return static_cast<const int64_t*>(result);
case GRIN_DATATYPE::UInt64:
return static_cast<const uint64_t*>(result);
case GRIN_DATATYPE::Float:
return static_cast<const float*>(result);
case GRIN_DATATYPE::Double:
return static_cast<const double*>(result);
case GRIN_DATATYPE::String:
return static_cast<const std::string*>(result)->c_str();
case GRIN_DATATYPE::Date32:
return static_cast<const int32_t*>(result);
case GRIN_DATATYPE::Time32:
return static_cast<const int32_t*>(result);
case GRIN_DATATYPE::Timestamp64:
return static_cast<const int64_t*>(result);
default:
grin_error_code = GRIN_ERROR_CODE::UNKNOWN_DATATYPE;
return NULL;
}
}
#endif

0 comments on commit e35a263

Please sign in to comment.