@SuppressWarnings("unchecked") private Path toDirectoryName(Path dir, PartitionKey key) { Path result = dir; for (int i = 0; i < key.getLength(); i++) { final FieldPartitioner fp = partitionStrategy.getFieldPartitioners().get(i); if (result != null) { result = new Path(result, convert.dirnameForValue(fp, key.get(i))); } else { result = new Path(convert.dirnameForValue(fp, key.get(i))); } } return result; }
@Test public void testDirnameMinWidth() { Assert.assertEquals( "min=01", PathConversion.dirnameForValue(new MinuteFieldPartitioner("timestamp", "min"), 1)); Assert.assertEquals( "hour=01", PathConversion.dirnameForValue(new HourFieldPartitioner("timestamp", "hour"), 1)); Assert.assertEquals( "day=01", PathConversion.dirnameForValue(new DayOfMonthFieldPartitioner("timestamp", "day"), 1)); Assert.assertEquals( "month=01", PathConversion.dirnameForValue(new MonthFieldPartitioner("timestamp", "month"), 1)); Assert.assertEquals( "year=2013", PathConversion.dirnameForValue(new YearFieldPartitioner("timestamp", "year"), 2013)); }
@Test public void testUsesFieldName() { Assert.assertEquals( "day_of_month_field", Iterables.getFirst( EQ.split( PathConversion.dirnameForValue( new DayOfMonthFieldPartitioner("day", "day_of_month_field"), 10)), null)); }