Custom Java SQL Methods?

134 views
Skip to first unread message

Ravi Sandepudi

unread,
Nov 27, 2014, 1:41:28 AM11/27/14
to orient-...@googlegroups.com
Hi,

Are there plans to support custom SQL methods? This would really help us in writing powerful pipeline filters, something like:

SELECT out(CREATE)[@class='USER_ID'][timestamp.dateDiffLessThan(sysdate(), 300)=true].in(CREATE)[@class='EMAIL_ID'].size()

I wrote a custom function, but it doesn't seem to work in pipeline filtering:

SELECT out(CREATE)[@class='USER_ID'][dateDiffLessThan(sysdate(), timestamp, 300)=true].in(CREATE)[@class='EMAIL_ID'].size()

Custom methods seem to be easy to write (seeing https://github.com/orientechnologies/orientdb/blob/master/core/src/main/java/com/orientechnologies/orient/core/sql/functions/text/OSQLMethodRight.java) but there doesn't seem to be an easy way to register them.

Thanks,

Ravi

Ravi

unread,
Dec 1, 2014, 3:35:42 AM12/1/14
to orient-...@googlegroups.com
Any thoughts on this?

xvik

unread,
Dec 1, 2014, 8:53:43 AM12/1/14
to orient-...@googlegroups.com
Function registration:
OSQLEngine.getInstance().registerFunction(YourFunction.NAME, new YourFunction());

понедельник, 1 декабря 2014 г., 14:35:42 UTC+6 пользователь Ravi написал:
Any thoughts on this?

Ravi Sandepudi

unread,
Dec 1, 2014, 10:19:48 AM12/1/14
to orient-...@googlegroups.com

Yep. I'm aware of registering functions. I wanted to know if there are plans to support the same for methods (https://github.com/orientechnologies/orientdb/wiki/SQL-Methods).

Apologize if I'm missing something.

--

---
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/p_Z37_GRmM4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

xvik

unread,
Dec 1, 2014, 10:50:26 AM12/1/14
to orient-...@googlegroups.com
Sorry, read too fast.
Default methods factory is loaded by service locator, so most likely if you add your factory declaration it will be used too:

create file
META-INF/services/com.orientechnologies.orient.core.sql.method.OSQLMethodFactory
and put full class name of your factory there (like in orientdb-core.jar)

I haven't checked this yet, but it may work


понедельник, 1 декабря 2014 г., 21:19:48 UTC+6 пользователь Ravi написал:

Luca Garulli

unread,
Dec 3, 2014, 2:13:15 PM12/3/14
to orient-database
Exactly,
It works in the same way. By the way with OrientDB 2.0-SNAPSHOT we improved performance of JS engine. So maybe you should evaluate if it could be useful to use Server-Side Functions instead of writing Java functions/methods.

Lvc@


--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.

xvik

unread,
Dec 4, 2014, 4:36:21 AM12/4/14
to orient-...@googlegroups.com
But java functions/methods performance should still be better (maybe much better) isn't it?

четверг, 4 декабря 2014 г., 1:13:15 UTC+6 пользователь Lvc@ написал:

Luca Garulli

unread,
Dec 5, 2014, 12:50:47 PM12/5/14
to orient-database
Yes,
But Java8 has a good Nashorn JS engine that compile in byte code Javascript, so performance could be close in some cases.

Lvc@

Ravi

unread,
Dec 30, 2014, 9:48:57 AM12/30/14
to orient-...@googlegroups.com
Sorry quick add on here: it's not possible to write methods in JS right? So if we want to use these in pipeline filtering, we need to stick to writing Java based methods. Please correct me if I'm wrong or if there's a better way in solving the issue I mentioned in the original post.

Luca Garulli

unread,
Dec 30, 2014, 1:59:08 PM12/30/14
to orient-database
Hey Ravi,
I'm sorry but methods can be written only in Java now. However it's very easy to do that, would you like to create a new issue for that?

Thanks,
Lvc@

Reply all
Reply to author
Forward
0 new messages