Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
xitongsys committed Sep 2, 2019
2 parents 274b02a + e89cbb5 commit 39d950c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
18 changes: 17 additions & 1 deletion layout/rowgroup.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package layout

import (
"errors"

"github.com/xitongsys/parquet-go/common"
"github.com/xitongsys/parquet-go/source"
"github.com/xitongsys/parquet-go/schema"
Expand Down Expand Up @@ -40,6 +42,7 @@ func (rowGroup *RowGroup) RowGroupToTableMap() *map[string]*Table {

//Read one RowGroup from parquet file (Deprecated)
func ReadRowGroup(rowGroupHeader *parquet.RowGroup, PFile source.ParquetFile, schemaHandler *schema.SchemaHandler, NP int64) (*RowGroup, error) {
var err error
rowGroup := new(RowGroup)
rowGroup.RowGroupHeader = rowGroupHeader

Expand All @@ -64,6 +67,19 @@ func ReadRowGroup(rowGroupHeader *parquet.RowGroup, PFile source.ParquetFile, sc
}

go func(index int64, bgn int64, end int64) {
defer func() {
if r := recover(); r != nil {
switch x := r.(type) {
case string:
err = errors.New(x)
case error:
err = x
default:
err = errors.New("unknown error")
}
}
}()

for i := bgn; i < end; i++ {
offset := columnChunks[i].FileOffset
PFile := PFile
Expand Down Expand Up @@ -93,5 +109,5 @@ func ReadRowGroup(rowGroupHeader *parquet.RowGroup, PFile source.ParquetFile, sc
rowGroup.Chunks = append(rowGroup.Chunks, chunksList[c]...)
}

return rowGroup, nil
return rowGroup, err
}
14 changes: 14 additions & 0 deletions writer/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/binary"
"reflect"
"sync"
"errors"

"github.com/apache/thrift/lib/go/thrift"
"github.com/xitongsys/parquet-go/common"
Expand Down Expand Up @@ -185,6 +186,19 @@ func (self *ParquetWriter) flushObjs() error {
}

go func(b, e int, index int64) {
defer func() {
if r := recover(); r != nil {
switch x := r.(type) {
case string:
err = errors.New(x)
case error:
err = x
default:
err = errors.New("unknown error")
}
}
}()

if e <= b {
doneChan <- 0
return
Expand Down

0 comments on commit 39d950c

Please sign in to comment.