use of org.apache.accumulo.core.client.BatchWriter in project accumulo by apache.
the class ScanRangeIT method insertData.
private void insertData(Connector c, String table) throws Exception {
BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig());
for (int i = 0; i < ROW_LIMIT; i++) {
Mutation m = new Mutation(createRow(i));
for (int j = 0; j < CF_LIMIT; j++) {
for (int k = 0; k < CQ_LIMIT; k++) {
for (int t = 0; t < TS_LIMIT; t++) {
m.put(createCF(j), createCQ(k), t, new Value(String.format("%06d_%03d_%03d_%03d", i, j, k, t).getBytes(UTF_8)));
}
}
}
bw.addMutation(m);
}
bw.close();
}
use of org.apache.accumulo.core.client.BatchWriter in project accumulo by apache.
the class ScannerContextIT method testClearContext.
@Test
public void testClearContext() throws Exception {
Path dstPath = copyTestIteratorsJarToTmp();
try {
Connector c = getConnector();
// Set the classloader context property on the table to point to the test iterators jar file.
c.instanceOperations().setProperty(CONTEXT_PROPERTY, CONTEXT_CLASSPATH);
// Insert rows with the word "Test" in the value.
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
for (int i = 0; i < ITERATIONS; i++) {
Mutation m = new Mutation("row" + i);
m.put("cf", "col1", "Test");
bw.addMutation(m);
}
bw.close();
try (Scanner one = c.createScanner(tableName, Authorizations.EMPTY)) {
IteratorSetting cfg = new IteratorSetting(21, "reverse", "org.apache.accumulo.test.functional.ValueReversingIterator");
one.addScanIterator(cfg);
one.setClassLoaderContext(CONTEXT);
Iterator<Entry<Key, Value>> iterator = one.iterator();
for (int i = 0; i < ITERATIONS; i++) {
assertTrue(iterator.hasNext());
Entry<Key, Value> next = iterator.next();
assertEquals("tseT", next.getValue().toString());
}
one.removeScanIterator("reverse");
one.clearClassLoaderContext();
iterator = one.iterator();
for (int i = 0; i < ITERATIONS; i++) {
assertTrue(iterator.hasNext());
Entry<Key, Value> next = iterator.next();
assertEquals("Test", next.getValue().toString());
}
}
} finally {
// Delete file in tmp
fs.delete(dstPath, true);
}
}
use of org.apache.accumulo.core.client.BatchWriter in project accumulo by apache.
the class ScannerContextIT method testOneScannerDoesntInterfereWithAnother.
@Test
public void testOneScannerDoesntInterfereWithAnother() throws Exception {
Path dstPath = copyTestIteratorsJarToTmp();
try {
Connector c = getConnector();
// Set the classloader context property on the table to point to the test iterators jar file.
c.instanceOperations().setProperty(CONTEXT_PROPERTY, CONTEXT_CLASSPATH);
// Insert rows with the word "Test" in the value.
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
for (int i = 0; i < ITERATIONS; i++) {
Mutation m = new Mutation("row" + i);
m.put("cf", "col1", "Test");
bw.addMutation(m);
}
bw.close();
try (Scanner one = c.createScanner(tableName, Authorizations.EMPTY);
Scanner two = c.createScanner(tableName, Authorizations.EMPTY)) {
IteratorSetting cfg = new IteratorSetting(21, "reverse", "org.apache.accumulo.test.functional.ValueReversingIterator");
one.addScanIterator(cfg);
one.setClassLoaderContext(CONTEXT);
Iterator<Entry<Key, Value>> iterator = one.iterator();
for (int i = 0; i < ITERATIONS; i++) {
assertTrue(iterator.hasNext());
Entry<Key, Value> next = iterator.next();
assertEquals("tseT", next.getValue().toString());
}
Iterator<Entry<Key, Value>> iterator2 = two.iterator();
for (int i = 0; i < ITERATIONS; i++) {
assertTrue(iterator2.hasNext());
Entry<Key, Value> next = iterator2.next();
assertEquals("Test", next.getValue().toString());
}
}
} finally {
// Delete file in tmp
fs.delete(dstPath, true);
}
}
use of org.apache.accumulo.core.client.BatchWriter in project accumulo by apache.
the class AccumuloFileOutputFormatIT method testRealWrite.
@Test
public void testRealWrite() throws Exception {
Connector c = getConnector();
c.tableOperations().create(TEST_TABLE);
BatchWriter bw = c.createBatchWriter(TEST_TABLE, new BatchWriterConfig());
Mutation m = new Mutation("Key");
m.put("", "", "");
bw.addMutation(m);
bw.close();
handleWriteTests(true);
}
use of org.apache.accumulo.core.client.BatchWriter in project accumulo by apache.
the class TokenFileIT method testMR.
@Test
public void testMR() throws Exception {
String[] tableNames = getUniqueNames(2);
String table1 = tableNames[0];
String table2 = tableNames[1];
Connector c = getConnector();
c.tableOperations().create(table1);
c.tableOperations().create(table2);
BatchWriter bw = c.createBatchWriter(table1, new BatchWriterConfig());
for (int i = 0; i < 100; i++) {
Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
bw.addMutation(m);
}
bw.close();
File tf = folder.newFile("root_test.pw");
PrintStream out = new PrintStream(tf);
String outString = new Credentials(getAdminPrincipal(), getAdminToken()).serialize();
out.println(outString);
out.close();
MRTokenFileTester.main(new String[] { tf.getAbsolutePath(), table1, table2 });
assertNull(e1);
try (Scanner scanner = c.createScanner(table2, new Authorizations())) {
Iterator<Entry<Key, Value>> iter = scanner.iterator();
assertTrue(iter.hasNext());
Entry<Key, Value> entry = iter.next();
assertEquals(Integer.parseInt(new String(entry.getValue().get())), 100);
assertFalse(iter.hasNext());
}
}
Aggregations