You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2011/03/19 21:13:08 UTC
svn commit: r1083274 - in /hbase/trunk/src/docbkx: book.xml configuration.xml
Author: stack
Date: Sat Mar 19 20:13:08 2011
New Revision: 1083274
URL: http://svn.apache.org/viewvc?rev=1083274&view=rev
Log:
HBASE-3655 Revision to HBase book, more examples in data model, more metrics, more performance -- part one
Modified:
hbase/trunk/src/docbkx/book.xml
hbase/trunk/src/docbkx/configuration.xml
Modified: hbase/trunk/src/docbkx/book.xml
URL: http://svn.apache.org/viewvc/hbase/trunk/src/docbkx/book.xml?rev=1083274&r1=1083273&r2=1083274&view=diff
==============================================================================
--- hbase/trunk/src/docbkx/book.xml (original)
+++ hbase/trunk/src/docbkx/book.xml Sat Mar 19 20:13:08 2011
@@ -319,7 +319,8 @@ Tables in HBase are initially created wi
<title>Get/Scan</title>
<para>Gets are implemented on top of Scans. The below discussion of
- Get applies equally to Scans.</para>
+ <link xlink:href="http://hbase.apache.org/docs/current/api/org/apache/hadoop/hbase/client/Get.html">Get</link> applies equally to <link
+ xlink:href="http://hbase.apache.org/docs/current/api/org/apache/hadoop/hbase/client/Scan.html">Scans</link>.</para>
<para>By default, i.e. if you specify no explicit version, when
doing a <literal>get</literal>, the cell whose version has the
@@ -343,6 +344,29 @@ Tables in HBase are initially created wi
desired version and set the max versions to 1.</para>
</listitem>
</itemizedlist>
+
+ </section>
+ <section>
+ <title>Default Get Example</title>
+ <para>The following Get will only retrieve the current version of the row
+ <programlisting>
+ Get get = new Get( Bytes.toBytes("row1") );
+ Result r = htable.get(get);
+ byte[] b = r.getValue( Bytes.toBytes("cf"), Bytes.toBytes("attr") ); // returns current version of value
+ </programlisting>
+ </para>
+ </section>
+ <section>
+ <title>Versioned Get Example</title>
+ <para>The following Get will return the last 3 versions of the row.
+ <programlisting>
+ Get get = new Get( Bytes.toBytes("row1") );
+ get.setMaxVersions(3); // will return last 3 versions of row
+ Result r = htable.get(get);
+ byte[] b = r.getValue( Bytes.toBytes("cf"), Bytes.toBytes("attr") ); // returns current version of value
+ List<KeyValue> kv = r.getColumn( Bytes.toBytes("cf"), Bytes.toBytes("attr") ); // returns all versions of this column
+ </programlisting>
+ </para>
</section>
<section>
@@ -358,6 +382,27 @@ Tables in HBase are initially created wi
<para>To overwrite an existing value, do a put at exactly the same
row, column, and version as that of the cell you would
overshadow.</para>
+ <section>
+ <title>Implicit Version Example</title>
+ <para>The following Put will be implicitly versioned by HBase with the current time.
+ <programlisting>
+ Put put = new Put(Bytes.toBytes(row));
+ put.add(Bytes.toBytes("cf"), Bytes.toBytes("attr1"), Bytes.toBytes( data));
+ htable.put(put);
+ </programlisting>
+ </para>
+ </section>
+ <section>
+ <title>Explicit Version Example</title>
+ <para>The following Put has the version timestamp explicitly set.
+ <programlisting>
+ Put put = new Put( Bytes.toBytes( row ) );
+ long explicitTimeInMs = 555; // just an example
+ put.add(Bytes.toBytes("cf"), Bytes.toBytes("attr1"), explicitTimeInMs, Bytes.toBytes( data));
+ htable.put(put);
+ </programlisting>
+ </para>
+ </section>
</section>
<section>
Modified: hbase/trunk/src/docbkx/configuration.xml
URL: http://svn.apache.org/viewvc/hbase/trunk/src/docbkx/configuration.xml?rev=1083274&r1=1083273&r2=1083274&view=diff
==============================================================================
--- hbase/trunk/src/docbkx/configuration.xml (original)
+++ hbase/trunk/src/docbkx/configuration.xml Sat Mar 19 20:13:08 2011
@@ -259,15 +259,21 @@ of all regions.
<section xml:id="client_dependencies"><title>Client configuration and dependencies connecting to an HBase cluster</title>
<para>
- Since the HBase Master may move around, clients bootstrap by looking ZooKeeper. Thus clients
- require the ZooKeeper quorum information in a <filename>hbase-site.xml</filename> that
- is on their <varname>CLASSPATH</varname>.</para>
+ Since the HBase Master may move around, clients bootstrap by looking to ZooKeeper for
+ current critical locations. ZooKeeper is where all these values are kept. Thus clients
+ require the location of the ZooKeeper ensemble information before they can do anything else.
+ Usually this the ensemble location is kept out in the <filename>hbase-site.xml</filename> and
+ is picked up by the client from the <varname>CLASSPATH</varname>.</para>
+
<para>If you are configuring an IDE to run a HBase client, you should
- include the <filename>conf/</filename> directory on your classpath.
+ include the <filename>conf/</filename> directory on your classpath so
+ <filename>hbase-site.xml</filename> settings can be found (or
+ add <filename>src/test/resources</filename> to pick up the hbase-site.xml
+ used by tests).
</para>
<para>
- Minimally, a client of HBase needs the hbase, hadoop, log4j, commons-logging, and zookeeper jars
- in its <varname>CLASSPATH</varname> connecting to a cluster.
+ Minimally, a client of HBase needs the hbase, hadoop, log4j, commons-logging, commons-lang,
+ and zookeeper jars in its <varname>CLASSPATH</varname> connecting to a cluster.
</para>
<para>
An example basic <filename>hbase-site.xml</filename> for client only
@@ -283,9 +289,31 @@ of all regions.
</description>
</property>
</configuration>
-]]>
- </programlisting>
+]]></programlisting>
+ </para>
+ <section>
+ <title>Java client configuration connecting to an HBase cluster</title>
+ <subtitle>How Java reads <filename>hbase-site.xml</filename> content</subtitle>
+ <para>The configuration used by a client is kept
+ in an <link xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HBaseConfiguration">HBaseConfiguration</link> instance.
+ Through the factory method on HBaseConfiguration...
+ <programlisting>Configuration config = HBaseConfiguration.create();</programlisting>
+ .. a client will pick up a configuration sourced from the first <filename>hbase-site.xml</filename> found on
+ the client's <varname>CLASSPATH</varname>, if one is present
+ (We'll also factor in any <filename>hbase-default.xml</filename> found; an hbase-default.xml ships inside
+ the <filename>hbase.X.X.X.jar</filename>).
+ It is also possible to specify configuration directly without having to read from a
+ <filename>hbase-site.xml</filename>. For examplt to set the
+ <link linkend="zookeeper">zookeeper</link> ensemble for the cluster programmatically do as follows...
+ <programlisting>Configuration config = HBaseConfiguration.create();
+ config.set("hbase.zookeeper.quorum", "localhost"); // we are running zookeeper locally
+ </programlisting>
+ If multiple <link linkend="zookeeper">zookeeper</link> instances make up your zookeeper ensemble,
+ they may be specified in a comma-list (just as in the <filename>hbase-site.xml</filename> file).
+ This populated Configuration instance can then be passed to an
+ <link xlink:href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/HTable.html">HTable</link> instance via the overloaded constructor.
</para>
+ </section>
</section>
</chapter>