Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
788fd02
commit 251053e
Showing
18 changed files
with
327 additions
and
148 deletions.
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
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
This file was deleted.
Oops, something went wrong.
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,51 @@ | ||
package decoders | ||
|
||
import ( | ||
"fmt" | ||
"github.com/wader/fq/format/avro/schema" | ||
"github.com/wader/fq/pkg/decode" | ||
"github.com/wader/fq/pkg/scalar" | ||
) | ||
|
||
type DecodeFn func(string, *decode.D) interface{} | ||
|
||
func DecodeFnForSchema(s schema.SimplifiedSchema) (DecodeFn, error) { | ||
var sms []scalar.Mapper | ||
mapper := logicalMapperForSchema(s) | ||
if mapper != nil { | ||
sms = append(sms, mapper) | ||
} | ||
|
||
switch s.Type { | ||
case schema.ARRAY: | ||
return decodeArrayFn(s, sms...) | ||
case schema.BOOLEAN: | ||
return decodeBoolFn(s, sms...) | ||
case schema.BYTES: | ||
return decodeBytesFn(s, sms...) | ||
case schema.DOUBLE: | ||
return decodeDoubleFn(s, sms...) | ||
case schema.ENUM: | ||
return decodeEnumFn(s, sms...) | ||
case schema.FIXED: | ||
return decodeFixedFn(s, sms...) | ||
case schema.FLOAT: | ||
return decodeFloatFn(s, sms...) | ||
case schema.INT: | ||
return decodeIntFn(s, sms...) | ||
case schema.LONG: | ||
return decodeLongFn(s, sms...) | ||
case schema.NULL: | ||
return decodeNullFn(s, sms...) | ||
case schema.RECORD: | ||
return decodeRecordFn(s, sms...) | ||
case schema.STRING: | ||
return decodeStringFn(s, sms...) | ||
case schema.UNION: | ||
return decodeUnionFn(s, sms...) | ||
case schema.MAP: | ||
return decodeMapFn(s, sms...) | ||
default: | ||
return nil, fmt.Errorf("unknown type: %s", s.Type) | ||
} | ||
} |
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
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
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
Oops, something went wrong.