Reuse streams in different queries

Post Reply
jbmzh
Posts: 5
Joined: Mon Feb 23, 2015 1:26 pm

Reuse streams in different queries

Post by jbmzh » Thu Mar 05, 2015 2:05 pm

Hi,

I'm currently trying to come up with a solution for reusing streams I joined from different sources. Namely, I have 40 sources from 20 sensors. For each sensor I first have to join and manipulate the two source streams. Afterwards, I need to join the joined streams with other streams in several other queries. Since I have to join up to 4 of such streams for each sensor, I would create the same streams over and over. Furthermore, this leads to very large and confusing queries. Is there a way to reuse a joined stream several times in different queries (e.g. by declaring them as sources)?

Thank you and regards

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: Reuse streams in different queries

Post by Marco Grawunder » Thu Mar 05, 2015 4:08 pm

Yes. You can use := to define complex queries as views or you can use ::= to defined complex queries as streams. In the first case a logical plan will be interserted in the second case a physicial plan in the resulting query.

See: http://wiki.odysseus.offis.uni-oldenbur ... andSources

jbmzh
Posts: 5
Joined: Mon Feb 23, 2015 1:26 pm

Re: Reuse streams in different queries

Post by jbmzh » Thu Mar 05, 2015 4:18 pm

Sadly that doesn't work. Neither with := nor with ::= . I always get the following exception:

'Parsing and Executing Query' has encountered a problem.
Script Execution Error: The input source "FullEventStream" is not registered.
The input source "FullEventStream" is not registered.

Query:
FullEventStream := RENAME({
aliases = [
'eCamera',
'eTimestamp',
'eObjectID',
'eventType',
'cItemName',
'eStatus',
'height'
]},
MAP({
expressions = [
'"141.13.161.92"',
'timestamp',
'objectID',
'eventType',
'cItemName',
'status',
'height'
]
}, EventStreamTuples))

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: Reuse streams in different queries

Post by Marco Grawunder » Thu Mar 05, 2015 4:25 pm

Can you post the whole example (including usage)? It is important, that the source definition and the source definition are in different #(ADD|RUN)QUERY statements.

jbmzh
Posts: 5
Joined: Mon Feb 23, 2015 1:26 pm

Re: Reuse streams in different queries

Post by jbmzh » Thu Mar 05, 2015 4:32 pm

Query1.qry:

#PARSER PQL
#QUERY

/// Camera1
/// Event Stream
XovisEVentStreamConnectorCamera1EG := ACCESS({
source='EventSource1',
wrapper='GenericPull',
transport='Xovis',
protocol='GPB',
datahandler='KeyValueObject',
options=[
['host', '141.13.161.92'],
['port', '49156'],
['streamtype', 'event']
],
schema=[['timestamp','Integer'],
['objectID','Integer'],
['eventType','String'],
['cItemName','String'],
['status','String'],
['height','Integer']]
}
)

___________________________________________________________________________________________--

Query2.qry:

#PARSER PQL
#QUERY
EventStreamTuples = KEYVALUETOTUPLE ({
schema = [
['timestamp','Timestamp'],
['objectID','Integer'],
['eventType','String'],
['cItemName','String'],
['status','String'],
['height','Integer']
],
type = 'Measurement',
keepinput = 'false'
},
XovisEVentStreamConnectorCamera1EG
)

FullEventStream := RENAME({
aliases = [
'eCamera',
'eTimestamp',
'eObjectID',
'eventType',
'cItemName',
'eStatus',
'height'
]},
MAP({
expressions = [
'"141.13.161.92"',
'timestamp',
'objectID',
'eventType',
'cItemName',
'status',
'height'
]
}, EventStreamTuples))

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: Reuse streams in different queries

Post by Marco Grawunder » Thu Mar 05, 2015 4:38 pm

Please send a bug report ... it seems to be ok.

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: Reuse streams in different queries

Post by Marco Grawunder » Thu Mar 05, 2015 5:41 pm

Ok. The problem ist, that the queries contains also an operator that uses the view as input in the same query (not to see above). This is not possible. A view or stream cannot be defined and used in the same query :-)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest