Digital Developer Conference: a FREE half-day online conference focused on AI & Cloud – North America: Nov 2 – India: Nov 9 – Europe: Nov 14 – Asia Nov 23 Register now

Close outline
  • United States
IBM?
  • Site map
IBM?
  • Marketplace

  • Close
    Search
  • Sign in
    • Sign in
    • Register
  • IBM Navigation
IBM Developer Answers
  • Spaces
    • Blockchain
    • IBM Cloud platform
    • Internet of Things
    • Predictive Analytics
    • Watson
    • See all spaces
  • Tags
  • Users
  • Badges
  • FAQ
  • Help
Close

Name

Community

  • Learn
  • Develop
  • Connect

Discover IBM

  • ConnectMarketplace
  • Products
  • Services
  • Industries
  • Careers
  • Partners
  • Support
10.190.13.195

Refine your search by using the following advanced search options.

Criteria Usage
Questions with keyword1 or keyword2 keyword1 keyword2
Questions with a mandatory word, e.g. keyword2 keyword1 +keyword2
Questions excluding a word, e.g. keyword2 keyword1 -keyword2
Questions with keyword(s) and a specific tag keyword1 [tag1]
Questions with keyword(s) and either of two or more specific tags keyword1 [tag1] [tag2]
To search for all posts by a user or all posts with a specific tag, start typing and choose from the suggestion list. Do not use a plus or minus sign with a tag, e.g., +[tag1].
  • Ask a question

How to handle the tumbling window by java operator?

270003E6AC gravatar image
Question by waldstein  (29) | May 17, 2013 at 03:19 AM streamsdev

See below example in the document:

stream<int32 maxSalary, uint32 ageOfMaxSalary> Agg0 = Aggregate(Beat)
{
window
Beat : tumbling, count(5);
output
Agg0 : maxSalary = Max(salary), ageOfMaxSalary = ArgMax(salary, age);
}

I want to handle the tuples in the window when eviction. But where can I place the java operator? I do not think I can put operator after above code..

I did not find relating topics in info center....

Please help.

Thx

People who like this

  0
Comment
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

8 answers

  • Sort: 
120000HAGM gravatar image

Answer by Stan Bradbury (1290) | May 22, 2013 at 06:18 PM

When the tunbling window evicts the the tuples it sends all of them to the output stream. When this stream is the input to the Java Primative it will receive all the tuples (22,42,34). I couldn't find good sample that demonstrated that so nodificed the JavaOperators sample that comes with Streams (see: <INSTALL>/samples/spl/feature/javaOperators). The attached SPL file is modified so the Java Primative DirectoryLister (source = DirectoryPropertyLister.java) recieves the evicted / flushed tuples from a SORT operator. Setup the sample program and replace the SPL code with the code in the one attached to this post. Give it a try to see that all the tuples are recieved in batches of five.

I see you've been active on the forum so perhaps you have figured this out already. Hope this helps.


JavaOperatorsSorted.spl (6.4 kB)
Comment
Seth Packham

People who like this

  1   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
120000GEAB gravatar image

Answer by Dan Debrunner (1175) | May 31, 2013 at 01:35 PM

Your original question doesn't really make sense, the Aggregate operator is performing its own windowing using the windowing library, there is no mechanism to access the evicted tuples.

A Java Operator handles windowing by use of a window handler, not through its process method. Your operator registers an implementation of com.ibm.streams.operator.window.StreamWindowListener during initialization. Then your implementation will receive all window events (insertion, eviction etc.).

There are two sample Java operators that use windowing in the package com.ibm.streams.operator.samples.windows.

Comment
Seth Packham

People who like this

  1   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
120000HAGM gravatar image

Answer by Stan Bradbury (1290) | May 17, 2013 at 06:36 PM

You may find the following helpful, I know I do. I believe example 033 Java Primative Operator at Work will demonstrate what you what to do.

