Atitit. GroupBy LINQ Implementation (1)-----LINQ Framework Selection java. net PHP
Implementation methods have such as the following
1. Dsl/java8 Streams AP, targeted query API, recommended 1
2. Linq::: DSL 1 for like SQL
1.1. linq4j (JDK6 ok,jdk7 compilation error , horse jar download ) 1
1.2. Quaere: LINQon Java ( new sourcecode) 1
1.3. Josql is also API 2 similar to Quaere
1.4..
Net LINQ 2
3. SQL parsing 2
4. Lambda 2
5. GA Self-Implementation 3
1.5. LINQ4J Code 3
6. Apache Collections4 ( no , Trot on groupby) 3
7. Forest Bar ::: self DSL from Stream API jdk8 similar to 3
8. Stream API N LINQ different 3
9. References 3
Do report statistics AH. There is a big problem. There is a whole collection of groupby Query Summary (Sum) No yo?? has been used linq4j,quaere,josql,. Ms does not work with Map dictionaries.
1. Dsl/java8 Streams AP, targeted query API, recommended
Persons1. GroupBy (A = a.name). Select (g = (New {name = G.key, Count
The advantages are: Type-safe queries, and the ability to use smart hints!
2. Linq::: dsl1.1 of like SQL. LINQ4J (Jdk6 ok,jdk7Compile Error,another horse .JarDownload)
Linq4j d fun0, Fun1, fun2 is not a good DSL either.
Author :: Old Wow's paw attilax ayron,email:[email protected]
Reprint please indicate source: Http://blog.csdn.net/attilax
1.2. Quaere:Javaon theLINQ(not new.sourcecode)
The following example obtains a list of product names from a product list:
List products = Arrays.aslist (Product.getallproducts ());
Iterable Productnames =
From ("P").
Select ("P.getproductname ()");
1.3.JosqlAlso withQuaeresimilar toAPI
This is a jar to download ... doesn't seem to support list (map), only list (bean)
caused by: java.lang.IllegalArgumentException : Cannot find method with Name:url in Class:java.util.Map
1.4.. NET LINQ
Statement Description: LINQ uses Group by and count to get the number of products in each CategoryID.
Description: First by CategoryID classification, remove the CategoryID value and the number of individual products.
1. Counting
1 var q =
2 from P in db. Products
3 Group p by P.categoryid into G
4 Select New {
5 G.key,
6 numproducts = g. Count ()
7};
3. SQL parsing
The disadvantage is that you cannot use the IDE smart hints
4. Lambda
5. GA Self-Realization
1.5. LINQ4J Code
linq4j. asEnumerable (emps)
. GroupBy (
emp_deptno_selector , new Function0<< /c7>String>() {
public String apply() {
return null;
}
} &NBSP; new &NBSP; Function2 < string &NBSP; employee Span style= "COLOR: #676767", &NBSP; String > () {
public string Apply (string /c8>v1, Employee e0) {
return v1 == NULL ? E0.name : (v1 + "+" + E0.name);
}
} &NBSP; new &NBSP; Function2 < integer &NBSP; string Span style= "COLOR: #676767", &NBSP; String > () {
public string &NBSP; apply ( integer Span style= "COLOR: #707070" >&NBSP; v1 &NBSP; string &NBSP; v2 ) {
return v1 + ":" + v2;
}
})
. by (Functions.<String>identityselector())
. toList ()
. toString ();
6. Apache Collections4 (No, trot on GroupBy) 7. Lin Bar::: Own DSL from stream API jdk8 similar to 8. Stream API N LINQ differs
Stream is a lambda -based DSL, syntax not with a SQL Jas 10 ... This is more flexible . ...
Linq, Jas 10 DSL, walk Ten syntax with a SQL Jas 10 . LINQ is easier ...
9. References
How to convert a common LINQ expression to a Java 8 Streams API expression.
Linq uses Group by Experience summary -51cto.com.htm
Java8 How to perform stream,reduce,collection operation -51cto.com.htm
Atitit. GroupBy LINQ Implementation (1)-----LINQ Framework Selection java. NET PHP