-
Notifications
You must be signed in to change notification settings - Fork 6
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
Implement stream-based input record decoder's instead of batch-based #52
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e730345
Implement stream based record decoders instead of batch based
syucream 5de7542
Remove batch based formatters
syucream c19f8b0
Add CHANGELOG
syucream 75d4a0e
jsonDecoder -> jsonStringConverter
syucream baf29c0
Check errors more in record pkg
syucream d2d8591
Use Fatal
syucream File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# v0.1.x | ||
|
||
## Release v0.1.0 - 2020/08/xx | ||
|
||
### Breaking changes | ||
|
||
- `Columnifier` interface stops supporting `io.WriterCloser` | ||
|
||
### Enhancement | ||
|
||
- #52 Implement stream-based input record decoder's to reduce memory consumption. | ||
|
||
|
||
# v0.0.x | ||
|
||
## Release v0.0.4 - 2020/07/29 | ||
|
||
### Bug fix | ||
|
||
- Fix #49 Capture the first error caused by columnifier | ||
|
||
... And some small improvements. | ||
|
||
## Release v0.0.3 - 2020/06/02 | ||
|
||
Ready to publish columnify as an OSS. | ||
|
||
## Release v0.0.2 - 2020/06/02 | ||
|
||
Ready for production. | ||
|
||
## Release v0.0.1 - 2020/04/19 | ||
|
||
Initial release. |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
package columnifier | ||
|
||
import ( | ||
"io" | ||
"io/ioutil" | ||
"os" | ||
|
||
"github.com/reproio/columnify/record" | ||
|
||
"github.com/reproio/columnify/parquet" | ||
"github.com/reproio/columnify/schema" | ||
"github.com/xitongsys/parquet-go-source/local" | ||
"github.com/xitongsys/parquet-go/marshal" | ||
parquetSource "github.com/xitongsys/parquet-go/source" | ||
"github.com/xitongsys/parquet-go/writer" | ||
) | ||
|
@@ -65,36 +68,32 @@ func NewParquetColumnifier(st string, sf string, rt string, output string, confi | |
} | ||
|
||
// Write reads, converts input binary data and write it to buffer. | ||
func (c *parquetColumnifier) Write(data []byte) (int, error) { | ||
func (c *parquetColumnifier) WriteFromReader(reader io.Reader) (int, error) { | ||
// Intermediate record type is map[string]interface{} | ||
syucream marked this conversation as resolved.
Show resolved
Hide resolved
|
||
c.w.MarshalFunc = parquet.MarshalMap | ||
records, err := record.FormatToMap(data, c.schema, c.rt) | ||
c.w.MarshalFunc = marshal.MarshalJSON | ||
syucream marked this conversation as resolved.
Show resolved
Hide resolved
|
||
decoder, err := record.NewJsonDecoder(reader, c.schema, c.rt) | ||
if err != nil { | ||
return -1, err | ||
} | ||
|
||
beforeSize := c.w.Size | ||
for _, r := range records { | ||
if err := c.w.Write(r); err != nil { | ||
for { | ||
var v string | ||
err = decoder.Decode(&v) | ||
abicky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if err != nil { | ||
if err == io.EOF { | ||
break | ||
} else { | ||
return -1, err | ||
} | ||
} | ||
|
||
if err := c.w.Write(v); err != nil { | ||
return -1, err | ||
} | ||
} | ||
afterSize := c.w.Size | ||
|
||
// Intermediate record type is wrapped Apache Arrow record | ||
// It requires Arrow Golang implementation more logical type supports | ||
// ref. https://github.com/apache/arrow/blob/9c9dc2012266442d0848e4af0cf52874bc4db151/go/arrow/array/builder.go#L211 | ||
/* | ||
c.w.MarshalFunc = parquet.MarshalArrow | ||
records, err := record.FormatToArrow(data, c.schema, c.rt) | ||
if err != nil { | ||
return err | ||
} | ||
if err := c.w.Write(&records); err != nil { | ||
return err | ||
} | ||
*/ | ||
|
||
return int(afterSize - beforeSize), nil | ||
} | ||
|
||
|
@@ -103,11 +102,12 @@ func (c *parquetColumnifier) WriteFromFiles(paths []string) (int, error) { | |
var n int | ||
|
||
for _, p := range paths { | ||
data, err := ioutil.ReadFile(p) | ||
f, err := os.Open(p) | ||
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. I guess this PR makes iterating processes reading some blocks of the file instead of reading the whole file. That's good. |
||
if err != nil { | ||
return -1, err | ||
} | ||
if n, err = c.Write(data); err != nil { | ||
|
||
if n, err = c.WriteFromReader(f); err != nil { | ||
return -1, err | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Good changelog 👍