}
@Test
@SuppressWarnings("deprecation")
public void testPartitionedWriterDouble() throws IOException {
PartitionStrategy partitionStrategy = new PartitionStrategy.Builder()
.hash("username", 2).hash("email", 3).build();
FileSystemDataset<Record> ds = new FileSystemDataset.Builder()
.name("partitioned-users")
.configuration(getConfiguration())
.descriptor(new DatasetDescriptor.Builder()
.schema(USER_SCHEMA)
.format(format)
.location(testDirectory)
.partitionStrategy(partitionStrategy)
.build())
.build();
Assert.assertTrue("Dataset is partitioned", ds.getDescriptor()
.isPartitioned());
Assert.assertEquals(partitionStrategy, ds.getDescriptor()
.getPartitionStrategy());
writeTestUsers(ds, 10);
checkTestUsers(ds, 10);
PartitionKey key0 = Accessor.getDefault().newPartitionKey(0);
PartitionKey key1 = Accessor.getDefault().newPartitionKey(1);
int total = readTestUsersInPartition(ds, key0, "email")
+ readTestUsersInPartition(ds, key0, "email");
Assert.assertEquals(10, total);
total = 0;
for (int i1 = 0; i1 < 2; i1++) {
for (int i2 = 0; i2 < 3; i2++) {
String part = "username=" + i1 + "/email=" + i2;
Assert.assertTrue("Partitioned directory " + part + " exists",
fileSystem.exists(new Path(testDirectory, part)));
total += readTestUsersInPartition(ds,
partitionStrategy.partitionKey(i1, i2), null);
}
}
Assert.assertEquals(10, total);
testPartitionKeysAreEqual(ds, key0, key1);