Skip to content

Commit 826e61d

Browse files
committed
Merge pull request #164 from IBMStreams/issue162
Fixes #162 for master branch
2 parents 7602976 + ff53379 commit 826e61d

File tree

3 files changed

+53
-11
lines changed

3 files changed

+53
-11
lines changed

com.ibm.streamsx.inet/com.ibm.streamsx.inet/InetSource/InetSource_cpp.cgt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ void MY_OPERATOR::process(uint32_t idx)
224224
SPLAPPTRC(L_DEBUG, "Processing...", "InetSource");
225225

226226
OPort0Type tuple;
227-
string record;
228227
istringstream retrievalBuffer;
229228
int recordCounter = 0;
230229
<% if($doNotStreamInitialFetch) { %>
@@ -323,12 +322,17 @@ void MY_OPERATOR::process(uint32_t idx)
323322
*/
324323

325324
// Start of loop here, one loop cycle per input record, until retrieval buffer is exhausted
326-
getline(retrievalBuffer, record);
327-
if(record.size() > 0 || !retrievalBuffer.eof())
328-
{
329-
do
330-
{
331-
if(inputLinesPerRecord_ > 1)
325+
326+
while(!retrievalBuffer.eof()) {
327+
string record;
328+
getline(retrievalBuffer,record);
329+
330+
// if there's no data left, we should exit this loop
331+
if(retrievalBuffer.eof() && record.size() == 0) {
332+
break;
333+
}
334+
335+
if(inputLinesPerRecord_ > 1)
332336
{
333337
/*
334338
* Here, the user asked for multiple lines per record, so append the contents of the additional
@@ -432,9 +436,7 @@ void MY_OPERATOR::process(uint32_t idx)
432436
else break; // when there is no fragmentation, we are done
433437
}
434438
<% } %>
435-
if(!retrievalBuffer.eof()) getline(retrievalBuffer, record);
436-
} while(!retrievalBuffer.eof());
437-
} // end of if(record.size() > 0 || !retrievalBuffer.eof())
439+
}
438440
<% if($outputTypeIsList && $emitTuplePerURI) { %>
439441
/*
440442
* Here, emitTuplePerURI was requested, so flush the internal list buffer(s) into its(their)

com.ibm.streamsx.inet/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Alternatively, you can fully qualify the operators that are provided by toolkit
4848
4. Start the InfoSphere Streams instance.
4949
5. Run the application. You can submit the application as a job by using the **streamtool submitjob** command or by using Streams Studio.
5050
</description>
51-
<version>2.6.0</version>
51+
<version>2.6.1</version>
5252
<requiredProductVersion>4.0.0.0</requiredProductVersion>
5353
</identity>
5454
<dependencies/>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
/**
3+
* This composite is meant to be run as a test. If compiled in standalone mode and executed,
4+
* it will give return 0 if the test is successful, and non-zero if the test fails. It should
5+
* be able to be invoked by any test harness.
6+
*/
7+
8+
composite Main {
9+
10+
graph
11+
stream<rstring result> NoNewline = com.ibm.streamsx.inet::InetSource() {
12+
param
13+
// the data returned by this URL does not have a newline at the end.
14+
URIList: ["http://services.faa.gov/airport/status/ATL?format=application/xml"];
15+
fetchInterval: 5.0;
16+
17+
}
18+
19+
// make sure we got the last line.
20+
() as checkNoNewline = Custom(NoNewline) {
21+
logic state: {
22+
mutable int32 numEnter = 0;
23+
mutable int32 numExits = 0;
24+
}
25+
onTuple NoNewline: {
26+
if (size(regexMatch(result,"\\s*<AirportStatus>\\s*")) > 0) {
27+
numEnter++;
28+
}
29+
else if (size(regexMatch(result,"\\s*</AirportStatus\\s*"))>0) {
30+
numExits++;
31+
}
32+
if (numEnter-numExits > 1) {
33+
abort();
34+
}
35+
if (numEnter == numExits && numExits > 0) {
36+
shutdownPE();
37+
}
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)