Adding a new procedure that returns all the procedures in the system by alonre24 · Pull Request #1377 · RedisGraph/RedisGraph · GitHub
Skip to content

Adding a new procedure that returns all the procedures in the system#1377

Merged
swilly22 merged 4 commits into
masterfrom
Add_a_procedure_that_returns_all_procedures
Oct 13, 2020
Merged

Adding a new procedure that returns all the procedures in the system#1377
swilly22 merged 4 commits into
masterfrom
Add_a_procedure_that_returns_all_procedures

Conversation

@alonre24

Copy link
Copy Markdown
Collaborator

This procedure may yield up to two fields for each procedure: its name and/or its mode (READ/WRITE).
#1376

… This procedure may yield up to two fields for each procedure: its name and/or its mode (READ/WRITE).
Comment thread src/procedures/proc_procedures.c Outdated
Comment on lines +7 to +10

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General formatting comment:
Order the include statement according to line length

Comment thread src/procedures/proc_procedures.c Outdated
Comment on lines +15 to +16
raxIterator *current_proc; // Current proc
SIValue *output; // Array with a maximum of 4 entries: ["name", name, "mode", mode].

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General struct formatting:

  1. take the longest line and write the comment 4 spaces from its end. Align all other lines accordingly.
  2. try to sort variables line by length, when possible

Comment thread src/procedures/proc_procedures.c Outdated
} ProceduresContext;

ProcedureResult Proc_ProceduresInvoke(ProcedureCtx *ctx,
const SIValue *args, const char **yield) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation?

Comment thread src/procedures/proc_procedures.c
Comment thread src/procedures/proc_procedures.c
Comment thread src/procedures/procedure.c Outdated
}

const char *Procedure_GetName(const ProcedureCtx *proc) {
assert(proc);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include "RG.h" and use ASSERT macro
This is debugging time assert

Comment thread src/procedures/procedure.h Outdated
Comment on lines +51 to +57
// Returns the rax that contains all the procedures
rax *Proc_Get_All();

// Returns true if the procedure is read-only
bool Procedure_IsReadOnly(const ProcedureCtx *proc);

//Returns the procedure's name

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General comments formatting:
A sentence starts with capital letters and ends with a period.

Comment thread src/procedures/procedure.c Outdated
}

bool Procedure_IsReadOnly(const ProcedureCtx *proc) {
assert(proc);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASSERT

Comment thread tests/flow/test_procedures.py Outdated
Comment on lines +326 to +330
# The following two procedure are a part of the expected results
expected_result = ["db.labels", "READ"]
self.env.assertContains(expected_result, actual_resultset)
expected_result = ["db.idx.fulltext.createNodeIndex", "WRITE"]
self.env.assertContains(expected_result, actual_resultset)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make it a single array?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, because the assertContains utility works only with searching a singleton in a set

return PROCEDURE_OK;
}

SIValue *Proc_ProceduresStep(ProcedureCtx *ctx) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comments explaining what the step does

@alonre24 alonre24 force-pushed the Add_a_procedure_that_returns_all_procedures branch 2 times, most recently from c214890 to e919a70 Compare October 12, 2020 09:02
Comment thread src/procedures/proc_procedures.c Outdated
Comment thread src/procedures/proc_procedures.c Outdated
return PROCEDURE_OK;
}

// Promote the rax iterator to the next procedure and return its name and mode

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Promote the rax iterator to the next procedure and return its name and mode
// Promote the rax iterator to the next procedure and return its name and mode.

Comment thread src/procedures/proc_procedures.c Outdated

