Improve the C++ client example

This does some small things to improve the C++ client example:

1. I used shellcheck to find and fix some warnings with
   client_examples-test.sh. Mostly pedantic stuff.
2. I fixed a bug with the lsof command where it wasn't filtering
   lines, so it ran some bogus numeric comparisons on extra lines.
   Obviously this didn't break the script but it generated errors.
3. I added support for multimaster to the example script. I tested it
   manually but I didn't change client_examples-test.sh to use
   multimaster, since it seemed like it would just make it more
   complex and possibly more flaky without much payoff.
4. I fixed up the example code so it no longer uses any deprecated
   APIs. Specifically, I got rid of a use of 'split_rows' in the
   table creation step and the swapped in KuduScanBatch for
   vector<RowResult> in the scanner part.
5. I fixed up the wording and removed a duplicated section from the
   example's README.

Change-Id: I7fcc9f46b5e28b18f1a96082fd61a1f3402f59ff
Reviewed-on: http://gerrit.cloudera.org:8080/9838
Reviewed-by: Adar Dembo <a...@cloudera.com>
Tested-by: Kudu Jenkins
Reviewed-by: Andrew Wong <aw...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/32d276e0
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/32d276e0
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/32d276e0

Branch: refs/heads/master
Commit: 32d276e08fe7bf7a0e68236e01312813b68d0eee
Parents: 9bf32a4
Author: Will Berkeley <wdberke...@apache.org>
Authored: Wed Mar 28 01:40:58 2018 -0700
Committer: Will Berkeley <wdberke...@gmail.com>
Committed: Wed Mar 28 21:42:51 2018 +0000

----------------------------------------------------------------------
 examples/cpp/README.adoc                | 146 +++++++++++++--------------
 examples/cpp/example.cc                 |  64 ++++++------
 src/kudu/client/client_examples-test.sh |  88 ++++++++--------
 src/kudu/client/scan_batch.h            |   2 +-
 4 files changed, 149 insertions(+), 151 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/32d276e0/examples/cpp/README.adoc
----------------------------------------------------------------------
diff --git a/examples/cpp/README.adoc b/examples/cpp/README.adoc
index 6bad943..ba77682 100644
--- a/examples/cpp/README.adoc
+++ b/examples/cpp/README.adoc
@@ -19,7 +19,7 @@
 :homepage: https://kudu.apache.org/
 
 == Summary
-The Kudu {cpp} client library distribution contains {cpp} example application
+The Kudu {cpp} client library distribution contains a {cpp} example application
 that demonstrates how to use the Kudu {cpp} client API.  The example
 can be used as a starting point for a custom Kudu {cpp} client application.
 This note contains information on how to build the Kudu {cpp} client example.
@@ -45,63 +45,37 @@ super-user access and pollutes the `example` directory with
 intermediate files.
 For example, to copy the `/usr/share/doc/kuduClient/examples` directory
 recursively into `/tmp/kuduClient`:
-[source,shell]
++
+[source,bash]
+----
 cp -r /usr/share/doc/kuduClient/examples /tmp/kuduClient
+----
 
 . Navigate into the directory where the `example.cc.gz` file was copied and
 unpack the example source file.  For example:
-[source,shell]
++
+[source,bash]
+----
 cd /tmp/kuduClient/examples
 gunzip example.cc.gz
+----
 
 . Run `cmake` to generate appropriate makefiles.  For example, if targeting
 for a debug build
-(for a release build, use `release` for `CMAKE_BUILD_TYPE` correspondingly):
-[source,shell]
++
+[source,bash]
+----
 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=debug
+----
++
+For a release build, use `release` for `CMAKE_BUILD_TYPE` instead.
 
 . Run `make` to build the example:
-[source,shell]
++
+[source,bash]
+----
 make
-
-. After the example is built, it is ready to run against your Kudu master 
server.
-The example application assumes the target Kudu cluster has at least 3
-tablet servers up and running (because it creates a table with replication
-factor 3).  If it's not the case, you can modify the `example.cc` accordingly
-and re-compile it.  Below is the example output with log messages in the middle
-removed: the `example` binary runs against Kudu master server running
-with the default parameters at the same machine.  Port 7051 is the default
-one and could be omitted along with the preceding colomn because the master
-server is running with the default parameters (it's left only to illustrate how
-to specify port number).
-[source,shell]
-$ ./example 127.0.0.1:7051
-Running with Kudu client version: kudu 1.1.0-SNAPSHOT (rev 
91a1ed09c4c572a22bab15360ddaf481d5632927)
-Long version info: kudu 1.1.0-SNAPSHOT
-revision 91a1ed09c4c572a22bab15360ddaf481d5632927
-build type DEBUG
-built by aserbin at 06 Oct 2016 14:15:10 PST on ve0518.halxg.cloudera.com
-Received log message from Kudu client library
- Severity: 0
- Filename: /home/aserbin/Projects/kudu/src/kudu/util/thread.cc
- Line number: 546
- Time: Thu Oct 06 14:50:47 2016
- Message: Started thread 11197 - kernel-watchdog:kernel-watcher
-...
-Received log message from Kudu client library
- Severity: 0
- Filename: /home/aserbin/Projects/kudu/src/kudu/client/client-internal.cc
- Line number: 534
- Time: Thu Oct 06 14:50:47 2016
- Message: Considering host 10.17.240.17 local
-Created a client connection
-Created a schema
-Created a table
-Altered a table
-Inserted some rows into a table
-Scanned some rows out of a table
-Deleted a table
-Done
+----
 
 == How to build the example if building Kudu from source
 This section describes how to build the example if building Kudu from source.
@@ -109,7 +83,7 @@ To install the `example.cc` and other files, an alternate 
destination root
 is used.
 
 Specifying an alternate destination root allows you to install the
-Kudu {cpp} client library, the example file and other content
+Kudu {cpp} client library, the example file, and other content
 under the specified destination prefix.
 
 . Follow the 
https://kudu.apache.org/docs/installation.html#_build_from_source[instructions 
on the Kudu Web site]
@@ -118,57 +92,72 @@ to build the project from source.
 . Once the project is built, change into the `<build_dir>/src/kudu/client`
 sub-directory.
 
-. Run `make install` with an alternate destination root.  For example, if
+. Run `make install` with an alternate destination root. For example, if
 installing into `/tmp/client_alt_root`
-[source,shell]
++
+[source,bash]
+----
 make install DESTDIR=/tmp/client_alt_root
+----
 
 . Change the current working directory into the
 `usr/local/share/doc/kuduClient/examples` subdirectory of the alternate
 destination root.  For example, if installing into `/tmp/client_alt_root`
-[source,shell]
++
+[source,bash]
+----
 cd /tmp/client_alt_root/usr/local/share/doc/kuduClient/examples
+----
 
-. Run `cmake` to generate appropriate makefiles.  For example, if installing
+. Run `cmake` to generate appropriate makefiles. For example, if installing
 into `/tmp/client_alt_root` and targeting for a debug build
-(for a release build, use `release` for `CMAKE_BUILD_TYPE` correspondingly):
-[source,shell]
++
+[source,bash]
+----
 cmake -G "Unix Makefiles" 
-DkuduClient_DIR=/tmp/client_alt_root/usr/local/share/kuduClient/cmake 
-DCMAKE_BUILD_TYPE=debug
+----
++
+For a release build, set `release` for `CMAKE_BUILD_TYPE` instead.
 
 . Run `make` to build the example:
-[source,shell]
++
+[source,bash]
+----
 make
+----
 
-. After the example is built, it is ready to run against your Kudu master 
server.
+== Running the sample application
+After the example is built, it is ready to run against your Kudu cluster.
 The example application assumes the target Kudu cluster has at least 3
