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

Add DimensionSchema for specifying dimension types and properties #75

Merged
merged 1 commit into from
Mar 17, 2016

Conversation

jon-wei
Copy link
Member

@jon-wei jon-wei commented Mar 8, 2016

This PR changes the way dimensions are specified in the DimensionsSpec.

Instead of a String name, a new DimensionSchema class has been introduced, which specifies dimension type and additional properties.

This change is made to support long and float-typed dimensions within Druid.

The user can still pass in String names into the DimensionsSpec; this will create the default String-type dimension.

This PR also deprecates the "spatialDimensions" field; spatial dimensions are now represented with a subclass of DimensionSchema, and stored in the main "dimensions" list.

The user can still use the old "spatialDimensions" field; spatial dims within that list will be converted to the new form.

@JsonSubTypes.Type(name = "string", value = StringDimensionSchema.class),
@JsonSubTypes.Type(name = "long", value = LongDimensionSchema.class),
@JsonSubTypes.Type(name = "float", value = FloatDimensionSchema.class),
@JsonSubTypes.Type(name = "spatial", value = NewSpatialDimensionSchema.class),
Copy link
Member

Choose a reason for hiding this comment

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

can we remove New from the name?

Copy link
Member

Choose a reason for hiding this comment

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

also, I thought spatial was going to be an index, not a column type

Copy link
Member Author

Choose a reason for hiding this comment

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

@fjy Added a comment on the intended approach/future direction for NewSpatialDimensionSchema:

/**
 * NOTE: 
 * This class should be deprecated after Druid supports configurable index types on dimensions.
 * When that exists, this should be the implementation: https://github.com/druid-io/druid/issues/2622
 * 
 * This is a stop-gap solution to consolidate the dimension specs and remove the separate spatial 
 * section in DimensionsSpec.
 */

Copy link
Member

Choose a reason for hiding this comment

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

@jon-wei we should add new dimension schema whenever adding new type. can we just use type field and validate?

Copy link
Member Author

Choose a reason for hiding this comment

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

@navis What kind of validation did you have in mind?

@fjy
Copy link
Member

fjy commented Mar 11, 2016

👍

protected DimensionSchema(String name)
{
Preconditions.checkArgument(name != null, "Dimension name cannot be null.");
this.name = name;
Copy link
Member

Choose a reason for hiding this comment

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

can just say this.name = Preconditions.checkNotNull(name, "msg")


public class FloatDimensionSchema extends DimensionSchema
{
private static final String TYPENAME = "float";
Copy link
Member

Choose a reason for hiding this comment

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

can/should this use DimensionSchema.FLOAT_TYPE_NAME?

Copy link
Member Author

Choose a reason for hiding this comment

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

@himanshug changed these to use the statics from DimensionSchema, thanks

private final Map<String, DimensionSchema> dimensionSchemaMap;

@Deprecated
private List<SpatialDimensionSchema> spatialDimensions;
Copy link
Member

Choose a reason for hiding this comment

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

not sure why we need to retain this global variable, eventually it is set to null. i see we use it in verify() but it should be possible to adjust that.

Copy link
Member Author

Choose a reason for hiding this comment

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

@himanshug got rid of that variable

@himanshug
Copy link
Member

@jon-wei looks good over all after few more comments.

@himanshug
Copy link
Member

👍 (pls squash the commits)

@jon-wei
Copy link
Member Author

jon-wei commented Mar 17, 2016

@fjy @himanshug squashed, thanks for the review!

himanshug added a commit that referenced this pull request Mar 17, 2016
Add DimensionSchema for specifying dimension types and properties
@himanshug himanshug merged commit 4ee7b8e into druid-io:master Mar 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants