Random random = new Random();
long bytesWritten = 0;
BatchWriter bw = null;
FileSKVWriter writer = null;
rootCredentials = new AuthInfo(username, ByteBuffer.wrap(passwd.getBytes()), instance.getInstanceID());
if (ingestArgs.outputToMapFile) {
Configuration conf = CachedConfiguration.getInstance();
FileSystem fs = FileSystem.get(conf);
writer = FileOperations.getInstance().openWriter(ingestArgs.outputFile + "." + Constants.MAPFILE_EXTENSION, fs, conf,
AccumuloConfiguration.getDefaultConfiguration());
writer.startDefaultLocalityGroup();
} else if (ingestArgs.outputToRFile) {
Configuration conf = CachedConfiguration.getInstance();
FileSystem fs = FileSystem.get(conf);
writer = FileOperations.getInstance().openWriter(ingestArgs.outputFile + "." + RFile.EXTENSION, fs, conf,
AccumuloConfiguration.getDefaultConfiguration());
writer.startDefaultLocalityGroup();
} else {
Connector connector = instance.getConnector(rootCredentials.user, rootCredentials.password);
bw = connector.createBatchWriter("test_ingest", 20000000l, 60000l, 10);
}
Authenticator authenticator = ZKAuthenticator.getInstance();
authenticator.changeAuthorizations(rootCredentials, rootCredentials.user, AUTHS);
ColumnVisibility le = new ColumnVisibility("L1&L2&G1&GROUP2");
Text labBA = new Text(le.getExpression());
// int step = 100;
long startTime = System.currentTimeMillis();
for (int i = 0; i < ingestArgs.rows; i++) {
int rowid;
if (ingestArgs.stride > 0) {
rowid = ((i % ingestArgs.stride) * (ingestArgs.rows / ingestArgs.stride)) + (i / ingestArgs.stride);
} else {
rowid = i;
}
Text row = generateRow(rowid, ingestArgs.startRow);
Mutation m = new Mutation(row);
for (int j = 0; j < ingestArgs.cols; j++) {
Text colf = new Text(ingestArgs.columnFamily);
Text colq = new Text(FastFormat.toZeroPaddedString(j, 5, 10, COL_PREFIX));
if (writer != null) {
Key key = new Key(row, colf, colq, labBA);
if (ingestArgs.hasTimestamp) {
key.setTimestamp(ingestArgs.timestamp);
} else {
key.setTimestamp(System.currentTimeMillis());
}
if (ingestArgs.delete) {
key.setDeleted(true);
} else {
key.setDeleted(false);
}
bytesWritten += key.getSize();
if (ingestArgs.delete) {
writer.append(key, new Value(new byte[0]));
} else {
byte value[];
if (ingestArgs.random) {
value = genRandomValue(random, randomValue, ingestArgs.seed, rowid + ingestArgs.startRow, j);
} else {
value = bytevals[j % bytevals.length];
}
Value v = new Value(value);
writer.append(key, v);
bytesWritten += v.getSize();
}
} else {
Key key = new Key(row, colf, colq, labBA);
bytesWritten += key.getSize();
if (ingestArgs.delete) {
if (ingestArgs.hasTimestamp)
m.putDelete(colf, colq, le, ingestArgs.timestamp);
else
m.putDelete(colf, colq, le);
} else {
byte value[];
if (ingestArgs.random) {
value = genRandomValue(random, randomValue, ingestArgs.seed, rowid + ingestArgs.startRow, j);
} else {
value = bytevals[j % bytevals.length];
}
bytesWritten += value.length;
if (ingestArgs.hasTimestamp) {
m.put(colf, colq, le, ingestArgs.timestamp, new Value(value, true));
} else {
m.put(colf, colq, le, new Value(value, true));
}
}
}
}
if (bw != null)
bw.addMutation(m);
}
if (writer != null) {
writer.close();
} else if (bw != null) {
try {
bw.close();
} catch (MutationsRejectedException e) {
if (e.getAuthorizationFailures().size() > 0) {