-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generify DruidDimensionLoader #449
Generify DruidDimensionLoader #449
Conversation
@@ -130,11 +127,9 @@ public DruidDimensionsLoader( | |||
// time if `dimensions` were a flat list instead of a list of singleton lists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't update this comment
Not sure why I couldn't review this part, but it appears I missed this as well |
dfa8c81
to
085d358
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this code were more load bearing I'd ask for more tests on some of the inner details (making sure that columns are loaded on all table that they're on)
But it's not and I don't care that much about that optimization.
079ae99
to
ae84d62
Compare
@michael-mclawhorn This is now more of a dramatic change involding the Basically what changed is
|
It also might be interesting to add a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most comments are opinions, feel free to discuss if you think otherwise. Besides the opinions, it is goo.
*/ | ||
protected DruidDimensionsLoader buildDruidDimensionsLoader( | ||
protected DimensionLoader buildDruidDimensionsLoader( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need more than one dimension loader per application this point right? @michael-mclawhorn .Would be nice if we can deprecate this method in a backward compatible way so that we can change the name of this method also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could mark both buildDruidDimensionsLoader(...)
and setupDruidDimensionsLoader(...)
as deprecated and make a method to provide the collection of AbstractDimensionRowProvider
?
* | ||
* @param healthCheckRegistry The health check registry to register Dimension lookup health checks | ||
* @param dataDruidDimensionsLoader The DruidDimensionLoader used for monitoring and health checks | ||
* @param dataDimensionLoader The DruidDimensionLoader used for monitoring and health checks | ||
*/ | ||
protected final void setupDruidDimensionsLoader( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to keep two separate method for dimension loader setup, would be nice to change this name also.
@@ -879,7 +879,7 @@ protected final ConfigurationLoader getConfigurationLoader() { | |||
* @return A configurationLoader instance | |||
*/ | |||
protected ConfigurationLoader buildConfigurationLoader( | |||
DimensionLoader dimensionLoader, | |||
com.yahoo.bard.webservice.data.config.dimension.DimensionLoader dimensionLoader, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should try to rename things anyways, so try to get rid of the conflict by renaming.
/** | ||
* The AbstractDimensionRowProvider provides a way to load dimension rows onto dimensions. | ||
*/ | ||
public abstract class AbstractDimensionRowProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DimensionRow or DimensionValue? depends on you, both are fine but personally I think value feels better, the concept of a dimension table is not obvious in fili.
private final List<Dimension> dimensions; | ||
private final List<DataSource> dataSources; | ||
|
||
private HttpErrorCallback errorCallback; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class assumes dimensions are provided through http request? Not sure if we can be a bit more generic or not... I think I would prefer a generic retrieval method ignorant class for this class. @michael-mclawhorn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea it's kind of weird to put it here I agree. I thought it would be easier for the DimensionRowProvider
implementation to only use it where it's applicable.
* @param dimension The dimension to load. | ||
* @param dataSource The datasource to query values for. | ||
*/ | ||
protected abstract void query(Dimension dimension, DataSource dataSource); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put this to the top of method list so that it is more obvious to find.
private HttpErrorCallback errorCallback; | ||
private FailureCallback failureCallback; | ||
private BiConsumer<Dimension, DimensionRow> dimensionRowConsumer; | ||
private Consumer<Dimension> dimensionLoadedConsumer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer not to store these two consumers, but instead pass in to function that uses consumer. It feels weird that a provider stores the consumer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively I could just pull the two methods that are actually used from DimensionLoader
into AbstractDimensionRowProvider
since they're unlikely to change
@Override
public void accept(Dimension dimension, DimensionRow dimensionRow) {
dimension.addDimensionRow(dimensionRow);
}
@Override
public void accept(Dimension dimension) {
// Tell the dimension it's been updated
dimension.setLastUpdated(DateTime.now());
}
*/ | ||
@Singleton | ||
public class DimensionLoader extends Loader<Boolean> | ||
implements BiConsumer<Dimension, DimensionRow>, Consumer<Dimension> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if implementing consumer is useful here, it is unclear that a loader is a consumer.
3f4a01a
to
f379906
Compare
f379906
to
380b146
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Provider should probably be a Loader.
Suggested fix:
Change interface Loader to LoadTask
Change DimensionValueLoader to DimensionValueLoadTask
Change DimensionValueProvider to DimensionValueLoader
) { | ||
this.dimensions = dimensionsToLoad.stream() | ||
.map(dimensionDictionary::findByApiName) | ||
.collect(Collectors.toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be better as a Set?
private final Collection<AbstractDimensionValueProvider> dimensionRowProviders; | ||
|
||
/** | ||
* DimensionLoader fetches data from Druid and adds it to the dimension cache. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Druid?
|
||
/** | ||
* DimensionLoader sends requests to the druid search query interface to get a list of dimension | ||
* values to add to the dimension cache. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Druid?
SYSTEM_CONFIG.getPackageVariableName("druid_dim_loader_timer_duration"); | ||
public static final String DRUID_DIM_LOADER_TIMER_DELAY_KEY = | ||
SYSTEM_CONFIG.getPackageVariableName("druid_dim_loader_timer_delay"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Druid in local constant name?
Changing the configuration parameter will require a deprecation.
|
||
private static final long TEN_YEARS_MILLIS = 10 * TimeUnit.DAYS.toMillis(365); | ||
private static final Duration DURATION = new Duration(TEN_YEARS_MILLIS); | ||
private static final Interval INTERVAL = new Interval(DURATION, DateTime.now()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http://joda-time.sourceforge.net/apidocs/org/joda/time/Years.html#years(int)
new Interval (Years.years(10), DateTime.now())
* @param dimensionDictionary The dimension dictionary to load dimensions from. | ||
* @param dimensionsToLoad The dimensions to use. | ||
*/ | ||
public AbstractDimensionValueProvider( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See if you can create an interface for this
Resolve conflicts, Add the interface name change to the CHANGE LOG, rebase and then someone can merge at will. |
- This fixed the naming schema by moving DimensionRow -> DimensionValue - Removed the abstraction of consumers for loading dimensions
- Loader -> LoadTask - Lots of other refactoring got dragged in - DimensionValueLoader -> DimensionValueLoadTask - DimensionValueProvider -> DimensionValueLoader (interface) - Fix tests
839ee60
to
cbcc50c
Compare
The DruidDimensionLoader now only tries to load dimensions on datasources that contain that dimension.