开发包装器 [英] Developing a Wrapper

查看:65
本文介绍了开发包装器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我们的Web包装引擎Cameleon编写一个包装器。

目前Cameleon能够回答某些SQL查询,但是对所有SQL都有一个

的限制查询必须有谓词。这非常类似于BLAST包装器的b $ b。例如,Cameleon可以通过访问雅虎的IBM财务网页来回答查询





但是,如果谓词Ticker,则该查询无意义。

缺席。 Cameleon的工作原理是将SQL构建成一个URL,并以


interchange.mit.edu/cameleon_sharp/camserv.aspx?query=SELECT+HEADLINES%2C+LASTTRADE%2C+TICKER+FROM+YAHOO+WHERE+TICKER+%3D+IBM&format=xml&regdir=&debug=false target =_ blank> http://interchange.mit.edu/cameleon_...r=&debug=false



请注意,SQL查询附于URL的结尾。我已经学习了

从DB2传递给

的请求对象重构一些SQL查询到包装器。


当前阶段,我的Cameleon包装器可以回答简单的查询

如上所述。但是,我无法回答复杂的查询。

以下是一些示例。


一个有效的查询

- 选择yahoo。 lasttrade from(select companyticker from companytable

where industry =''Biotechnology''and companyticker =''ACAD''")AS x,yahoo

where yahoo .ticker = x.companyticker"


此查询由包装器负责,因为DB2将

查询分解为两个查询请求对象,它们是

1.从公司表中选择公司票据

industry =''Biotechnology''和companyticker ='''ABGX''

2.从雅虎选择lasttrade ticker =''ABGX''


这些单独的查询可以由包装器回答。


查询无法正常工作

但是稍作修改(用<替换=运算符),

查询不再负责。

·选择yahoo.lasttrade来自(选择公司代码来自

companytable,其中industry =''Biotechnology''和companyticker<

''ACAG''')AS x ,雅虎,其中yahoo.ticker = x.companyticker"


在这种情况下,查询也被分解为两个请求对象。

1.从中选择companyticker公司表格

industry =''Biotechnology''和companyticker< ''ACAD''

2.从yahoo选择yahoo.lasttrade,其中yahoo.ticker =

此查询片段的请求对象转储是:


..SELECT(LASTTRADE),(TICKER).FROM LYNNWU .YAHOO.WHERE([< operator

kind> = [< column kind> TICKER] [<未绑定的类型>]])。

根据请求对象,yahoo.ticker是一个无界的运算符。

显然这个查询实际上不是一个有效的SQL所以包装器不能回答它...

我的问题是

为什么DB2给我一个奇怪的请求对象,不能

重构为功能SQL?请问包装器怎么能回答这种要求呢?在简单的fileWrapper中(以

样本的形式给出),包装器完全忽略了所有谓词请求,并且

返回了所有数据。但在我的情况下,我需要谓词来获得任何

的结果。我该如何处理这种情况?如果可能,我想回答这样的

查询。

第二个问题

如何处理和/或

·选择标题,LastTrade来自Yahoo,其中Ticker =''JDSU''或

Ticker =''IBM'


请求对象转储是

..SELECT(LASTTRADE),(HEADLINES),(TICKER).FROM LYNNWU

..YAHOO.WHERE([< operator kind> SINLIST [< column kind> TICKER] [< constant

kind> JDSU] [< constant kind> IBM]])。


Cameleon引擎可以回答部分查询。

- 选择标题,LastTrade来自雅虎,其中Ticker =''JDSU''

- 选择标题,LastTrade来自雅虎,其中Ticker =''IBM

因为我们的引擎无法处理多个谓词,如IN,AND

和OR,我希望DB2发送两个单独的请求而不是使用

SINLIST 。那可能吗?这样我可以单独处理两个子查询



I am trying to write a Wrapper for our web wrapping engine, Cameleon.
Currently Cameleon is able to answer certain SQL queries but with a
restriction that all SQL queries must have a predicate. This is very
similar to the BLAST wrapper. For example, Cameleon can answer queries
like this by accessing Yahoo''s IBM finance webpage

Select Headlines, LastTrade From yahoo where Ticker=''IBM''

However, this query is meaningless if the predicate "Ticker" is
absent. Cameleon works by constructing the SQL into an URL and feed it
to the cameleon engine in the form of

http://interchange.mit.edu/cameleon_...r=&debug=false

Notice the SQL query is attached at the end of the URL. I have learned
to reconstruct some SQL queries from the request object that DB2 passed
to the wrapper.

In the current stage, my Cameleon wrapper can answer simple queries
like the above. However, I have trouble answering complex queries.
Below are some examples.

