siddhi gpl执行geo扩展距离函数抛出数据类型错误

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了siddhi gpl执行geo扩展距离函数抛出数据类型错误相关的知识,希望对你有一定的参考价值。

我正在尝试创建一个siddhi应用程序,当一个人接近某些预设位置时,它会添加输出。这些位置存储在数据库中。截至目前,输入是从邮递员发送的。

但我不断收到错误,说数据类型不是'double'。我甚至检查了表的详细信息,并将mysql表中的数据类型设置为double。

以下是siddhi代码和错误的详细信息。有人可以指导我。

siddhi扩展的位置:https://wso2-extensions.github.io/siddhi-gpl-execution-geo/api/latest/

Siddhi代码:

@App:name('ShipmentHistoryApp')

@source(type = 'http', receiver.url='http://localhost:5008/RawMaterials', @map(type = 'json'))
define stream WalkingStream(latitude DOUBLE, longitude DOUBLE, device_id string);

@store(type='rdbms', jdbc.url="jdbc:mysql://127.0.0.1:3306/SweetFactoryDB", username="root", password="root" , jdbc.driver.name="com.mysql.jdbc.Driver")
define table Offers(c string, offer string, latitude DOUBLE, longitude DOUBLE);

@sink(type='log')
define stream SetLocation(a string, b string,one bool, two bool, dis double);

@sink(type='log', prefix='Only log')
define stream info(one bool, two bool);

from WalkingStream as w
join SetLocation as o
select o.a, o.b, instanceOfDouble(o.latitude) as one, instanceOfDouble(o.longitude) as two, geo:distance(w.latitude,w.longitude,o.latitude,o.longitude) as dis insert into Output;  

我在尝试找到两个位置之间的距离时遇到此错误。

org.wso2.siddhi.core.exception.SiddhiAppRuntimeException: Invalid input given to geo:distance() function. Third argument should be double
    at org.wso2.extension.siddhi.gpl.execution.geo.function.GeoDistanceFunctionExecutor.execute(GeoDistanceFunctionExecutor.java:123)
    at org.wso2.siddhi.core.executor.function.FunctionExecutor.execute(FunctionExecutor.java:109)
    at org.wso2.siddhi.core.query.selector.attribute.processor.AttributeProcessor.process(AttributeProcessor.java:41)
    at org.wso2.siddhi.core.query.selector.QuerySelector.processNoGroupBy(QuerySelector.java:145)
    at org.wso2.siddhi.core.query.selector.QuerySelector.process(QuerySelector.java:87)
    at org.wso2.siddhi.core.query.input.stream.join.JoinProcessor.process(JoinProcessor.java:110)
    at org.wso2.siddhi.core.query.processor.stream.window.LengthWindowProcessor.process(LengthWindowProcessor.java:135)
    at org.wso2.siddhi.core.query.processor.stream.window.WindowProcessor.processEventChunk(WindowProcessor.java:66)
    at org.wso2.siddhi.core.query.processor.stream.AbstractStreamProcessor.process(AbstractStreamProcessor.java:123)
    at org.wso2.siddhi.core.query.input.stream.join.JoinProcessor.process(JoinProcessor.java:118)
    at org.wso2.siddhi.core.query.input.ProcessStreamReceiver.processAndClear(ProcessStreamReceiver.java:187)
    at org.wso2.siddhi.core.query.input.ProcessStreamReceiver.process(ProcessStreamReceiver.java:97)
    at org.wso2.siddhi.core.query.input.ProcessStreamReceiver.receive(ProcessStreamReceiver.java:133)
    at org.wso2.siddhi.core.stream.StreamJunction.sendEvent(StreamJunction.java:151)
    at org.wso2.siddhi.core.stream.StreamJunction$Publisher.send(StreamJunction.java:358)
    at org.wso2.siddhi.core.stream.input.InputDistributor.send(InputDistributor.java:34)
    at org.wso2.siddhi.core.stream.input.InputEntryValve.send(InputEntryValve.java:44)
    at org.wso2.siddhi.core.stream.input.InputHandler.send(InputHandler.java:61)
    at org.wso2.siddhi.core.stream.input.source.PassThroughSourceHandler.sendEvent(PassThroughSourceHandler.java:35)
    at org.wso2.siddhi.core.stream.input.source.InputEventHandler.sendEvent(InputEventHandler.java:76)
    at org.wso2.extension.siddhi.map.json.sourcemapper.JsonSourceMapper.mapAndProcess(JsonSourceMapper.java:211)
    at org.wso2.siddhi.core.stream.input.source.SourceMapper.onEvent(SourceMapper.java:132)
    at org.wso2.extension.siddhi.io.http.source.HttpWorkerThread.run(HttpWorkerThread.java:62)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

或者,我也尝试在查询中将纬度从表转换为double。

答案

当geo:distance函数的第3个参数变为null时,可能会发生这种情况。你能验证o.latitude是否可以变为空吗?

以上是关于siddhi gpl执行geo扩展距离函数抛出数据类型错误的主要内容,如果未能解决你的问题,请参考以下文章

getGEO 函数

getGEO 函数

getGEO 函数

getGEO 函数

FLINK SIDDHI ADDON 学习笔记

两个 GEO 位置之间的距离 [重复]