Skip to content

Conversation

akshaisarma
Copy link
Member

Addresses #5

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 99.51% when pulling 9967fc4 on akshaisarma:config-validation into 825f2b9 on yahoo:master.

* Constructor that loads just the defaults.
*/
public BulletConfig() {
super(DEFAULT_CONFIGURATION_NAME);
Copy link
Member

Choose a reason for hiding this comment

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

As we discussed - can we do validate() here in the constructor?


// It is ok for this to be static since the VALIDATOR itself does not change for different values for fields
// in the BulletConfig.
private static final Validator VALIDATOR = new Validator();
Copy link
Member

Choose a reason for hiding this comment

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

I know we normally do member/static variables at the top of the file, but in this case I would vote to put all this at the bottom just for readability? And maybe a comment line above it separating/explaining it?

Copy link
Member Author

Choose a reason for hiding this comment

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

IDEs can collapse stuff as an alternative? Anyway, I left it out for now so the changes to this are easier to spot in my review addressing commits here.


/**
* This represents a binary relationship between two fields in a {@link BulletConfig}. You should have defined
* {@link Entry} for these fields before you try to define relationships between them. You can use this apply a
Copy link
Member

Choose a reason for hiding this comment

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

"You can use this to* apply"?

.castTo(Validator::asInt);
VALIDATOR.define(COUNT_DISTINCT_AGGREGATION_SKETCH_SAMPLING)
.defaultTo(DEFAULT_COUNT_DISTINCT_AGGREGATION_SKETCH_SAMPLING)
.checkIf(Validator::isPositive)
Copy link
Member

Choose a reason for hiding this comment

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

Check if <= 1?


VALIDATOR.define(GROUP_AGGREGATION_SKETCH_ENTRIES)
.defaultTo(DEFAULT_GROUP_AGGREGATION_SKETCH_ENTRIES)
.checkIf(Validator::isPositiveInt)
Copy link
Member

Choose a reason for hiding this comment

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

Check if is a power of two? ...Things don't break if it's not, but it's a waste and might indicate someone is doing something unintended.


VALIDATOR.define(DISTRIBUTION_AGGREGATION_SKETCH_ENTRIES)
.defaultTo(DEFAULT_DISTRIBUTION_AGGREGATION_SKETCH_ENTRIES)
.checkIf(Validator::isPositiveInt)
Copy link
Member

Choose a reason for hiding this comment

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

Check if a power of two? Also for TOP_K_AGGREGATION_SKETCH_ENTRIES below?

.defaultTo(DEFAULT_PUBSUB_CLASS_NAME)
.checkIf(Validator::isString);

VALIDATOR.relate("Max should be less or equal to default", SPECIFICATION_MAX_DURATION, SPECIFICATION_DEFAULT_DURATION)
Copy link
Member

Choose a reason for hiding this comment

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

"Max should be greater* than or equal to default"? or if this message is an error message: "Max is* less than default"?


VALIDATOR.relate("Max should be less or equal to default", SPECIFICATION_MAX_DURATION, SPECIFICATION_DEFAULT_DURATION)
.checkIf(Validator::isGreaterOrEqual);
VALIDATOR.relate("Max should be less or equal to default", AGGREGATION_MAX_SIZE, AGGREGATION_DEFAULT_SIZE)
Copy link
Member

Choose a reason for hiding this comment

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

"Max should be greater* than or equal to default"? or if this message is an error message: "Max is* less than default"?

.checkIf(Validator::isGreaterOrEqual);
VALIDATOR.relate("Max should be less or equal to default", AGGREGATION_MAX_SIZE, AGGREGATION_DEFAULT_SIZE)
.checkIf(Validator::isGreaterOrEqual);
VALIDATOR.relate("Metadata is enabled and keys are not defined", RESULT_METADATA_ENABLE, RESULT_METADATA_METRICS)
Copy link
Member

Choose a reason for hiding this comment

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

If this is an error message: "Metadata is enabled, but* keys are not defined"?

* Add a piece of meta information.
* @param key The name of the meta tag
*
* @param key The name of the meta tag
Copy link
Member

Choose a reason for hiding this comment

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

Indentation?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 99.512% when pulling ebdb69c on akshaisarma:config-validation into 825f2b9 on yahoo:master.

@akshaisarma akshaisarma merged commit 443071f into bullet-db:master Nov 22, 2017
@akshaisarma akshaisarma deleted the config-validation branch November 22, 2017 22:34
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