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

Adjust granularity automatically only if necessary #227

Open
adrianmroz opened this issue Nov 8, 2018 · 4 comments
Open

Adjust granularity automatically only if necessary #227

adrianmroz opened this issue Nov 8, 2018 · 4 comments
Labels
enhancement New feature

Comments

@adrianmroz
Copy link
Collaborator

Right now when changing anything in time filter, granularity of time split is adjusted by RulesEvaluator and often it changes granularity unnecessarily.

Goal should be to:

  1. If user changed granularity we should keep it as long as possible.
  2. We should change it if it doesn't make sense
  3. We should change it for performance reasons
  4. We should change it if data granularity is bigger than granularity setting

At first, we need to check what's possible with current implementation of RulesEvaluator.

@adrianmroz
Copy link
Collaborator Author

adrianmroz commented Nov 13, 2018

Granularity is decided there:

public updateWithFilter(filter: Filter, dimensions: Dimensions): Splits {
const specificFilter = filter.getSpecificFilter(Timekeeper.globalNow(), Timekeeper.globalNow(), Timezone.UTC);
return this.updateSplits(splits => splits.map(split => {
const { bucket, reference } = split;
if (bucket) return split;
const splitDimension = dimensions.getDimensionByName(reference);
const splitKind = splitDimension.kind;
if (!splitDimension || !(splitKind === "time" || splitKind === "number") || !splitDimension.canBucketByDefault()) {
return split;
}
if (splitKind === "time") {
const clause = specificFilter.clauses.find(clause => clause instanceof FixedTimeFilterClause) as FixedTimeFilterClause;
return split.changeBucket(clause
? getBestBucketUnitForRange(clause.values.first(), false, splitDimension.bucketedBy, splitDimension.granularities)
: getDefaultGranularityForKind("time", splitDimension.bucketedBy, splitDimension.granularities)
);
} else if (splitKind === "number") {
const clause = specificFilter.clauses.find(clause => clause instanceof NumberFilterClause) as NumberFilterClause;
return split.changeBucket(clause
? getBestBucketUnitForRange(clause.values.first(), false, splitDimension.bucketedBy, splitDimension.granularities)
: getDefaultGranularityForKind("number", splitDimension.bucketedBy, splitDimension.granularities)
);
}
throw new Error("unknown extent type");
}));
}

This method is called whenever splits change or filters change. We should limit that.

@adrianmroz
Copy link
Collaborator Author

Hmm, looks like we have a bug there - we search clause by type, we should search by split reference and type.

const clause = specificFilter.clauses.find(clause => clause instanceof FixedTimeFilterClause) as FixedTimeFilterClause;

@adrianmroz
Copy link
Collaborator Author

adrianmroz commented Nov 14, 2018

Observations:

  • We don't use data values when finding best bucketing. That probably implies that bucketing should be changed only when changes filter on the same dimension.

  • We don't have information about previous bucketing source. Was it calculated by turnilo or selected by user? Keeping such information wouldn't be trivial.

  • Right now after changing filter, all splits that refers to changed clause have their bucketing set to null. Because of that, later in updateWithFilter we don't have previous bucketing and we couldn't compare it to newfound.

  • Interesting tidbit: when converting to "specific" ("non relative") filter, we also reset bucketing. That's happening when sharing fixed url.

@mkuthan mkuthan added the enhancement New feature label Dec 12, 2018
@adrianmroz adrianmroz modified the milestone: next Jan 22, 2020
@adrianmroz
Copy link
Collaborator Author

Probably linked with #598

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature
Projects
None yet
Development

No branches or pull requests

2 participants