-tablet servers up and running (because it creates a table with replication
-factor 3).  If it's not the case, you can modify the `example.cc` accordingly
-and re-compile it.  Below is the example output with log messages in the middle
-removed: the `example` binary runs against Kudu master server running
-with the default parameters at the same machine.  Port 7051 is the default
-one and could be omitted along with the preceding colomn because the master
-server is running with the default parameters (it's left only to illustrate how
-to specify port number).
-[source,shell]
-$ ./example 127.0.0.1:7051
-Running with Kudu client version: kudu 1.1.0-SNAPSHOT (rev 
91a1ed09c4c572a22bab15360ddaf481d5632927)
-Long version info: kudu 1.1.0-SNAPSHOT
-revision 91a1ed09c4c572a22bab15360ddaf481d5632927
+running tablet servers, because it creates a table with replication factor 3.
+If that's not the case, modify `example.cc` accordingly and re-compile. By
+default, the `example` binary runs against a local Kudu master using the
+default port 7051. You may also specify a different master or multiple masters
+as arguments to the binary, as shown. The following output shows a successful
+invocation of the example application, with some uninteresting log messages
+removed:
+
+[source,bash]
+----
+$ ./example localhost:9876 localhost:9877 localhost:9878
+Running with Kudu client version: kudu 1.8.0-SNAPSHOT (rev 
bbbb45fd31f2eb1570563e925639e549047b0707)
+Long version info: kudu 1.8.0-SNAPSHOT
+revision bbbb45fd31f2eb1570563e925639e549047b0707
 build type DEBUG
-built by aserbin at 06 Oct 2016 14:15:10 PST on ve0518.halxg.cloudera.com
+built by wdberkeley at 27 Mar 2018 23:52:18 PST on cloudbook.local
 Received log message from Kudu client library
  Severity: 0
- Filename: /home/aserbin/Projects/kudu/src/kudu/util/thread.cc
- Line number: 546
- Time: Thu Oct 06 14:50:47 2016
- Message: Started thread 11197 - kernel-watchdog:kernel-watcher
-...
-Received log message from Kudu client library
+ Filename: /Users/wdberkeley/src/kudu/src/kudu/util/thread.cc
+ Line number: 570
+ Time: Wed Mar 28 01:50:48 2018
+ Message: Started thread 17452818 - kernel-watchdog:kernel-watcher
+ ...
+ Received log message from Kudu client library
  Severity: 0
- Filename: /home/aserbin/Projects/kudu/src/kudu/client/client-internal.cc
- Line number: 534
- Time: Thu Oct 06 14:50:47 2016
- Message: Considering host 10.17.240.17 local
+ Filename: /Users/wdberkeley/src/kudu/src/kudu/client/client-internal.cc
+ Line number: 581
+ Time: Wed Mar 28 01:50:48 2018
+ Message: Considering host 192.168.1.4 local
 Created a client connection
 Created a schema
 Created a table
@@ -177,6 +166,7 @@ Inserted some rows into a table
 Scanned some rows out of a table
 Deleted a table
 Done
+----
 
 == References
 . https://kudu.apache.org/[The Kudu Project Web Site]

http://git-wip-us.apache.org/repos/asf/kudu/blob/32d276e0/examples/cpp/example.cc
----------------------------------------------------------------------
diff --git a/examples/cpp/example.cc b/examples/cpp/example.cc
index 9b5d65e..5d17ac2 100644
--- a/examples/cpp/example.cc
+++ b/examples/cpp/example.cc
@@ -34,7 +34,7 @@ using kudu::client::KuduColumnSchema;
 using kudu::client::KuduError;
 using kudu::client::KuduInsert;
 using kudu::client::KuduPredicate;
-using kudu::client::KuduRowResult;
+using kudu::client::KuduScanBatch;
 using kudu::client::KuduScanner;
 using kudu::client::KuduSchema;
 using kudu::client::KuduSchemaBuilder;
@@ -53,10 +53,10 @@ using std::ostringstream;
 using std::string;
 using std::vector;
 
