Переглянути джерело

HPCC-24512 Use streaming in writeResultCursorXml()

The flushContent() is added to IXmlWriter. It can be used
to call the flush() in writeResultCursorXml() (and other
IXmlWriters, such as CSV writer and JSON writer) without
affecting the existing functionalities.

Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
wangkx 4 роки тому
батько
коміт
975f01e62c

+ 2 - 1
common/fileview2/fileview.hpp

@@ -162,7 +162,8 @@ extern FILEVIEW_API int findResultSetColumn(const INewResultSet * results, const
 extern FILEVIEW_API unsigned getResultCursorXml(IStringVal & ret, IResultSetCursor * cursor, const char * name, unsigned start=0, unsigned count=0, const char * schemaName=NULL, const IProperties *xmlns=NULL);
 extern FILEVIEW_API unsigned getResultXml(IStringVal & ret, INewResultSet * cursor,  const char* name, unsigned start=0, unsigned count=0, const char * schemaName=NULL, const IProperties *xmlns=NULL);
 extern FILEVIEW_API unsigned getResultJSON(IStringVal & ret, INewResultSet * cursor,  const char* name, unsigned start=0, unsigned count=0, const char * schemaName=NULL);
-extern FILEVIEW_API unsigned writeResultCursorXml(IXmlWriter & writer, IResultSetCursor * cursor, const char * name, unsigned start=0, unsigned count=0, const char * schemaName=NULL, const IProperties *xmlns = NULL);
+extern FILEVIEW_API unsigned writeResultCursorXml(IXmlWriter & writer, IResultSetCursor * cursor, const char * name,
+    unsigned start=0, unsigned count=0, const char * schemaName=NULL, const IProperties *xmlns = NULL, bool flushContent = false);
 extern FILEVIEW_API unsigned writeResultXml(IXmlWriter & writer, INewResultSet * cursor,  const char* name, unsigned start=0, unsigned count=0, const char * schemaName=NULL, const IProperties *xmlns = NULL);
 
 extern FILEVIEW_API unsigned getResultCursorBin(MemoryBuffer & ret, IResultSetCursor * cursor, unsigned start=0, unsigned count=0);

+ 8 - 1
common/fileview2/fvresultset.cpp

@@ -2318,7 +2318,8 @@ extern FILEVIEW_API unsigned getResultJSON(IStringVal & ret, INewResultSet * res
     return rc;
 }
 
-extern FILEVIEW_API unsigned writeResultCursorXml(IXmlWriter & writer, IResultSetCursor * cursor, const char * name, unsigned start, unsigned count, const char * schemaName, const IProperties *xmlns)
+extern FILEVIEW_API unsigned writeResultCursorXml(IXmlWriter & writer, IResultSetCursor * cursor, const char * name,
+    unsigned start, unsigned count, const char * schemaName, const IProperties *xmlns, bool flushContent)
 {
     if (schemaName)
     {
@@ -2329,6 +2330,8 @@ extern FILEVIEW_API unsigned writeResultCursorXml(IXmlWriter & writer, IResultSe
         meta.getXmlXPathSchema(xsd, false);
         writer.outputInlineXml(xsd.str());
         writer.outputEndNested("XmlSchema");
+        if (flushContent)
+            writer.flushContent(false);
     }
 
     writer.outputBeginDataset(name, true);
@@ -2348,6 +2351,8 @@ extern FILEVIEW_API unsigned writeResultCursorXml(IXmlWriter & writer, IResultSe
     for(bool ok=cursor->absolute(start);ok;ok=cursor->next())
     {
         cursor->writeXmlRow(writer);
+        if (flushContent)
+            writer.flushContent(false);
 
         c++;
         if(count && c>=count)
@@ -2355,6 +2360,8 @@ extern FILEVIEW_API unsigned writeResultCursorXml(IXmlWriter & writer, IResultSe
     }
     cursor->endWriteXmlRows(writer);
     writer.outputEndDataset(name);
+    if (flushContent)
+        writer.flushContent(false);
     return c;
 }
 

+ 4 - 0
common/thorhelper/roxiedebug.cpp

@@ -529,6 +529,10 @@ public:
     {
         // nothing for now
     }
+    virtual void flushContent(bool close) override
+    {
+        // nothing for now
+    }
 };
 
 class ContainsFieldSearcher : public SimpleFieldSearcher

+ 3 - 0
plugins/javaembed/javaembed.cpp

@@ -2750,6 +2750,9 @@ public:
     virtual void outputInline(const char* text)
     {
     }
+    virtual void flushContent(bool close)
+    {
+    };
 
 public:
     CheckedJNIEnv *JNIenv;

+ 6 - 0
rtl/eclrtl/rtlformat.hpp

@@ -67,6 +67,7 @@ public:
     virtual void cutFrom(IInterface *location, StringBuffer& databuf) override { UNIMPLEMENTED; }
     virtual void outputNumericString(const char *field, const char *fieldname) override { UNIMPLEMENTED; }
     virtual void outputInline(const char* text) override { UNIMPLEMENTED; }
+    virtual void flushContent(bool close) override { UNIMPLEMENTED; }
 
 protected:
     StringBuffer out;
@@ -164,6 +165,7 @@ public:
     {
         outputCString(field, fieldname);
     }
+    virtual void flushContent(bool close) override { flush(close); }
 
 protected:
     bool checkForAttribute(const char * fieldname);
@@ -256,6 +258,7 @@ public:
 
     void outputBeginRoot(){out.append('{');}
     void outputEndRoot(){out.append('}');}
+    virtual void flushContent(bool close) override { flush(close); }
 
 protected:
     inline void flush(bool isClose)
@@ -342,6 +345,8 @@ public:
     virtual void outputEndArray(const char *fieldname) override {};
     virtual void outputSetAll();
     virtual void outputXmlns(const char *name, const char *uri);
+    virtual void flushContent(bool close) override {};
+    
 
 protected:
     bool checkForAttribute(const char * fieldname);
@@ -606,6 +611,7 @@ public:
     void outputCSVHeader(const char* name, const char* type);
     void finishCSVHeaders();
     const char* auditStr() const { return auditOut.str(); }
+    virtual void flushContent(bool close) override { flush(close); }
 
 protected:
     IXmlStreamFlusher* flusher;

+ 1 - 0
rtl/include/eclhelper.hpp

@@ -169,6 +169,7 @@ interface IRecordSize : public IInterface
 interface IXmlWriter : public IInterface
 {
 public:
+    virtual void flushContent(bool close) = 0;
     virtual void outputQuoted(const char *text) = 0;
     virtual void outputString(unsigned len, const char *field, const char *fieldname) = 0;
     virtual void outputBool(bool field, const char *fieldname) = 0;