@Test
  public void test_walk() {
    final RiakClient c = new RiakClient(RIAK_URL);

    final String ROOT = "root";
    final String LEAF1 = "leaf1";
    final String LEAF2 = "leaf2";
    final String EXCLUDED_LEAF = "excluded_leaf";
    final byte[] INCLUDED_VALUE = CharsetUtils.utf8StringToBytes("included");
    final byte[] EXCLUDED_VALUE = CharsetUtils.utf8StringToBytes("excluded");
    final String TAG_INCLUDE = "tag_include";
    final String TAG_EXCLUDE = "tag_exclude";

    // Clear out the objects we're testing with
    assertSuccess(c.delete(BUCKET, ROOT));
    assertSuccess(c.delete(BUCKET, LEAF1));
    assertSuccess(c.delete(BUCKET, LEAF2));
    assertSuccess(c.delete(BUCKET, EXCLUDED_LEAF));

    // Add a few objects
    RiakObject leaf1 = new RiakObject(BUCKET, LEAF1, INCLUDED_VALUE);
    RiakObject leaf2 = new RiakObject(BUCKET, LEAF2, INCLUDED_VALUE);
    RiakObject excludedLeaf = new RiakObject(BUCKET, EXCLUDED_LEAF, EXCLUDED_VALUE);
    RiakObject root =
        new RiakObject(c, BUCKET, ROOT)
            .addLink(new RiakLink(BUCKET, LEAF1, TAG_INCLUDE))
            .addLink(new RiakLink(BUCKET, LEAF2, TAG_INCLUDE))
            .addLink(new RiakLink(BUCKET, EXCLUDED_LEAF, TAG_EXCLUDE));
    assertSuccess(c.store(root, WRITE_3_REPLICAS()));
    assertSuccess(c.store(leaf1, WRITE_3_REPLICAS()));
    assertSuccess(c.store(leaf2, WRITE_3_REPLICAS()));
    assertSuccess(c.store(excludedLeaf, WRITE_3_REPLICAS()));

    // Perform walk
    WalkResponse walkresp = root.walk(BUCKET, TAG_INCLUDE).run();
    assertSuccess(walkresp);
    assertTrue(walkresp.hasSteps());
    assertEquals(1, walkresp.getSteps().size());
    assertEquals(2, walkresp.getSteps().get(0).size());

    // Verify expected only linked to objects are returned
    List<? extends List<RiakObject>> steps = walkresp.getSteps();
    List<String> keys = new ArrayList<String>();
    for (List<RiakObject> step : steps) {
      for (RiakObject object : step) {
        keys.add(object.getKey());
        assertArrayEquals(INCLUDED_VALUE, object.getValueAsBytes());
      }
    }
    assertTrue(keys.contains(LEAF1));
    assertTrue(keys.contains(LEAF2));
  }
    private void dumpToRiak() {
      try {
        if (blogStats.blogs.size() == 0) return;
        int count = 0;
        Date t0 = new Date();
        System.out.println(
            "dumping " + blogStats.blogs.size() + " blogstats into riak. First key: " + firstKey);
        for (String blogId : blogStats.blogs.keySet()) {
          count++;
          Blog blog = blogStats.blogs.get(blogId);

          RiakObject riakObject = new RiakObject(bucketName, blogId);
          String json = serialize(blog);
          if (count % 1000 == 0) {
            long millis = System.currentTimeMillis() - start.getTime();
            System.out.println(
                "dumped: "
                    + count
                    + " blogs. firstKey: "
                    + firstKey
                    + " totalDumped: "
                    + totalDumped
                    + " totalSecs: "
                    + millis / 1000
                    + " prsec "
                    + (1000 * totalDumped / millis));
          }

          riakObject.setValue(json);
          riakObject.setContentType("application/json");
          riakClient.store(riakObject);
          totalDumped++;
        }
        long elapsed = System.currentTimeMillis() - t0.getTime();
        System.out.println(
            "Done dumping data into riak. TooK: "
                + elapsed
                + " milliseconds. records pr. sec: "
                + 1000 * (blogStats.blogs.size() / elapsed));
        blogStats.blogs = new HashMap<String, Blog>();
      } catch (Exception e) {
        e.printStackTrace(); // To change body of catch statement use File | Settings | File
        // Templates.
      }
    }