Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions entity/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ go_library(
"build.go",
"change_provider.go",
"request.go",
"speculation_tree.go",
],
importpath = "github.com/uber/submitqueue/entity",
visibility = ["//visibility:public"],
Expand Down
37 changes: 37 additions & 0 deletions entity/speculation_tree.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package entity

// SpeculationPathAction defines the possible actions for a speculation path.
type SpeculationPathAction string

const (
// SpeculationPathActionUnknown is the default zero value for SpeculationPathAction.
SpeculationPathActionUnknown SpeculationPathAction = ""
// TODO: Add comprehensive list of actions
)

// SpeculationInfo represents metadata about a single speculation path, including the path through the dependency graph, its current state, and the predicted build score.
type SpeculationInfo struct {
// Path represents the speculation path; which is an ordered list of batches.
Path []string
// Action is a state that this path is in.
Action SpeculationPathAction
// Score is score for this speculation path.
Comment thread
manjari25 marked this conversation as resolved.
Score float32
}

// SpeculationTree represents the set of speculation paths constructed for a batch based on its dependency graph.
type SpeculationTree struct {
// BatchID is the batch for which this speculation tree is constructed.
BatchID string
// Speculations is a list of speculation paths for this batch based on a graph of its
// dependents.
Comment thread
manjari25 marked this conversation as resolved.
//
// For e.g - Consider batches - queueA/batch/1, queueA/batch/2, queueA/batch/3
// such that - queueA/batch/2 and queueA/batch/3 depend on queueA/batch/1
//
// Speculations for queueA/batch/1 - [{Path: []string{"queueA/batch/1"}, State: "scheduled", Score: 0.1}]
// Speculations for queueA/batch/2 - [{Path: []string{"queueA/batch/2"}, State: "scheduled", Score: 0.9}, {Path: []string{"queueA/batch/1", "queueA/batch/2"}, State: "scheduled", Score: 0.3}]
// Speculations for queueA/batch/3 - [{Path: []string{"queueA/batch/3"}, State: "scheduled", Score: 0.9}, {Path: []string{"queueA/batch/1", "queueA/batch/3"}, State: "scheduled", Score: 0.3}]
//
Speculations []SpeculationInfo
}
5 changes: 5 additions & 0 deletions extension/storage/mysql/schema/speculation_tree.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE IF NOT EXISTS speculation_tree (
batch_id VARCHAR(255) NOT NULL,
speculations JSON NOT NULL,
PRIMARY KEY (batch_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;