Auto-defuse SUP output#7016
Open
mattnibs wants to merge 1 commit into
Open
Conversation
This pr adds functionality to auto-defuse fusion values in sup output. If the -fusion flag is enabled fusion values will be displayed.
nwt
reviewed
Jun 3, 2026
| } | ||
| p.sr.Reset(super.DecodeString(in.Bytes())) | ||
| val, err := p.zr.Read() | ||
| val, err := sup.ParseValue(p.sctx, byteconv.UnsafeString(in.Bytes())) |
Member
There was a problem hiding this comment.
This change creates a lot of extra work for the garbage collector on each parse_sup() call. I wouldn't cry about that if there were no other way to avoid the import cycle, but how about doing it in anyio instead of supio?
--- a/sio/anyio/writer.go
+++ b/sio/anyio/writer.go
@@ -4,7 +4,11 @@ import (
"fmt"
"io"
+ "github.com/brimdata/super"
"github.com/brimdata/super/csup"
+ "github.com/brimdata/super/runtime/sam/expr"
+ "github.com/brimdata/super/runtime/sam/expr/function"
+ "github.com/brimdata/super/sbuf"
"github.com/brimdata/super/sio/arrowio"
"github.com/brimdata/super/sio/bsupio"
"github.com/brimdata/super/sio/csvio"
@@ -20,12 +24,13 @@ import (
)
type WriterOpts struct {
- Format string
- BSUP *bsupio.WriterOpts // Nil means use defaults via bsupio.NewWriter.
- CSV csvio.WriterOpts
- DB dbio.WriterOpts
- JSON jsonio.WriterOpts
- SUP supio.WriterOpts
+ Format string
+ SUPFusion bool
+ BSUP *bsupio.WriterOpts // Nil means use defaults via bsupio.NewWriter.
+ CSV csvio.WriterOpts
+ DB dbio.WriterOpts
+ JSON jsonio.WriterOpts
+ SUP supio.WriterOpts
}
func NewWriter(w io.WriteCloser, opts WriterOpts) (vio.PushCloser, error) {
@@ -52,7 +57,11 @@ func NewWriter(w io.WriteCloser, opts WriterOpts) (vio.PushCloser, error) {
case "parquet":
return parquetio.NewWriter(w), nil
case "sup", "":
- return supio.NewWriter(w, opts.SUP), nil
+ w := supio.NewWriter(w, opts.SUP)
+ if !opts.SUPFusion {
+ return &supDefuser{w, function.NewDefuse(super.NewContext())}, nil
+ }
+ return w, nil
case "table":
return tableio.NewWriter(w), nil
case "tsv":
@@ -65,6 +74,21 @@ func NewWriter(w io.WriteCloser, opts WriterOpts) (vio.PushCloser, error) {
}
}
+type supDefuser struct {
+ *supio.Writer
+ defuse expr.Function
+}
+
+func (d *supDefuser) Push(vec vector.Any) error {
+ for _, val := range sbuf.Materialize(vec).Values() {
+ val = d.defuse.Call([]super.Value{val})
+ if err := d.Writer.Write(val); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
Collaborator
Author
There was a problem hiding this comment.
Ugh I really don't have like having surprising behavior like this.
Collaborator
Author
There was a problem hiding this comment.
I'd honestly rather just duplicate the code in supio.Reader in sam/expr/function.ParseSUP.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pr adds functionality to auto-defuse fusion values in SUP output. If the -fusion flag is enabled, fusion values will be displayed.