Browse Source

优化数据结构

feature_wq
Sydonian 10 months ago
parent
commit
8fed4c9e74
4 changed files with 52 additions and 9 deletions
  1. +4
    -0
      pkgs/ioswitch/dag/node.go
  2. +0
    -5
      pkgs/ioswitch/dag/var.go
  3. +39
    -0
      pkgs/ioswitch/plan/ops/store.go
  4. +9
    -4
      sdks/storage/storage_feature.go

+ 4
- 0
pkgs/ioswitch/dag/node.go View File

@@ -475,6 +475,10 @@ func (s ValueOutputSlot) Var() *ValueVar {
return s.Node.OutputValues().Get(s.Index)
}

func (s ValueOutputSlot) ToSlot(slot ValueInputSlot) {
s.Var().To(slot.Node, slot.Index)
}

type ValueInputSlot struct {
Node Node
Index int


+ 0
- 5
pkgs/ioswitch/dag/var.go View File

@@ -64,11 +64,6 @@ func (v *ValueVar) To(to Node, slotIdx int) {
to.InputValues().Slots.Set(slotIdx, v)
}

func (v *ValueVar) ToSlot(slot ValueInputSlot) {
v.Dst.Add(slot.Node)
slot.Node.InputValues().Slots.Set(slot.Index, v)
}

func (v *ValueVar) NotTo(node Node) {
v.Dst.Remove(node)
node.InputValues().Slots.Clear(v)


+ 39
- 0
pkgs/ioswitch/plan/ops/store.go View File

@@ -26,6 +26,20 @@ func (o *Store) String() string {
return fmt.Sprintf("Store %v: %v", o.Key, o.Var)
}

type StoreConst struct {
Key string
Value exec.VarValue
}

func (o *StoreConst) Execute(ctx *exec.ExecContext, e *exec.Executor) error {
e.Store(o.Key, o.Value)
return nil
}

func (o *StoreConst) String() string {
return fmt.Sprintf("StoreConst %v: %v", o.Key, o.Value)
}

type StoreNode struct {
dag.NodeBase
Key string
@@ -53,3 +67,28 @@ func (t *StoreNode) GenerateOp() (exec.Op, error) {
// func (t *StoreType) String() string {
// return fmt.Sprintf("Store[%s]%v%v", t.StoreKey, formatStreamIO(node), formatValueIO(node))
// }

type StoreConstNode struct {
dag.NodeBase
Key string
Value exec.VarValue
}

func (b *GraphNodeBuilder) NewStoreConst(key string, value exec.VarValue) *StoreConstNode {
node := &StoreConstNode{
Key: key,
Value: value,
}
b.AddNode(node)
return node
}

func (t *StoreConstNode) GenerateOp() (exec.Op, error) {
return &StoreConst{
Key: t.Key,
Value: t.Value,
}, nil
}

// func (t *StoreConstType) String() string {
// return fmt.Sprintf("StoreConst[%s]%v%v", t.StoreKey, formatStreamIO(node), formatValueIO(node))

+ 9
- 4
sdks/storage/storage_feature.go View File

@@ -80,11 +80,16 @@ func (f *InternalServerlessCallFeature) String() string {
}

// 存储服务之间直传文件
type S2SFeature struct {
serder.Metadata `union:"S2S"`
type S2STransferFeature struct {
serder.Metadata `union:"S2STransfer"`
Type string `json:"type"`
TempDir string `json:"tempDir"` // 临时文件存放目录
}

func (f *S2SFeature) GetFeatureType() string {
return "S2S"
func (f *S2STransferFeature) GetFeatureType() string {
return "S2STransfer"
}

func (f *S2STransferFeature) String() string {
return "S2STransfer"
}

Loading…
Cancel
Save