-
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
Create a default base class for all dimension types #177
Conversation
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.
Changelog entry needed.
Otherwise, just some fairly small things I think. Thanks for the submission!
@@ -0,0 +1,134 @@ | |||
// Copyright 2016 Yahoo Inc. |
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.
- (May apply to other new files, I won't comment in those places)
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.
Sure. Changing it in all the new files
return physicalName; | ||
} | ||
|
||
public String getDescription() { |
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.
All of these methods, if they override a method declared in the interface, should have an @Override
annotation.
|
||
|
||
/** | ||
* A Dimension instance holds all of the information needed to construct a 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.
This thing is not a dimension instance, since it's not a Dimension
, right?
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.
Yes, you are right, changing the description of Default..
classes
* @param keyValueStore The key value store holding dimension row data. | ||
* @param searchProvider The search provider for field value lookups on this dimension. | ||
*/ | ||
public DefaultDimensionConfig( |
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.
Since this includes a KeyValueStore
and a SearchProvider
, it's actually not the config for a general dimension, but it's the config for a KeyValueStoreDimension
(which happens to be Fili's default).
So, perhaps a better name is DefaultKeyValueStoreDimensionConfig
?
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.
Sure.
* @param keyValueStore The key value store holding dimension row data. | ||
* @param searchProvider The search provider for field value lookups on this dimension. | ||
* @param namespaces A list of namespaces used to configure the Lookup 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.
These javadocs need to call out the differences between these two constructors. It's not obvious what the differences are at a quick glance.
* @param defaultDimensionFields The default set of fields for this dimension to be shown in the response. | ||
* @param keyValueStore The key value store holding dimension row data. | ||
* @param searchProvider The search provider for field value lookups on this dimension. | ||
* @param lookups A list of lookups used to configure the Lookup 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.
Again, need to document the differences in these constructors
package com.yahoo.bard.webservice.data.config.names; | ||
|
||
/** | ||
* Defines the name of a 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.
what name? Physical? Logical? etc.
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'm not sure dimensions have a 'physical name', dimension+table combos have a physical name, perhaps.
@@ -38,4 +49,16 @@ | |||
public String asName() { | |||
return camelName; | |||
} | |||
|
|||
public String getDescription() { |
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 thing is a DimensionName
object, why are we stuffing all of these other parameters in there as well? They don't seem to have anything to do with names.
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.
possibly just change the class name to WikiApiDimensionConfigInfo or summary or something.
@NotNull String physicalName, | ||
@NotNull String description, | ||
@NotNull String longName, | ||
@NotNull String category, |
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 all of these are required I don't think. In particular, description
, physicalName
, longName
, and category
are optional and have defaults provided when the actual dimensions are made I think.
I'm not necessarily opposed to having the default config objects be stricter or better encouraging of best practices, but I just wanted to point these differences out.
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.
Don't make the four Rick identified be required to be NotNull, please.
CONTINENT("Description of Continent", "wikipedia continent", "General"), | ||
COUNTRY("Description of Country", "wikipedia country", "General"), | ||
REGION("Description of Region", "wikipedia region", "General"), | ||
CITY("Description of City", "wikipedia city", "General"); |
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.
Since this is an example for others to look at for how to set up a good Fili instance, it would be great to show something more than default-style placeholder text for these descriptions, long names, etc.
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.
e.g. be a little more interesting with the descriptions perhaps?
/** | ||
* A Dimension instance holds all of the information needed to construct a Dimension. | ||
*/ | ||
public class DefaultDimensionConfig implements DimensionConfig { |
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 this to be an abstract
class with the name BaseDimensionConfig
since we have a BasePhysicalTable
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 think the point of this change is so that an app-specific class isn't needed, so making this abstract defeats that purpose. This work originated from some folks standing up a new Fili instance that had also done a previous one, and noticing that they had to implemented the exact same class for each instance in order to implement the DimensionConfig
interface.
Can you call out a specific reason for wanting this abstract? What additions would you expect a concrete version of that abstract one to add?
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.
Ok, I misunderstood what this class is. The name should be changed as rick suggested. Also, I think it is a good idea to have a BaseDimensionConfig
abstract class so that we can implement DruidBackedDimensionConfig
and so on in the future.
/** | ||
* A Lookup Dimension instance holds all of the information needed to construct a Lookup Dimension. | ||
*/ | ||
public class LookupDefaultDimensionConfig extends DefaultDimensionConfig implements LookupDimensionConfig { |
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 think we should move the Default
part of the name to the front like DefaultLookupDimensionConfig
.
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'm not sure happy with the inconsistencies of parameter list capitalizations and formatting in javadoc but I'm not going to fuss too much about that.
Basically this looks fine.
@NotNull String physicalName, | ||
@NotNull String description, | ||
@NotNull String longName, | ||
@NotNull String category, |
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.
Don't make the four Rick identified be required to be NotNull, please.
|
||
/** | ||
* Construct a DefaultDimensionConfig Instance from Dimension Name , dimension fields and default dimension fields. | ||
* |
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 one of these opening sentences on the ...DimensionConfig constructors is slightly wrong and contains the same pre-comma whitespace and inconsistent capitalization
package com.yahoo.bard.webservice.data.config.names; | ||
|
||
/** | ||
* Defines the name of a 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.
I'm not sure dimensions have a 'physical name', dimension+table combos have a physical name, perhaps.
@@ -38,4 +49,16 @@ | |||
public String asName() { | |||
return camelName; | |||
} | |||
|
|||
public String getDescription() { |
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.
possibly just change the class name to WikiApiDimensionConfigInfo or summary or something.
CONTINENT("Description of Continent", "wikipedia continent", "General"), | ||
COUNTRY("Description of Country", "wikipedia country", "General"), | ||
REGION("Description of Region", "wikipedia region", "General"), | ||
CITY("Description of City", "wikipedia city", "General"); |
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.
e.g. be a little more interesting with the descriptions perhaps?
d2cc90e
to
99a4ca8
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.
Getting closer! Just some small things I think.
@@ -74,9 +78,10 @@ public WikiDimensions() { | |||
* | |||
* @return set of dimension configurations | |||
*/ | |||
public LinkedHashSet<DimensionConfig> getDimensionConfigurationsByApiName(WikiApiDimensionName... dimensionNames) { | |||
public LinkedHashSet<DimensionConfig> getDimensionConfigurationsByApiName( | |||
WikiApiDimensionConfigInfo... dimensionNames) { |
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.
) {
should be on the next line down, aligned with the start of the method declaration line
@@ -0,0 +1,64 @@ | |||
// Copyright 2016 Yahoo Inc. |
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.
2017
CONTINENT("Continent refers to one of the seven region", "wiki continent", "General"), | ||
COUNTRY("Country is identified as a distinct national entity in political geography", "wiki country", "General"), | ||
REGION("Regions are areas that are broadly divided by several distinct characteristics ", "wiki region", "General"), | ||
CITY("City is a large and permanent human settlement", "wiki city", "General"); |
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.
No need to change them, since they are accurate, but generally descriptions of dimensions are likely to connect to the domain of the facts for which they are dimensions (usually). For example, while a city is where humans live, in this context it is the city in which the user making the edit was detected to be located. (ie. it's where the user was when they made the edit).
return camelName; | ||
} | ||
|
||
public String getDescription() { |
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.
Should all have @Override
annotations
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.
Interface DimensionName
has only asName()
method to be implemented
Addressed all the comments |
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.
In general good, just some convention stuff in Fili to fix. Otherwise we are good.
import java.util.LinkedHashSet; | ||
import javax.validation.constraints.NotNull; | ||
|
||
|
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.
Extra line.
* @param searchProvider The search provider for field value lookups on this dimension. | ||
*/ | ||
public DefaultKeyValueStoreDimensionConfig( | ||
DimensionName apiName, |
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.
Does it make sense that the other constructor requires some of these arguments to be @NotNull
but this constructor does not require? And we should just put @NotNull
for all the arguments since thats easier. Apply to other files too.
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.
Re: Making all parameters not null: Not all parameters are required, so no, we should not make them all @NotNull
Re: Making the constructors have the same "nullability" for corresponding parameters: I think that's probably a good idea, yes.
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.
So we should take a look at its super
class to determine what arguments needs to be @NotNull
.
import java.util.LinkedHashSet; | ||
import java.util.List; | ||
|
||
|
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.
Extra line.
NAME, | ||
AGE, | ||
ETHNICITY, | ||
GENDER; |
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.
Move the semicolon to the next line so that when we add things to the enum list in the future, the last item won't be shown as deleted and then re-added due to moving semicolon to the next item. Apply to other files also.
String description, | ||
String longName, | ||
String category, | ||
LinkedHashSet<DimensionField> defaultDimensionFields, |
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 think this should be fields
instead of defaultDimensionFields
, default one is the one can be inferred from fields, not the other way around. Apply to other files too.
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 is a good idea. And the parameter comment in the JavaDoc should be updated to reflect that this set of fields will also be used for the default fields (ie. all fields on the Dimension will be the default)
@@ -74,9 +78,11 @@ public WikiDimensions() { | |||
* | |||
* @return set of dimension configurations | |||
*/ | |||
public LinkedHashSet<DimensionConfig> getDimensionConfigurationsByApiName(WikiApiDimensionName... dimensionNames) { | |||
public LinkedHashSet<DimensionConfig> getDimensionConfigurationsByApiName( |
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.
Should change the name of the method since it does not take ApiName
now.
* @param longName The Long Name is the external, end-user-facing long name for the dimension. | ||
* @param category The Category is the external, end-user-facing category for the dimension. | ||
*/ | ||
WikiApiDimensionConfigInfo(String description, String longName, String category) { |
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.
Consider get rid of the category
property from the enum and simply return in the method using default category.
@Override
public String getCategory() {
return Dimension.DEFAULT_CATEGORY;
}
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.
Can we make this change? @asifmansoora
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.
addressed it
31ef672
to
711a4ba
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.
This still needs an entry in the CHANGELOG.md file, describing the changes (mostly additions of default implementations, it looks like).
Once that's in, we can merge this right away.
c5a69e8
to
d415f82
Compare
Create a common base class for Dimension Config , Lookup Dimension Config , Registered Lookup Dimension Config and DimensionName Interface
Made the changes to Wikipedia example to include the new Default Dimension Config class