A query that works
- select yahoo.lasttrade from ("select companyticker from companytable
where industry=''Biotechnology'' and companyticker = ''ACAD''") AS x, yahoo
where yahoo.ticker = x.companyticker"

This query is answerable by the wrapper because DB2 decomposes the
query into two query requests objects and they are
1. select companyticker from companytable where
industry=''Biotechnology'' and companyticker =''ABGX''
2. select lasttrade from yahoo where ticker =''ABGX''

These individual queries can be answered by the wrapper.

A query that doesn''t work
However with a slight modification(replacing the = operator with <),
the query is no longer answerable.
· select yahoo.lasttrade from ("select companyticker from
companytable where industry=''Biotechnology'' and companyticker <
''ACAD''") AS x, yahoo where yahoo.ticker = x.companyticker"

In this case, the query is also decomposed into two request objects.
1. select companyticker from companytable where
industry=''Biotechnology'' and companyticker < ''ACAD''
2. select yahoo.lasttrade from yahoo where yahoo.ticker =
The request object dump for this query fragment is:

..SELECT (LASTTRADE), (TICKER).FROM LYNNWU .YAHOO.WHERE ([<operator
kind>=[<column kind>TICKER][<unbound kind>]] ).

According to the request object, yahoo.ticker is an unbounded operator.
Obviously this query is not really a valid SQL so the wrapper can not
answer it...
My question is
Why is DB2 giving me an strange request object that can not be
reconstructed into a functional SQL? How can the wrapper be expected to
answer this kind of request? In the simple fileWrapper (given as a
sample), the wrapper simply ignored all the predicates request and
returned all the data. But in my case, I need the predicate to get any
result. How do I deal with this situation? I would like to answer such
query if possible.
2nd problem
How to handle AND/OR
· select Headlines, LastTrade From Yahoo where Ticker=''JDSU'' OR
Ticker=''IBM''

The request object dump is
..SELECT (LASTTRADE), (HEADLINES) , (TICKER).FROM LYNNWU
..YAHOO.WHERE ([<operator kind>SINLIST[<column kind>TICKER][<constant
kind>JDSU][<constant kind>IBM ]]).

Cameleon engine can, however, answer parts of the query.
- select Headlines, LastTrade From Yahoo where Ticker=''JDSU''
- select Headlines, LastTrade From Yahoo where Ticker=''IBM
Because our engine can not handle multiple predicates such as IN, AND
and OR, I would like DB2 to send two separate request instead of using
SINLIST. Is that possible? That way I could handle the two sub queries
individually?

推荐答案

li ***** @ gmail.com 写道:
li*****@gmail.com wrote:
一个不起作用的查询<然而,稍作修改(用<替换=运算符),
查询就不再负责了。
?选择yahoo.lasttrade(选择公司代码来自
businesstable'''生物技术''和公司代码<
''ACAD''")AS x,yahoo where yahoo.ticker = x.companyticker"

在这种情况下,查询也被分解为两个请求对象。
1.从公司表中选择公司代码,其中
industry ='''Biotechnology''和companyticker< ''ACAD''
2.从雅虎选择yahoo.lasttrade,其中yahoo.ticker =
此查询片段的请求对象转储是:

.SELECT(LASTTRADE), (TICKER).FROM LYNNWU .YAHOO.WHERE([< operator
kind> = [< column kind> TICKER] [< unbound kind>]])。

根据请求对象,yahoo.ticker是一个无界的运算符。
显然这个查询实际上不是一个有效的SQL,所以包装器无法回答它...


我不能说为什么你有< unbound kind>在那里和/或如果这是错误的。

但我怀疑请求对象中还有更多内容,

应该会提供有关比较的信息。 />
我的问题是
为什么DB2给我一个奇怪的请求对象,无法将其重构为功能SQL?如何期待包装器回答这种请求?在简单的fileWrapper(作为
示例给出)中,包装器只是忽略了所有谓词请求,并且
返回了所有数据。但就我而言,我需要谓词来获得任何结果。我该如何处理这种情况?如果可能的话,我想回答这样的问题。


您忽略的任何运算符都由DB2补偿。因此,如果您忽略带有< unbound kind>的

部分,DB2将为您进行比较并过滤

。你只需返回更复杂的结果集。

第二个问题
如何处理和/或
?选择标题,LastTrade来自雅虎,其中Ticker =''JDSU' '或
Ticker =''IBM''

请求对象转储是
.SELECT(LASTTRADE),(HEADLINES),(TICKER).FROM LYNNWU
.YAHOO.WHERE([< operator kind> SINLIST [< column kind> TICKER] [< constant
kind> JDSU] [< constant kind> IBM]])。

>然而,Cameleon引擎可以回答部分查询。
- 选择标题,LastTrade来自Yahoo,其中Ticker =''JDSU''
- 选择标题,LastTrade来自Yahoo,其中Ticker =''IBM <由于我们的引擎无法处理多个谓词,如IN,AND
和OR,我希望DB2发送两个单独的请求而不是使用
SINLIST。那可能吗?这样我可以单独处理两个子查询?
A query that doesn''t work
However with a slight modification(replacing the = operator with <),
the query is no longer answerable.
?· select yahoo.lasttrade from ("select companyticker from
companytable where industry=''Biotechnology'' and companyticker <
''ACAD''") AS x, yahoo where yahoo.ticker = x.companyticker"

In this case, the query is also decomposed into two request objects.
1. select companyticker from companytable where
industry=''Biotechnology'' and companyticker < ''ACAD''
2. select yahoo.lasttrade from yahoo where yahoo.ticker =
The request object dump for this query fragment is:

.SELECT (LASTTRADE), (TICKER).FROM LYNNWU .YAHOO.WHERE ([<operator
kind>=[<column kind>TICKER][<unbound kind>]] ).

According to the request object, yahoo.ticker is an unbounded operator.
Obviously this query is not really a valid SQL so the wrapper can not
answer it...
I can''t say why you have the "<unbound kind>" there and or if this is wrong.
But I would suspect that there is something more in the request object,
which should give you the information about the comparison.
My question is
Why is DB2 giving me an strange request object that can not be
reconstructed into a functional SQL? How can the wrapper be expected to
answer this kind of request? In the simple fileWrapper (given as a
sample), the wrapper simply ignored all the predicates request and
returned all the data. But in my case, I need the predicate to get any
result. How do I deal with this situation? I would like to answer such
query if possible.
Any operator that you ignore is compensated by DB2. Thus, if you ignore the
part with the "<unbound kind>", DB2 will do the comparison and filtering
for you. You just have to return the more complex result set.
2nd problem
How to handle AND/OR
?· select Headlines, LastTrade From Yahoo where Ticker=''JDSU'' OR
Ticker=''IBM''

The request object dump is
.SELECT (LASTTRADE), (HEADLINES) , (TICKER).FROM LYNNWU
.YAHOO.WHERE ([<operator kind>SINLIST[<column kind>TICKER][<constant
kind>JDSU][<constant kind>IBM ]]).

Cameleon engine can, however, answer parts of the query.
- select Headlines, LastTrade From Yahoo where Ticker=''JDSU''
- select Headlines, LastTrade From Yahoo where Ticker=''IBM
Because our engine can not handle multiple predicates such as IN, AND
and OR, I would like DB2 to send two separate request instead of using
SINLIST. Is that possible? That way I could handle the two sub queries
individually?




那么就不要把OR(或者你不能处理的任何东西)在回复中

对象。 DB2会看到你不能处理它并分解计划或

补偿不可用的功能。


-

Knut Stolze

DB2信息集成开发

IBM德国



Then just don''t put the OR (or whatever you can''t handle) in the response
object. DB2 will see that you can''t deal with it and break up the plan or
compensate the not-available functionality.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany


根据请求 - 回复-compensate协议,我们被允许

接受或拒绝谓词。在我的示例中,谓词由

OR连接,DB2使用

SINLIST将两个谓词转换为单个谓词。


WHERE([< operator kind> SINLIST [< column kind> TICKER] [< constant
According to the request-reply-compensate protocol, we are allowed to
accept or reject predicates. In my example, predicates are joined by
OR, and DB2 convert the two predicates into a single predicate using
SINLIST.

WHERE ([<operator kind>SINLIST[<column kind>TICKER][<constant
kind> JDSU] [< constant kind> IBM]])。
kind>JDSU][<constant kind>IBM ]]).




根据我的理解,我必须拒绝整个

谓词(整个SINLIST)。但我想要的是能够分离

单个谓词并接受谓词的一部分。具体来说

WHERE ticker =''ibm''

WHERE ticker =''jdsu''


无论如何要做这个?



Based on my understanding, I have to either reject the entire
predicate(the entire SINLIST). But I want is to able to separate the
single predicate and accept a part of the predicate. Specifically
WHERE ticker = ''ibm''
WHERE ticker = ''jdsu''

Is there anyway to do this?


li*****@gmail.com 写道:
li*****@gmail.com wrote:
根据请求 - 回复 - 补偿协议,我们可以接受或拒绝谓词。在我的示例中,谓词由
OR连接,DB2使用
SINLIST将两个谓词转换为单个谓词。

WHERE([< operator kind> SINLIST [< ;列类型> TICKER] [< constant
According to the request-reply-compensate protocol, we are allowed to
accept or reject predicates. In my example, predicates are joined by
OR, and DB2 convert the two predicates into a single predicate using
SINLIST.

WHERE ([<operator kind>SINLIST[<column kind>TICKER][<constant
kind> JDSU] [< constant kind> IBM]])。
kind>JDSU][<constant kind>IBM ]]).



问题是DB2不会简单地传递语句,因为你在命令行(或者什么)上输入了
。相反,它将作为OR谓词一部分的

多重比较组合成符合以下条件的单个

谓词:


自动收报机IN(''JDSU'','''IBM'')

这就是SINLIST的全部内容。

只是为了解释这个,如果你有一个类似的谓词


col1 =''ABC''或col2 =''DEF''


那么请求对象将是(缩进表示谓词的
树结构):


谓词:1

--- ----------------------------------------

表达式1

---------------

种类:操作者

代币:或

---------------

表达式1

-------------- -

种类:操作者

代币:=

---------------

表达式1

---------------

种类:COLUMN

列名:COL1

---------------

表达式2

---------------

种类:CONSTANT

数据: ABC

---------------

表达式2

-------- -------

种类:操作者

代币:=

------------- -

表达式1

---------------

种类:COLUMN

列名:COL2

---------------

表达式2

- --------------

种类:CONSTANT

数据:DEF


基于我的理解,我要么拒绝整个
谓词(整个SINLIST)。但我想要的是能够分离单个谓词并接受谓词的一部分。特别是
WHERE ticker =''ibm''
WHERE ticker =''jdsu''

无论如何都要这样做吗?


The thing is that DB2 does not simply pass-through the statement as you
typed it in on the command line (or whereever). Instead, it combines the
multiple comparisons that are part of the OR-predicate into a single
predicate that conforms to:

ticker IN ( ''JDSU'', ''IBM'' )

That''s what the SINLIST is all about.
Just to explain this, ff you have a predicate like

col1 = ''ABC'' OR col2 = ''DEF''

then the request object will be (the indentation indicates the
tree-structure of the predicates):

Predicates: 1
-------------------------------------------
Expression 1
---------------
kind: OPERATOR
token: OR
---------------
Expression 1
---------------
kind: OPERATOR
token: =
---------------
Expression 1
---------------
kind: COLUMN
column name: COL1
---------------
Expression 2
---------------
kind: CONSTANT
data: ABC
---------------
Expression 2
---------------
kind: OPERATOR
token: =
---------------
Expression 1
---------------
kind: COLUMN
column name: COL2
---------------
Expression 2
---------------
kind: CONSTANT
data: DEF

Based on my understanding, I have to either reject the entire
predicate(the entire SINLIST). But I want is to able to separate the
single predicate and accept a part of the predicate. Specifically
WHERE ticker = ''ibm''
WHERE ticker = ''jdsu''

Is there anyway to do this?




我不太确定我理解你想要的东西,即发送到远程数据源的
是什么。因为,如果你只发送ticker =

'JDSU'',在,然后你不会得到ticker =''IBM''的结果。所以你的

结果将是不完整的。那么你想在fenced

服务器/查询对象中看到什么作为要处理/发送到数据的语句

source?


请注意,您始终可以拒绝完整的SINLIST谓词,但是将响应对象中的OR-predicate信息存储为

执行的一部分

描述。然后你可以在运行期间获得谓词,并且可以做你想做的任何事情,例如发送到数据源的单独的

请求并返回所有行。 />

我还没有尝试过这个,但你可以在回复对象中添加一个

谓词。我不知道DB2会做什么。

明天我会试一试。


-

Knut Stolze

DB2信息集成开发

IBM德国



I''m not quite sure I understand what you want to have, i.e. what is to be
sent to the remote data source. Because, if you only send the "ticker =
''JDSU''" on, then you won''t get the results for "ticker = ''IBM''". So your
result would be incomplete. So what do you want to see in fenced
server/query object as the statement to be processed/sent on to the data
source?

Note that you could always reject the complete SINLIST predicate but store
the information about the OR-predicate in the response-object as part of
the execution descriptor. Then you have the predicate available during
run-time and can do whatever you want, for example send to separate
requests to the data source and return all rows.

I haven''t tried this yet, but you might be able to add just one of the
predicates into the reply object. I don''t know what DB2 will do then.
I''ll give this a try tomorrow.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany


这篇关于开发包装器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