use of org.apache.accumulo.core.client.BatchWriterConfig in project accumulo by apache.
the class ConfigurableCompactionIT method writeFlush.
private void writeFlush(Connector conn, String tablename, String row) throws Exception {
BatchWriter bw = conn.createBatchWriter(tablename, new BatchWriterConfig());
Mutation m = new Mutation(row);
m.put("", "", "");
bw.addMutation(m);
bw.close();
conn.tableOperations().flush(tablename, null, null, true);
}
use of org.apache.accumulo.core.client.BatchWriterConfig in project accumulo by apache.
the class VolumeChooserIT method writeDataToTable.
public static void writeDataToTable(Connector connector, String tableName) throws Exception {
// Write some data to the table
BatchWriter bw = connector.createBatchWriter(tableName, new BatchWriterConfig());
for (String s : rows) {
Mutation m = new Mutation(new Text(s));
m.put(EMPTY, EMPTY, EMPTY_VALUE);
bw.addMutation(m);
}
bw.close();
}
use of org.apache.accumulo.core.client.BatchWriterConfig in project accumulo by apache.
the class VolumeIT method testRelativePaths.
@Test
public void testRelativePaths() throws Exception {
List<String> expected = new ArrayList<>();
Connector connector = getConnector();
String tableName = getUniqueNames(1)[0];
connector.tableOperations().create(tableName, new NewTableConfiguration().withoutDefaultIterators());
Table.ID tableId = Table.ID.of(connector.tableOperations().tableIdMap().get(tableName));
SortedSet<Text> partitions = new TreeSet<>();
// with some splits
for (String s : "c,g,k,p,s,v".split(",")) partitions.add(new Text(s));
connector.tableOperations().addSplits(tableName, partitions);
BatchWriter bw = connector.createBatchWriter(tableName, new BatchWriterConfig());
// create two files in each tablet
String[] rows = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(",");
for (String s : rows) {
Mutation m = new Mutation(s);
m.put("cf1", "cq1", "1");
bw.addMutation(m);
expected.add(s + ":cf1:cq1:1");
}
bw.flush();
connector.tableOperations().flush(tableName, null, null, true);
for (String s : rows) {
Mutation m = new Mutation(s);
m.put("cf1", "cq1", "2");
bw.addMutation(m);
expected.add(s + ":cf1:cq1:2");
}
bw.close();
connector.tableOperations().flush(tableName, null, null, true);
verifyData(expected, connector.createScanner(tableName, Authorizations.EMPTY));
connector.tableOperations().offline(tableName, true);
connector.securityOperations().grantTablePermission("root", MetadataTable.NAME, TablePermission.WRITE);
try (Scanner metaScanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
metaScanner.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
metaScanner.setRange(new KeyExtent(tableId, null, null).toMetadataRange());
BatchWriter mbw = connector.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
for (Entry<Key, Value> entry : metaScanner) {
String cq = entry.getKey().getColumnQualifier().toString();
if (cq.startsWith(v1.toString())) {
Path path = new Path(cq);
String relPath = "/" + path.getParent().getName() + "/" + path.getName();
Mutation fileMut = new Mutation(entry.getKey().getRow());
fileMut.putDelete(entry.getKey().getColumnFamily(), entry.getKey().getColumnQualifier());
fileMut.put(entry.getKey().getColumnFamily().toString(), relPath, entry.getValue().toString());
mbw.addMutation(fileMut);
}
}
mbw.close();
connector.tableOperations().online(tableName, true);
verifyData(expected, connector.createScanner(tableName, Authorizations.EMPTY));
connector.tableOperations().compact(tableName, null, null, true, true);
verifyData(expected, connector.createScanner(tableName, Authorizations.EMPTY));
for (Entry<Key, Value> entry : metaScanner) {
String cq = entry.getKey().getColumnQualifier().toString();
Path path = new Path(cq);
Assert.assertTrue("relative path not deleted " + path.toString(), path.depth() > 2);
}
}
}
use of org.apache.accumulo.core.client.BatchWriterConfig in project accumulo by apache.
the class VolumeIT method writeData.
private void writeData(String tableName, Connector conn) throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException, MutationsRejectedException {
TreeSet<Text> splits = new TreeSet<>();
for (int i = 1; i < 100; i++) {
splits.add(new Text(String.format("%06d", i * 100)));
}
conn.tableOperations().create(tableName);
conn.tableOperations().addSplits(tableName, splits);
BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig());
for (int i = 0; i < 100; i++) {
String row = String.format("%06d", i * 100 + 3);
Mutation m = new Mutation(row);
m.put("cf1", "cq1", "1");
bw.addMutation(m);
}
bw.close();
}
use of org.apache.accumulo.core.client.BatchWriterConfig in project accumulo by apache.
the class UserCompactionStrategyIT method writeFlush.
private void writeFlush(Connector conn, String tablename, String row) throws Exception {
BatchWriter bw = conn.createBatchWriter(tablename, new BatchWriterConfig());
Mutation m = new Mutation(row);
m.put("", "", "");
bw.addMutation(m);
bw.close();
conn.tableOperations().flush(tablename, null, null, true);
}
Aggregations