1
        FlatBufferBuilder fbb = new FlatBufferBuilder(1024);

        String directory = "/Users/samarnath/RmsOne/CreateFlatBuffer/src/com/rms/objects/resources";
        File [] policyfiles = ReturnFilesWithPattern(directory, "singlecoverriskpolicy");

        for (File file: policyfiles)
        {

            Long StructureId = 0L;
            int insurer = 0;
            int insured = 0;
            int UnderWriter = 0;
            int inception = 0;
            int Expiration = 0;
            int ExternalID = 0;
            Long SubjectId =0L;
            int SubjectName = 0;
            int SubjectStructureName = 0;
            int Share = 0;
            Double blanketLimit = 0.0;
            Double attachment = 0.0;
            int causeofLoss = 0;
            int maxDeductible = 0;
            int attachmentCurrency = 0;
            int offset= 0;
            int deductibleCurrencyOffset = 0;
            int createOffset =0;
            int blanketLimitCurrency = 0;


            String folderName = "nfs://dev-spark-share.lab.rmsonecloud.net/mnt/data/UserData/import/outputfiles/Job_5/SmokeTest_2M/eufl_only_client4_2_edm__20151203-134544__24/contract/";
            List<String> lines = Files.readAllLines(file.toPath());
            List<String> actualLines = lines.subList(1, lines.size());

            for (String line:actualLines)
            {
                String [] riskitems = line.split("~");

                SingleCoverRiskPolicy.startSingleCoverRiskPolicy(fbb);
                Long Id  = Long.parseLong(riskitems[0]);
                int policyName = fbb.createString(riskitems[1]);

在上述行之后,我收到一条错误消息,提示线程“main”java.lang.AssertionError 中的异常:FlatBuffers:对象序列化不能嵌套。我在 fbb.createString 中遇到错误。

代码很简单,我无法弄清楚这里有什么问题

4

1 回答 1

4

文档中:“必须在引用它们的表开始之前创建其他所有内容(其他表、字符串、向量)。”

所以 move和你之前int policyName = fbb.createString(riskitems[1])引用的任何其他字符串/向量/表。SingleCoverRiskPolicystartSingleCoverRiskPolicy

于 2016-01-11T21:29:47.937 回答