Skip to content

Commit

Permalink
avoid java/c++ style of try-catch
Browse files Browse the repository at this point in the history
  • Loading branch information
hangxie committed May 16, 2022
1 parent 134bd04 commit e48decf
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 84 deletions.
15 changes: 0 additions & 15 deletions layout/rowgroup.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package layout

import (
"errors"
"sync"

"github.com/xitongsys/parquet-go/common"
Expand Down Expand Up @@ -68,20 +67,6 @@ func ReadRowGroup(rowGroupHeader *parquet.RowGroup, PFile source.ParquetFile, sc

wg.Add(1)
go func(index int64, bgn int64, end int64) {
defer func() {
wg.Done()
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
14 changes: 0 additions & 14 deletions marshal/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package marshal
import (
"bytes"
"encoding/json"
"errors"
"reflect"
"strings"

Expand All @@ -16,19 +15,6 @@ import (

//ss is []string
func MarshalJSON(ss []interface{}, schemaHandler *schema.SchemaHandler) (tb *map[string]*layout.Table, err error) {
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")
}
}
}()

res := make(map[string]*layout.Table)
pathMap := schemaHandler.PathMap
nodeBuf := NewNodeBuf(1)
Expand Down
14 changes: 0 additions & 14 deletions marshal/marshal.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package marshal

import (
"errors"
"reflect"
"strings"

Expand Down Expand Up @@ -231,19 +230,6 @@ func (p *ParquetMap) Marshal(node *Node, nodeBuf *NodeBufType) []*Node {

//Convert the objects to table map. srcInterface is a slice of objects
func Marshal(srcInterface []interface{}, schemaHandler *schema.SchemaHandler) (tb *map[string]*layout.Table, err error) {
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("unkown error")
}
}
}()

src := reflect.ValueOf(srcInterface)
res := make(map[string]*layout.Table)
pathMap := schemaHandler.PathMap
Expand Down
14 changes: 0 additions & 14 deletions marshal/unmarshal.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package marshal

import (
"errors"
"reflect"
"strings"

Expand Down Expand Up @@ -29,19 +28,6 @@ type SliceRecord struct {

//Convert the table map to objects slice. dstInterface is a slice of pointers of objects
func Unmarshal(tableMap *map[string]*layout.Table, bgn int, end int, dstInterface interface{}, schemaHandler *schema.SchemaHandler, prefixPath string) (err error) {
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")
}
}
}()

tableNeeds := make(map[string]*layout.Table)
tableBgn, tableEnd := make(map[string]int), make(map[string]int)
for name, table := range *tableMap {
Expand Down
14 changes: 0 additions & 14 deletions schema/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package schema

import (
"encoding/json"
"errors"
"fmt"

"github.com/xitongsys/parquet-go/common"
Expand All @@ -19,19 +18,6 @@ func NewJSONSchemaItem() *JSONSchemaItemType {
}

func NewSchemaHandlerFromJSON(str string) (sh *SchemaHandler, err error) {
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")
}
}
}()

schema := NewJSONSchemaItem()
if err := json.Unmarshal([]byte(str), schema); err != nil {
return nil, fmt.Errorf("error in unmarshalling json schema string: %v", err.Error())
Expand Down
13 changes: 0 additions & 13 deletions schema/schemahandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,19 +228,6 @@ func NewItem() *Item {

//Create schema handler from a object
func NewSchemaHandlerFromStruct(obj interface{}) (sh *SchemaHandler, err error) {
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("error occurred")
}
}
}()

ot := reflect.TypeOf(obj).Elem()
item := NewItem()
item.GoType = ot
Expand Down

0 comments on commit e48decf

Please sign in to comment.