This package (SPL-Examples-For-Beginners.tar.gz) includes 50 different Streams Studio projects. These are simple examples that will help developers who are just beginning to wrap their minds around IBM Streams Processing Language (SPL).

https://www.ibm.com/developerworks/mydeveloperworks/files/app?lang=en#/collection/ef9f8aa9-240f-4854-aae3-ef3b065791da

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270003E6AC gravatar image

Answer by waldstein (29) | May 20, 2013 at 04:44 AM

Hello Stan,

thank you for the examples. They are comprehensive!

However, I think 033 can not solve my problem. In fact, I want to know how Java operator handle the current tuples in a tumbling or sliding window. But the process() function can only deal with with each incoming tuple, right?

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
120000HAGM gravatar image

Answer by Stan Bradbury (1290) | May 20, 2013 at 08:18 PM

I'm not understanding what you are trying to do. Would you please describe the processing you wish you implement - please include an input and output example. Your question about process() appears to be covered in the docs including how to implement an operator that handles information contained in more that one tuple.

Please see:

http://pic.dhe.ibm.com/infocenter/streams/v3r0/topic/com.ibm.swg.im.infosphere.streams.spl-toolkit-development-reference.doc/doc/implementingoperators.html

The section on persisting information across tuples:

A tuple that is passed in as a parameter to a process function can be used during the lifetime of the processfunction call. A pointer or a reference to the tuple should not be stored for use in a context other than that of the current process call. A tuple received from the process call can be safely submitted as long as the submit call is performed in the context of the process call. If the tuple is to be stored as part of the operator state and made available across process calls, then a copy should be made.

Note that the tuples can contain other Tuples and complex types and so is not like a standard row found in a common relational database. Some of the sample classes may be helpful:

A number of sample classes are provided that demonstrate operators implemented in Java:

  • com.ibm.streams.operator.samples.operators.DecimalScaleSetter: Operator that submits a tuple for every input tuple, modifying a single decimal attribute by setting its scale (see java.math.BigDecimal.scale()).
  • com.ibm.streams.operator.samples.patterns.TupleInTupleOut: An abstract pattern class that exposes filtering and transformation to a sub-class but hides the mechanics of tuple reception and submission. For each incoming tuple the sub-class's filter() method is called and if that returns false no further processing for that tuple is performed. If true is returned then transform() is called. Transform allows the sub-class to set the attributes of the outgoing tuple and simply return true to deliver the tuple to the output port.
  • com.ibm.streams.operator.samples.operators.Regex: Operator that extends the TupleInTupleOut class to perform filtering using regular expression matching from the standard java.util.regex package.

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270003E6AC gravatar image

Answer by waldstein (29) | May 20, 2013 at 09:39 PM

Hi Stan,

sorry for misunderstanding you.

Let me take an example. For a tumbling window of size 3, its current status is (22,42,34). All the tuples in the window is going to evict after next tuple is inputting. If the next tuple is 30, then the tuples in the window will be (30), 22, 42 and 34 will be flushed. Hereby I want to handle these 3 figures by java operator. Which function should I choose? I thought process() can handle the new tuple 30, but I do not know how to handle the tuples (22,42,34) in the window.

Please let me know if I still can not make it clear :-)

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270003E6AC gravatar image

Answer by waldstein (29) | May 22, 2013 at 10:26 PM

Hi Stan,

thank you!

I am wondering if I want to handle the tuples in the window before it flushes. How can I do that?

In another case, if I am using a sliding window, when the window reaches its size, it will just evict one tuple (say, the oldest one), how can I handle the remain tuples in the window?

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
120000HAGM gravatar image

Answer by Stan Bradbury (1290) | May 23, 2013 at 01:43 PM


Windows can provide powerful capabilities but can be difficult to grasp initially. The following section covers windows thoroughly, please take a look at the examples provided to help you better understand windows.

