Java 结构化数据处理开源库 SPL
沈阳市和平区爱尚职业培训机构
发表于:2022-05-31 16:14:18 23次浏览需要什么样的能力?
引入SPL
Orders=T(d:/Orders.csv)
Orders.new(OrderID, Amount, OrderDate)
Orders.new(OrderID, Amount, year(OrderDate))
Orders.new(OrderID:ID, SellerId, year(OrderDate):y)
Orders.groups(year(_5),_2; sum(_4))
join@1(Orders:o,SellerId ; Employees:e,EId).groups(e.Dept; sum(o.Amount))
Orders.select(Amount>1000 && Amount<=3000 && like(Client,*bro*))
Orders.sort(-Client,Amount)
Orders.groups(year(OrderDate),Client; sum(Amount))
join(Orders:o,SellerId ; Employees:e,EId).groups(e.Dept; sum(o.Amount))
Orders.select(Amount>1000)
Orders.select(Amount>1000 && Amount<2000)
Orders.sum(Amount*Amount)
Orders.sort(-Client, Amount)
Orders.groups(Client;sum(Amount):amt).select(amt>1000 && like(Client,*S*))
join(Orders:o,SellerId ; Employees:e,Eid).groups(e.Dept; sum(o.Amount))
Sales2021.group(month(sellDate)).(~.groups(Client;sum(Amount):sumValue)).(~.sort(-sumValue)) .(~.select(#<=10)).(~.(Client)).isect()
$select * from d:/Orders.csv where (OrderDate=date('2020-12-31') and Amount>100)
$select year(OrderDate),Client ,sum(Amount),count(1) from d:/Orders.csvgroup by year(OrderDate),Clienthaving sum(Amount)<=100
$select o.OrderId,o.Client,e.Name e.Dept from d:/Orders.csv ojoin d:/Employees.csv e on o.SellerId=e.Eid
$with t as (select Client ,sum(amount) s from d:/Orders.csv group by Client)select t.Client, t.s, ct.Name, ct.address from tleft join ClientTable ct on t.Client=ct.Client
更多语言优势
A | |
1 | =T(score.csv).group(subject) |
2 | =A2.(~.rank(score).pselect@a(~<=10)) |
3 | =A1.(~(A3(#)).(name)).isect() |
SPL序表的字段可以存储记录或记录集合,这样可以用对象引用的方式,直观地表达关联关系,即使关系再多,也能直观地表达。比如,根据员工表找到女经理下属的男员工:
Orders.select@1(Amount>1000)
Orders.select@m(Amount>1000)
Orders.select@b(Amount>1000)
Orders.select@1b(Amount>1000)
join(Orders:o,SellerId ; Employees:e,EId)
A.select(f(x):{x%2==0} )
A | B | |
1 | =T(Orders.txt) | /订单序表 |
2 | =A1.groups(year(Date):y,month(Date):m; sum(Amount):amt) | /按年月分组汇总 |
3 | =A2.derive(amt/amt[-1]:lrr, amt[-1:1].avg():ma) | /计算比上期和移动平均 |
无缝集成、低耦合、热切换
…Class.forName(com.esproc.jdbc.InternalDriver);Connection conn =DriverManager.getConnection(jdbc:esproc:local://);PrepareStatement st = conn.prepareStatement(=T(\D:/Orders.txt\).select(Amount>1000 && Amount<=3000 && like(Client,\*S*\)));ResultSet result=st.execute();.
…Class.forName(com.esproc.jdbc.InternalDriver);Connection conn =DriverManager.getConnection(jdbc:esproc:local://);Statement st = connection.();CallableStatement st = conn.prepareCall({call splscript1(?, ?)});st.setObject(1, 3000);st.setObject(2, 5000); ResultSet result=st.execute();...
将脚本外置于Java程序,一方面可以降低代码耦合性,另一方面利用解释执行的特点还可以支持热切换,业务逻辑变动时只要修改脚本即可立即生效,不像使用Java时常常要重启整个应用。这种机制特别适合编写微服务架构中的业务处理逻辑。
Java 结构化数据处理开源库 SPL原创内容,请点击 沈阳JAVA培训
热门课程
-
沈阳Java零基础5-10人就业班
询价
-
java编程速成就业班
询价
-
沈阳Java软件开发工程师培训课程
询价
-
java工程师培训零基础入门
询价
-
java实战软件开发工程师
询价