use of org.apache.accumulo.core.client.rfile.RFileWriter in project accumulo by apache.
the class CryptoTest method testRFileEncrypted.
@Test
public void testRFileEncrypted() throws Exception {
AccumuloConfiguration cryptoOnConf = getAccumuloConfig(ConfigMode.CRYPTO_ON);
FileSystem fs = FileSystem.getLocal(hadoopConf);
ArrayList<Key> keys = testData();
SummarizerConfiguration sumConf = SummarizerConfiguration.builder(KeyCounter.class.getName()).build();
String file = "target/testFile1.rf";
fs.delete(new Path(file), true);
try (RFileWriter writer = RFile.newWriter().to(file).withFileSystem(fs).withTableProperties(cryptoOnConf).withSummarizers(sumConf).build()) {
Value empty = new Value();
writer.startDefaultLocalityGroup();
for (Key key : keys) {
writer.append(key, empty);
}
}
Scanner iter = RFile.newScanner().from(file).withFileSystem(fs).withTableProperties(cryptoOnConf).build();
ArrayList<Key> keysRead = new ArrayList<>();
iter.forEach(e -> keysRead.add(e.getKey()));
assertEquals(keys, keysRead);
Collection<Summary> summaries = RFile.summaries().from(file).withFileSystem(fs).withTableProperties(cryptoOnConf).read();
Summary summary = Iterables.getOnlyElement(summaries);
assertEquals(keys.size(), (long) summary.getStatistics().get("keys"));
assertEquals(1, summary.getStatistics().size());
assertEquals(0, summary.getFileStatistics().getInaccurate());
assertEquals(1, summary.getFileStatistics().getTotal());
}
use of org.apache.accumulo.core.client.rfile.RFileWriter in project accumulo by apache.
the class BulkFailureIT method createTestFile.
private String createTestFile(long txid, SortedMap<Key, Value> testData, FileSystem fs) throws IOException {
Path base = new Path(getCluster().getTemporaryPath(), "testBulk_ICI_" + txid);
fs.delete(base, true);
fs.mkdirs(base);
Path files = new Path(base, "files");
try (RFileWriter writer = RFile.newWriter().to(new Path(files, "ici_01.rf").toString()).withFileSystem(fs).build()) {
writer.append(testData.entrySet());
}
String filesStr = fs.makeQualified(files).toString();
return filesStr;
}
Aggregations