// Promote the rax iterator to the next procedure and return its name and mode
SIValue *Proc_ProceduresStep(ProcedureCtx *ctx) {
assert(ctx->privateData);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASSERT

Comment on lines +150 to +159
const char *Procedure_GetName(const ProcedureCtx *proc) {
ASSERT(proc != NULL);
return proc->name;
}

bool Procedure_IsReadOnly(const ProcedureCtx *proc) {
ASSERT(proc != NULL);
return proc->readOnly;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the only caller to those functions is proc_procedures
consider moving them there as auxiliary static functions

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

op_procedure_call.c access procedure's readOnly attribute,
please change op_procedure_call.c to call this function instead.

Comment thread tests/flow/test_procedures.py Outdated
Comment on lines +327 to +329
expected_result = [["db.labels", "READ"], ["db.idx.fulltext.createNodeIndex", "WRITE"]]
for res in expected_result:
self.env.assertContains(res, actual_resultset)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure all current procedures show up in the result-set.

@alonre24 alonre24 force-pushed the Add_a_procedure_that_returns_all_procedures branch from 9d7e577 to cc00897 Compare October 12, 2020 11:29
@alonre24 alonre24 force-pushed the Add_a_procedure_that_returns_all_procedures branch from cc00897 to d55a69a Compare October 12, 2020 15:48
DvirDukhan
DvirDukhan previously approved these changes Oct 12, 2020

@swilly22 swilly22 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good job, please see comments.

Comment thread tests/flow/test_procedures.py Outdated
Comment on lines +327 to +329
expected_result = [["db.labels", "READ"], ["db.idx.fulltext.createNodeIndex", "WRITE"]]
for res in expected_result:
self.env.assertContains(res, actual_resultset)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure all current procedures show up in the result-set.

Comment thread src/procedures/procedures.h Outdated
#include "proc_fulltext_drop_index.h"
#include "proc_fulltext_create_index.h"

#include "proc_procedures.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lines should be sorts by length.

Comment thread src/procedures/procedure.h Outdated
Comment on lines +51 to +52
// Returns the rax that contains all the procedures.
rax *Procedure_GetProceduresRax();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove, Have the procedures procedure access __procedures directly. (use extern)

Comment thread src/procedures/procedure.h Outdated
// Returns true if the procedure is read-only.
bool Procedure_IsReadOnly(const ProcedureCtx *proc);

//Returns the procedure's name.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after /

Comment thread src/procedures/procedure.c
Comment thread src/procedures/proc_procedures.c Outdated
ProcProceduresPrivateData *pdata = rm_malloc(sizeof(ProcProceduresPrivateData));

// Initialize an iterator to the rax that contains all procedures
rax *rax = Procedure_GetProceduresRax();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rax *procedures = __procedures

Comment thread src/procedures/proc_procedures.c Outdated

// Initialize an iterator to the rax that contains all procedures
rax *rax = Procedure_GetProceduresRax();
raxIterator *it = rm_malloc(sizeof(raxIterator));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove.

Comment thread src/procedures/proc_procedures.c Outdated
// Initialize an iterator to the rax that contains all procedures
rax *rax = Procedure_GetProceduresRax();
raxIterator *it = rm_malloc(sizeof(raxIterator));
raxStart(it, rax);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raxStart(it, &pdata->iter);

Comment thread src/procedures/proc_procedures.c Outdated
// Returns the current procedure's name and mode.
ProcGenerator gen = it->data;
ProcedureCtx *curr_proc_ctx = gen();
pdata->output[1] = SI_DuplicateStringVal(Procedure_GetName(curr_proc_ctx));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to duplicate procedure name, as the name is a static string.

Comment thread src/procedures/proc_procedures.c Outdated
if(ctx->privateData) {
ProcProceduresPrivateData *pdata = ctx->privateData;
array_free(pdata->output);
rm_free(pdata->procedure_rax_it);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

procedure_rax_it should be heap alocated.

…proc_proceudres_private_data. More PR code fixes
@alonre24 alonre24 force-pushed the Add_a_procedure_that_returns_all_procedures branch from 8c7e962 to 6d58b17 Compare October 13, 2020 09:10
Comment thread src/procedures/procedure.h Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have Procedure_IsReadOnly do we really need both Procedure_IsReadOnly and Procedure_ReadOnly can we do with just one?

@alonre24 alonre24 force-pushed the Add_a_procedure_that_returns_all_procedures branch 2 times, most recently from 6438816 to e35666e Compare October 13, 2020 11:34
…name, leaving only the getter "Procedure_IsReadOnly" that gets the whole procedure object.
@alonre24 alonre24 force-pushed the Add_a_procedure_that_returns_all_procedures branch from e35666e to 65ecf17 Compare October 13, 2020 12:01
@swilly22 swilly22 merged commit cd97f6c into master Oct 13, 2020
@swilly22 swilly22 deleted the Add_a_procedure_that_returns_all_procedures branch October 13, 2020 13:17
swilly22 added a commit that referenced this pull request Nov 8, 2020
* added init time NodeScanCtx update on label scan (#1358)

* added init time NodeScanCtx update on label scan

* rephrase comment

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* Bfs procedure call (#1306)

* Import LAGraph files

* Apply autoformatter

* Add LAGraph include file

* WIP Add BFS procedure

* tmp Utility

* Revert LAGraph inclusions

* Replace LAGraph reference with GraphBLAS references

* WIP

* WIP

* Add BFSTree procedure

* Add unit tests

* Update documentation

* Resolve compiler warnings

* Address PR comments

* Make singular BFS procedure with variable outputs

* Remove start_node yield

* Address PR comments

* Remove yield-edges BFS input arg

* Address PR comments

* Switch to LAGraph_bfs_pushpull

* Remove unused code paths from LAGraph BFS algorithm

* procedure invocation receives yield array

* consume BFS result using iterator

* test BFS returning no results

* clean up, address PR comments

Co-authored-by: swilly22 <roi@redislabs.com>
Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* Separate ExecutionPlan op construction logic into different files (#1352)

* Separate ExecutionPlan op construction logic into different files

* Address PR comments

* Refactor header files

* Address PR comments

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* Support array properties in bulk loader (#1365)

* Support array properties in bulk loader

* Address PR comments

* Add no_multi_key & hash_policy (#1363)

* Add no_multi_key & hash_policy

* Update ramp.yml

At the moment we can't handle user hash policy due to virtual keys

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* Add LGTM (#1367)

* read only query (#1364)

* read only query

* added sleep, try to avoid ci failure

* added more write scenarios. added replica shutdown

* added skip flag to avoid memcheck failure

* fixed PR comments

* Update module.c

* try to skip on any debugger. added more write scenarios

* checkSlaveSynced moved to use time.sleep. Another try to skip debuger

* added RO_QUERY to commands

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* Fix typo (#1368)

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* Add GRAPH.BULK documentation and link to bulk loader documentation (#1371)

* Add GRAPH.BULK documentation and link to bulk loader documentation

* Address PR comments

* Allow upper case letters in proc names (#1372)

* added to_lower for procedure name in Proc_get to support both upper and lower cases

* new test for lookup_case_insensitive

* Created strutil and moved the implementations of str_tolower and str_toupper to it. Remove the static implementations of these functions and replaced every call with a new call for str_tolower.
minor changes in getProc and procRegister due to PR

* fix indentations

* fix indentations

* minor changes

* minor changes

* indentations fix

* indentations fix

* indentations fix

* indentations fix

* indentations fix

* PR fixes

* PR fixes

* PR fixes

* PR fixes

* PR fixes

* PR fixes

* PR fixes

* PR fixes

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* Adding a new procedure that returns all the procedures in the system (#1377)

* Adding a new procedure that returns all the procedures in the system. This procedure may yield up to two fields for each procedure: its name and/or its mode (READ/WRITE).

* PR fixes

* Saving raxIterator reference instead of allocating it on the heap in proc_proceudres_private_data. More PR code fixes

* Remove the getter "Procedure_ReadOnly" that gets only the procedures name, leaving only the getter "Procedure_IsReadOnly" that gets the whole procedure object.

* Always set GraphCtx in QueryCtx while decoding graph keys (#1381)

* LGTM alert fixes (#1383)

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* Avoid double free of heap-allocated values in CASE...WHEN statements (#1386)

* Avoid double free of heap-allocated values in CASE...WHEN statements

* Update test_function_calls.py

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* With filter scoping (#1361)

* Don't migrate WITH filters into Merge and Apply scopes

* Don't place filters in previous scope for filtered aliases

* Fix memory error

* remove vector

* consolidate operation locating

* execution plan construction refactoring WIP

* move arithmetic expression construction from AST to AR_EXP

* discover skip, limit and black-listed ops modifiers

* PR fixes

* Fixes continued

* Fix ResultSet updates in UNION queries

* Clarify comments, minor cleanup

* Fix unit tests

* Fix caching logic for SKIP and LIMIT

* Address PR comments

* tidy up execution plan construction and join op

* reset limit on aggregation

* define 16 as the default batch size for traversal operations

Co-authored-by: swilly22 <roi@redislabs.com>
Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* Updates to Astyle config file (#1384)

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* replace gitter with Discord (#1395)

* reaplace gitter with Discord

* replace gitter to discord

* Allow property accesses on non-identifier entity references (#1389)

* Allow property accesses on non-identifier entity references

* access entity attribute only via the property function

* address PR comments

Co-authored-by: swilly22 <roi@redislabs.com>
Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>

* Minor suggested update. (#1398)

* replace automation service (#1399)

* redundent filter construction and placement (#1397)

* redundent filter construction and placement

* Add validating flow tests

Co-authored-by: Jeffrey Lovitz <jeffrey.lovitz@gmail.com>

* Parse full argv array on main thread (#1298)

* Parse full argv array on main thread

* remove read_flags from cmd_query

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>
Co-authored-by: swilly22 <roi@redislabs.com>

* query validation should not check if procedure outputs been defined (#1406)

* query validation should not check if procedure outputs been defined

* address PR comments

* Add trusted-by logos (#1412)

* Add trusted-by logos

* add more logos

* Fuzzy test crashes (#1408)

* Correctly place filters without referenced variables

* Emit compile-time error on constant non-boolean filter

* Validate references per clause instead of per scope

* Emit error on failed filter placement in optimize_cartesian_product

* Fix free of invalid value in OpUnwind

* Handle NULL sources in variable-length traversals

* Address PR comments

* Post-rebase fixes

* Address PR comments

* introduce AST unsupported op error

Co-authored-by: swilly22 <roi@redislabs.com>

* Graph version (#1382)

* add graph version to graph context object

* change graph version from string to uint32

* testing graph version

* response with an error when graph version mismatch

* release graph context on version mismatch

* address PR comments

* increase command arity to accomadate graph version argument

* address PR comments

Co-authored-by: DvirDukhan <dvir@redislabs.com>

* Release version 2.2.8. Merged from master.

Co-authored-by: DvirDukhan <dvir@redislabs.com>
Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>
Co-authored-by: Jeffrey Lovitz <jeffrey.lovitz@gmail.com>
Co-authored-by: swilly22 <roi@redislabs.com>
Co-authored-by: Guy Korland <gkorland@gmail.com>
Co-authored-by: Yahya <5457202+anakaiti@users.noreply.github.com>
Co-authored-by: Simon Prickett <simon@crudworks.org>
pnxguide pushed a commit to CMU-SPEED/RedisGraph that referenced this pull request Mar 22, 2023
…edisGraph#1377)

* Adding a new procedure that returns all the procedures in the system. This procedure may yield up to two fields for each procedure: its name and/or its mode (READ/WRITE).

* PR fixes

* Saving raxIterator reference instead of allocating it on the heap in proc_proceudres_private_data. More PR code fixes

* Remove the getter "Procedure_ReadOnly" that gets only the procedures name, leaving only the getter "Procedure_IsReadOnly" that gets the whole procedure object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants