/** * 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); } }
) throws IllegalArgumentException { Predicate<PhysicalTable> tableDoesNotSatisfy = physicalTable -> !physicalTable.getSchema() .getTimeGrain() .satisfies(timeGrain);
/** * Constructor. * * @param name Name that represents set of fact table names that are put together under this table * @param timeGrain The time grain of the table. The time grain has to satisfy all grains of the tables * @param columns The columns for this table * @param physicalTables A set of PhysicalTables that are put together under this table. The * tables shall have zoned time grains that all satisfy the provided timeGrain * @param logicalToPhysicalColumnNames Mappings from logical to physical names * @param availability The Availability of this table */ public BaseCompositePhysicalTable( @NotNull TableName name, @NotNull ZonedTimeGrain timeGrain, @NotNull Set<Column> columns, @NotNull Set<? extends PhysicalTable> physicalTables, @NotNull Map<String, String> logicalToPhysicalColumnNames, @NotNull Availability availability ) { super( name, timeGrain, columns, logicalToPhysicalColumnNames, availability ); verifyGrainSatisfiesAllSourceTables(getSchema().getTimeGrain(), physicalTables); }
@Override public DateTime getTableAlignment() { return getSchema().getTimeGrain().roundFloor( IntervalUtils.firstMoment(getAllAvailableIntervals().values()).orElse(new DateTime()) ); }
/** * 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; } }
res.put( "timeGrain", e.getValue().getSchema().getTimeGrain().getName().toLowerCase(Locale.ENGLISH) ); res.put("uri", SlicesServlet.getSliceDetailUrl(e.getKey(), uriInfo));
"request.physical.table." + bestTable.getName() + "." + bestTable.getSchema().getTimeGrain() ).mark(); LOG.trace("Found best Table: {}", bestTable);
/** * Gets the timezone of the backing table for the given druid query. * * @param druidQuery The druid query to find the timezone for * * @return the {@link DateTimeZone} of the physical table for this query. */ private DateTimeZone getTimeZone(DruidAggregationQuery<?> druidQuery) { return druidQuery.getDataSource() .getPhysicalTable() .getSchema() .getTimeGrain() .getTimeZone(); }
generated.put("timeGrain", table.getSchema().getTimeGrain().getName()); generated.put("timeZone", table.getSchema().getTimeGrain().getTimeZoneName()); generated.put("dimensions", dimensionsResult); generated.put("metrics", metricsResult);