public String getPartString() { return period.format(partSpec); }
@Override public String call() { return format().format(date); } });
@Override public Date call() throws Exception { return format().parse(dateString); } });
@Override public String call() { return format().format(date); } });
@Override public Date call() throws Exception { return format().parse(dateString); } });
public Date parse(final String dateString) throws ParseException { try { return stringToDateCache.get(dateString, new Callable<Date>() { @Override public Date call() throws Exception { return format().parse(dateString); } }); } catch (ExecutionException e) { return format().parse(dateString); } }
public String format(final Date date) { try { return dateToStringCache.get(date, new Callable<String>() { @Override public String call() { return format().format(date); } }); } catch (ExecutionException e) { return format().format(date); } }
public String format(final Date date) { try { return dateToStringCache.get(date, new Callable<String>() { @Override public String call() { return format().format(date); } }); } catch (ExecutionException e) { return format().format(date); } }
public Date parse(final String dateString) throws ParseException { try { return stringToDateCache.get(dateString, new Callable<Date>() { @Override public Date call() throws Exception { return format().parse(dateString); } }); } catch (ExecutionException e) { return format().parse(dateString); } }
private Map<String, String> getPartitionSpec(UpdatePeriod updatePeriod, Map<String, Date> partitionTimestamps) { Map<String, String> partSpec = new HashMap<>(); for (Map.Entry<String, Date> entry : partitionTimestamps.entrySet()) { String pval = updatePeriod.format(entry.getValue()); partSpec.put(entry.getKey(), pval); } return partSpec; }
public Map<String, String> getStoragePartSpec() { if (fullPartSpec == null) { fullPartSpec = new HashMap<String, String>(); for (Map.Entry<String, Date> entry : timePartSpec.entrySet()) { fullPartSpec.put(entry.getKey(), updatePeriod.format(entry.getValue())); } if (nonTimePartSpec != null) { fullPartSpec.putAll(nonTimePartSpec); } } return fullPartSpec; }
private Map<String, String> getPartitionSpec(UpdatePeriod updatePeriod, Map<String, Date> partitionTimestamps) { Map<String, String> partSpec = new HashMap<>(); for (Map.Entry<String, Date> entry : partitionTimestamps.entrySet()) { String pval = updatePeriod.format(entry.getValue()); partSpec.put(entry.getKey(), pval); } return partSpec; }
public Map<String, String> getStoragePartSpec() { if (fullPartSpec == null) { fullPartSpec = new HashMap<String, String>(); for (Map.Entry<String, Date> entry : timePartSpec.entrySet()) { fullPartSpec.put(entry.getKey(), updatePeriod.format(entry.getValue())); } if (nonTimePartSpec != null) { fullPartSpec.putAll(nonTimePartSpec); } } return fullPartSpec; }
private TimePartition(@NonNull UpdatePeriod updatePeriod, @NonNull Date date) { this.updatePeriod = updatePeriod; this.date = updatePeriod.truncate(date); this.dateString = updatePeriod.format(this.date); }
private TimePartition(@NonNull UpdatePeriod updatePeriod, @NonNull Date date) { this.updatePeriod = updatePeriod; this.date = updatePeriod.truncate(date); this.dateString = updatePeriod.format(this.date); }
@Test public void testGetFormattedFilter() throws Exception { String dailyFormat = DAILY.format(DATE); String hourlyFormat = HOURLY.format(DATE); assertEquals(fp1.getFormattedFilter("table"), "table.p = '" + dailyFormat + "'"); assertEquals(fp2.getFormattedFilter("table2"), "table2.p = '" + dailyFormat + "' AND table2.q = '" + hourlyFormat + "'"); }
public static String getTimeRangeString(String partCol, UpdatePeriod updatePeriod, int startOffset, int endOffset, UpdatePeriod formatWith) { return getTimeRangeString(partCol, formatWith.format(getDateWithOffset(updatePeriod, startOffset)), formatWith.format(getDateWithOffset(updatePeriod, endOffset))); }
@Override public void validateConsecutive(String whereClause, DateFormat format) { String expected = null; if (format == null) { expected = getBetweenClause("test", "dt", TWODAYS_BACK, NOW, DAILY.format()); } else { expected = getBetweenClause("test", "dt", TWODAYS_BACK, NOW, format); } Assert.assertEquals(expected, whereClause); }
@Test(dataProvider = "update-periods") public void testFormat(UpdatePeriod period) throws Exception { RandomDateGenerator randomDateGenerator = new RandomDateGenerator(); for (int i = 0; i < 5000; i++) { Date randomDate = randomDateGenerator.nextDate(); randomDate = period.truncate(randomDate); assertEquals(randomDate, period.parse(period.format(randomDate))); } } }
private void validateBetweenOnlySingle(String whereClause, DateFormat format) { String expected = null; if (format == null) { expected = getBetweenClause("test", "dt", getDateWithOffset(DAILY, -1), getDateWithOffset(DAILY, -1), DAILY.format()); } else { expected = getBetweenClause("test", "dt", getDateWithOffset(DAILY, -1), getDateWithOffset(DAILY, -1), format); } Assert.assertEquals(expected, whereClause); }