且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么过滤器方法不起作用?

更新时间:2023-01-09 21:38:50

我认为发生这种情况是因为您的过滤器和接收器已分配给另一个TStream对象,而不是要打印的对象.
可能您需要尝试以下方法:

I think that happened because your filter and sink have been assigned to another TStream object, not the one you are printing out.
Probably you need to try this:

TempSensor ts = new TempSensor();
TStream<Double> temp = top.poll(ts, 1, TimeUnit.MILLISECONDS).filter(tuple ->
tuple < OPTIMAL_TEMP_LOW || tuple > OPTIMAL_TEMP_HIGH);
temp.sink(tuple -> System.out.println("Temperature is out of range! "
+ "It is " + tuple + "\u00b0F!"));

// See what the temperatures look like
temp.print();

dp.submit(top);