Menu

#23 Serialization Issue for AbstractLine object

v1.0_(example)
open
1
2022-08-05
2022-08-04
Anonymous
No

Do we have any version available where AbstractLine is serializable or any way I can serialize AbstractLine object?

Discussion

  • Bruce Martin

    Bruce Martin - 2022-08-04

    Can you explain what you are trying to do / situation so I have a better understanding

    But the AbstractLine interface has a getData() which will return a byte array.
    This line in Cobol Format and can be trnsported & loaded into a new line or used directly
    in Cobol.

    The Schema can also be sent if needed:

    1) Send the Cobol Copybook
    2) Convert the Schema to Xml (and send)

    To Load a Cobol Copybook and create a Xml Schema:

               ICobolIOBuilder iob = JRecordInterface1.COBOL
                                    .newIOBuilder(copybookName)
                                       .setFont("cp037") 
                                       .setFileOrganization(Constants.IO_STANDARD_TEXT_FILE)
                                       .setSplitCopybook(CopybookLoader.SPLIT_NONE)
                                           ;  
                StringWriter sw = new StringWriter();
                JRecordInterface1.SCHEMA_XML.export(sw, iob.getExternalRecord());
    

    To create a new IoBuilder from the Xml:

                IFileIOBuilder newIOBuilder = JRecordInterface1.SCHEMA_XML.newIOBuilder(new StringReader(sw.toString()), "copybookName");
    

    To create a new line from a byteArray

               AbstractLine newLine = newIOBuilder.newLine(oldLine.getData().clone());
    

    CodeGen solution

    The Pojo template in the CodeGen sub project will

    • Create a java pojo from a Cobol Copybook
    • A class to convert the Pojo to/from an array of bytes.

    FieldIterator

    If there are no redefines, It would be easy to use the newLine.getFieldIterator("recordName")
    to create a map of FieldName / values

     
  • Anonymous

    Anonymous - 2022-08-04

    Thanks for the quick response!

    I am trying to parse mainframe files which are in EBCDIC format and load the data to BigQuery table using dataflow.

    But I had some performance issue if I was iterating through lines and fields in the same transformation so, I tried breaking it into two different transformation and for that I needed AbstractLine to be serializable.

    I tried using getData() and xml schema, and it worked perfectly fine!

    Thanks once again

     
  • Bruce Martin

    Bruce Martin - 2022-08-05

    If you have any information on performance issues I would be interested to here where they are

     

Anonymous
Anonymous

Add attachments
Cancel