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
Unify string handling #29
Conversation
6299879
to
ae5d631
Compare
@id not planing to add more for this PR. |
README.md
Outdated
@@ -217,6 +225,10 @@ For a big union like below | |||
] | |||
``` | |||
|
|||
### Caution when unioning string type and int/long arrays. | |||
|
|||
As `[integer()]` list is `string()` in Erlang, this will confuse the encoder, please make sure to `binary()` as avro string encoding input. |
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.
"make sure to use"
include/avro_internal.hrl
Outdated
@@ -1,3 +1,4 @@ | |||
%%%----------------------------------------------------------------------------- | |||
%%% Copyright (c) 2013-2016 Klarna AB |
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.
update copyright
include/erlavro.hrl
Outdated
@@ -1,3 +1,4 @@ | |||
%%%----------------------------------------------------------------------------- | |||
%%% Copyright (c) 2013-2016 Klarna AB |
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.
update copyright
%%! -smp enable -sname notcoveredlinessummary -pa ebin -pa ../ebin | ||
|
||
%%% | ||
%%% Copyright (c) 2015-2016, Klarna AB |
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.
update copyright
|
||
%%%============================================================================= | ||
%%% @doc | ||
%%% @copyright 2016 Klarna AB |
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.
update copyright
src/avro_schema_store.erl
Outdated
@@ -124,162 +109,92 @@ import_files(Files, Store) when ?IS_STORE(Store) -> | |||
lists:foldl(fun(File, S) -> import_file(File, S) end, Store, Files). | |||
|
|||
%% @doc Import avro JSON file into schema store. | |||
%% In case the schema is unnaed, the file basename is used as its |
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.
unnamed
src/avro_union.erl
Outdated
do_encode(Type, Union, EncodeFun) -> | ||
MemberTypes = avro_union:get_types(Type), | ||
try_encode_union_loop(Type, MemberTypes, Union, 0, EncodeFun). | ||
%% @private Build the member type name to member idnex mapping. |
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.
index
2c4c369
to
b78ce33
Compare
Type names, namespaces, enum symbols, map keys, record field names are allowed to be atom() | string() | binary() Atom, string, binary are allowed as 'string' type value All strings are canonicalized as binary() internally
bb05c3e
to
5675c4a
Compare
Disadvantages of old logic: 1. 'enclosing_ns' option has to be given for named type defenitions in order to have their full names set properly. 2. EnclosingNs variable has to be passed down the type decoding call stacks in order to resolve children type full names. After this change, children type full names are recursively resolved when they are used to define a parent (named) type.
When defining complex types, array / union / record it is quite anoying if we have to call avro_pmititive:xyz_type() to define primitive type. In this commit, atom/binary/string for primitive type names are allowed to use as shortcuts
5675c4a
to
c146fbc
Compare
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.
Great job! 💯 👍
No description provided.