/** * Test whether table aligns with the interval collection supplied. * * @param table The table whose alignment is under test * * @return true if this physical table's buckets can align to the request. */ @Override public boolean test(PhysicalTable table) { return alignsTo.stream().allMatch(table.getSchema().getTimeGrain()::aligns); } }
/** * Get the columns from the schema for this physical table. * * @return The columns of this physical table * * @deprecated In favor of getting the columns directly from the schema */ @Deprecated default Set<Column> getColumns() { return getSchema().getColumns(); }
@Override public PhysicalTableSchema getSchema() { return getSourceTable().getSchema(); }
@Override public boolean test(PhysicalTable table) { if (!requestConstraint.getMinimumGranularity().satisfiedBy(table.getSchema().getGranularity())) { return false; } Set<String> supplyNames = table.getSchema().getColumns().stream() .map(Column::getName) .collect(Collectors.toCollection(LinkedHashSet::new)); Set<String> columnNames = requestConstraint.getAllColumnNames(); return supplyNames.containsAll(columnNames); }
Set<? extends PhysicalTable> physicalTables ) throws IllegalArgumentException { Predicate<PhysicalTable> tableDoesNotSatisfy = physicalTable -> !physicalTable.getSchema() .getTimeGrain() .satisfies(timeGrain);
/** * Compare two physical tables identifying which one has fewer time buckets. * * @param table1 The first table * @param table2 The second table * * @return negative if table1 has coarser grain (i.e. fewer rows per time) than table2 */ @Override public int compare(final PhysicalTable table1, final PhysicalTable table2) { // compare to returns -1 if the timeGrain for table1 is finer (expressed in more milliseconds) than table2 int compare = table1.getSchema().getTimeGrain() .getEstimatedDuration() .compareTo(table2.getSchema().getTimeGrain().getEstimatedDuration()); LOG.trace("{} {} {}", table1, compare < 0 ? "<" : ">", table2); // shorter duration means more rows per time, so negate to order by fewer rows rather than shorter duration return -1 * compare; } }
/** * Build a constraint which should not filter away any part of a given table. * * @param table The table whose dimensions and metrics are to be queried * * @return a constraint which should provide no restrictions */ public static DataSourceConstraint unconstrained(PhysicalTable table) { return new DataSourceConstraint( table.getDimensions(), Collections.emptySet(), Collections.emptySet(), table.getSchema().getMetricColumnNames(), table.getDimensions(), table.getDimensions().stream() .map(Dimension::getApiName) .collect(Collectors.toSet()), table.getSchema().getColumnNames(), new ApiFilters(Collections.emptyMap()) ); }
"request.physical.table." + bestTable.getName() + "." + bestTable.getSchema().getTimeGrain() ).mark(); LOG.trace("Found best Table: {}", bestTable);