Skip to content
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

Merged
merged 1 commit into from
Mar 7, 2017

Conversation

asifmansoora
Copy link
Collaborator

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

Copy link
Collaborator

@cdeszaq cdeszaq left a 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. (May apply to other new files, I won't comment in those places)

Copy link
Collaborator Author

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() {
Copy link
Collaborator

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.
Copy link
Collaborator

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?

Copy link
Collaborator Author

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(
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.
*/
Copy link
Collaborator

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.
Copy link
Collaborator

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.
Copy link
Collaborator

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.

Copy link
Contributor

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() {
Copy link
Collaborator

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.

Copy link
Contributor

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,
Copy link
Collaborator

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.

Copy link
Contributor

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");
Copy link
Collaborator

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.

Copy link
Contributor

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 {
Copy link
Collaborator

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

Copy link
Collaborator

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?

Copy link
Collaborator

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 {
Copy link
Collaborator

@garyluoex garyluoex Feb 17, 2017

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.

Copy link
Contributor

@michael-mclawhorn michael-mclawhorn left a 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,
Copy link
Contributor

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.
*
Copy link
Contributor

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.
Copy link
Contributor

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() {
Copy link
Contributor

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");
Copy link
Contributor

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?

@asifmansoora asifmansoora force-pushed the Refactor-Dimension-Config branch from d2cc90e to 99a4ca8 Compare February 24, 2017 21:27
Copy link
Collaborator

@cdeszaq cdeszaq left a 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) {
Copy link
Collaborator

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.
Copy link
Collaborator

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");
Copy link
Collaborator

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() {
Copy link
Collaborator

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

Copy link
Collaborator Author

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

@asifmansoora
Copy link
Collaborator Author

Addressed all the comments

Copy link
Collaborator

@garyluoex garyluoex left a 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;


Copy link
Collaborator

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,
Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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;


Copy link
Collaborator

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;
Copy link
Collaborator

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,
Copy link
Collaborator

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.

Copy link
Collaborator

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(
Copy link
Collaborator

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) {
Copy link
Collaborator

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;
    }

Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed it

Copy link
Collaborator

@cdeszaq cdeszaq left a 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.

@asifmansoora asifmansoora force-pushed the Refactor-Dimension-Config branch from c5a69e8 to d415f82 Compare March 7, 2017 19:31
@cdeszaq cdeszaq merged commit 799ed30 into yahoo:master Mar 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants