| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="utf-8" /> |
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> |
| <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> |
| <meta name="description" content="A new open source Apache Hadoop ecosystem project, Apache Kudu completes Hadoop's storage layer to enable fast analytics on fast data" /> |
| <meta name="author" content="Cloudera" /> |
| <title>Apache Kudu - Developing Applications With Apache Kudu (incubating)</title> |
| <!-- Bootstrap core CSS --> |
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" |
| integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" |
| crossorigin="anonymous"> |
| |
| <!-- Custom styles for this template --> |
| <link href="/css/kudu.css" rel="stylesheet"/> |
| <link href="/css/asciidoc.css" rel="stylesheet"/> |
| <link rel="shortcut icon" href="/img/logo-favicon.ico" /> |
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css" /> |
| |
| |
| |
| <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> |
| <!--[if lt IE 9]> |
| <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> |
| <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> |
| <![endif]--> |
| </head> |
| <body> |
| <div class="kudu-site container-fluid"> |
| <!-- Static navbar --> |
| <nav class="navbar navbar-default"> |
| <div class="container-fluid"> |
| <div class="navbar-header"> |
| <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> |
| <span class="sr-only">Toggle navigation</span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| </button> |
| |
| <a class="logo" href="/"><img |
| src="//d3dr9sfxru4sde.cloudfront.net/i/k/apachekudu_logo_0716_80px.png" |
| srcset="//d3dr9sfxru4sde.cloudfront.net/i/k/apachekudu_logo_0716_80px.png 1x, //d3dr9sfxru4sde.cloudfront.net/i/k/apachekudu_logo_0716_160px.png 2x" |
| alt="Apache Kudu"/></a> |
| |
| </div> |
| <div id="navbar" class="collapse navbar-collapse"> |
| <ul class="nav navbar-nav navbar-right"> |
| <li > |
| <a href="/">Home</a> |
| </li> |
| <li > |
| <a href="/overview.html">Overview</a> |
| </li> |
| <li class="active"> |
| <a href="/docs/">Documentation</a> |
| </li> |
| <li > |
| <a href="/releases/">Download</a> |
| </li> |
| <li > |
| <a href="/blog/">Blog</a> |
| </li> |
| <!-- NOTE: this dropdown menu does not appear on Mobile, so don't add anything here |
| that doesn't also appear elsewhere on the site. --> |
| <li class="dropdown"> |
| <a href="/community.html" role="button" aria-haspopup="true" aria-expanded="false">Community <span class="caret"></span></a> |
| <ul class="dropdown-menu"> |
| <li class="dropdown-header">GET IN TOUCH</li> |
| <li><a class="icon email" href="/community.html">Mailing Lists</a></li> |
| <li><a class="icon slack" href="https://getkudu-slack.herokuapp.com/">Slack Channel</a></li> |
| <li role="separator" class="divider"></li> |
| <li><a href="/community.html#meetups-user-groups-and-conference-presentations">Events and Meetups</a></li> |
| <li><a href="/committers.html">Project Committers</a></li> |
| <!--<li><a href="/roadmap.html">Roadmap</a></li>--> |
| <li><a href="/community.html#contributions">How to Contribute</a></li> |
| <li role="separator" class="divider"></li> |
| <li class="dropdown-header">DEVELOPER RESOURCES</li> |
| <li><a class="icon github" href="https://github.com/apache/incubator-kudu">GitHub</a></li> |
| <li><a class="icon gerrit" href="http://gerrit.cloudera.org:8080/#/q/status:open+project:kudu">Gerrit Code Review</a></li> |
| <li><a class="icon jira" href="https://issues.apache.org/jira/browse/KUDU">JIRA Issue Tracker</a></li> |
| <li role="separator" class="divider"></li> |
| <li class="dropdown-header">SOCIAL MEDIA</li> |
| <li><a class="icon twitter" href="https://twitter.com/ApacheKudu">Twitter</a></li> |
| </ul> |
| </li> |
| <li > |
| <a href="/faq.html">FAQ</a> |
| </li> |
| </ul><!-- /.nav --> |
| </div><!-- /#navbar --> |
| </div><!-- /.container-fluid --> |
| </nav> |
| |
| <!-- |
| |
| Licensed 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. |
| --> |
| |
| |
| <div class="container"> |
| <div class="row"> |
| <div class="col-md-9"> |
| |
| <h1>Developing Applications With Apache Kudu (incubating)</h1> |
| <div id="preamble"> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>Kudu provides C++ and Java client APIs, as well as reference examples to illustrate |
| their use. A Python API is included, but it is currently considered experimental, |
| unstable, and subject to change at any time.</p> |
| </div> |
| <div class="admonitionblock warning"> |
| <table> |
| <tr> |
| <td class="icon"> |
| <i class="fa icon-warning" title="Warning"></i> |
| </td> |
| <td class="content"> |
| Use of server-side or private interfaces is not supported, and interfaces |
| which are not part of public APIs have no stability guarantees. |
| </td> |
| </tr> |
| </table> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_viewing_the_api_documentation"><a class="link" href="#_viewing_the_api_documentation">Viewing the API Documentation</a></h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <div class="title">C++ API Documentation</div> |
| <p>The documentation for the C++ client APIs is included in the header files in |
| <code>/usr/include/kudu/</code> if you installed Kudu using packages or subdirectories |
| of <code>src/kudu/client/</code> if you built Kudu from source. If you installed Kudu using parcels, |
| no headers are included in your installation. and you will need to <a href="#build_kudu">build |
| Kudu from source</a> in order to have access to the headers and shared libraries.</p> |
| </div> |
| <div class="paragraph"> |
| <p>The following command is a naive approach to finding relevant header files. Use |
| of any APIs other than the client APIs is unsupported.</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlight"><code class="language-bash" data-lang="bash">$ find /usr/include/kudu -type f -name *.h</code></pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <div class="title">Java API Documentation</div> |
| <p>You can view the <a href="../apidocs/index.html">Java API documentation</a> online. Alternatively, |
| after <a href="#build_java_client">building the Java client</a>, Java API documentation is available |
| in <code>java/kudu-client/target/apidocs/index.html</code>.</p> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_working_examples"><a class="link" href="#_working_examples">Working Examples</a></h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>Several example applications are provided in the |
| <a href="https://github.com/cloudera/kudu-examples">kudu-examples</a> Github |
| repository. Each example includes a <code>README</code> that shows how to compile and run |
| it. These examples illustrate correct usage of the Kudu APIs, as well as how to |
| set up a virtual machine to run Kudu. The following list includes some of the |
| examples that are available today. Check the repository itself in case this list goes |
| out of date.</p> |
| </div> |
| <div class="dlist"> |
| <dl> |
| <dt class="hdlist1"><code>java-example</code></dt> |
| <dd> |
| <p>A simple Java application which connects to a Kudu instance, creates a table, writes data to it, then drops the table.</p> |
| </dd> |
| <dt class="hdlist1"><code>collectl</code></dt> |
| <dd> |
| <p>A small Java application which listens on a TCP socket for time series data corresponding to the Collectl wire protocol. |
| The commonly-available collectl tool can be used to send example data to the server.</p> |
| </dd> |
| <dt class="hdlist1"><code>clients/python</code></dt> |
| <dd> |
| <p>An experimental Python client for Kudu.</p> |
| </dd> |
| <dt class="hdlist1"><code>demo-vm-setup</code></dt> |
| <dd> |
| <p>Scripts to download and run a VirtualBox virtual machine with Kudu already installed. |
| See <a href="quickstart.html">Quickstart</a> for more information.</p> |
| </dd> |
| </dl> |
| </div> |
| <div class="paragraph"> |
| <p>These examples should serve as helpful starting points for your own Kudu applications and integrations.</p> |
| </div> |
| <div class="sect2"> |
| <h3 id="_maven_artifacts"><a class="link" href="#_maven_artifacts">Maven Artifacts</a></h3> |
| <div class="paragraph"> |
| <p>The following Maven <code><dependency></code> element is valid for the Kudu public beta:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlight"><code class="language-xml" data-lang="xml"><dependency> |
| <groupId>org.kududb</groupId> |
| <artifactId>kudu-client</artifactId> |
| <version>0.5.0</version> |
| </dependency></code></pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>Because the Maven artifacts are not in Maven Central, use the following <code><repository></code> |
| element:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlight"><code class="language-xml" data-lang="xml"><repository> |
| <id>cdh.repo</id> |
| <name>Cloudera Repositories</name> |
| <url>https://repository.cloudera.com/artifactory/cloudera-repos</url> |
| <snapshots> |
| <enabled>false</enabled> |
| </snapshots> |
| </repository></code></pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>See subdirectories of <a href="https://github.com/cloudera/kudu-examples/tree/master/java" class="bare">https://github.com/cloudera/kudu-examples/tree/master/java</a> for |
| example Maven pom.xml files.</p> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_example_impala_commands_with_kudu"><a class="link" href="#_example_impala_commands_with_kudu">Example Impala Commands With Kudu</a></h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>See <a href="kudu_impala_integration.html">Using Impala With Kudu</a> for guidance on installing |
| and using Impala with Kudu, including several <code>impala-shell</code> examples.</p> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_kudu_integration_with_spark"><a class="link" href="#_kudu_integration_with_spark">Kudu integration with Spark</a></h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>Kudu integrates with spark through the spark data source api as of version 0.9 |
| Include the kudu-spark using the --jars</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlight"><code>spark-shell --jars /kudu-spark-0.9.0.jar</code></pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>Then import kudu-spark and create a dataframe:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlight"><code>// Import kudu datasource |
| import org.kududb.spark.kudu._ |
| val kuduDataFrame = sqlContext.read.options(Map("kudu.master"-> "your.kudu.master.here","kudu.table"-> "your.kudu.table.here")).kudu |
| // Then query using spark api or register a temporary table and use spark sql |
| kuduDataFrame.select("id").filter("id">=5).show() |
| // Register kuduDataFrame as a temporary table for spark-sql |
| kuduDataFrame.registerTempTable("kudu_table") |
| // Select from the dataframe |
| sqlContext.sql("select id from kudu_table where id>=5").show() |
| |
| // create a new kudu table from a dataframe |
| val kuduContext = new KuduContext("your.kudu.master.here") |
| kuduContext.createTable("testcreatetable", df.schema, Seq("key"), new CreateTableOptions().setNumReplicas(1)) |
| |
| // then we can insert data into the kudu table |
| df.write.options(Map("kudu.master"-> "your.kudu.master.here","kudu.table"-> "your.kudu.table.here")).mode("append").kudu |
| |
| // to update existing data change the mode to 'overwrite' |
| df.write.options(Map("kudu.master"-> "your.kudu.master.here","kudu.table"-> "your.kudu.table.here")).mode("overwrite").kudu |
| |
| // to check for existance of a kudu table |
| kuduContext.tableExists("your.kudu.table.here") |
| |
| // to delete a kudu table |
| kuduContext.deleteTable("your.kudu.table.here")</code></pre> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_integration_with_mapreduce_yarn_and_other_frameworks"><a class="link" href="#_integration_with_mapreduce_yarn_and_other_frameworks">Integration with MapReduce, YARN, and Other Frameworks</a></h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>Kudu was designed to integrate with MapReduce, YARN, Spark, and other frameworks in |
| the Hadoop ecosystem. See <a href="https://github.com/apache/incubator-kudu/blob/master/java/kudu-client-tools/src/main/java/org/kududb/mapreduce/tools/RowCounter.java">RowCounter.java</a> |
| and |
| <a href="https://github.com/apache/incubator-kudu/blob/master/java/kudu-client-tools/src/main/java/org/kududb/mapreduce/tools/ImportCsv.java">ImportCsv.java</a> |
| for examples which you can model your own integrations on. Stay tuned for more examples |
| using YARN and Spark in the future.</p> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="col-md-3"> |
| |
| <div id="toc" data-spy="affix" data-offset-top="70"> |
| <ul> |
| |
| <li> |
| |
| <a href="introduction.html">Introducing Kudu</a> |
| </li> |
| <li> |
| |
| <a href="release_notes.html">Kudu Release Notes</a> |
| </li> |
| <li> |
| |
| <a href="quickstart.html">Getting Started with Kudu</a> |
| </li> |
| <li> |
| |
| <a href="installation.html">Installation Guide</a> |
| </li> |
| <li> |
| |
| <a href="configuration.html">Configuring Kudu</a> |
| </li> |
| <li> |
| |
| <a href="kudu_impala_integration.html">Using Impala with Kudu</a> |
| </li> |
| <li> |
| |
| <a href="administration.html">Administering Kudu</a> |
| </li> |
| <li> |
| |
| <a href="troubleshooting.html">Troubleshooting Kudu</a> |
| </li> |
| <li> |
| <span class="active-toc">Developing Applications with Kudu</span> |
| <ul class="sectlevel1"> |
| <li><a href="#_viewing_the_api_documentation">Viewing the API Documentation</a></li> |
| <li><a href="#_working_examples">Working Examples</a> |
| <ul class="sectlevel2"> |
| <li><a href="#_maven_artifacts">Maven Artifacts</a></li> |
| </ul> |
| </li> |
| <li><a href="#_example_impala_commands_with_kudu">Example Impala Commands With Kudu</a></li> |
| <li><a href="#_kudu_integration_with_spark">Kudu integration with Spark</a></li> |
| <li><a href="#_integration_with_mapreduce_yarn_and_other_frameworks">Integration with MapReduce, YARN, and Other Frameworks</a></li> |
| </ul> |
| </li> |
| <li> |
| |
| <a href="schema_design.html">Kudu Schema Design</a> |
| </li> |
| <li> |
| |
| <a href="transaction_semantics.html">Kudu Transaction Semantics</a> |
| </li> |
| <li> |
| |
| <a href="contributing.html">Contributing to Kudu</a> |
| </li> |
| <li> |
| |
| <a href="style_guide.html">Kudu Documentation Style Guide</a> |
| </li> |
| <li> |
| |
| <a href="configuration_reference.html">Kudu Configuration Reference</a> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </div> |
| </div> |
| <footer class="footer"> |
| <p class="small"> |
| Copyright © 2016 The Apache Software Foundation. Last updated 2016-05-24 08:02:44 PDT |
| </p> |
| </footer> |
| </div> |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> |
| <script> |
| // Try to detect touch-screen devices. Note: Many laptops have touch screens. |
| $(document).ready(function() { |
| if ("ontouchstart" in document.documentElement) { |
| $(document.documentElement).addClass("touch"); |
| } else { |
| $(document.documentElement).addClass("no-touch"); |
| } |
| }); |
| </script> |
| <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" |
| integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" |
| crossorigin="anonymous"></script> |
| <script> |
| (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
| (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
| m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
| })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); |
| |
| ga('create', 'UA-68448017-1', 'auto'); |
| ga('send', 'pageview'); |
| </script> |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/anchor-js/3.1.0/anchor.js"></script> |
| <script> |
| anchors.options = { |
| placement: 'right', |
| visible: 'touch', |
| }; |
| anchors.add(); |
| </script> |
| </body> |
| </html> |
| |