线程“主要” org.apache.avro.SchemaParseException中的异常:无法重新定义:test.record4

时间:2019-09-14 22:14:02

标签: avro

我正在尝试将test.avsc avro模式文件编译为Java代码。 线程“主要” org.apache.avro.SchemaParseException中的异常:无法重新定义:test.record4

想法是record4在name4和name5中应该是相同的类型

我的test.avsc是:

{

    "type":"record",
    "namespace":"test",
    "name":"record1",
    "fields":[
        {
            "name": "orbject1",
            "type":{
                "type": "array",
                "items":{
                    "type":"record", "name":"record2", "fields": [
                        {"name": "name1",
                            "type":{
                                "type": "array",
                                "items":{
                                    "type":"record", "name":"record3", "fields": [
                                        {"type": {
                                            "type":"record", "name":"record4", "fields": [
                                                {"name":"name2", "type":"long"}
                                                ]
                                            },
                                            "name":"name4"
                                        },
                                        {"type": {
                                            "type":"record","name":"test.record4"
                                            },
                                            "name":"name5"
                                        }
                                    ]
                                }
                            }
                        }
                    ]
                }
            }
        }
    ]
}

1 个答案:

答案 0 :(得分:0)

如果重新排列架构使其看起来像这样,则test.record4错误将得到修复:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void main()
{
    unsigned char str[] = "abcdefg";
    unsigned char *str1 = (unsigned char*)malloc(sizeof(str) -1);

    memcpy(str1, str, (sizeof(str)-1) );

    for(int i = 0; i<(sizeof(str) - 1); i++)
        printf("%c", str1[i]);

    free(str1);
}