Setting Array Data Using FETPAPI

Hi @philippeVerney

I was going through the method serializeIjkGrid in Just wondering how we can do the same using FETPAPI. I am not able to understand how we set array data (in properties, grids etc…). If there is any guide or sample code that would really help.

Please guide me. Thanks in advance.

Hi @asim.jadoon

In basic mode, FETPAPI would do everything for you. You would not have to directly set array data on ETP, FETPAPI would do it for you when calling methods such as pushBackUShortHdf5Array3dOfValues (line 494) or setGeometryAsCoordinateLineNodes for IjkGrid.
This is done through the specialized HdfProxy delivered with FETPAPI : fetpapi/FesapiHdfProxy.h at main · F2I-Consulting/fetpapi · GitHub
Thus, the only thing to do is to set this specialized HdfProxy as the HdfProxy of your RESQML dataobject before to call such methods. This is what we are doing at line 104 of the FETPAPI example : fetpapiClient/ at 7e726199c1caccf99cb6d786dab1e1f285da8d31 · F2I-Consulting/fetpapiClient · GitHub
This specialized HdfProxy replaces the default one. The default one, delivered with FESAPI, reads/writes data from an HDF5 file. The specialized one, delivered with FETPAPI, reads/writes data from an ETP session. FYI, it also exists at least a third HdfProxy which can read data from an HDF5 file in parallel (when using FESAPI in an HPC context, mainly for flow simulation use case)

Main advantage of using this approach is that it is easy to port an existing application powered with FESAPI to an ETP aware application.
Main drawback is that you don’t really control anything. For example, this HdfProxy uses the websocket session in a blocking/synchronous way which may lead in low performance in some scenario. Another example is that FETPAPI splits array message according to its own splitting algorithm where some users may want another split pattern. Etc…

For now, we just deliver this specialized HdfProxy but we may think to provide some others in the future. We also know that some of our users develop their own (mainly for FEAPI usage, not FETPAPI yet). It may allow more flexibility on users side but it will be (much) more complex.

Finally, users wanting best performance would probably have to go even deepper and manage data array directly at the DataArrayHandlers class. In this latter case, it would require a strong knowledge of ETP and even of RESQML since you would have to recode a quite large part of what FESAPI and FETPAPI hide for you.

That’s cool. Very impressive. So in my FESAPI code it’s just a matter of setting the proxy and that’s it. I will test.

For datarray yes. And also set the FETPAPI DataArrayHandlers to your client session as we have previously discussed.

Also notice that pushing dataobject (and not datarray) is not automatically done but should be done this way:

  • getting the dataobject from the repository
  • build an ETP dataobject from it using FesapiHelpers::buildEtpDataObjectFromEnergisticsObject
  • putting this ressource

See fetpapiClient/main.cpp at 7e726199c1caccf99cb6d786dab1e1f285da8d31 · F2I-Consulting/fetpapiClient · GitHub (only in C++ for now)
You can get all uuids and do the above lines in a loop if you want to send all your dataobject repository. For that please use DataObjectRepository::getUuids

Finally The open ETP server may require to start a transaction before to send your data and to end your transaction after having sent everything.
Please then use the three methods there.

Can you please share the syntax for creating/setting proxy? Here the getDefaultProxy is null.

Sorry I am just learning this please bear with me on this.

Here it is in C++ (which should be very close to Java): fetpapiClient/main.cpp at 7e726199c1caccf99cb6d786dab1e1f285da8d31 · F2I-Consulting/fetpapiClient · GitHub

Youy must create it after having defined the HDF Proxy factory : fetpapiClient/ at 7e726199c1caccf99cb6d786dab1e1f285da8d31 · F2I-Consulting/fetpapiClient · GitHub