You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@accumulo.apache.org by Benson Margulies <bi...@gmail.com> on 2012/02/08 14:30:20 UTC

writing to more than one table

I've sketched code that creates rows in two tables at the same time.
So I've got two batch writers, and presumably I need to divide my
threads amongst them. Is there something I'm missing here; like some
other variation on the writer classes that is more suited to multiple
tables?

Re: writing to more than one table

Posted by Aaron Cordova <aa...@cordovas.org>.
There is indeed. As of 1.4, maybe earlier there is a class called MultiTableBatchWriter.

I believe the usage is as follows. 

One obtains one via calling:

MultiTableBatchWriter mtbw = conn.createMultiTableBatchWriter(long maxMemory, long maxLatency, int maxWriteThreads)

on a Connector object.

Then obtain BatchWriters for your various tables

BatchWriter bw1 = mtbw.getBatchWriter("table1");
BatchWriter bw2 = mtbw.getBatchWriter("table2");

When done, one closes the MultiTableBatchWriter

mtbw.close()

On Feb 8, 2012, at 8:30 AM, Benson Margulies wrote:

> I've sketched code that creates rows in two tables at the same time.
> So I've got two batch writers, and presumably I need to divide my
> threads amongst them. Is there something I'm missing here; like some
> other variation on the writer classes that is more suited to multiple
> tables?