Database Performance at Scale by Felipe Cardeneti Mendes & Piotr Sarna & Pavel Emelyanov & Cynthia Dunlop

Database Performance at Scale by Felipe Cardeneti Mendes & Piotr Sarna & Pavel Emelyanov & Cynthia Dunlop

Author:Felipe Cardeneti Mendes & Piotr Sarna & Pavel Emelyanov & Cynthia Dunlop
Language: eng
Format: epub
ISBN: 9781484297117
Publisher: Apress


Examples

Let’s take a look at a few examples of user-defined functions. The function serving as the example operates on floating point numbers; given two parameters, it returns the sum of them, inverted. Given 5 and 7, it should return 1/5+1/7, which is approximately 0.34285714285.

Here’s how it could be defined in Apache Cassandra, which allows user-defined function definitions to be provided in Java, its native language, as well as in other languages: CREATE OR REPLACE FUNCTION add_inverse(val1 double, val2 double)

RETURNS NULL ON NULL INPUT

RETURNS double LANGUAGE java

AS '

return (val1 == 0 || val2 == 0)

? Double.NaN

: (1/val1 + 1/val2);

';



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.