/** * Compare two Physical Tables based on how much missing time they have. * * @param left The first table * @param right The second table * * @return negative if table1 has less missing time than table2 */ @Override public int compare(PhysicalTable left, PhysicalTable right) { // choose table with most data available for given columns long missingDurationLeft = IntervalUtils.getTotalDuration( partialDataHandler.findMissingTimeGrainIntervals( left.getAvailableIntervals(requestConstraint), new SimplifiedIntervalList(requestConstraint.getIntervals()), requestConstraint.getRequestGranularity() ) ); long missingDurationRight = IntervalUtils.getTotalDuration( partialDataHandler.findMissingTimeGrainIntervals( right.getAvailableIntervals(requestConstraint), new SimplifiedIntervalList(requestConstraint.getIntervals()), requestConstraint.getRequestGranularity() ) ); long difference = missingDurationLeft - missingDurationRight; return (int) Math.max(Math.min(Integer.MAX_VALUE, difference), Integer.MIN_VALUE); } }
return IntervalUtils.getTotalDuration(tableAvailability.intersect(volatilePartialRequestIntervals));