Replies: 6 comments 5 replies
-
It a great Idea. We have a lot of functions defined in OrientDB that must be ported. |
Beta Was this translation helpful? Give feedback.
-
@lvca , should you take the path of "functions" under database folder for script files, would you pls consider making it either a variable that we can set anywhere we like or functionable with symbolic link so we can point from wherever we like ( we keep things under the project repos. With orientdb we have setup_db script which init a db along with the existing embedded functions; then we can store our functions in similar fashion.) |
Beta Was this translation helpful? Give feedback.
-
I like this idea. Is there any update on this feature? |
Beta Was this translation helpful? Give feedback.
-
I think it's a great idea.
Sorry but I was full time on other projects. I'am nearly starting again
with Arcade.
To answer Luca's question, I implemented the OServerPluginAbstract and put
it in the lib.
If you can mimic the same interface it could be great to have full speed in
functions.
See you soon.
El lun, 20 nov 2023 a las 11:33, Zafar Ansari ***@***.***>)
escribió:
… Part 1: #281 <#281>
ArcadeDB already supports custom functions written in any language
supported by the JVM. The most common is Javascript and it's available out
of the box.
In order to define a new function "math" in Javascript you can execute
this (This syntax has been inherited from OrientDB):
define function math.sum \"return a + b\" parameters [a,b] language js
Since functions are not persistent, every time a server starts, the
function must be registered. Also, there is no easy way to write and run
functions from Studio or an IDE.
I believe custom functions will play an important role in the future of
ArcadeDB, mainly because:
- it's hard to write a general-purpose query optimizer on graphs
- complex queries are hard for beginners because they require a deep
knowledge of ArcadeDB (or Cypher)
- complex queries are hard to debug
What if ArcadeDB provides the support of IDEs and a minimal code editor in
Studio? Also, if possible, the ability to debug the code in the server
would be extremely helpful for the developer.
IDE Support
In order to use any IDE with ArcadeDB functions, the easiest way would be
to have a new folder "functions" under the database directory containing
the code of the functions in files with the suffix .js for Javascript. In
this way, you can work with any IDE. A file database.js could be created
by default containing all the functions (with no implementation) of the
supported functions callable from ArcadeDB. Example:
database.js
function database_lookupDocumentByRID( databaseInstance, rid ) {}
The IDE could load this file and provide a syntax completion out of the
box. Of course, this file must be updated with the real server-side
functions available on the Server.
customer.js
function getById( customerId ) {
let result = database_lookupDocumentByKey( db, "Customer", ["id"], [ customerId ] );
return result.length > 0 ? result[0] : null;}
The provided JS functions could mimic the current Java API with the class
name as a prefix separated by an underscore. This would avoid using OO in
Javascript.
At startup, the ArcadeDB server will load all the files with extensions
.js from the functions directory and registers the functions. The
functions above would be translated as:
define function customer.getById"let result = database_lookupDocumentByKey( db, \"Customer\", [\"id\"], [ customerId ] ); return result.length > 0 ? result[0] : null;"
parameters [customerId] language js
Note that the file name becomes the library (customer) where the function
is registered.
And the user can call the function from SQL (console, studio, postgres
driver, etc), such as:
select `customer.getById( 12345 )` as customer
Or SQL from Java with a prepared statement:
final ResultSet result = database.command("sql", "select `customer.getById(?)` as customer", 12345);
Or directly via Java API:
Vertex customer = database.getSchema().getFunction("customer", "getById").execute(12345);
Thoughts? Ideas? WDYT?
Contributions are welcome!
I like this idea. Is there any update on this feature?
—
Reply to this email directly, view it on GitHub
<#1155 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABIRCDHIM7YOL5LJDRPA3KDYFNS3PAVCNFSM6AAAAAAZ5FSHF6VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TMMRQGIYTC>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
There's no algorithm because it just a full path. I only do a deep
traverse till to node or max deep and continue with backtracking from
the last node. It is really important to use the filter with the
include/exclude filters to limit the function.
The git repo is this: https://github.com/mdre/FullPath
El lun, 20 nov 2023 a las 19:11, Luca Garulli
***@***.***>) escribió:
…
Thanks @mdre, out of this scope, I'm considering adding your function to ArcadeDB's graph library. What's the graph algorithm you have used to find all the paths?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Yes. I prevent finding if a node exists in the current path before it
is added. If it exists it is ignored because it is processing in the
backtracking.
When a path is found, it is added to the resulting collection of paths.
El mar, 21 nov 2023 a las 0:47, Luca Garulli ***@***.***>)
escribió:
… Do you take care of circular references?
—
Reply to this email directly, view it on GitHub
<#1155 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABIRCDGKFZHN5E6PZB4DG5LYFQP3JAVCNFSM6AAAAAAZ5FSHF6VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TMMRVHEYTK>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Part 1: #281
ArcadeDB already supports custom functions written in any language supported by the JVM. The most common is Javascript and it's available out of the box.
In order to define a new function "math" in Javascript you can execute this (This syntax has been inherited from OrientDB):
Since functions are not persistent, every time a server starts, the function must be registered. Also, there is no easy way to write and run functions from Studio or an IDE.
I believe custom functions will play an important role in the future of ArcadeDB, mainly because:
What if ArcadeDB provides the support of IDEs and a minimal code editor in Studio? Also, if possible, the ability to debug the code in the server would be extremely helpful for the developer.
IDE Support
In order to use any IDE with ArcadeDB functions, the easiest way would be to have a new folder "functions" under the database directory containing the code of the functions in files with the suffix
.js
for Javascript. In this way, you can work with any IDE. A filedatabase.js
could be created by default containing all the functions (with no implementation) of the supported functions callable from ArcadeDB. Example:database.js
The IDE could load this file and provide a syntax completion out of the box. Of course, this file must be updated with the real server-side functions available on the Server.
customer.js
The provided JS functions could mimic the current Java API with the class name as a prefix separated by an underscore. This would avoid using OO in Javascript.
At startup, the ArcadeDB server will load all the files with extensions
.js
from thefunctions
directory and registers the functions. The functions above would be translated as:Note that the file name becomes the library (customer) where the function is registered.
And the user can call the function from SQL (console, studio, postgres driver, etc), such as:
Or SQL from Java with a prepared statement:
Or directly via Java API:
Thoughts? Ideas? WDYT?
Contributions are welcome!
Beta Was this translation helpful? Give feedback.
All reactions