static public String makeName(String collectionName, CalendarDate runtime) { String nameNoBlanks = StringUtil2.replace(collectionName, ' ', "_"); return nameNoBlanks + "-" + cf.toString(runtime); }
private List<CollectionManager> makePartitionsByPeriod() throws IOException { this.type = Type.timePeriod; List<DatedMFile> files = new ArrayList<DatedMFile>(); for (MFile mfile : getFiles()) { CalendarDate cdate = dateExtractor.getCalendarDate(mfile); if (cdate == null) logger.error("Date extraction failed on file= {} dateExtractor = {}", mfile.getPath(), dateExtractor); files.add( new DatedMFile(mfile, cdate)); } Collections.sort(files); CalendarDateFormatter cdf = new CalendarDateFormatter("yyyyMMdd"); List<CollectionManager> result = new ArrayList<CollectionManager>(); TimePartitionCollectionManager curr = null; for (DatedMFile dmf : files) { if ((curr == null) || (!curr.endPartition.isAfter(dmf.cdate))) { CalendarPeriod period = CalendarPeriod.of(config.timePartition); CalendarDate start = dmf.cdate.truncate(period.getField()); // start on a boundary CalendarDate end = start.add( period); String name = collectionName + "-"+ cdf.toString(dmf.cdate); curr = new TimePartitionCollectionManager(name, start, end, getRoot(), this.auxInfo, this.logger); result.add(curr); } curr.add(dmf); } return result; }
@Test public void testCalendarToDate() { CalendarDate cdate = CalendarDateFormatter.isoStringToCalendarDate(Calendar.uniform30day, "1968-01-30T15:00:00.000Z"); System.out.printf("%s%n", cdate); System.out.printf("%s%n", cdate.getDateTime()); System.out.printf("%s%n", cdate.toDate()); System.out.printf("%s%n", CalendarDateFormatter.toDateTimeStringISO(cdate.toDate())); System.out.printf("%s%n", CalendarDateFormatter.toDateString(cdate)); CalendarDateFormatter cdf = new CalendarDateFormatter("yyyyMMdd"); System.out.printf("%s%n", cdf.toString(cdate)); }
public Iterable<MCollection> makePartitions(CollectionUpdateType forceCollection) throws IOException { List<MCollection> result = new ArrayList<>(); CollectionListRange curr = null; CalendarDate startDate = null; CalendarDate endDate = null; for (MFile mfile : getFilesSorted()) { CalendarDate cdate = dateExtractor.getCalendarDate(mfile); if (cdate == null) continue; // skip - error should be logged if ((curr == null) || !endDate.isAfter(cdate)) { startDate = cdate.truncate(timePeriod.getField()); // start on a boundary endDate = startDate.add( timePeriod); String name = collectionName + "-"+ cdf.toString(startDate); curr = new CollectionListRange(name, root, startDate, endDate, this.logger); curr.putAuxInfo(FeatureCollectionConfig.AUX_CONFIG, this.config); if (!wasRemoved( curr)) result.add(curr); // skip if in removed list } //System.out.printf("%s%n", mfile); curr.addFile(mfile); } return result; }