@@ -2557,6 +2557,81 @@ void xmlSize(const char *filename, double pc)
2557
2557
}
2558
2558
}
2559
2559
2560
+ void loadXMLTest (const char *filename, bool parseOnly, bool useLowMemPTree, bool saveFormattedXML)
2561
+ {
2562
+ OwnedIFile iFile = createIFile (filename);
2563
+ OwnedIFileIO iFileIO = iFile->open (IFOread);
2564
+ if (!iFileIO)
2565
+ {
2566
+ WARNLOG (" File '%s' not found" , filename);
2567
+ return ;
2568
+ }
2569
+
2570
+ class CDummyPTreeMaker : public CSimpleInterfaceOf <IPTreeMaker>
2571
+ {
2572
+ StringBuffer xpath;
2573
+ unsigned level = 0 ;
2574
+ public:
2575
+ virtual IPropertyTree *queryRoot () override { return nullptr ; }
2576
+ virtual IPropertyTree *queryCurrentNode () override { return nullptr ; }
2577
+ virtual void reset () override { }
2578
+ virtual IPropertyTree *create (const char *tag) override { return nullptr ; }
2579
+ // IPTreeNotifyEvent impl.
2580
+ virtual void beginNode (const char *tag, bool sequence, offset_t startOffset) override { }
2581
+ virtual void newAttribute (const char *name, const char *value) override { }
2582
+ virtual void beginNodeContent (const char *tag) override { }
2583
+ virtual void endNode (const char *tag, unsigned length, const void *value, bool binary, offset_t endOffset) override { }
2584
+ };
2585
+
2586
+ byte flags=ipt_none;
2587
+ PTreeReaderOptions readFlags=ptr_ignoreWhiteSpace;
2588
+ Owned<IPTreeMaker> iMaker;
2589
+ if (!parseOnly)
2590
+ {
2591
+ PROGLOG (" Creating property tree from file: %s" , filename);
2592
+ byte flags = ipt_none;
2593
+ if (useLowMemPTree)
2594
+ {
2595
+ PROGLOG (" Using low memory property trees" );
2596
+ flags = ipt_lowmem;
2597
+ }
2598
+ iMaker.setown (createPTreeMaker (flags));
2599
+ }
2600
+ else
2601
+ {
2602
+ PROGLOG (" Reading property tree from file (without creating it): %s" , filename);
2603
+ iMaker.setown (new CDummyPTreeMaker ());
2604
+ }
2605
+
2606
+ offset_t fSize = iFileIO->size ();
2607
+ OwnedIFileIOStream stream = createIOStream (iFileIO);
2608
+ OwnedIFileIOStream progressedIFileIOStream = createProgressIFileIOStream (stream, fSize , " Load progress" , 1 );
2609
+ Owned<IPTreeReader> reader = createXMLStreamReader (*progressedIFileIOStream, *iMaker, readFlags);
2610
+
2611
+ ProcessInfo memInfo (ReadMemoryInfo);
2612
+ __uint64 rss = memInfo.getActiveResidentMemory ();
2613
+ CCycleTimer timer;
2614
+ reader->load ();
2615
+ memInfo.update (ReadMemoryInfo);
2616
+ __uint64 rssUsed = memInfo.getActiveResidentMemory () - rss;
2617
+ reader.clear ();
2618
+ progressedIFileIOStream.clear ();
2619
+ PROGLOG (" Load took: %.2f - RSS consumed: %.2f MB" , (float )timer.elapsedMs ()/1000 , (float )rssUsed/0x100000 );
2620
+
2621
+ if (!parseOnly && saveFormattedXML)
2622
+ {
2623
+ assertex (iMaker->queryRoot ());
2624
+ StringBuffer outFilename (filename);
2625
+ outFilename.append (" .out.xml" );
2626
+ PROGLOG (" Saving to %s" , outFilename.str ());
2627
+ timer.reset ();
2628
+ saveXML (outFilename, iMaker->queryRoot (), 2 );
2629
+ PROGLOG (" Save took: %.2f" , (float )timer.elapsedMs ()/1000 );
2630
+ }
2631
+
2632
+ ::LINK (iMaker->queryRoot ()); // intentionally leak (avoid time clearing up)
2633
+ }
2634
+
2560
2635
void translateToXpath (const char *logicalfile, DfsXmlBranchKind tailType)
2561
2636
{
2562
2637
CDfsLogicalFileName lfn;
0 commit comments