public StorageKey reuseFor(Path path, PathConversion conversion) { conversion.toKey(path, this); this.path = path; return this; }
expected.replaceValues((List) Lists.newArrayList(1L, 2013, 11)); Assert.assertEquals(expected, convert.toKey( new Path(ROOT_PATH, "id=1/year=2013/month=11"), new StorageKey(strategy))); Assert.assertEquals(expected, convert.toKey( new Path(ROOT_PATH, "id=1/year=2013"), new StorageKey(strategy))); Assert.assertEquals(expected, convert.toKey( new Path(ROOT_PATH, "id=1"), new StorageKey(strategy))); Assert.assertEquals(expected, convert.toKey( ROOT_PATH, new StorageKey(strategy)));
@Test @SuppressWarnings("unchecked") public void toDirNameIdentityWithNonString() { PartitionStrategy strategy = new PartitionStrategy.Builder() .identity("id") .build(); StorageKey expected = new StorageKey(strategy); expected.replace(0, 0L); Assert.assertEquals("Should convert to schema type", expected, convert.toKey(new Path("id=0"), new StorageKey(strategy))); } }
@Test @SuppressWarnings("unchecked") public void testToKey() { PartitionStrategy strategy = new PartitionStrategy.Builder() .year("timestamp") .month("timestamp") .day("timestamp") .build(); StorageKey expected = new StorageKey(strategy); expected.replaceValues((List) Lists.newArrayList(2013, 11, 5)); Assert.assertEquals(expected, convert.toKey( new Path("year=2013/month=11/day=5"), new StorageKey(strategy))); }