accumulo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Armstrong <>
Subject Re: Writing data - example and how to create table
Date Thu, 02 Aug 2012 19:51:17 GMT
On 08/02/2012 03:37 PM, Edmon Begoli wrote:
> I am looking at the official example of how to write data and I do not
> see where is
> table created.
> Text rowID = new Text("row1");
> Text colFam = new Text("myColFam");
> Text colQual = new Text("myColQual");
> ColumnVisibility colVis = new ColumnVisibility("public");
> long timestamp = System.currentTimeMillis();
> Value value = new Value("myValue".getBytes());
> Mutation mutation = new Mutation(rowID);
> mutation.put(colFam, colQual, colVis, timestamp, value);

Start with

String accInstance;	// Accumulo instance name
String[] zookeepers;	// list of zookeepers
String user;		// Accumulo username
String password;	// Accumulo password
String tableName;
long bwMem;		// memory for BatchWriters to use, in B
long bwLat;		// latency for BatchWriters, in ms
int bwTheads;		// number of threads for BatchWriters to use

First you need a ZooKeeperInstance:

ZooKeeperInstance zk = new ZooKeeperInstance(accInstance, zookeepers)

Next you need a Connector:

Connector conn = zk.getConnector(user, password.getBytes());

Now you can make a table:


Given that, you can make a BatchWriter:

BatchWriter bw = conn.createBatchWriter(tableName,

And THEN you can add your mutations:


Don't forget to close!



View raw message