zoukankan      html  css  js  c++  java
  • 关于Avro中的Unions类型

    Avro中的复杂类型

    Avro支持六种复杂类型:

    • records
    • enums
    • arrays
    • maps
    • unions
    • fixed

    Unions类型介绍

    Unions使用JSON数组表示。
    例如,[“null”,“string”]声明一个字段的类型可以是null或string。

    注意
    当替类型为union的字段指定默认值时,默认值的类型必须与union的第一个元素匹配。比如,在与对于包含“null”的union(例如,[“null”,“string”]),通常会列出“null” 首先,因为此类联合的默认值通常为null。

    除了包含record,fixed和enum类型之外,union中不能包含多个相同类型, 例如,union不允许包含两种array类型或两种map类型, 即[“array”,“array”]和[“map”,“map”]都是非法的。
    Unions中也不能包含其他unions.

    Unions类型的排序规则

    union类型的数据根据其包含的数据类型得顺序进行排序。 例如,定义为[“int”,“string”] 的union将首先对所有int类型的值进行排序,然后对所有字符串值行排序。

    Union在读/写数据时的规则 [TO-DO]

    比较写入字段数据时的类型(writer’s schema)与读取数据时的类型(reader’s schema):

    • 如果它们都是unions:
      The first schema in the reader’s union that matches the selected writer’s union schema is recursively resolved against it. if none match, an error is signalled.

    • 如果读取时使用union, 但写入的时候不是
      The first schema in the reader’s union that matches the writer’s schema is recursively resolved against it. If none match, an error is signalled.

    • 如果写入时使用union, 但读取的时候不是
      If the reader’s schema matches the selected writer’s schema, it is recursively resolved against it. If they do not match, an error is signalled.

  • 相关阅读:
    职场“十不要”,让你少奋斗30年
    360与QQ在用户界面上的明显BUG
    urlMappings在asp.net2.0,asp.net4.0中的差异
    NHibernate主键生成方式
    MDaemon 常用视频教程
    sqlserver 差异备份与还原示例
    没有不死的爱情, 只有平淡的亲情——如何维系我们的婚姻
    25 个在 Web 中嵌入图表的免费资源
    atoi,atol,strtod,strtol,strtoul实现类型转换
    人生之精华,胜读十年书
  • 原文地址:https://www.cnblogs.com/lestatzhang/p/10611329.html
Copyright © 2011-2022 走看看