Skip to content
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

Support encoding in parallel and partial flush - WIP #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Posrabi
Copy link

@Posrabi Posrabi commented Apr 26, 2022

  • Add SetFirst, SetArray to allow using multiple stream encoder at once.
  • Flush the buf when its contents reach 64 kB ( needs more testing to find the most suitable number).
  • Do not enclose the array if the array field is set to false.

encoder.go Show resolved Hide resolved
return sw
}

func (sw *StreamEncoder) SetArray(array bool) *StreamEncoder {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be in the constructor rather than here, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yeah

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I don't think so, I am doing this so I could override the default encoder settings here.
https://github.com/multiprocessio/datastation/blob/9de174a0a88d5623bfedf74601cd13a67c1e6f90/runner/file.go#L34

@@ -32,8 +32,20 @@ func NewGenericStreamEncoder(w io.Writer, marshalFn Marshaler, array bool) *Stre
}
}

func (sw *StreamEncoder) SetFirst(first bool) *StreamEncoder {
sw.first = first
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be surrounded with a mutex if this is modified by EncodeRow

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm only using it on initializing.

encoder.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants