Closed dkambur closed 5 years ago
Dalen,
It was thought about. You want to use the retrieve beans that takes a queuesize parameter and returns a CpoResultSet. I have include the javadoc below.
/**
@throws CpoException Thrown if there are errors accessing the datasource
*/
@Override
public <T, C> CpoResultSet
retrieverThread.start(); return resultSet; }
The jUnits include a file called RetrieveBeanTest. There are several tests that called "testRetrieveBeansNoWaitSizeXX" that use the queuesize and then operate on the iterator. Here is an example:
public void testRetrieveBeansNoWaitSize20() {
String method = "testRetrieveBeansNoWaitSize20:";
CpoResultSet
try { ValueObject valObj = new ValueObjectBean(); crs = cpoAdapter.retrieveBeans(null, valObj, valObj, null, null, null, 20); logger.debug("Returned from retrieveBeans"); for (ValueObject vo : crs) { if (vo != null) { count++; } logger.debug("Retrieved Object #" + count); } assertTrue("Result size is " + count, count == al.size());
} catch (Exception e) { fail(method + e.getMessage()); } }
I hope this helps. I know with MySQL you need to provide specific connection string parameters for it to allow streaming/non-blocking. You may need to do this with oracle as well.
Dave
-----Original Message----- From: dkambur notifications@github.com To: synchronoss/cpo-api cpo-api@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Sent: Mon, Nov 19, 2018 4:29 am Subject: [synchronoss/cpo-api] Streaming from CPO (#37)
Hi guys, Was there ever any thought put into streaming from CPO and how is this envisioned to work? On a particular project in SNCR, we have implemented streaming via JAXRS however one big issue is around getting actual data using CPO in blocks: namely, we implement multiple calls to cpo.retrieveBeans each to retrieve one block of data from Oracle whereas each block is filtered using rownums so that first request takes say rownum < 1000, second one is 1001 to 2000 etc. While this kind of works the way it was written, there are several issues:
if the underlying table changes (say by inserting or deleting a row), all rows read subsequently will be skewed so we'll end up with missing or duplicate rows it's not very fast as sending multiple queries, one after one, using rownum to filter upon specific block of data seems to be relatively slow it's very prone to errors in coding as all resulting columns need be specified in ORDER BY to make sure reads are consistent
If we were not using CPO, I'd read from a ResultSet first block, and maintain the same ResultSet in between calls for individual blocks but I'm not sure how this can be done in CPO world. Any thoughts or ideas you can share? Thanks, Dalen — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Hey Dave,
Thanks for the quick response.
We'll try this out and see how we get on but this won't be any time in next month or so so you're welcome to close the issue in the mean time...
Thanks,
Dalen
Functionality exists. Close for now
Hi guys,
Was there ever any thought put into streaming from CPO and how is this envisioned to work?
On a particular project in SNCR, we have implemented streaming via JAXRS however one big issue is around getting actual data using CPO in blocks: namely, we implement multiple calls to cpo.retrieveBeans each to retrieve one block of data from Oracle whereas each block is filtered using rownums so that first request takes say rownum < 1000, second one is 1001 to 2000 etc.
While this kind of works the way it was written, there are several issues:
If we were not using CPO, I'd read from a ResultSet first block, and maintain the same ResultSet in between calls for individual blocks but I'm not sure how this can be done in CPO world.
Any thoughts or ideas you can share?
Thanks,
Dalen