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

Support Partition Assignment V2. #1917

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

yu-shipit
Copy link
Contributor

@yu-shipit yu-shipit commented Dec 19, 2024

Create a trait class PartitionAssignmentTrait to support both V1 and V2 assignemnt. Query service has to re-compile but does not have to change anything. For single partition assignment queries, the behavior does not change. For multiple partition assignment queries without partition assignment change, use MultiPartitionDistConcatExec to assemble all time series. For multiple partition namespace queries with partition assignment, stitch the time series before and after changes.

Pull Request checklist

  • The commit(s) message(s) follows the contribution guidelines ?
  • Tests for the changes have been added (for bug fixes / features) ?
  • Docs have been added / updated (for bug fixes / features) ?

Current behavior : (link exiting issues here : https://help.github.com/articles/basic-writing-and-formatting-syntax/#referencing-issues-and-pull-requests)

New behavior :
Filodb can support queries for multi-partitioned assignment.
Add two APIs for supporting that.

  def getPartitionsTrait(routingKey: Map[String, String], timeRange: TimeRange): List[PartitionAssignmentTrait] = {
    getPartitions(routingKey, timeRange)
  }
  def getMetadataPartitionsTrait(nonMetricShardKeyFilters: Seq[ColumnFilter],
                            timeRange: TimeRange): List[PartitionAssignmentTrait] = {
        getMetadataPartitions(nonMetricShardKeyFilters, timeRange)
  }

getPartitions and getMetadataPartitionsTrait are deprecated but still can be used for backwards compatibility.

BREAKING CHANGES

Breaking changes may include:

  • Any schema changes to any Cassandra tables
  • The serialized format for Dataset and Column (see .toString methods)
  • Over the wire formats for Akka messages / case classes
  • Changes to the HTTP public API
  • Changes to query parsing / PromQL parsing

Other information:

@yu-shipit yu-shipit force-pushed the develop branch 2 times, most recently from 82f0f45 to 8fb4fa3 Compare December 19, 2024 18:19
Create a trait class PartitionAssignmentTrait to support both V1 and V2 assignemnt.
Query service has to re-compile but does not have to change anything.
For single partition assignment queries, the behavior does not change.
For multiple partition assignment queries without partition assignment change, use MultiPartitionDistConcatExec to assemble all time series.
For multiple partition assignment queries with partition assignment, stitch the time series  before and after changes.
@@ -22,15 +22,34 @@ import filodb.query.LogicalPlan._
import filodb.query.exec._

//scalastyle:off file.size.limit
case class PartitionDetails(partitionName: String, httpEndPoint: String,
grpcEndPoint: Option[String], proportion: Float)
trait PartitionAssignmentTrait {
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: maybe we can add a Scala doc for the trait to just outline the use of proportionMap, timerange and some examples ?

=> (pa.partitionName, params.startSecs * 1000L,
params.endSecs * 1000L, pa.grpcEndPoint)
case Some(pa: PartitionAssignmentTrait)
=> (pa.proportionMap.keys.head, params.startSecs * 1000L,
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: should we add a simple helper function in PartitionAssignmentTrait to get the keys and values of proportionMap ?

@@ -388,24 +407,46 @@ class MultiPartitionPlanner(val partitionLocationProvider: PartitionLocationProv
PlanResult(execPlan:: Nil)
}

private def materializeForPartition(logicalPlan: LogicalPlan,
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: please add a Scala doc

val proportionMap: Map[String, PartitionDetails] =
Map(partitionName -> PartitionDetails(partitionName, httpEndPoint, grpcEndPoint, 1.0f))
}
case class PartitionAssignmentV2(proportionMap: Map[String, PartitionDetails],
Copy link
Contributor

Choose a reason for hiding this comment

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

should we add an assertion in PartitionAssignmentV2 such that all the proportion in proportionMap will sum up to 1.0f ?


execPlan.isInstanceOf[StitchRvsExec] shouldEqual (true)
// Should have two MultiPartitionDistConcatExec for before and after assignment change.
execPlan.children.count(plan => plan.isInstanceOf[MultiPartitionDistConcatExec]) shouldEqual 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for adding good unit tests @yu-shipit 👍

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.

2 participants