Skip to content

Commit

Permalink
first attempt at resolving nil dereference errors
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomi-dr committed Jan 9, 2022
1 parent 7857c95 commit 5f74d27
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 5 additions & 3 deletions marshal/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package marshal

import (
"errors"
"reflect"
"strings"

"fmt"
"github.com/xitongsys/parquet-go/common"
"github.com/xitongsys/parquet-go/layout"
"github.com/xitongsys/parquet-go/parquet"
"github.com/xitongsys/parquet-go/schema"
"github.com/xitongsys/parquet-go/types"
"reflect"
"runtime/debug"
"strings"
)

type Node struct {
Expand Down Expand Up @@ -237,6 +238,7 @@ func Marshal(srcInterface []interface{}, schemaHandler *schema.SchemaHandler) (t
case string:
err = errors.New(x)
case error:
fmt.Printf("RECOVER PANIC FROM PARQUET-GO: %s: %s", x, debug.Stack())
err = x
default:
err = errors.New("unkown error")
Expand Down
2 changes: 2 additions & 0 deletions schema/schemahandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"reflect"
"runtime/debug"

"github.com/xitongsys/parquet-go/common"
"github.com/xitongsys/parquet-go/parquet"
Expand Down Expand Up @@ -234,6 +235,7 @@ func NewSchemaHandlerFromStruct(obj interface{}) (sh *SchemaHandler, err error)
case string:
err = errors.New(x)
case error:
fmt.Printf("RECOVER PANIC FROM PARQUET-GO: %s: %s", x, debug.Stack())
err = x
default:
err = errors.New("error occurred")
Expand Down
10 changes: 7 additions & 3 deletions writer/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"context"
"encoding/binary"
"errors"
"fmt"
"io"
"reflect"
"runtime/debug"
"sync"

"github.com/apache/thrift/lib/go/thrift"
Expand Down Expand Up @@ -259,7 +261,6 @@ func (pw *ParquetWriter) flushObjs() error {
if bgn >= l {
bgn, end = l, l
}

wg.Add(1)
go func(b, e int, index int64) {
defer func() {
Expand All @@ -269,6 +270,7 @@ func (pw *ParquetWriter) flushObjs() error {
case string:
errs[index] = errors.New(x)
case error:
fmt.Printf("RECOVER PANIC FROM PARQUET-GO: %s: %s", x, debug.Stack())
errs[index] = x
default:
errs[index] = errors.New("unknown error")
Expand Down Expand Up @@ -300,8 +302,10 @@ func (pw *ParquetWriter) flushObjs() error {
}()

} else {
pagesMapList[index][name], _ = layout.TableToDataPages(table, int32(pw.PageSize),
pw.CompressionType)
if table.Schema.Type != nil {
pagesMapList[index][name], _ = layout.TableToDataPages(table, int32(pw.PageSize),
pw.CompressionType)
}
}
}
} else {
Expand Down

0 comments on commit 5f74d27

Please sign in to comment.