-static Status CreateClient(const string& addr,
+static Status CreateClient(const vector<string>& master_addrs,
                            shared_ptr<KuduClient>* client) {
   return KuduClientBuilder()
-      .add_master_server_addr(addr)
+      .master_server_addrs(master_addrs)
       .default_admin_operation_timeout(MonoDelta::FromSeconds(20))
       .Build(client);
 }
@@ -91,25 +91,24 @@ static Status CreateTable(const shared_ptr<KuduClient>& 
client,
                           const string& table_name,
                           const KuduSchema& schema,
                           int num_tablets) {
-  // Generate the split keys for the table.
-  vector<const KuduPartialRow*> splits;
+  vector<string> column_names;
+  column_names.push_back("key");
+
+  // Set the schema and range partition columns.
+  KuduTableCreator* table_creator = client->NewTableCreator();
+  table_creator->table_name(table_name)
+      .schema(&schema)
+      .set_range_partition_columns(column_names);
+
+  // Generate and add the range partition splits for the table.
   int32_t increment = 1000 / num_tablets;
   for (int32_t i = 1; i < num_tablets; i++) {
     KuduPartialRow* row = schema.NewRow();
     KUDU_CHECK_OK(row->SetInt32(0, i * increment));
-    splits.push_back(row);
+    table_creator->add_range_partition_split(row);
   }
 
-  vector<string> column_names;
-  column_names.push_back("key");
-
-  // Create the table.
-  KuduTableCreator* table_creator = client->NewTableCreator();
-  Status s = table_creator->table_name(table_name)
-      .schema(&schema)
-      .set_range_partition_columns(column_names)
-      .split_rows(splits)
-      .Create();
+  Status s = table_creator->Create();
   delete table_creator;
   return s;
 }
@@ -127,7 +126,7 @@ static Status AlterTable(const shared_ptr<KuduClient>& 
client,
 
 static void StatusCB(void* unused, const Status& status) {
   KUDU_LOG(INFO) << "Asynchronous flush finished with status: "
-                      << status.ToString();
+                 << status.ToString();
 }
 
 static Status InsertRows(const shared_ptr<KuduTable>& table, int num_rows) {
@@ -176,6 +175,11 @@ static Status ScanRows(const shared_ptr<KuduTable>& table) 
{
 
   KuduScanner scanner(table.get());
 
+  // To be guaranteed results are returned in primary key order, make the
+  // scanner fault-tolerant. This also means the scanner can recover if,
+  // for example, the server it is scanning fails in the middle of a scan.
+  KUDU_RETURN_NOT_OK(scanner.SetFaultTolerant());
+
   // Add a predicate: WHERE key >= 5
   KuduPredicate* p = table->NewComparisonPredicate(
       "key", KuduPredicate::GREATER_EQUAL, KuduValue::FromInt(kLowerBound));
@@ -187,17 +191,17 @@ static Status ScanRows(const shared_ptr<KuduTable>& 
table) {
   KUDU_RETURN_NOT_OK(scanner.AddConjunctPredicate(p));
 
   KUDU_RETURN_NOT_OK(scanner.Open());
-  vector<KuduRowResult> results;
+  KuduScanBatch batch;
 
   int next_row = kLowerBound;
   while (scanner.HasMoreRows()) {
-    KUDU_RETURN_NOT_OK(scanner.NextBatch(&results));
-    for (vector<KuduRowResult>::iterator iter = results.begin();
-        iter != results.end();
-        iter++, next_row++) {
-      const KuduRowResult& result = *iter;
+    KUDU_RETURN_NOT_OK(scanner.NextBatch(&batch));
+    for (KuduScanBatch::const_iterator it = batch.begin();
+         it != batch.end();
+         ++it, ++next_row) {
+      KuduScanBatch::RowPtr row(*it);
       int32_t val;
-      KUDU_RETURN_NOT_OK(result.GetInt32("key", &val));
+      KUDU_RETURN_NOT_OK(row.GetInt32("key", &val));
       if (val != next_row) {
         ostringstream out;
         out << "Scan returned the wrong results. Expected key "
@@ -205,7 +209,6 @@ static Status ScanRows(const shared_ptr<KuduTable>& table) {
         return Status::IOError(out.str());
       }
     }
-    results.clear();
   }
 
   // next_row is now one past the last row we read.
@@ -263,10 +266,13 @@ int main(int argc, char* argv[]) {
   // This is to install and automatically un-install custom logging callback.
   LogCallbackHelper log_cb_helper;
 
-  if (argc != 2) {
-    KUDU_LOG(FATAL) << "usage: " << argv[0] << " <master host>";
+  if (argc < 2) {
+    KUDU_LOG(FATAL) << "usage: " << argv[0] << " <master host> ...";
+  }
+  vector<string> master_addrs;
+  for (int i = 1; i < argc; i++) {
+    master_addrs.push_back(argv[i]);
   }
-  const string master_host = argv[1];
 
   const string kTableName = "test_table";
 
@@ -275,7 +281,7 @@ int main(int argc, char* argv[]) {
 
   // Create and connect a client.
   shared_ptr<KuduClient> client;
-  KUDU_CHECK_OK(CreateClient(master_host, &client));
+  KUDU_CHECK_OK(CreateClient(master_addrs, &client));
   KUDU_LOG(INFO) << "Created a client connection";
 
   // Disable the verbose logging.

http://git-wip-us.apache.org/repos/asf/kudu/blob/32d276e0/src/kudu/client/client_examples-test.sh
----------------------------------------------------------------------
diff --git a/src/kudu/client/client_examples-test.sh 
b/src/kudu/client/client_examples-test.sh
index ad0e86c..75d5ac7 100755
--- a/src/kudu/client/client_examples-test.sh
+++ b/src/kudu/client/client_examples-test.sh
@@ -24,18 +24,18 @@
 
 # Clean up after the test. Must be idempotent.
 cleanup() {
-  if [ -n "$TS_PID" ]; then
+  if [[ -n $TS_PID ]]; then
       kill -9 "$TS_PID" || :
-      wait $TS_PID || :
+      wait "$TS_PID" || :
   fi
-  if [ -n "$MASTER_PID" ]; then
+  if [[ -n $MASTER_PID ]]; then
       kill -9 "$MASTER_PID" || :
-      wait $MASTER_PID || :
+      wait "$MASTER_PID" || :
   fi
-  if [ -n "$BASE_DIR" -a -d "$BASE_DIR" ]; then
+  if [[ -n $BASE_DIR ]] && [[ -d $BASE_DIR ]]; then
       rm -rf "$BASE_DIR"
   fi
-  if [ -n "$LIBRARY_DIR" -a -d "$LIBRARY_DIR" ]; then
+  if [[ -n $LIBRARY_DIR ]] && [[ -d $LIBRARY_DIR ]]; then
       rm -rf "$LIBRARY_DIR"
   fi
 }
@@ -51,24 +51,25 @@ wait_for_listen_port() {
   local num_attempts=$3
 
   local attempt=0
-  while [ true ]; do
+  while true; do
     # The lsof utility does not allow to distinguish between an existing
     # process not listening to the specified port and a non-existing process
     # by its return code. For the fast check let's verify that the process
     # is still running.
-    if ! kill -0 $pid; then
+    if ! kill -0 "$pid"; then
       return 1
     fi
-    local ports=$(lsof -wbnP -Fn -p $pid -a -i 4TCP -a -s TCP:LISTEN | \
-        sed '1d;s/^[^:].*://')
+    local ports
+    ports=$(lsof -wbnP -Fn -p "$pid" -a -i 4TCP -a -s TCP:LISTEN | \
+            sed -n '/^n/ s/^[^:].*://p')
     for i in $ports; do
-      if [ $i -eq $expected_port ]; then
+      if [[ $i -eq $expected_port ]]; then
         return 0
       fi
     done
 
     attempt=$((attempt+1))
-    if [ $attempt -ge $num_attempts ]; then
+    if [[ $attempt -ge $num_attempts ]]; then
       break
     fi
     sleep 1
@@ -82,40 +83,41 @@ exit_error() {
 
   set +x
   echo ----------------------------------------------------------------------
-  echo ERROR: $err_msg
+  echo ERROR: "$err_msg"
   echo ----------------------------------------------------------------------
   exit 1
 }
 
-OUTPUT_DIR=$(cd $(dirname "$BASH_SOURCE"); pwd)
+OUTPUT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)
 
 # Install the client library to a temporary directory.
 # Try to detect whether we're building using Ninja or Make.
 LIBRARY_DIR=$(mktemp -d -t kudu-examples-test.XXXXXXXXXXXXX)
 PREFIX_DIR=$LIBRARY_DIR/usr/local
 EXAMPLES_DIR=$PREFIX_DIR/share/doc/kuduClient/examples
-pushd $OUTPUT_DIR/..
+pushd "$OUTPUT_DIR/.."
 NINJA=$(which ninja 2>/dev/null) || NINJA=""
-if [ -r build.ninja -a -n "$NINJA" ]; then
+if [[ -r build.ninja ]] && [[ -n $NINJA ]]; then
   DESTDIR=$LIBRARY_DIR ninja install
 else
-  make -j$(getconf _NPROCESSORS_ONLN) DESTDIR=$LIBRARY_DIR install
+  # nproc is not available on macOS.
+  make -j"$(getconf _NPROCESSORS_ONLN)" DESTDIR="$LIBRARY_DIR" install
 fi
 popd
 
 # Test that all of the installed headers can be compiled on their own.
 # This catches bugs where we've made a mistake in 'include-what-you-use'
 # within the library.
-for include_file in $(find $LIBRARY_DIR -name \*.h) ; do
-  echo Checking standalone compilation of $include_file...
+for include_file in $(find "$LIBRARY_DIR" -name \*.h) ; do
+  echo Checking standalone compilation of "$include_file"...
   if ! ${CXX:-g++} \
        -o /dev/null \
-       -I$LIBRARY_DIR/usr/local/include \
-       $include_file ; then
+       -I"$LIBRARY_DIR/usr/local/include" \
+       "$include_file" ; then
     set +x
     echo
     echo -----------------------------------------
-    echo $include_file fails to build on its own.
+    echo "$include_file" fails to build on its own.
     echo See log above for details.
     echo -----------------------------------------
     exit 1
@@ -126,23 +128,23 @@ done
 # to be usable with older versions of cmake. But if it isn't there,
 # use the one from thirdparty.
 CMAKE=$(which cmake || :)
-if [ -z "$CMAKE" ]; then
+if [[ -z $CMAKE ]]; then
   # TODO: temporary hack which assumes this script is in src/build/<type>/bin
   CMAKE=$OUTPUT_DIR/../../../thirdparty/installed/common/bin/cmake
 fi
 
 # Build the client examples using the client library.
 # We can just always use Make here, since we're calling cmake ourselves.
-pushd $EXAMPLES_DIR
+pushd "$EXAMPLES_DIR"
 CMAKE_PREFIX_PATH=$PREFIX_DIR $CMAKE .
-make -j$(getconf _NPROCESSORS_ONLN)
+make -j"$(getconf _NPROCESSORS_ONLN)"
 popd
 
 LOCALHOST_IP=127.0.0.1
-if [ "$(uname)" == "Linux" ]; then
+if [[ $(uname) == Linux ]]; then
   # Pick a unique localhost IP address so this can run in parallel with other
   # tests. This only works on Linux.
-  LOCALHOST_IP=127.$[($$ >> 8) & 0xff].$[$$ & 0xff].1
+  LOCALHOST_IP=127.$((($$ >> 8) & 0xff)).$(($$ & 0xff)).1
 fi
 echo Using localhost IP $LOCALHOST_IP
 
@@ -150,16 +152,16 @@ echo Using localhost IP $LOCALHOST_IP
 # Start master+ts
 export TMPDIR=${TMPDIR:-/tmp}
 export TEST_TMPDIR=${TEST_TMPDIR:-$TMPDIR/kudutest-$UID}
-mkdir -p $TEST_TMPDIR
-BASE_DIR=$(mktemp -d $TEST_TMPDIR/client_examples-test.XXXXXXXX)
+mkdir -p "$TEST_TMPDIR"
+BASE_DIR=$(mktemp -d "$TEST_TMPDIR/client_examples-test.XXXXXXXX")
 MASTER_RPC_PORT=7051
 mkdir -p "$BASE_DIR/master/logs"
-$OUTPUT_DIR/kudu-master \
+"$OUTPUT_DIR/kudu-master" \
   --unlock_experimental_flags \
   --default_num_replicas=1 \
-  --log_dir=$BASE_DIR/master/logs \
-  --fs_wal_dir=$BASE_DIR/master/wals \
-  --fs_data_dirs=$BASE_DIR/master/data \
+  --log_dir="$BASE_DIR/master/logs" \
+  --fs_wal_dir="$BASE_DIR/master/wals" \
+  --fs_data_dirs="$BASE_DIR/master/data" \
   --webserver_interface=$LOCALHOST_IP \
   --webserver_port=0 \
   --rpc_bind_addresses=$LOCALHOST_IP:$MASTER_RPC_PORT &
@@ -167,13 +169,13 @@ MASTER_PID=$!
 
 TSERVER_RPC_PORT=7050
 mkdir -p "$BASE_DIR/ts/logs"
-$OUTPUT_DIR/kudu-tserver \
+"$OUTPUT_DIR/kudu-tserver" \
   --unlock_experimental_flags \
   --heartbeat_interval_ms=200 \
   --heartbeat_rpc_timeout_ms=1000 \
-  --log_dir=$BASE_DIR/ts/logs \
-  --fs_wal_dir=$BASE_DIR/ts/wals \
-  --fs_data_dirs=$BASE_DIR/ts/data \
+  --log_dir="$BASE_DIR/ts/logs" \
+  --fs_wal_dir="$BASE_DIR/ts/wals" \
+  --fs_data_dirs="$BASE_DIR/ts/data" \
   --rpc_bind_addresses=$LOCALHOST_IP:$TSERVER_RPC_PORT \
   --local_ip_for_outbound_sockets=$LOCALHOST_IP \
   --webserver_interface=$LOCALHOST_IP \
@@ -195,24 +197,24 @@ fi
 max_attempts=10
 attempt=0
 num_tservers=0
-while [ true ]; do
-  if ! num_tservers=$($OUTPUT_DIR/kudu tserver list \
+while true; do
+  if ! num_tservers=$("$OUTPUT_DIR/kudu" tserver list \
       $LOCALHOST_IP:$MASTER_RPC_PORT -format=space | wc -l); then
     exit_error "failed to determine number of registered tservers"
   fi
-  if [ $num_tservers -ge 1 ]; then
+  if [[ $num_tservers -ge 1 ]]; then
     break
   fi
   attempt=$((attempt+1))
-  if [ $attempt -ge $max_attempts ]; then
+  if [[ $attempt -ge $max_attempts ]]; then
     break
   fi
   sleep 1
 done
 
-if [ $num_tservers -lt 1 ]; then
+if [[ $num_tservers -lt 1 ]]; then
   exit_error "tserver has not registered with the master"
 fi
 
 # Run the examples.
-$EXAMPLES_DIR/example $LOCALHOST_IP
+"$EXAMPLES_DIR/example" $LOCALHOST_IP

http://git-wip-us.apache.org/repos/asf/kudu/blob/32d276e0/src/kudu/client/scan_batch.h
----------------------------------------------------------------------
diff --git a/src/kudu/client/scan_batch.h b/src/kudu/client/scan_batch.h
index 30fe2b1..f381ae2 100644
--- a/src/kudu/client/scan_batch.h
+++ b/src/kudu/client/scan_batch.h
@@ -63,7 +63,7 @@ class KuduSchema;
 /// regular for loop (C++03):
 /// @code
 ///   for (KuduScanBatch::const_iterator it = batch.begin(), it != batch.end();
-///        ++i) {
+///        ++it) {
 ///     KuduScanBatch::RowPtr row(*it);
 ///     ...
 ///   }

Reply via email to