Repository navigation
change database load to partition ingest into multiple objects #7437
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,45 +14,52 @@ import ( | |
| "github.com/superdb/super/vector/vio" | ||
| ) | ||
|
|
||
| var maxFrameSize uint32 = 120_000 | ||
|
|
||
| // XXX a future PR will wire in compress / thresh options to command line. | ||
| // XXX Rows is the key flag we need for the rows writer. | ||
| type WriterOpts struct { | ||
| Compress bool | ||
| // FrameThresh is the minimum frame size in uncompressed bytes. | ||
| FrameThresh int | ||
| Rows bool | ||
| FrameCap uint64 | ||
| Rows bool | ||
| } | ||
|
|
||
| const DefaultFrameCap = 20_000 | ||
|
|
||
| // ColumnWriter implements the vio.Pusher interface. A Pusher creates a vector | ||
| // BSUP object from a stream of vector.Any. | ||
| type ColumnWriter struct { | ||
| writer io.WriteCloser | ||
| dynamic *vbuild.DynamicBuilder | ||
| sctx *super.Context | ||
| fuser fuser | ||
| size uint64 | ||
| ctrl *RowWriter | ||
| writer io.WriteCloser | ||
| dynamic *vbuild.DynamicBuilder | ||
| sctx *super.Context | ||
| fuser fuser | ||
| size uint64 | ||
| ctrl *RowWriter | ||
| framecap uint64 | ||
| } | ||
|
|
||
| var _ vio.Pusher = (*ColumnWriter)(nil) | ||
|
|
||
| func NewColumnWriter(w io.WriteCloser) *ColumnWriter { | ||
| return NewColumnWriterWithCap(w, DefaultFrameCap) | ||
| } | ||
|
|
||
| func NewColumnWriterWithCap(w io.WriteCloser, frameCap uint64) *ColumnWriter { | ||
|
Comment on lines
39
to
+43
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I think it's tidier to have just one constructor for which the zero value for a parameter gets you a reasonable default. |
||
| sctx := super.NewContext() | ||
| return &ColumnWriter{ | ||
| writer: w, | ||
| dynamic: vbuild.NewDynamicBuilder(), | ||
| sctx: sctx, | ||
| fuser: newFuser(sctx), | ||
| writer: w, | ||
| dynamic: vbuild.NewDynamicBuilder(), | ||
| sctx: sctx, | ||
| fuser: newFuser(sctx), | ||
| framecap: frameCap, | ||
| } | ||
| } | ||
|
|
||
| func NewWriterWithOpts(w io.WriteCloser, opt WriterOpts) vio.PushCloser { | ||
| if opt.Rows { | ||
| return NewRowWriter(w) | ||
| writer := NewRowWriter(w) | ||
| writer.framecap = uint32(opt.FrameCap) | ||
| return writer | ||
| } | ||
| return NewColumnWriter(w) | ||
| writer := NewColumnWriter(w) | ||
| writer.framecap = opt.FrameCap | ||
| return writer | ||
| } | ||
|
|
||
| func (c *ColumnWriter) Close() error { | ||
|
|
@@ -87,7 +94,7 @@ func (c *ColumnWriter) WriteSuperFrame(vec vector.Any) (uint64, error) { | |
| func (c *ColumnWriter) Push(vec vector.Any) error { | ||
| if vec.Len() != 0 { | ||
| c.dynamic.Write(vec) | ||
| if c.dynamic.Len() >= maxFrameSize { | ||
| if c.dynamic.Len() >= uint32(c.framecap) { | ||
| return c.pushFrame() | ||
| } | ||
| } | ||
|
|
@@ -202,6 +209,7 @@ type RowWriter struct { | |
| size uint64 | ||
| bytes []byte | ||
| len uint32 | ||
| framecap uint32 | ||
| } | ||
|
|
||
| var _ vio.Pusher = (*RowWriter)(nil) | ||
|
|
@@ -215,6 +223,7 @@ func NewRowWriter(w io.WriteCloser) *RowWriter { | |
| sctx: sctx, | ||
| fuser: newFuser(sctx), | ||
| superfuser: newFuser(sctx), | ||
| framecap: DefaultFrameCap, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -237,7 +246,7 @@ func (r *RowWriter) Push(vec vector.Any) error { | |
| } | ||
| } | ||
| r.len += vec.Len() | ||
| if r.len >= maxFrameSize { | ||
| if r.len >= r.framecap { | ||
| return r.pushFrame(false) | ||
| } | ||
| return nil | ||
|
|
@@ -253,7 +262,7 @@ func (r *RowWriter) write(val super.Value, ctrl bool) error { | |
| r.fuser.fuse(typ) | ||
| r.superfuser.fuse(typ) | ||
| r.len++ | ||
| if r.len >= maxFrameSize || ctrl { | ||
| if r.len >= r.framecap || ctrl { | ||
| return r.pushFrame(ctrl) | ||
| } | ||
| return nil | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||
| script: | | ||||||
| seq 100 | super -inputcap 5 -framecap 5 -o out.bsup - | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Put a prefix on this flag since it only affects BSUP.
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's discuss. I'm gonna leave this for now and we can visit flags names overall. |
||||||
| super dev bsup out.bsup | super -s -c "count() by nameof(typeof(this)) | ? Header or Footer | sort count" - | ||||||
|
|
||||||
| outputs: | ||||||
| - name: stdout | ||||||
| data: | | ||||||
| {nameof:"SuperFooter",count:1} | ||||||
| {nameof:"ColumnHeader",count:20} | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ func (f *Flags) SetFlags(fs *flag.FlagSet) { | |
| }) | ||
| fs.BoolVar(&f.Dynamic, "dynamic", false, "disable static type checking of inputs") | ||
| fs.StringVar(&opts.Format, "i", "auto", "format of input data [auto,arrows,bsup,csv,json,line,parquet,sup,tsv,zeek]") | ||
| fs.IntVar(&opts.InputCap, "inputcap", 0, "limit size of batched units of input") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Put this after "i" so these remain ordered by flag name. |
||
| fs.BoolVar(&f.Static, "static", false, "force static type checking of inputs") | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ import ( | |
| ) | ||
|
|
||
| const ( | ||
| DefaultThreshold = 500 * 1024 * 1024 | ||
| DefaultObjectCap = 1024 * 1024 | ||
| ) | ||
|
Comment on lines
17
to
19
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: const DefaultObjectCap = 024 * 1024 |
||
|
|
||
| // A FileKind is the first part of a file name, used to differentiate files | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I don't feel strongly about this but knobs like these are usually suffixed with "lim", "limit", or "max" so one of those instead of "cap" might make their behavior a little clearer to system users and code readers. (My initial reaction was, "'Cap' probably means maximum here but if that were the case it'd just be 'max" so maybe it means something else.")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second nit:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm gonna leave these as is since we will discuss and replace them all in a subsequent PR. No since replacing all the tests now and changing again.