Code Monkey home page Code Monkey logo

reactor-ql's Introduction

用SQL来描述ReactorAPI进行数据处理

Codacy Badge Maven Central Maven metadata URL Build Status codecov

Reactor + JSqlParser = ReactorQL

场景

  1. 规则引擎,在线编写SQL来定义数据处理规则.
  2. 实时统计每分钟平均温度.
  3. 统计每20条滚动数据平均值.
  4. ........

特性

  1. 支持字段映射 select name username from user.
  2. 支持聚合函数 count,sum,avg,max,min.
  3. 支持运算 select val/100 percent from cpu_usage.
  4. 支持分组 select sum(val) sum from topic group by interval('10s'). 按时间分组.
  5. 支持多列分组 select count(1) total,productId,deviceId from messages group by productId,deviceId.
  6. 支持having select avg(temp) avgTemp from temps group by interval('10s') having avgTemp>10 .
  7. 支持case when select case type when 1 then '警告' when 2 then '故障' else '其他' end type from topic.
  8. 支持Join select t1.name,t2.detail from t1,t2 where t1.id = t2.id.

例子

引入依赖

<dependency>
 <groupId>org.jetlinks</groupId>
    <artifactId>reactor-ql</artifactId>
    <version>{version}</version>
</dependency>

用例:

  ReactorQL.builder()
        .sql("select avg(this) total from test group by interval('1s') having total > 2") //按每秒分组,并计算流中数据平均值,如果平均值大于2则下游收到数据.
        .build()
        .start(Flux.range(0, 10).delayElements(Duration.ofMillis(500)))
        .doOnNext(System.out::println)
        .as(StepVerifier::create)
        .expectNextCount(4)
        .verifyComplete();

更多用法请看 单元测试

reactor-ql's People

Contributors

ccwxl avatar codacy-badger avatar zhou-hao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.