Repository: asterixdb-site Updated Branches: refs/heads/asf-site 9c40a66dc -> d00eca894
http://git-wip-us.apache.org/repos/asf/asterixdb-site/blob/d00eca89/docs/0.9.4/udf.html ---------------------------------------------------------------------- diff --git a/docs/0.9.4/udf.html b/docs/0.9.4/udf.html new file mode 100644 index 0000000..83f7114 --- /dev/null +++ b/docs/0.9.4/udf.html @@ -0,0 +1,266 @@ +<!DOCTYPE html> +<!-- + | Generated by Apache Maven Doxia Site Renderer 1.8.1 from src/site/markdown/udf.md at 2018-10-02 + | Rendered using Apache Maven Fluido Skin 1.7 +--> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> + <meta charset="UTF-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta name="Date-Revision-yyyymmdd" content="20181002" /> + <meta http-equiv="Content-Language" content="en" /> + <title>AsterixDB – Support for User Defined Functions in AsterixDB</title> + <link rel="stylesheet" href="./css/apache-maven-fluido-1.7.min.css" /> + <link rel="stylesheet" href="./css/site.css" /> + <link rel="stylesheet" href="./css/print.css" media="print" /> + <script type="text/javascript" src="./js/apache-maven-fluido-1.7.min.js"></script> + + </head> + <body class="topBarDisabled"> + <div class="container-fluid"> + <div id="banner"> + <div class="pull-left"><a href="./" id="bannerLeft"><img src="images/asterixlogo.png" alt="AsterixDB"/></a></div> + <div class="pull-right"></div> + <div class="clear"><hr/></div> + </div> + + <div id="breadcrumbs"> + <ul class="breadcrumb"> + <li id="publishDate">Last Published: 2018-10-02</li> + <li id="projectVersion" class="pull-right">Version: 0.9.4</li> + <li class="pull-right"><a href="index.html" title="Documentation Home">Documentation Home</a></li> + </ul> + </div> + <div class="row-fluid"> + <div id="leftColumn" class="span2"> + <div class="well sidebar-nav"> + <ul class="nav nav-list"> + <li class="nav-header">Get Started - Installation</li> + <li><a href="ncservice.html" title="Option 1: using NCService"><span class="none"></span>Option 1: using NCService</a></li> + <li><a href="ansible.html" title="Option 2: using Ansible"><span class="none"></span>Option 2: using Ansible</a></li> + <li><a href="aws.html" title="Option 3: using Amazon Web Services"><span class="none"></span>Option 3: using Amazon Web Services</a></li> + <li class="nav-header">AsterixDB Primer</li> + <li><a href="sqlpp/primer-sqlpp.html" title="Option 1: using SQL++"><span class="none"></span>Option 1: using SQL++</a></li> + <li><a href="aql/primer.html" title="Option 2: using AQL"><span class="none"></span>Option 2: using AQL</a></li> + <li class="nav-header">Data Model</li> + <li><a href="datamodel.html" title="The Asterix Data Model"><span class="none"></span>The Asterix Data Model</a></li> + <li class="nav-header">Queries - SQL++</li> + <li><a href="sqlpp/manual.html" title="The SQL++ Query Language"><span class="none"></span>The SQL++ Query Language</a></li> + <li><a href="sqlpp/builtins.html" title="Builtin Functions"><span class="none"></span>Builtin Functions</a></li> + <li class="nav-header">Queries - AQL</li> + <li><a href="aql/manual.html" title="The Asterix Query Language (AQL)"><span class="none"></span>The Asterix Query Language (AQL)</a></li> + <li><a href="aql/builtins.html" title="Builtin Functions"><span class="none"></span>Builtin Functions</a></li> + <li class="nav-header">API/SDK</li> + <li><a href="api.html" title="HTTP API"><span class="none"></span>HTTP API</a></li> + <li><a href="csv.html" title="CSV Output"><span class="none"></span>CSV Output</a></li> + <li class="nav-header">Advanced Features</li> + <li><a href="aql/fulltext.html" title="Support of Full-text Queries"><span class="none"></span>Support of Full-text Queries</a></li> + <li><a href="aql/externaldata.html" title="Accessing External Data"><span class="none"></span>Accessing External Data</a></li> + <li><a href="feeds/tutorial.html" title="Support for Data Ingestion"><span class="none"></span>Support for Data Ingestion</a></li> + <li class="active"><a href="#"><span class="none"></span>User Defined Functions</a></li> + <li><a href="aql/filters.html" title="Filter-Based LSM Index Acceleration"><span class="none"></span>Filter-Based LSM Index Acceleration</a></li> + <li><a href="aql/similarity.html" title="Support of Similarity Queries"><span class="none"></span>Support of Similarity Queries</a></li> +</ul> + <hr /> + <div id="poweredBy"> + <div class="clear"></div> + <div class="clear"></div> + <div class="clear"></div> + <div class="clear"></div> +<a href="./" title="AsterixDB" class="builtBy"><img class="builtBy" alt="AsterixDB" src="images/asterixlogo.png" /></a> + </div> + </div> + </div> + <div id="bodyColumn" class="span10" > +<!-- + ! Licensed to the Apache Software Foundation (ASF) under one + ! or more contributor license agreements. See the NOTICE file + ! distributed with this work for additional information + ! regarding copyright ownership. The ASF licenses this file + ! to you under the Apache License, Version 2.0 (the + ! "License"); you may not use this file except in compliance + ! with the License. You may obtain a copy of the License at + ! + ! http://www.apache.org/licenses/LICENSE-2.0 + ! + ! Unless required by applicable law or agreed to in writing, + ! software distributed under the License is distributed on an + ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ! KIND, either express or implied. See the License for the + ! specific language governing permissions and limitations + ! under the License. + !--> +<h1>Support for User Defined Functions in AsterixDB</h1> +<div class="section"> +<h2><a name="Table_of_Contents"></a><a name="atoc" id="#toc">Table of Contents</a></h2> +<ul> + +<li><a href="#PreprocessingCollectedData">Using UDF to preprocess feed-collected data</a></li> +<li><a href="#WritingAnExternalUDF">Writing an External UDF</a></li> +<li><a href="#CreatingAnAsterixDBLibrary">Creating an AsterixDB Library</a></li> +<li><a href="#installingUDF">Installing an AsterixDB Library</a></li> +</ul> +<p>In this document, we describe the support for implementing, using, and installing user-defined functions (UDF) in AsterixDB. We will explain how we can use UDFs to preprocess, e.g., data collected using feeds (see the <a href="feeds/tutorial.html">feeds tutorial</a>).</p> +<div class="section"> +<h3><a name="Installing_an_AsterixDB_Library"></a><a name="installingUDF">Installing an AsterixDB Library</a></h3> +<p>We assume you have followed the <a href="../install.html">installation instructions</a> to set up a running AsterixDB instance. Let us refer your AsterixDB instance by the name “my_asterix”.</p> +<ul> + +<li> + +<p>Step 1: Stop the AsterixDB instance if it is in the ACTIVE state.</p> + +<div> +<div> +<pre class="source">$ managix stop -n my_asterix +</pre></div></div> +</li> +<li> + +<p>Step 2: Install the library using Managix install command. Just to illustrate, we use the help command to look up the syntax</p> + +<div> +<div> +<pre class="source">$ managix help -cmd install +Installs a library to an asterix instance. +Options +n Name of Asterix Instance +d Name of the dataverse under which the library will be installed +l Name of the library +p Path to library zip bundle +</pre></div></div> +</li> +</ul> +<p>Above is a sample output and explains the usage and the required parameters. Each library has a name and is installed under a dataverse. Recall that we had created a dataverse by the name - “feeds” prior to creating our datatypes and dataset. We shall name our library - “testlib”.</p> +<p>We assume you have a library zip bundle that needs to be installed. To install the library, use the Managix install command. An example is shown below.</p> + +<div> +<div> +<pre class="source"> $ managix install -n my_asterix -d feeds -l testlib -p extlibs/asterix-external-data-0.8.7-binary-assembly.zip +</pre></div></div> + +<p>You should see the following message:</p> + +<div> +<div> +<pre class="source"> INFO: Installed library testlib +</pre></div></div> + +<p>We shall next start our AsterixDB instance using the start command as shown below.</p> + +<div> +<div> +<pre class="source"> $ managix start -n my_asterix +</pre></div></div> + +<p>You may now use the AsterixDB library in AQL statements and queries. To look at the installed artifacts, you may execute the following query at the AsterixDB web-console.</p> + +<div> +<div> +<pre class="source"> for $x in dataset Metadata.Function + return $x + + for $x in dataset Metadata.Library + return $x +</pre></div></div> + +<p>Our library is now installed and is ready to be used.</p></div></div> +<div class="section"> +<h2><a name="Preprocessing_Collected_Data"></a><a name="PreprocessingCollectedData" id="PreprocessingCollectedData">Preprocessing Collected Data</a></h2> +<p>In the following we assume that you already created the <tt>TwitterFeed</tt> and its corresponding data types and dataset following the instruction explained in the <a href="feeds/tutorial.html">feeds tutorial</a>.</p> +<p>A feed definition may optionally include the specification of a user-defined function that is to be applied to each feed object prior to persistence. Examples of pre-processing might include adding attributes, filtering out objects, sampling, sentiment analysis, feature extraction, etc. We can express a UDF, which can be defined in AQL or in a programming language such as Java, to perform such pre-processing. An AQL UDF is a good fit when pre-processing a object requires the result of a query (join or aggregate) over data contained in AsterixDB datasets. More sophisticated processing such as sentiment analysis of text is better handled by providing a Java UDF. A Java UDF has an initialization phase that allows the UDF to access any resources it may need to initialize itself prior to being used in a data flow. It is assumed by the AsterixDB compiler to be stateless and thus usable as an embarrassingly parallel black box. In contrast, the AsterixDB compiler can reason about an AQL UDF and involve the use of indexes during its invocation.</p> +<p>We consider an example transformation of a raw tweet into its lightweight version called <tt>ProcessedTweet</tt>, which is defined next.</p> + +<div> +<div> +<pre class="source"> use dataverse feeds; + + create type ProcessedTweet if not exists as open { + id: string, + user_name:string, + location:point, + created_at:string, + message_text:string, + country: string, + topics: {{string}} + }; + + create dataset ProcessedTweets(ProcessedTweet) + primary key id; +</pre></div></div> + +<p>The processing required in transforming a collected tweet to its lighter version of type <tt>ProcessedTweet</tt> involves extracting the topics or hash-tags (if any) in a tweet and collecting them in the referred “topics” attribute for the tweet. Additionally, the latitude and longitude values (doubles) are combined into the spatial point type. Note that spatial data types are considered as first-class citizens that come with the support for creating indexes. Next we show a revised version of our example TwitterFeed that involves the use of a UDF. We assume that the UDF that contains the transformation logic into a “ProcessedTweet” is available as a Java UDF inside an AsterixDB library named ‘testlib’. We defer the writing of a Java UDF and its installation as part of an AsterixDB library to a later section of this document.</p> + +<div> +<div> +<pre class="source"> use dataverse feeds; + + create feed ProcessedTwitterFeed if not exists + using "push_twitter" + (("type-name"="Tweet"), + ("consumer.key"="************"), + ("consumer.secret"="**************"), + ("access.token"="**********"), + ("access.token.secret"="*************")) + + apply function testlib#addHashTagsInPlace; +</pre></div></div> + +<p>Note that a feed adaptor and a UDF act as pluggable components. These contribute towards providing a generic “plug-and-play” model where custom implementations can be provided to cater to specific requirements.</p> +<div class="section"> +<div class="section"> +<h4><a name="Building_a_Cascade_Network_of_Feeds"></a>Building a Cascade Network of Feeds</h4> +<p>Multiple high-level applications may wish to consume the data ingested from a data feed. Each such application might perceive the feed in a different way and require the arriving data to be processed and/or persisted differently. Building a separate flow of data from the external source for each application is wasteful of resources as the pre-processing or transformations required by each application might overlap and could be done together in an incremental fashion to avoid redundancy. A single flow of data from the external source could provide data for multiple applications. To achieve this, we introduce the notion of primary and secondary feeds in AsterixDB.</p> +<p>A feed in AsterixDB is considered to be a primary feed if it gets its data from an external data source. The objects contained in a feed (subsequent to any pre-processing) are directed to a designated AsterixDB dataset. Alternatively or additionally, these objects can be used to derive other feeds known as secondary feeds. A secondary feed is similar to its parent feed in every other aspect; it can have an associated UDF to allow for any subsequent processing, can be persisted into a dataset, and/or can be made to derive other secondary feeds to form a cascade network. A primary feed and a dependent secondary feed form a hierarchy. As an example, we next show an example AQL statement that redefines the previous feed “ProcessedTwitterFeed” in terms of their respective parent feed (TwitterFeed).</p> + +<div> +<div> +<pre class="source"> use dataverse feeds; + + drop feed ProcessedTwitterFeed if exists; + + create secondary feed ProcessedTwitterFeed from feed TwitterFeed + apply function testlib#addHashTags; + + connect feed ProcessedTwitterFeed to dataset ProcessedTweets; +</pre></div></div> + +<p>The <tt>addHashTags</tt> function is already provided in the example UDF.To see what objects are being inserted into the dataset, we can perform a simple dataset scan after allowing a few moments for the feed to start ingesting data:</p> + +<div> +<div> +<pre class="source"> use dataverse feeds; + + for $i in dataset ProcessedTweets limit 10 return $i; +</pre></div></div> + +<p>For an example of how to write a Java UDF from scratch, the source for the example UDF that has been used in this tutorial is available [here] (<a class="externalLink" href="https://github.com/apache/asterixdb/tree/master/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library">https://github.com/apache/asterixdb/tree/master/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library</a>)</p></div></div></div> +<div class="section"> +<h2><a name="Unstalling_an_AsterixDB_Library"></a><a name="installingUDF">Unstalling an AsterixDB Library</a></h2> +<p>To uninstall a library, use the Managix uninstall command as follows:</p> + +<div> +<div> +<pre class="source"> $ managix stop -n my_asterix + + $ managix uninstall -n my_asterix -d feeds -l testlib +</pre></div></div></div> + </div> + </div> + </div> + <hr/> + <footer> + <div class="container-fluid"> + <div class="row-fluid"> +<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache + feather logo, and the Apache AsterixDB project logo are either + registered trademarks or trademarks of The Apache Software + Foundation in the United States and other countries. + All other marks mentioned may be trademarks or registered + trademarks of their respective owners. + </div> + </div> + </div> + </footer> + </body> +</html> http://git-wip-us.apache.org/repos/asf/asterixdb-site/blob/d00eca89/download.md ---------------------------------------------------------------------- diff --git a/download.md b/download.md index 92b25b9..fd485d6 100644 --- a/download.md +++ b/download.md @@ -2,8 +2,6 @@ title: Download --- -Please note that version 0.9.2 requires Java 8; Java 9 will not work. - <div class="row"> <div class="col-md-6" markdown="1"> ### Source @@ -47,52 +45,3 @@ This packaging is most suitable for running a sample cluster on a single machine </div> </div> - - -<div class="row"> - -<div class="col-md-6" markdown="1"> -### Standalone Cluster Installer - - -</div> -</div> - -<div class="row"> - -<div class="col-md-6" markdown="1"> -This packaging is most suitable for installation on a cluster without Hadoop or YARN. -</div> - -<div class="col-md-6" markdown="1"> - -<p><a class="btn btn-md btn-success" href="{{ site.STABLE_DOWNLOAD_URL }}" role="button">Download AsterixDB {{ site.STABLE_VERSION }} <i class="fa fa-download fa-lg"></i> </a></p> - -</div> - -</div> - - -<div class="row"> - - -<div class="col-md-6" markdown="1"> -### YARN Cluster Installer - - -</div> -</div> - -<div class="row"> - -<div class="col-md-6" markdown="1"> -This is AsterixDB packaged with the YARN installer. If you already have a cluster running Hadoop YARN, this is the easiest way to start out with AsterixDB. -</div> - -<div class="col-md-6" markdown="1"> - -<p><a class="btn btn-md btn-success" href="{{ site.STABLE_YARN_URL }}" role="button">Download AsterixDB {{ site.STABLE_VERSION }} <i class="fa fa-download fa-lg"></i> </a></p> - -</div> - -</div> http://git-wip-us.apache.org/repos/asf/asterixdb-site/blob/d00eca89/index.md ---------------------------------------------------------------------- diff --git a/index.md b/index.md index 3ba2e18..d404841 100644 --- a/index.md +++ b/index.md @@ -86,7 +86,7 @@ If you would like to know more about how to contribute to AsterixDB or any of it </div> <div class="col-md-4" markdown="1"> ### Download - <p><a class="btn btn-md btn-success" href="{{ site.STABLE_DOWNLOAD_URL }}" role="button">Download AsterixDB {{ site.STABLE_VERSION }} <i class="fa fa-download fa-lg"></i></a> + <p><a class="btn btn-md btn-success" href="{{ site.STABLE_NCSERVICE_URL }}" role="button">Download AsterixDB {{ site.STABLE_VERSION }} <i class="fa fa-download fa-lg"></i></a> <a class="btn btn-md btn-info" href="https://github.com/apache/asterixdb/" role="button">GitHub <i class="fa fa-github fa-lg"></i></a></p> [Installation Guide]({{ site.DOCS_BASE_URL }}/{{ site.STABLE_VERSION }}/ncservice.html)