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.

  • 相关阅读:
    ubuntu 查看进程,查看服务
    ubuntu16.04下配置静态ip
    php监听客户端连接状态
    Excel有用的宏
    openfire插件开发1
    linux ps命令
    转:linux下面/usr/local和opt目录有何区别
    linux 开机自启动软件(包含xampp方法)
    转:java两个jre目录和三个lib目录
    linux PATH环境变量
  • 原文地址:https://www.cnblogs.com/lestatzhang/p/10611329.html
Copyright © 2011-2022 走看看