-
Notifications
You must be signed in to change notification settings - Fork 1
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
Cost Estimator implementation (DRAFT) #6
Conversation
@@ -0,0 +1,71 @@ | |||
package com.flamestream.optimizer.sql.agents; | |||
|
|||
import com.flamestream.optimizer.testutils.TestPipelineOptions; |
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.
Забыл добавить.
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.
Ага, добавил сейчас
} | ||
|
||
public static BeamRelNode getSecondQueryPlan() { | ||
return getNEXMarkQueryPlan(QUERY_2); |
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.
VolcanoPlanner
все равно оптимизует этот план из ожидаемого ((Person x Bid) x Auction)
в (Bid x (Person x Auction))
. Если выкинуть правила JoinAssociateRule
и JoinPushThroughJoinRule
, то получаются ожидаемые планы и разные стоимости.
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.
Также помогает уменьшить количество уникальных Person.id/Auction.seller с тысячи до десяти.
Добавил SqlQueryInspector и SqlQueryInspectorTest |
|
||
if (left instanceof BeamIOSourceRel) { | ||
// left is a non-recursive subquery | ||
map.put(left, fieldsList.get(firstRexInput.getIndex()).getName()); |
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.
Такой подход перестанет работать сразу же, как только beam вставит между таблицей и джойном проекцию. Надёжнее будет завести в inspectSubquery
отдельный параметр с множеством интересных колонок у node
: ImmutableBitSet interestingColumns
.
…isiting relation nodes
Да, ImmutableBitSet тут самое то, мне все нравится! |
agents/src/main/java/com/flamestream/optimizer/sql/agents/CostEstimatorImpl.java
Outdated
Show resolved
Hide resolved
.setRowSchema(auctionsWithReceiveTime) | ||
.setRowSchema(auctionsWithReceiveTime); | ||
|
||
Schema peoplesWithReceiveTime = Schema.builder() |
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.
peoples это "народы", в рамках лингвистического занудства предлагаю просто people
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.
Поправил)
|
||
import java.util.HashMap; | ||
|
||
public class SqlQueryInspector { |
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.
Давайте писать javadoc'и к классам, а то тут и не догадаешься, что делает этот замечательный класс.
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.
Добавил
for (Map.Entry<TupleTag<?>, PValue> input : withTags.expand().entrySet()) { | ||
PCollection<?> pCollection = (PCollection<?>) input.getValue(); | ||
BeamPCollectionTable<?> table; | ||
table = new BeamPCollectionTable(pCollection); |
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.
а если сделать BeamPCollectionTable<>(...)
, то IDEA перестанет выдавать warning :)
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.
Да, пофиксил, уже котлин засел плотно в голову видимо)
На ModifiedCalciteQueryPlanner можно не смотреть - это копия кода Никиты из его PR.
Итоговая цель - вызывая getCumulativeCost с разными провайдерами, получить разную стоимость.