-
Notifications
You must be signed in to change notification settings - Fork 228
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
AggregationDataStore: Schema #846
Merged
aklish
merged 11 commits into
AggregationDataStore
from
Issue818-static-attribute-aggregation
Jul 13, 2019
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
44ffd8d
AggregationDataStore: Static Attribute Aggregation
QubitPi 5055f73
Address comments
QubitPi 8572b05
Implement TimeDimension and all its supporting components
QubitPi 11ba04b
refactor
QubitPi 4838d73
Address comments from @aklish
QubitPi 1f18c71
Address comments from @aklish && Tests & Javadoc
QubitPi f8f3a68
Address comments from @aklish
QubitPi b3260bb
Address comments from @aklish and @hellohanchen
QubitPi 4c19e26
Address comments from Aaron
QubitPi b92e19f
ToMany is not supported
QubitPi 03aebc8
Address comments from Aaron
QubitPi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1214,6 +1214,36 @@ public boolean hasBinding(Class<?> cls) { | |
return bindJsonApiToEntity.contains(cls); | ||
} | ||
|
||
/** | ||
* Returns whether or not a specified annotation is present on an entity field or its corresponding method. | ||
* | ||
* @param fieldName The entity field | ||
* @param annotationClass The provided annotation class | ||
* | ||
* @param <A> The type of the {@code annotationClass} | ||
* | ||
* @return {@code true} if the field is annotated by the {@code annotationClass} | ||
*/ | ||
public <A extends Annotation> boolean attributeOrRelationAnnotationExists( | ||
Class<?> cls, | ||
String fieldName, | ||
Class<A> annotationClass | ||
) { | ||
return getAttributeOrRelationAnnotation(cls, annotationClass, fieldName) != null; | ||
} | ||
|
||
/** | ||
* Returns whether or not a specified field exists in an entity. | ||
* | ||
* @param cls The entity | ||
* @param fieldName The provided field to check | ||
* | ||
* @return {@code true} if the field exists in the entity | ||
*/ | ||
public boolean isValidField(Class<?> cls, String fieldName) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should add new test methods to EntityDictionaryTest for these new functions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure |
||
return getAllFields(cls).contains(fieldName); | ||
} | ||
|
||
/** | ||
* Binds the entity class if not yet bound. | ||
* @param entityClass the class to bind. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...de-datastore-aggregation/src/main/java/com/yahoo/elide/datastores/aggregation/Column.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright 2019, Yahoo Inc. | ||
* Licensed under the Apache License, Version 2.0 | ||
* See LICENSE file in project root for terms. | ||
*/ | ||
package com.yahoo.elide.datastores.aggregation; | ||
|
||
import com.yahoo.elide.datastores.aggregation.annotation.Meta; | ||
import com.yahoo.elide.datastores.aggregation.dimension.Dimension; | ||
import com.yahoo.elide.datastores.aggregation.metric.Metric; | ||
|
||
import lombok.Getter; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Base class that offers common components between {@link Metric} and {@link Dimension}. | ||
*/ | ||
public abstract class Column { | ||
|
||
@Getter | ||
protected final String name; | ||
@Getter | ||
protected final String longName; | ||
@Getter | ||
protected final String description; | ||
@Getter | ||
protected final Class<?> dataType; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param field The entity field or relation that this {@link Column} represents | ||
* @param annotation Provides static meta data about this {@link Column} | ||
* @param fieldType The Java type for this entity field or relation | ||
* | ||
* @throws NullPointerException if {@code field} or {@code fieldType} is {@code null} | ||
*/ | ||
public Column(String field, Meta annotation, Class<?> fieldType) { | ||
this.name = Objects.requireNonNull(field, "field"); | ||
this.longName = annotation == null || annotation.longName().isEmpty() ? field : annotation.longName(); | ||
this.description = annotation == null || annotation.description().isEmpty() ? field : annotation.description(); | ||
this.dataType = Objects.requireNonNull(fieldType, "fieldType"); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (this == other) { | ||
return true; | ||
} | ||
if (other == null || getClass() != other.getClass()) { | ||
return false; | ||
} | ||
final Column column = (Column) other; | ||
|
||
return getName().equals(column.getName()) | ||
&& getLongName().equals(column.getLongName()) | ||
&& getDescription().equals(column.getDescription()) | ||
&& getDataType().equals(column.getDataType()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getName(), getLongName(), getDescription(), getDataType()); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
A few general comments (I couldn't find one specific place to put these):
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'll refactor according to these