Browse Source

增加Const节点

pengcheng
Sydonian 6 months ago
parent
commit
fd3ff190fd
1 changed files with 29 additions and 0 deletions
  1. +29
    -0
      pkgs/ioswitch/plan/ops/var.go

+ 29
- 0
pkgs/ioswitch/plan/ops/var.go View File

@@ -1,6 +1,7 @@
package ops package ops


import ( import (
"gitlink.org.cn/cloudream/common/pkgs/ioswitch/dag"
"gitlink.org.cn/cloudream/common/pkgs/ioswitch/exec" "gitlink.org.cn/cloudream/common/pkgs/ioswitch/exec"
) )


@@ -21,3 +22,31 @@ func (o *ConstVar) Execute(ctx *exec.ExecContext, e *exec.Executor) error {
func (o *ConstVar) String() string { func (o *ConstVar) String() string {
return "ConstVar" return "ConstVar"
} }

type ConstNode struct {
dag.NodeBase
Value exec.VarValue
}

func (b *GraphNodeBuilder) NewConst(val exec.VarValue) *ConstNode {
node := &ConstNode{
Value: val,
}
b.AddNode(node)

node.OutputValues().Init(node, 1)
return node
}

func (t *ConstNode) Output() dag.ValueOutputSlot {
return dag.ValueOutputSlot{
Node: t,
Index: 0,
}
}

func (t *ConstNode) GenerateOp() (exec.Op, error) {
return &DropStream{
Input: t.Output().Var().VarID,
}, nil
}

Loading…
Cancel
Save