http://pic.dhe.ibm.com/infocenter/streams/v3r0/topic/com.ibm.swg.im.infosphere.streams.spl-toolkit-development-reference.doc/doc/windowhandling.html

Section 5.1.5 of the RedBook: "IBM InfoSphere Streams Assembling Continuous Insight in the Information Revolution" also covers Windows well. It can be downloaded here: http://www.redbooks.ibm.com/abstracts/SG247970.html?Open
I highly recommend this document.

Regarding Windowed operators in general, they allow the handling of a set of tuples. Streams can be consumed by operators either on a tuple-by-tuple basis or through windows that create logical groupings of tuples. If you want to handle single tuples use a non-windowed operator. Of course setting the trigger policy to count(1) will also cause processing to happen at the arrival or each tuple.

For handling tuples before they are evicted use a sliding window with a trigger policy set shorter than the eviction event. Sliding windows execute processing, including emitting an output stream based on the trigger policy.

You might find it helpful to think of a tumbling window as one where the eviction policy establishes the trigger policy.

I recommend you work with various operators using different window policies to help drive home the concepts.

Comment

People who like this

  0   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

Follow this question

No one has followed this question yet.

Answers

Answers & comments

Related questions

Programmatic way to create basic info.xml for SPL Application 1 Answer

I have problem in my TEDA Application in infosphere streams V 4.0.1 1 Answer

i am using infosphere streams V 4.0.1 can i make exception handling like (try , catch()) in my TEDA Application 3 Answers

Problem for retraining a HoltWinters2 model in Streams 4.2.1.1 1 Answer

Publish/Subscribe do not always link up 0 Answers

  • Contact
  • Privacy
  • IBM Developer Terms of use
  • Accessibility
  • Report Abuse
  • Cookie Preferences

Powered by AnswerHub

Authentication check. Please ignore.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • API Connect
  • Analytic Hybrid Cloud Core
  • Application Performance Management
  • Appsecdev
  • BPM
  • Blockchain
  • Business Transaction Intelligence
  • CAPI
  • CAPI SNAP
  • CICS
  • Cloud Analytics
  • Cloud Automation
  • Cloud Object Storage
  • Cloud marketplace
  • Collaboration
  • Content Services (ECM)
  • Continuous Testing
  • Courses
  • Customer Experience Analytics
  • DB2 LUW
  • Data and AI
  • DataPower
  • Decision Optimization
  • DevOps Build
  • DevOps Services
  • Developers IBM MX
  • Digital Commerce
  • Digital Experience
  • Finance
  • Global Entrepreneur Program
  • Hadoop
  • Hybrid Cloud Core
  • Hyper Protect
  • IBM Cloud platform
  • IBM Design
  • IBM Forms Experience Builder
  • IBM Maximo Developer
  • IBM StoredIQ
  • IBM StoredIQ-Cartridges
  • IIDR
  • ITOA
  • InformationServer
  • Integration Bus
  • Internet of Things
  • Kenexa
  • Linux on Power
  • LinuxONE
  • MDM
  • Mainframe
  • Messaging
  • Node.js
  • ODM
  • Open
  • PartnerWorld Developer Support
  • PowerAI
  • PowerVC
  • Predictive Analytics
  • Product Insights
  • PureData for Analytics
  • Push
  • QRadar App Development
  • Run Book Automation
  • Search Insights
  • Security Core
  • Storage
  • Storage Core
  • Streamsdev
  • Supply Chain Business Network
  • Supply Chain Insights
  • Swift
  • UBX Capture
  • Universal Behavior Exchange
  • UrbanCode
  • WASdev
  • WSRR
  • Watson
  • Watson Campaign Automation
  • Watson Content Hub
  • Watson Marketing Insights
  • dW Answers Help
  • dW Premium
  • developerWorks Sandbox
  • developerWorks Team
  • Watson Health
  • More
  • Tags
  • Questions
  • Users
  • Badges