accumulo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Medinets <>
Subject ROW ID Iterator - sanity check
Date Sat, 19 May 2012 22:09:37 GMT
I wanted a program to display Row Id values in the simplest way
possible. Please let me know if I have overlooked something. First, i
wrapped the RowIterator like this;

package com.codebits.accumulo;

import java.util.Iterator;
import java.util.Map.Entry;

import org.apache.accumulo.core.client.RowIterator;
import org.apache.accumulo.core.client.Scanner;

public class RowIdIterator implements Iterator<String>, Iterable<String> {

	Scanner scanner = null;
	RowIterator iterator = null;

	public RowIdIterator(Scanner scanner) {
		this.scanner = scanner;
		this.iterator = new RowIterator(scanner);

	public boolean hasNext() {
		return iterator.hasNext();

	public String next() {
		Iterator<Entry<Key, Value>> entry =;

	public void remove() {

	public Iterator<String> iterator() {
		return this;

And then I used a driver program like this;

package com.codebits.accumulo;

import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.ZooKeeperInstance;

public class RowIdInteratorDriver {

  public static void main(String[] args) throws AccumuloException,
AccumuloSecurityException, TableNotFoundException {
        String instanceName = "development";
        String zooKeepers = "localhost";
        String user = "root";
        byte[] pass = "password".getBytes();
        String tableName = "test_row_iterator";
        Authorizations authorizations = new Authorizations();

        ZooKeeperInstance instance = new
ZooKeeperInstance(instanceName, zooKeepers);
        Connector connector = instance.getConnector(user, pass);
        Scanner scanner = connector.createScanner(tableName, authorizations);

        for (String rowId : new RowIdIterator(scanner)) {
        	System.out.println("ROW ID: " + rowId);


This code works:

ROW ID: R001
ROW ID: R002
ROW ID: R003

My concern is that scanner that I am passing into the iterator. How is
that testable? And, of course, the class name is confusing..

View raw message