-
Notifications
You must be signed in to change notification settings - Fork 231
Support dynamic inline properties for CREATE and MERGE patterns #594
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
Conversation
9c49635
to
880ed76
Compare
|
||
uint node_count = array_len(op->nodes_to_merge); | ||
for(uint i = 0; i < node_count; i ++) { | ||
PropertyMap_Free(op->nodes_to_merge[i].properties); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plugged leak?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes; this should have been there all along.
@@ -28,6 +28,7 @@ typedef GrB_Index NodeID; | |||
typedef GrB_Index EdgeID; | |||
|
|||
typedef enum GraphEntityType { | |||
GETYPE_UNKNOWN, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this dangerous, is that compatible with old RDBs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GraphEntityType
never gets serialized; prior to now it had only been used in op_update.c
. I deleted the (nearly identical) enum EntityType
to declutter a bit.
static void _AddEdgeProperties(OpMerge *op, Schema *schema, Edge *e, PropertyMap *props) { | ||
if(props == NULL) return; | ||
|
||
static void _AddProperties(OpMerge *op, Record r, GraphEntity *ge, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIce!
@@ -15,6 +15,13 @@ | |||
|
|||
/* Creates new entities according to the CREATE clause. */ | |||
|
|||
// Container struct for properties to be added to a new graph entity | |||
typedef struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's wrong with PropertyMap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stores SIValues that have been converted from the AR_ExpNodes of PropertyMap. We could use the PropertyMap struct by calling AR_EXP_NewConstOperandNode
on each value, but I think that would be more wasteful than necessary.
@@ -317,13 +313,13 @@ AST_CreateContext AST_PrepareCreateOp(GraphContext *gc, RecordMap *record_map, A | |||
QueryGraph_AddPath(gc, ast, qg, path); | |||
|
|||
uint path_elem_count = cypher_ast_pattern_path_nelements(path); | |||
for(uint j = 0; j < path_elem_count; j ++) { | |||
for(uint k = 0; k < path_elem_count; k ++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How have we missed this?!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, I know. I can't believe that this type of bug doesn't trigger a compiler warning?
src/execution_plan/ops/op_create.c
Outdated
PendingProperties *_ConvertPropertyMap(Record r, const PropertyMap *map) { | ||
PendingProperties *converted = rm_malloc(sizeof(PendingProperties)); | ||
converted->property_count = map->property_count; | ||
converted->keys = map->keys; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about instead of holding keys as const char **
we use an array of attribute ids?
should save us some time when committing the properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/execution_plan/ops/op_create.c
Outdated
/* Convert query-level properties. */ | ||
PropertyMap *map = op->edges_to_create[i].properties; | ||
PendingProperties *converted_properties = NULL; | ||
if(map) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one liner
src/execution_plan/ops/op_create.c
Outdated
/* Convert query-level properties. */ | ||
PropertyMap *map = op->nodes_to_create[i].properties; | ||
PendingProperties *converted_properties = NULL; | ||
if(map) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one liner
src/execution_plan/ops/op_create.c
Outdated
for(uint i = 0; i < prop_count; i ++) { | ||
PendingProperties *props = op->node_properties[i]; | ||
if(props == NULL) continue; | ||
for(uint j = 0; j < props->property_count; j ++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introduce PendingProperties_Free function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/execution_plan/ops/op_create.c
Outdated
PendingProperties *converted = rm_malloc(sizeof(PendingProperties)); | ||
converted->property_count = map->property_count; | ||
converted->keys = map->keys; | ||
converted->attr_keys = rm_malloc(sizeof(Attribute_ID) * map->property_count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this was my miss understanding, I wanted to reduce the number of calls to GraphContext_FindOrAddAttribute
suppose we've got one PropertyMap
object,
MATCH (n) CREATE (m {n.v + 1})
and there are 1M n
nodes in our graph, as a result GraphContext_FindOrAddAttribute
will be called 1M times,
I think we should extend PropertyMap
to include Attribute_ID, this way we'll only need to call GraphContext_FindOrAddAttribute
once per attribute.
reducing the example above from 1M to just once.
94aba71
to
6bed431
Compare
…sGraph#594) * Remove extraneous entity type enum * Support non-constant inlined properties in CREATE and MERGE clauses * Fix memory leaks * Add additional tests * PR fixes * Early translation of string keys into Attribute IDs * Fix mis-sized allocation
No description provided.