- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
根据this question在嵌套 Avro schema 上,嵌套记录 schema 的正确方法如下:
{
"name": "person",
"type": "record",
"fields": [
{"name": "firstname", "type": "string"},
{"name": "lastname", "type": "string"},
{
"name": "address",
"type": {
"type" : "record",
"name" : "AddressUSRecord",
"fields" : [
{"name": "streetaddress", "type": "string"},
{"name": "city", "type": "string"}
]
},
}
]
}
我不喜欢为字段指定名称 address
,并且必须为字段的架构指定不同的名称 (AddressUSRecord
)。我可以为字段和架构指定相同的名称,地址
吗?
如果我想在多个其他架构中使用 AddressUSRecord
架构,而不仅仅是 person
该怎么办?如果我想在另一个架构中使用 AddressUSRecord
,比如说 business
,我是否必须将其命名为其他名称?
理想情况下,我想在单独的架构中定义 AddressUSRecord
,然后让 address
的类型引用 AddressUSRecord
。但是,尚不清楚 Avro 1.8.1 是否支持这种开箱即用的功能。这个2014 article表明子模式需要使用自定义代码进行处理。在 Avro 1.8.1 中定义可重用架构的最佳方法是什么?
注意:我想要一个与 Confluence Inc. 的架构注册表配合使用的解决方案。有一个Google Groups thread这似乎表明架构注册表不能很好地处理架构引用。
最佳答案
Can I give the field and schema the same name, address?
是的,您可以使用与字段名称相同的名称来命名记录。
What if I want to use the AddressUSRecord schema in multiple other schemas, not just person?
您可以通过多种技术来使用多个模式:avro 模式解析器客户端(JVM 和其他)允许您指定多个模式,通常通过 names
参数(Java Schema $Parser/parse
方法允许多个模式 String
参数)。
然后您可以将依赖架构指定为命名类型:
{
"type": "record",
"name": "Address",
"fields": [
{
"name": "streetaddress",
"type": "string"
},
{
"name": "city",
"type": "string"
}
]
}
并在父模式之前通过解析器运行它:
{
"name": "person",
"type": "record",
"fields": [
{
"name": "firstname",
"type": "string"
},
{
"name": "lastname",
"type": "string"
},
{
"name": "address",
"type": "Address"
}
]
}
顺便说一句,这允许您从单独的文件中进行解析。
或者,您也可以解析以相同方式引用架构的单个联合架构:
[
{
"type": "record",
"name": "Address",
"fields": [
{
"name": "streetaddress",
"type": "string"
},
{
"name": "city",
"type": "string"
}
]
},
{
"type": "record",
"name": "person",
"fields": [
{
"name": "firstname",
"type": "string"
},
{
"name": "lastname",
"type": "string"
},
{
"name": "address",
"type": "Address"
}
]
}
]
I'd like a solution that works with Confluent Inc.'s Schema Registry.
模式注册表不支持单独解析模式,但它支持后一个解析为联合类型的示例。
关于nested - 嵌套 Avro 架构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40854529/
我在名为 commonSourceMetadata.avsc 的 json 文件中定义了一个名为 "some.package.SourceMetadata" 的 Avro 类型: { "type"
我很想了解在 Avro 中编码两种非常特定类型的数据的最佳实践:时间戳和 IP 地址。 我遇到了时间戳 ( https://issues.apache.org/jira/browse/AVRO-739
如何在 Avro Schema 生成中为数据类型设置最大大小/长度限制。例如:在模式中,我想指定一个字段,该字段采用最大 len 25 的字符串。 最佳答案 我相信您可以使用“固定”avro 类型并指
即是否可以使字段需要类似于 ProtoBuf: 消息搜索请求{ 需要 字符串查询 = 1; } 最佳答案 默认情况下,Avro 中的所有字段都是必需的。照原样 mentioned在官方文档中,如果你想
我有用户编写 AVRO 文件,我想使用 Flume 将所有这些文件移动到使用 Flume 的 HDFS 中。所以我以后可以使用 Hive 或 Pig 来查询/分析数据。 在客户端我安装了 flume
我正在为似乎具有多个对象数组的 JSON 有效负载创建 avro 模式。我不确定如何在模式中表示这一点。有问题的关键是 content: { "id": "channel-id", "name
似乎没有任何方法可以将数据附加到现有的 Avro 序列化文件中。我想让多个进程写入一个 avro 文件,但看起来每次打开它时,我都会从头开始。我不想读入所有数据,然后再将其写回。 使用 ruby
我试图定义一个不太平凡的 Avro 模式,但收效甚微;当它不会抛出架构语法错误时,它不会生成我试图在架构中定义的所有类型。 是否有 avsc 定义的可能内容的完整规范?我一直根据我从 Doc 规范中理
我正在尝试使用 avro-tools-1.7.4.jar create schema 命令创建两个 Avro 模式。 我有两个 JSON 模式,如下所示: { "name": "TestAvro",
首先,我创建了一个如下所示的 avro hive 表。 CREATE EXTERNAL TABLE user STORED AS AVRO LOCATION '/work/user' TBLPROPE
我正在读一本书 Hadoop application architectures,这本书很老但很有趣,在阅读时,我注意到 Avro 被认为是数据序列化框架,而 Parquet 被认为是列数据格式。 我
我一直在四处寻找,看到了 jira https://issues.apache.org/jira/browse/AVRO-739对于这个问题,但我对用户文档中的日期时间的 avro 支持没有更好的了解
我尝试在安装了 Spark 2.4.8 的 Cloud Dataproc 集群 1.4 上运行我的 Spark/Scala 代码 2.3.0。我在读取 avro 文件时遇到错误。这是我的代码: spa
我正在处理 JSON 格式的服务器日志,我想以 Parquet 格式将我的日志存储在 AWS S3 上(并且 Parquet 需要 Avro 模式)。首先,所有日志都有一组共同的字段,其次,所有日志都
这是来自教程点的解串器。 public class Deserialize { public static void main(String args[]) throws Exception{
我正在使用 avro-maven-plugin 1.8.1 从 schema 生成 java 代码,所有字段都是公共(public)的且已弃用,如下所示: public class data_el
一个简单的例子说明了我的问题。 本质上,我正在处理一个跨多个存储库拆分代码的大型项目。在 repo 1 中,在 .avdl 文件中定义了一个 Avro 模式“S1”,该文件被编译到其 Avro 生成的
通过套接字发送avro(avro c)编码数据我正在尝试将 avro 编码数据转换为字节数组(使用 memcpy)后通过套接字发送。我所做的如下所示 /客户端:client.c/ avro_datum
我的问题是这样的。我有一个 2GB 的压缩 avro 文件,HDFS 上存储了大约 1000 条 avro 记录。我知道我可以编写代码来“打开这个 avro 文件”并打印出每条 avro 记录。我的问
我看到以下错误 exception Unsupported Avro type. Supported types are null, Boolean, Integer, Long, Float, Do
我是一名优秀的程序员,十分优秀!