2

巨大な 7GB xml をファイルに分割しようとしてきましたが、これまでのところ、試したオプションのどれも有望ではありませんでした。説明させてください:

外部ユーザーからのファイルがあるため、変更できません。データベースにロードするには、分割する必要があります。

チェック後、informatica には最大 4400 個のポートがあり、すべてのアイテムに少なくとも 4400 個のノードがあることを意味します。ファイルは 11 の異なるファイルに分割されます。



    <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
    <file>
        <fileHeader>This has some information</fileHeader>
        <fileBody>
            <Item id="1">
                <definition>
                    <id>1</id>
                    <name>Something</name>
                    <description>This is a dummy</description>
                </definition>
                <raw_materials>
                    <material>
                        <name>polycarbonate</name>
                        <description>Something to describe</description>
                        <cost>24.33</cost>
                        <units>LB</units>
                    </material>
                    <material txt="this" />
                    <material txt="had to" />
                    <material txt="be splitted" />
                    <material txt="into 3" />
                    <material txt="different files"/>
                </raw_materials>
                <specs>
                    <rating_usa issuer_id="3">A</rating_usa>
                    <rating_cnd issuer_id="9">10</rating_cnd>
                    <rating_br issuer_id="5">24.12</rating_bra>
                </specs>
                <budget>
                    <budget_usa>
                        <amount>465</amount>
                        <currency>USD</currency>
                        <usd_vs>1</usd_vs>
                    </budget_usa>
                    <budget_cnd>
                        <amount>30</amount>
                        <currency>CND</currency>
                        <usd_vs>1.24</usd_vs>
                    </budget_cnd>
                    <budget_bra>
                        <amount>20</amount>
                        <currency>BRP</currency>
                        <usd_vs>17.31</usd_vs>
                    </budget_bra>
                </budget>
                <vendor>  
                    <id>1HR24ZA</id>
                    <vendorName>Vendor</vendorName>
                    <deliveryRate>9.5</deliveryRate>
                    <location>
                        <country>Italy</country>
                        <address>Lamborghini Str. 245</address>
                        <phone>1234</phone>                 
                    </location>
                </vendor>
                <taxes>
                    <tax>
                        <country>MEX</country>
                        <federal_pct>16</federal_pct>
                        <currency>MXN</currency>
                        <pct_price>5</pct_price>
                    </tax>
                    <tax txt="this also"/>
                    <tax txt="contains too"/>
                    <tax txt="much nodes"/>
                </taxes>
            </Item>
            <Item id="2">
            </Item>
        </fileBody>
    </file>


ここでは、アイテムごとに 6 つの市長タグ (definition、raw_materials、specs、budget、vendor、taxs) しかありませんが、実際には 9 つ含まれています。

元のマッピングは次のようなものです: ソース -> ソース修飾子 -> ターゲット (XML)

問題を解決するために設定を変更しましたが、大幅な改善は見られませんでした。その後、すべてのファイルをタスク内のワークフローに入れ、すべてのタスクを並列に入れました。最終回は、オリジナルと同じでした。

その後、javaを試してみました。DOM はファイルをメモリにロードするため、オプションではありません。そこで、SAXとStAXを試してみたところ、SAXよりもStAXの方が優れた性能を示したので、その方向に進みました。

インフォマティカの最終ファイルには次のようなものがあることに言及する価値があります。



    <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
    <file>
        <fileHeader>This has some information</fileHeader>
        <fileBody>
            <Item id="1">
                <raw_materials>
                    <material>
                        <name>polycarbonate</name>
                        <description>Something to describe</description>                    
                    </material>
                    <material txt="this" />
                    <material txt="is hardcore" />
                </raw_materials>          
    </file>


ご覧のとおり、特定のタグがファイルに含まれているかどうかを確認する必要があります。そのため、新しいタグが追加されるたびに約 200 個のタグをチェックすることになり、そのタグを配置するすべてのファイルに対してそれを行います。



    public class XMLCopier implements javax.xml.stream.StreamFilter {
        static boolean allowStream = false;
        static boolean tagFinished = false;

        private static boolean isWithinValidTag = false;
        private static Map tagMap = new HashMap();
        private static String currentTag = "";

        public static void main(String[] args) throws Exception {        
            String filename = "/path/to/xml/xmlInput.xml";        
            String fileOutputName = "/path/to/target/finalXML.xml";
            try
            {

                XMLInputFactory xmlif = null;
                xmlif = XMLInputFactory.newInstance();          
                FileInputStream fis = new FileInputStream(filename);
                XMLStreamReader xmlr = xmlif.createFilteredReader(xmlif.createXMLStreamReader(fis),new XMLCopier());            

                OutputStream outputFile = new FileOutputStream(fileOutputName);                     
                XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();            
                XMLStreamWriter xmlWriter = outputFactory.createXMLStreamWriter(outputFile);

                while (xmlr.hasNext())          
                {               
                    write(xmlr, xmlWriter);             
                    xmlr.next();
                }
                write(xmlr, xmlWriter);                                 
                xmlWriter.flush();
                xmlWriter.close();          
                xmlr.close();
                outputFile.close();         
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
        }

        public boolean accept(XMLStreamReader reader) {
            int eventType = reader.getEventType();
            if ( eventType == XMLEvent.START_ELEMENT )
            {
                String currentName = reader.getLocalName();
                if (isWithinValidTag)
                    if ( ( (List)tagMap.get(currentTag) ).contains(currentName) )               
                    {   
                        allowStream = true;                 
                    }

                if ( tagMap.containsKey(currentName) )
                {   
                    isWithinValidTag = true;
                    currentTag = currentName;
                    allowStream = true;
                }
            }
            return allowStream;
        }

        private void write(XMLStreamReader xmlr, XMLStreamWriter writer) throws XMLStreamException
        {
            switch (xmlr.getEventType()) {
                case XMLEvent.START_ELEMENT:
                    final String localName = xmlr.getLocalName();
                    writer.writeStartElement(localName);
                break;
            }
        }


単一のクラスで実行しようとすると、コードの保守が難しくなり、インフォマティカのプロセスよりも 5 分ほど短い時間で完了しました。次に、並行して実行するためにクラスを分割しましたが、4400 ノードで 200 タグの検索を実行しているためか、informatica プロセスよりも 7 分短い時間で実行されたため、有望には見えません。11回。

ご覧のとおり、これは何かを作成する方法ではなく、何かをすばやく作成する方法に関するものです。

ファイル分割をどのように改善できるかについて何か考えはありますか?

PD。サーバーには JVM 1.4.2 があるため、それに固執する必要があります。PD2。ここではアイテムのみを表示しますが、実際のファイルには多くのアイテムがあります。

4

0 に答える 0